// JavaScript Document
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
		if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
		for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
		if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}













function MM_showHideLayers() { //v9.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3)
	with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
	obj.visibility=v; }
}






function toggleImg (div) {
	try {
		for ( $i=0;$i<50;$i++ ) {



			if ( 'div_arrow_'+$i != div ) {
				setVisibility ('arrow_'+$i, 'f');
			}
		}


		if($(div))
		$(div).style.display='block';

	}


	catch (ex) {}

}



function toggleMenu (div) {
	try {
		for ( $i=0;$i<50;$i++ ) {
			if ( 'div_arrow_'+$i != div ) {
				setVisibility ('menu_'+$i, 'f');
			}
		}

		var selOp = document.getElementById (div);
		selOp.style.display='block';
		
	}
	catch (ex) {}
}

function setVisibility (n, act) {
	try {
		//if ( getBrowser () == 'Internet Explorer' ) {
		//var selOp = eval ("document.all.div_"+n+"");
		//} else {
		var selOp = eval ("document.getElementById ('div_"+n+"');");
		//}
		//var selOp = eval ("document.all.div_"+n+"");
		if ( act == 't' ) {
			selOp.style.display='block';

		} else if ( act == 'f' ) {
			selOp.style.display='none';
		}

	}
	catch (ex) {}
}

function clickclear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}

function clickrecall(thisfield, defaulttext) {
	if (thisfield && thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}

var aa_73;
var aa_74;
var aa_75;
var aa_76;

var selectStatus = Array();
var submenuNames = Array();

function updateSelect(input,li){

	/*if(input.id=='input_73'){

	$('input_74').value='';
	$('input_74').focus();
	aa_74.activate();
	}

	if(input.id=='input_74'){
	$('input_75').value='';
	$('input_75').focus();
	aa_75.activate();
	}
	*/

	var parent='';


	if(input.id=='input_73'){
		selectStatus['input_73'] = li.id;
		selectStatus['input_74'] = null;
		selectStatus['input_75'] = null;
		$('input_74').value=submenuNames['input_74'];
		$('input_75').value=submenuNames['input_75'];

	}


	if(input.id=='input_74'){
		selectStatus['input_74'] = li.id;
		selectStatus['input_75'] = null;
		$('input_75').value=submenuNames['input_75'];
		new Ajax.Request(site_path + 'system/world-selector-get-parent?input=74&name='+input.value, {
			onSuccess: function(transport) {
				$('input_73').value = transport.responseText;
			}
		});

	}


	if(input.id=='input_75'){
		selectStatus['input_75'] = li.id;
		new Ajax.Request(site_path + 'system/world-selector-get-parent?input=75&name='+input.value, {
			asynchronous : false,
			onSuccess: function(transport) {
				$('input_74').value = transport.responseText;

			}
		});


		new Ajax.Request(site_path + 'system/world-selector-get-parent?input=74&name='+$('input_74').value, {
			onSuccess: function(transport) {
				$('input_73').value = transport.responseText;
			}
		});

	}







}

function updateCallback(input,entry){

	if(input.id=='input_74')
	return entry + '&parent='+selectStatus['input_73'];

	if(input.id=='input_75')
	return entry  + '&parent='+selectStatus['input_74']+ '&grandparent='+selectStatus['input_73'];


	else
	return entry;

}


function makeDefaultValue(id){

	if(id=="input_73"){
		$(id).value=submenuNames[id];
		selectStatus['input_73'] = null;

		selectStatus['input_74'] = null;
		$('input_74').value=submenuNames['input_74'];

		selectStatus['input_75'] = null;
		$('input_75').value=submenuNames['input_75'];

	}

	if(id=="input_74"){
		$(id).value=submenuNames[id];
		selectStatus['input_74'] = null;

		selectStatus['input_75'] = null;
		$('input_75').value=submenuNames['input_75'];

	}

	if(id=="input_75"){
		$(id).value=submenuNames[id];
	}

	if(id=="input_76"){
		$(id).value=submenuNames[id];
	}

}


function change_upload_content_type(type){

	if(type=="text"){

		$('content_label').innerHTML = 'Input Text';
		$('content_text').style.display = 'block';
		$('content_file').style.display = 'none';

	}

	if(type=="photo"){

		$('content_label').innerHTML = 'Upload Photo';
		$('content_file').style.display = 'block';
		$('content_text').style.display = 'none';

	}

	if(type=="audio"){

		$('content_label').innerHTML = 'Upload Audio';
		$('content_file').style.display = 'block';
		$('content_text').style.display = 'none';

	}

	if(type=="video"){

		$('content_label').innerHTML = 'Upload Video';
		$('content_file').style.display = 'block';
		$('content_text').style.display = 'none';

	}

}

function updateContentTags(){
	$('content_tags').value +=';'
}

function updateInterestsTags(){
	$('myspace_interests').value +=';'
}

function updateNowplayingTags(){
	$('myspace_playing').value +=';'
}

function selectAvatar(obj){

	if($('avatar_'+$('avatar_id').value))
	$('avatar_'+$('avatar_id').value).className = 'user_avatar';

	obj.className = 'user_avatar selected';
	$('avatar_id').value = obj.id.replace('avatar_','');
	$('avatar_preview').src=obj.childNodes[0].src;
}

function changeAvatarMethod(mode){
	//this.blur();
	if(mode=='std'){

		//$('avatar_method_std').className='avatar_method sel';
		$('avatar_button_adv').src=site_path+'images/adv_0.gif';
		$('avatar_button_std').src=site_path+'images/stand_1.gif';
		$('avatar_std').style.display='block';
		$('avatar_adv').style.display='none';

	}
	else{
		
		$('avatar_button_adv').src=site_path+'images/adv_1.gif';
		$('avatar_button_std').src=site_path+'images/stand_0.gif';
		
		if($('avatar_'+$('avatar_id').value))
		$('avatar_'+$('avatar_id').value).className = 'user_avatar';
		$('avatar_id').value = '';
		//$('avatar_method_adv').className='avatar_method sel';
		//$('avatar_method_std').className='avatar_method';
		$('avatar_std').style.display='none';
		$('avatar_adv').style.display='block';
		$('avatar_preview').src=def_avatar;
	}
	resizeIframes();
}

function deleteAvatar(){
	$('avatar_preview').src=site_path+'images/avatars/0.gif';
	def_avatar = site_path+'images/avatars/0.gif';

	if($('avatar_'+$('avatar_id').value))
	$('avatar_'+$('avatar_id').value).className = 'user_avatar';

	$('avatar_id').value = '0';

	return false;
}

function changeSex(value){

	var countervalue;
	if(value =='m' )
	countervalue = 'f';
	else
	countervalue = 'm';

	var avt_1 = document.getElementsByClassName('avatar_'+value);

	for (var i=0;i<avt_1.length;i++){

		avt_1[i].parentNode.style.display='block';
	}

	var avt_1 = document.getElementsByClassName('avatar_'+countervalue);

	for (var i=0;i<avt_1.length;i++){

		avt_1[i].parentNode.style.display='none';
	}
	avatarGalleryGo(1);

}

var timeMenu=Array();
var timeMenuRestore;

function menuMouseover(i,url){
	clearTimeout(timeMenuRestore);
	
	clearTimeout(timeMenu);
	menuMouseover_core(i,url);
}

function menuMouseover3(i,url){
	clearTimeout(timeMenuRestore);
	
	clearTimeout(timeMenu);
	menuMouseover_core(i,url);
}

function menuMouseover2(i,url){
	clearTimeout(timeMenuRestore);
	menuMouseover_core(1,url);
	clearTimeout(timeMenu);
}

function menuMouseover_core(i,url){
	toggleImg ('div_arrow_'+i);
	toggleMenu('div_menu_'+i);
	if($('active_menu'))
	$('active_menu').value=i;
	//this.blur();
}

function menuMouseout(i){
	clearTimeout(timeMenuRestore);
	timeMenuRestore = setTimeout('menuRestore()',300);
	MM_swapImgRestore();
}
var active_menu;
function menuRestore(){
	clearTimeout(timeMenuRestore);
	if(active_menu){
		toggleImg ('div_arrow_'+active_menu);
		toggleMenu('div_menu_'+active_menu);
		
	}
}

var default_val_search;

function updateSearchBox(active_menu){
	

}


function toggleZone(zone){
	if($(zone)){
		if($(zone).offsetHeight<10){
			$(zone).style.visibility='visible';
			$(zone).style.height='auto';
			$(zone).style.marginTop='5px';
		}
		else{
			$(zone).style.marginTop='0px';
			$(zone).style.visibility='hidden';
			$(zone).style.height='0px';
			$(zone).style.borderBottom='none';
		}

	}

	return false;
}

function URLDecode(encodedtext)
{
	// Replace + with ' '
	// Replace %xx with equivalent character
	// Put [ERROR] in output if %xx is invalid.
	var HEXCHARS = "0123456789ABCDEFabcdef";
	var encoded = encodedtext;
	var plaintext = "";
	var i = 0;
	while (i < encoded.length) {
		var ch = encoded.charAt(i);
		if (ch == "+") {
			plaintext += " ";
			i++;
		} else if (ch == "%") {
			if (i < (encoded.length-2)
			&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
			&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
			plaintext += ch;
			i++;
		}
	} // while

	return plaintext;
};

function resizeIframes(){
	var iframes = document.getElementsByTagName('iframe');
	for (var i = 0;i<iframes.length;i++){
		if(iframes[i].className=='uploader'){
			if (Prototype.Browser.IE){
				iframes[i].style.height = (iframes[i].contentWindow.document.body.scrollHeight?iframes[i].contentWindow.document.body.scrollHeight:23) + 'px';
				iframes[i].style.width = (iframes[i].contentWindow.document.body.scrollWidth?iframes[i].contentWindow.document.body.scrollWidth:310) + 'px';
			}
			else{
				iframes[i].style.height = (iframes[i].contentWindow.document.body.offsetHeight?iframes[i].contentWindow.document.body.offsetHeight:23) + 'px';
				iframes[i].style.width = (iframes[i].contentWindow.document.body.offsetWidth?iframes[i].contentWindow.document.body.offsetWidth:310) + 'px';
			}
		}
	}
}

function deletePhoto(id){
	if(confirm('Are you sure you want to delete the uploaded photo from the gallery?')){
		$('pu_status').removeChild($('imgGalleryPreview_'+id));
	
		var pcount =0;	
						
		for(var i=0; i<parent.$('pu_status').childNodes.length*1;i++)
			if(parent.$('pu_status').childNodes[i].style.display!='none')
				pcount++;
		
		
		
		if(Math.ceil(pcount/3)<pictureGalleryCurrentPag){
			pictureGalleryGo(Math.ceil(pcount/3))
		}
	
	
	
	}
}

function deletePguPhoto(id){
	if(confirm('Are you sure you want to delete the uploaded photo from the gallery?'))
	{
		$('pgu_status').removeChild($('imgGalleryPreview_'+id));
	
		
		var pcount =0;	
						
		for(var i=0; i<parent.$('pgu_status').childNodes.length*1;i++)
			if(parent.$('pgu_status').childNodes[i].style.display!='none')
				pcount++;
		
		
		
		if(Math.ceil(pcount/3)<personalGalleryCurrentPag){
			personalGalleryGo(Math.ceil(pcount/3))
		}
	
	}
}

var hhn = new Array();
var activeHhn;
function showHhn(id){
	$('homeHeaderMainTitle').innerHTML = URLDecode(hhn[id]['title']);
	$('homeHeaderMainText').innerHTML = URLDecode(hhn[id]['description']);
	$('homeHeaderMainLinks').innerHTML = URLDecode(hhn[id]['links']);
	$('homeHeaderMainInfo').innerHTML = URLDecode(hhn[id]['main_info']);





	if(activeHhn)
		if($('hhnBullet_'+activeHhn))
			$('hhnBullet_'+activeHhn).src = $('hhnBullet_'+activeHhn).src.replace('-act.gif','-inact.gif');

	$('hhnBullet_'+id).src = $('hhnBullet_'+id).src.replace('-inact.gif','-act.gif');

	swfobject.embedSWF(site_path+"images/video_simple.swf", "homeHeaderMainVideo", "300", "222", "9.0.0",null,{video_path:site_path+"user_content/"+id+"/video/0.flv"},{wmode:"transparent"});


	activeHhn = id;
}

function goNextHhn(){
	if(activeHhn)
		if(hhn[activeHhn]['next'])
			showHhn(hhn[activeHhn]['next']);
}

function goPreviousHhn(){
	if(activeHhn)
		if(hhn[activeHhn]['previous'])
			showHhn(hhn[activeHhn]['previous']);
}

function displayUserComments(page){

	var v_content;
	var v_sitepage;
	
	if($('sitepage_id'))
		v_sitepage = $('sitepage_id').value;
		
	if($('content_id'))
		v_content = $('content_id').value;
	
	
	
	new Ajax.Updater('user_comments', site_path_lang+'user-comments', {
		parameters: { content_id: v_content, page: page,sitepage_id: v_sitepage},evalScripts:true
	});

}

function addUserComment(){
	tinyMCE.triggerSave(false,true);
	new Ajax.Updater('user_comments',site_path_lang+'user-comments', {
		parameters: $('comment_form_add').serialize(true),evalScripts:true});



}

function showContent(hash){
	if(!hash)
		hash = "#text";

	if(hash=='#video'){
		if($('article_content_video'))
		$('article_content_video').style.display='block';

		if($('content_button_video'))
			$('content_button_video').style.display='none';


	}

	if(hash=='#text'){
		if($('article_content_text'))
		$('article_content_text').style.display='block';
	}


	if(hash=='#photo'){
		if($('article_content_photo'))
		$('article_content_photo').style.display='block';

		if($('content_button_photo'))
			$('content_button_photo').style.display='none';

	}
	if(hash=='#audio'){
		if($('article_content_audio'))
		$('article_content_audio').style.display='block';

		if($('content_button_audio'))
			$('content_button_audio').style.display='none';

	}
}


var clicked = new Array();

function star_over(unique,obj){
	var i;
	var current = obj.id.replace('u_'+unique+'_star_','');

	for (i=1;i<=5;i++){


		if (i<current)
		$('u_'+unique + '_star_' +i).src=site_path+'images/stars/star_1.gif';

		if (i==current)
		$('u_'+unique + '_star_' +i).src=site_path+'images/stars/star_1_selected.gif';

		if (i>current)
		$('u_'+unique + '_star_' +i).src=site_path+'images/stars/star_0.gif';

	}
}

function star_out(unique,obj,mark){

	var i;

	var current;

	if (clicked[unique])
	current = clicked[unique];
	else
	current = mark;



	for (i=1;i<=5;i++){


		if (Math.round(current)>=i)
		$('u_'+unique + '_star_' +i).src=site_path+'images/stars/star_1.gif';
		else
		$('u_'+unique + '_star_' +i).src=site_path+'images/stars/star_0.gif';

	}

}


function star_click(unique,obj){

	var current = obj.id.replace('u_'+unique+'_star_','');

	clicked[unique] = current;

	$('i_'+unique+'_value').value=current;

	new Ajax.Updater('rating_zone', site_path_lang+'system/rating', {
		parameters: {submit_rating:true,content_id:$('content_id').value, mark: current}
	});
}

var calendar_current_date = new Date();



function refresh_calendar(){
	$('calendar_day_name').innerHTML = weekday[calendar_current_date.getDay()];
	$('calendar_day_no').innerHTML = calendar_current_date.getDate();
	$('calendar_month_name').innerHTML = month[calendar_current_date.getMonth()] + ' ' + calendar_current_date.getFullYear();

	new Ajax.Updater('calendar_day_content', site_path_lang+'system/calendar', {
		parameters: { current_date: calendar_current_date.getFullYear()+'-'+(calendar_current_date.getMonth()+1<10?"0":"")+(calendar_current_date.getMonth()+1)+'-'+calendar_current_date.getDate()}
	});
}

function calendar_day_up(){
	calendar_new_date = new Date(calendar_current_date);

	calendar_new_date.setDate(calendar_current_date.getDate()+1);

	calendar_current_date = calendar_new_date;

	refresh_calendar();
}

function calendar_day_down(){
	calendar_new_date = new Date(calendar_current_date);

	calendar_new_date.setDate(calendar_current_date.getDate()-1);

	calendar_current_date = calendar_new_date;

	refresh_calendar();
}

function calendar_month_right(){
	calendar_new_date = new Date(calendar_current_date);

	calendar_new_date.setMonth(calendar_current_date.getMonth()+1);

	calendar_current_date = calendar_new_date;

	refresh_calendar();
}

function calendar_month_left(){

	calendar_new_date = new Date(calendar_current_date);

	calendar_new_date.setMonth(calendar_current_date.getMonth()-1);

	calendar_current_date = calendar_new_date;

	refresh_calendar();

}

function updateSelectRecipients(input,li){

	input.focus();
	input.value +=';'
}

function messangerStartup(){

	settingsA = {
		tl: { radius: 8 },
		tr: { radius: 8 },
		bl: { radius: 0 },
		br: { radius: 0 },
		antiAlias: true,
		autoPad: false,
		validTags: ["div"]
	}

	settingsB = {
		tl: { radius: 0 },
		tr: { radius: 0 },
		bl: { radius: 8 },
		br: { radius: 8 },
		antiAlias: true,
		autoPad: false,
		validTags: ["div"]
	}

	var composerHeader = new curvyCorners(settingsA, "composer_header");
	var composerFooter = new curvyCorners(settingsB, "composer_footer");
	composerHeader.applyCornersToAll();
	composerFooter.applyCornersToAll();

	jQuery('#reminderAcc').hoverAccordion({
		activateitem: '1',
		speed: 'fast',
		opened: 'accordion_toggle_active',
		closed: 'accordion_toggle',
		keepheight: 'true'
	});
	refresh_calendar();
}

function pushButtonReply(id){
		$('thread_reply_'+id).style.display='block';
		$('message_button_reply_'+id).style.display='none';

		if($('message_button_expand_'+id))
			pushButtonExpand(id);
}

function pushButtonExpand(id){
	$('message_button_expand_'+id).style.display='none';
	$('history_'+id).style.display='block';

}

function pushButtonColapse(id){
	if('message_button_expand_'+id){
		$('message_button_expand_'+id).style.display='inline';
		$('history_'+id).style.display='none';
	}

	$('thread_reply_'+id).style.display='none';
	$('message_button_reply_'+id).style.display='inline';

}

var newslist=new Array();
var cnt=0;			// current news item
var curr = "";
var i=-1;			// current letter being typed


/*
function newsticker2()
{
	
	if(newslist.length>0){
	if (i < newslist[cnt][0].length - 1)
	{
		i++;
		temp1 = newslist[cnt][0];
		temp1 = temp1.split('');
  		curr = curr+temp1[i];
		temp2 = newslist[cnt][1];
  		$('mtxt').innerHTML = "<a style=\"color:#ffffff;text-decoration:none;\" href='"+temp2+"'>"+curr+"_</a>";
  		setTimeout('newsticker2()',5)
		return;
	}

	
	i = -1; curr = "";
	if (cnt<newslist.length-1)
		cnt++;
	else
		cnt=0;
	setTimeout('newsticker2()',3000)
	}

}
*/

function newsticker2()
{
	if(!$('mtxt'))
		return;
	$('mtxt').style.display='none';
	Effect.Appear('mtxt', { duration: 0.3 });

	
	
	
	$('mtxt').innerHTML = "<a style=\"color:#ffffff;text-decoration:none;font-size:12px;\" href='"+newslist[cnt][1]+"'>"+newslist[cnt][0]+"</a>";
	
	
	
	
	
	if (cnt<newslist.length-1)
		cnt++;
	else
		cnt=0;
	
	setTimeout('newsticker2()',5000);
}





function reportComment(id){

	new Ajax.Request(site_path + 'system/comment-report?comment='+id, {
		onSuccess: function(transport) {

				$('reporter_'+id).style.display='none';
				displayUserComments($('commentsPage').value);
				alert('This comment has been reported. An administrator will check it out.');
		}
	});
}
function deleteComment(id){
	if(confirm('Are you sure you want to delete this comment?')){

		new Ajax.Request(site_path + 'system/comment-delete?comment='+id, {
			onSuccess: function(transport) {
				displayUserComments($('commentsPage').value);
				if(transport.responseText)
					alert(transport.responseText);
			}
		});

	}
}

function editComment(id){
	//$('add_comment').style.display='none';
	new Ajax.Updater('comment_div_'+id, site_path_lang+'edit-user-comment', {
		parameters: { comment_id: id},onSuccess:function(){

		},
		evalScripts:true

	});



}


function saveUserComment(){
	tinyMCE.triggerSave(false,true);
	new Ajax.Request(site_path_lang+'user-comments', {
		parameters: $('comment_form_edit').serialize(true),
		onSuccess: function(transport) {


			if(transport.responseText.indexOf('errors')<=0)
			displayUserComments($('commentsPage').value);

			tinyMCE.activeEditor.setContent('');
			alert(transport.responseText);
		}
	});


}


function displayUserOptions(obj){
	obj.style.display='block';
}


function sync_selects(type,unique){

	if(type == "genre"){
		$('game_selector_'+unique).value='';
		$('server_selector_'+unique).value='';
		$('guild_selector_'+unique).value='';
	}

	if(type == "game"){
		$('genre_selector_'+unique).value=get_parent('game',$('game_selector_'+unique).value);
		$('server_selector_'+unique).value='';
		$('guild_selector_'+unique).value='';
	}

	if(type == "server"){
		$('game_selector_'+unique).value=get_parent('server',$('server_selector_'+unique).value);
		$('genre_selector_'+unique).value=get_parent('game',$('game_selector_'+unique).value);
		$('guild_selector_'+unique).value='';
	}

	if(type == "guild"){
		$('server_selector_'+unique).value=get_parent('guild',$('guild_selector_'+unique).value);
		$('game_selector_'+unique).value=get_parent('server',$('server_selector_'+unique).value);
		$('genre_selector_'+unique).value=get_parent('game',$('game_selector_'+unique).value);
	}

}

var parents = Array();

function get_parent(type,value){
	var response ;

	if(parents[type+value])
		return parents[type+value];

	new Ajax.Request(site_path + 'system/getTagParent?type='+type+'&value='+value, {
			asynchronous: false,
			onSuccess: function(transport) {
				response = transport.responseText;
		}
	});
	parents[type+value] = response;
	return response;
}

function toggleUploadZone(type,stat){
	if($('Ucontent_'+type).offsetHeight<20 || stat == 'on'){

		
		$('Ucontent_'+type).style.display = 'block';
		$('uploader_'+type+'_button').src = $('uploader_'+type+'_button').src.replace('plus','minus');



	}
	else{

		
		$('Ucontent_'+type).style.display = 'none';
		$('uploader_'+type+'_button').src = $('uploader_'+type+'_button').src.replace('minus','plus');

	}
}

function vote_achievement(vote,content_id,unique){

	new Ajax.Updater('achievements_voter_'+unique, site_path_lang+'system/vote-achievement?content_id='+content_id+'&achiev_vote='+vote, {evalScripts:true});

}

function refreshUserContentListing(page){
	
	new Ajax.Updater('userContentListingBox', site_path_lang+'system/recent-user-content', {evalScripts:true,parameters:{userId:usercontentListingUserId,page:page}});

}

function userContentListingBullet(page){
	
	
	if(usercontentListingPage)
		$('userContentListingBullet'+usercontentListingPage).src=$('userContentListingBullet'+usercontentListingPage).src.replace('-act','-inact');
		
		$('userContentListingBullet'+page).src=$('userContentListingBullet'+page).src.replace('-inact','-act');
	
	usercontentListingPage = page;
	
	new Ajax.Updater('userContentListingBox', site_path_lang+'system/recent-user-content', {evalScripts:true,parameters:{userId:usercontentListingUserId,page:page}});
}

function userContentListingBulletPrev(){

	if(usercontentListingPage>1)
		var nextUsercontentListingPage = usercontentListingPage*1 - 1;
	else
		var nextUsercontentListingPage	= 1;
	
	userContentListingBullet(nextUsercontentListingPage);	
		
}

function userContentListingBulletNext(){

	if(usercontentListingPage<maxUsercontentListingPage)
		var nextUsercontentListingPage = usercontentListingPage*1 + 1;
	else
		var nextUsercontentListingPage	= maxUsercontentListingPage;

	userContentListingBullet(nextUsercontentListingPage);
	
}

function refreshUserContentUploadedMovies(page){
	
	new Ajax.Updater('uploadedMoviesBox', site_path_lang+'system/recent-uploaded-movies', {evalScripts:true,parameters:{userId:uploadedMoviesListingUserId,page:page}});
	
	uploadedMoviesListingPage = page;
}

function userContentUploadedMoviesPrev(){

	if(uploadedMoviesListingPage>1)
		var nextUsercontentListingPage = uploadedMoviesListingPage*1 - 1;
	else
		var nextUsercontentListingPage	= 1;
	
	refreshUserContentUploadedMovies(nextUsercontentListingPage);	
		
}


function userContentUploadedMoviesNext(){
	if(uploadedMoviesListingPage<maxUploadedMoviesListingPage)
		var nextUsercontentListingPage = uploadedMoviesListingPage*1 + 1;
	else
		var nextUsercontentListingPage	= maxUploadedMoviesListingPage;

	refreshUserContentUploadedMovies(nextUsercontentListingPage);
}

function markFavourite(content_id){
	new Ajax.Updater('tag_personal_favourite', site_path_lang+'system/favourite-actions', {evalScripts:true,parameters:{contentId:content_id,action:'mark'}});
}

function unMarkFavourite(content_id){
	new Ajax.Updater('tag_personal_favourite', site_path_lang+'system/favourite-actions', {evalScripts:true,parameters:{contentId:content_id,action:'unmark'}});
}

function listFriends(user,page){
	new Ajax.Updater('friendsBox', site_path_lang+'system/list-friends', {evalScripts:true,parameters:{page:page,user:user}});
}

function removeFriend(user,page,toremove){
	new Ajax.Updater('friendsBox', site_path_lang+'system/list-friends', {evalScripts:true,parameters:{page:page,user:user,remove:toremove}});
}

function requestFriendship(target){
	new Ajax.Updater('friendRequestStatus', site_path_lang+'system/request-friendship', {evalScripts:true,parameters:{target:target}});
}

function friendlistStartup(){

	jQuery('#friendlistAcc').hoverAccordion({
		activateitem: '1',
		speed: 'fast',
		opened: 'accordion_toggle_active',
		closed: 'accordion_toggle',
		keepheight: 'true'
	});
}

function acceptFriendship(target,page){
	new Ajax.Updater('requestsBox', site_path_lang+'system/friendship-action', {evalScripts:true,parameters:{target:target,action:'accept',page:page}});
}

function declineFriendship(target,page){
	new Ajax.Updater('requestsBox', site_path_lang+'system/friendship-action', {evalScripts:true,parameters:{target:target,action:'decline',page:page}});
}

function ignoreFriendship(target,page){
	new Ajax.Updater('requestsBox', site_path_lang+'system/friendship-action', {evalScripts:true,parameters:{target:target,action:'ignore',page:page}});
}

function listRequests(page){
	new Ajax.Updater('requestsBox', site_path_lang+'system/friendship-action', {evalScripts:true,parameters:{page:page,page:page}});
}

var selectedGaleryItem;

function appendImageToGallery(i,preview,sel){
	
		
	
	var tempDiv = document.createElement('div');
    tempDiv.setAttribute('class','imgGalleryPreview3');
    tempDiv.setAttribute('id','imgGalleryPreview_'+i);
    //tempDiv.innerHTML='<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td class=\"img\" align=\"center\" valign=\"middle\"><img src=\"'+site_path+''+preview+'\" alt=\"Preview\" /></td></tr><tr><td align=\"center\"><a href=\"#del\" onclick=\"deletePhoto(\''+i+'\');return false;\">Delete</a><input type=\"hidden\" name=\"pic['+i+']\" value=\"1\" id=\"pic_'+i+'\"></td></tr></table>';
    
    tempDiv.innerHTML='<div class=\"imgGalleryPreviewImg\"><table class=\"imgGalleryPreviewImgTable\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><img src=\"'+site_path+''+preview+'\" alt=\"Preview\" /></td></tr></table></div><div class=\"imgGalleryPreviewTools\"><a href=\"javascript:;\" onclick=\"deletePhoto(\''+i+'\');return false;\" class=\"imgGalleryPreviewToolsDelete\"><img src=\"'+site_path+'images/buttons/del_pic.gif\" /></a><a href=\"javascript:;\" onclick=\"selectGaleryItem(\''+i+'\');return false;\" class=\"imgGalleryPreviewToolsMark\" id=\"galMark_'+i+'\"><img src=\"'+site_path+'images/buttons/make_cover.gif\" /></a></div><div class=\"terminator\"></div><div style=\"display:none;\"><input type=\"hidden\" name=\"pic['+i+']\" value=\"1\" id=\"pic_'+i+'\"><input type=\"radio\" name=\"gallery_mark\" value=\"'+i+'\" id=\"check_'+i+'\"/></div>';
    
    parent.$('pu_status').appendChild(tempDiv);
    
     $('imgGalleryPreview_'+i).className = 'imgGalleryPreview3';
     
    
	
	if(sel==1)
		setTimeout('selectGaleryItem('+i+')',10);
		
		
	toggleUploadZone('image','on');
	
}

function appendImageToPersonalGallery(i,preview,sel){
	
	var text = '';
		
	var tempDiv = document.createElement('div');
    tempDiv.setAttribute('class','imgGalleryPreview3');
    tempDiv.setAttribute('id','imgGalleryPreview_'+i);

    //tempDiv.innerHTML='<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td class=\"img\" align=\"center\" valign=\"middle\"><img src=\"'+site_path+''+preview+'\" alt=\"Preview\" /></td></tr><tr><td align=\"center\"><a href=\"#del\" onclick=\"deletePhoto(\''+i+'\');return false;\">Delete</a><input type=\"hidden\" name=\"pic['+i+']\" value=\"1\" id=\"pic_'+i+'\"></td></tr></table>';
    
   text='<div class=\"imgGalleryPreviewImg\"><table class=\"imgGalleryPreviewImgTable\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><img src=\"'+site_path+''+preview+'\" alt=\"Preview\" /></td></tr></table></div><div class=\"imgGalleryPreviewTools\"><a href=\"javascript:;\" onclick=\"deletePguPhoto(\''+i+'\');return false;\" class=\"imgGalleryPreviewToolsDelete\"><img src=\"'+site_path+'images/buttons/del_pic.gif\" /></a>';
    
   text+='<a href=\"javascript:;\" onclick=\"selectGaleryItem(\''+i+'\');return false;\" class=\"imgGalleryPreviewToolsMark\" id=\"galMark_'+i+'\"><img src=\"'+site_path+'images/buttons/make_cover.gif\" /></a>';
    
   text+='</div><div class=\"terminator\"></div><div style=\"display:none;\"><input type=\"hidden\" name=\"pic['+i+']\" value=\"1\" id=\"pic_'+i+'\"><input type=\"radio\" name=\"gallery_mark\" value=\"'+i+'\" id=\"check_'+i+'\"/></div>';
    
    
    tempDiv.innerHTML = text;
    
    if(parent.$('pgu_status'))
    parent.$('pgu_status').appendChild(tempDiv);
	
    $('imgGalleryPreview_'+i).className = 'imgGalleryPreview3';
    
	if(sel==1)
		setTimeout('selectGaleryItem('+i+')',10);
	
}

function appendNormalImageToPersonalGallery(i,preview,sel,id,type,alt){
	
	var colname='';
	//var dir2='';
	
	if(type == 'user'){
		//dir1 = 'user_galleries';
		//dir2 = 'pgallery';
		colname = 'user_id';
	}
	else{
		//dir1 = 'user_content';
		//dir2 = 'photo';
		colname = 'content_id';
	}	
	
	var tempDiv = document.createElement('div');
    tempDiv.setAttribute('class','imgGalleryPreview3');
   // tempDiv.setAttribute('style','height:154px;overflow:hidden;');
   	tempDiv.setAttribute('id','imgGalleryPreview_'+i);

    tempDiv.innerHTML='<div class=\"imgGalleryPreviewImg\"><table class=\"imgGalleryPreviewImgTable\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a href=\"'+site_path+'images/user_image.php?'+colname+'='+id+'&image_id='+i+'\" rel=\"lightbox[prev]\"><img src=\"'+site_path+''+preview+'\" alt=\"'+alt+'\" /></a></td></tr></table></div>';
    if(parent.$('pgu_status'))
    parent.$('pgu_status').appendChild(tempDiv);
	
    $('imgGalleryPreview_'+i).className = 'imgGalleryPreview3';
    
	if(sel==1)
		setTimeout('selectGaleryItem('+i+')',10);
		
	
	
}





function selectGaleryItem(i){
	
	if($('imgGalleryPreview_'+selectedGaleryItem)){
		$('imgGalleryPreview_'+selectedGaleryItem).className = 'imgGalleryPreview3';
		$('galMark_'+selectedGaleryItem).innerHTML = '<img src=\"'+site_path+'images/buttons/make_cover.gif\" />';
	
	}
	
	$('imgGalleryPreview_'+i).className = 'imgGalleryPreview3Selected';
	
	if($('check_'+i)){	
	$('check_'+i).click();
	$('galMark_'+i).innerHTML = '<img src=\"'+site_path+'images/buttons/cover.gif\" />';
	//$('galMark_'+i).blur();
	selectedGaleryItem = i;
	}
	
}


var homeHeaderMainNews = Array();
var selectedHomeHeaderMainNews = 1;
var cachedHeaderNews = Array();

function headerMainLeadsGo(i){
	if(cachedHeaderNews[i]){
		$('homeHeaderCont').innerHTML = cachedHeaderNews[i];
	}
	else
	{
		new Ajax.Updater('homeHeaderCont', site_path_lang+'system/header-main-leads', {
			onComplete:function(transport){
				cachedHeaderNews[i] = transport.responseText;
			},
			parameters: { news_id:i},evalScripts:true
		});
	}

}

function headerMainLeadsNext(sel,max){
	if(sel*1 < max*1-1){
		headerMainLeadsGo(sel*1+1);
	}
	else
		headerMainLeadsGo(0);
}
function headerMainLeadsPrev(sel,max){
	
	if(sel*1 >=1){
		headerMainLeadsGo(sel*1-1);
		
	}
	
	else{
		headerMainLeadsGo(max-1);
		
	} 
}

var timeoutMainHeaderNewsTm;

function timeoutMainHeaderNews(sel,max){
	timeoutMainHeaderNewsTm = setTimeout('headerMainLeadsNext(\''+sel+'\',\''+max+'\')',5000);
}

personalGalleryCurrentPag = 1;

function personalGalleryScrollRight(){
	
	personalGalleryGo(personalGalleryCurrentPag+1);
	
}

function personalGalleryScrollLeft(){
	if(personalGalleryCurrentPag > 1)
	personalGalleryGo(personalGalleryCurrentPag-1);
	
}

function personalGalleryGo(pag){
	
	
	
	var count=0;
	
	for(var i=0; i<$('pgu_status').childNodes.length*1;i++){
		if($('pgu_status').childNodes[i].style.display!='none'){
			
			count++;
		}
	}
	
	if(Math.ceil(count/3)>=pag){

	$('pgu_status').style.marginLeft = -((pag-1) * 477) + 'px'
	personalGalleryCurrentPag = pag;
	
	}
}


avatarGalleryCurrentPag = 1;

function avatarGalleryScrollRight(){
	
	avatarGalleryGo(avatarGalleryCurrentPag+1);
	
}

function avatarGalleryScrollLeft(){
	if(avatarGalleryCurrentPag > 1)
	avatarGalleryGo(avatarGalleryCurrentPag-1);
	
}

function avatarGalleryGo(pag){
	var count=0;
	
	
	for(var i=0; i<$('avatar_scrooler').childNodes.length*1;i++){
		if($('avatar_scrooler').childNodes[i].style.display!='none'){
			
			count++;
		}
	}
	
	if(Math.ceil(count/4)>=pag){
	
	
	$('avatar_scrooler').style.marginLeft = -((pag-1) * 240) + 'px'
	avatarGalleryCurrentPag = pag;
	
	
	}
	
	
	
	
}


pictureGalleryCurrentPag = 1;

function pictureGalleryScrollRight(){
	
	pictureGalleryGo(pictureGalleryCurrentPag+1);
	
}

function pictureGalleryScrollLeft(){
	if(pictureGalleryCurrentPag > 1)
	pictureGalleryGo(pictureGalleryCurrentPag-1);
	
}

function pictureGalleryGo(pag){

	var count=0;
	
	for(var i=0; i<$('pu_status').childNodes.length*1;i++){
		if($('pu_status').childNodes[i].style.display!='none'){
			
			count++;
		}
	}
	
	if(Math.ceil(count/3)>=pag){
	
	
	$('pu_status').style.marginLeft = -((pag-1) * 477) + 'px'
	pictureGalleryCurrentPag = pag;
	
	
	}
}



var mceConfig = Array();

mceConfig['comment'] =
{
	theme : 'advanced',
	mode : 'textareas',
	editor_selector : 'mceEditor',
	plugins : 'bbcode',
	theme_advanced_buttons1 : 'bold,italic,underline,undo,redo,link,unlink,image,forecolor,styleselect,removeformat,code',
	theme_advanced_buttons2 : '',
	theme_advanced_buttons3 : '',
	theme_advanced_toolbar_location : 'top',
	theme_advanced_toolbar_align : 'left',
	theme_advanced_styles : "Quote=quoteStyle",
	content_css : site_path + "css/bbcode.css",
	entity_encoding : 'raw',
	add_unload_trigger : false,
	remove_linebreaks : false,
	force_br_newlines:true,
	inline_styles:false,
	convert_newlines_to_brs:true,
	apply_source_formatting:false,
	convert_fonts_to_spans : false

};

mceConfig['message_large'] = {
	theme : 'advanced',
	width: '292',
	mode : 'textareas',
	editor_selector : 'messengerBody',
	plugins : 'bbcode',
	theme_advanced_buttons1 : 'bold,italic,underline,forecolor,removeformat,code',
	theme_advanced_buttons2 : '',
	theme_advanced_buttons3 : '',
	theme_advanced_toolbar_location : 'top',
	theme_advanced_toolbar_align : 'left',
	theme_advanced_styles : "Quote=quoteStyle",
	content_css : site_path + "css/bbcode.css",
	entity_encoding : 'raw',
	add_unload_trigger : false,
	remove_linebreaks : false,
	force_br_newlines:true,
	inline_styles:false,
	convert_newlines_to_brs:true,
	apply_source_formatting:false,
	convert_fonts_to_spans : false
};



function notification(text){
	return alert(text);
}

function alert(text){
		
	iBox.addEvent(window, 'load', function() {
		notify(text);
	});
	
	return true;
}

function notify(text){
	
	text = String(text);
	text = text.replace('\n','<br/>')
	text = text.replace('\r','<br/>')
	
	text = text.replace('There were errors in your form submition:','<strong>There were errors in your form submition:</strong>');
	
	
	
	
	iBox.show(text,'Notification', {});
	var bImage = document.createElement('img');
	bImage.src = site_path+'images/background/box_bottom.gif';
		

	$('ibox_wrapper').appendChild(bImage);
	
	return true;
}

var currentTextPage = 1;

var previousTextPage;
var nextTextPage = 2;
var totalTextPages;



function autoPageTextContent(){
	if($('croppedContent')){
	var croppedHeight = $('croppedContent').offsetHeight * 1 ;
	var fullHeight = $('fullContent').offsetHeight * 1;
	
	var pagingContent = '';
	
	var pagingContainers;
	
	var firstPage = 1;
	var lastPage;
	
	
	
	if(croppedHeight >= fullHeight){
		$('croppedContent').style.height = 'auto';
		pagingContainers = document.getElementsByClassName('pagingContainer');
		
		for(var k=0;k<pagingContainers.length;k++){
			pagingContainers[k].style.display = 'none';
		}
	}
	else{
		
		totalTextPages = Math.ceil(fullHeight/croppedHeight);
		
		
		lastPage = totalTextPages;
		
		
		
		//notify(totalPages);
		
		for(var i=1; i<=totalTextPages; i++){
			
			pagingContent +='<a class="pageSelector_'+i+' '+(i==1?'act':'')+'"  style="font-family:Verdana;"  href="#toptext" onclick="displayTextPage('+i+');">' + i + '</a>';
			
		}
		
		
		pagingContainers = document.getElementsByClassName('pagingContainer');
		
		for(var k=0;k<pagingContainers.length;k++){
							
			
			
			pagingContainers[k].innerHTML = '<div class="pagingBlock" style="vertical-align:middle;"><div class="pagingPage">Page 1 of '+ totalTextPages +'</div><div class="pagingPagers"><a href="#toptext" onclick="displayFirstTextPage();" style="font-family:Verdana;">&laquo; First</a><a href="#toptext" onclick="displayPreviousTextPage();" style="font-family:Verdana;">&lt;</a>'+ pagingContent +'<a onclick="displayNextTextPage();" href="#toptext" style="font-family:Verdana;">&gt;</a><a style="font-family:Verdana;" onclick="displayLastTextPage();" href="#toptext" >Last &raquo;</a></div></div>' ;
			
		}
			
	
		
	}
	
	}

}


function displayTextPage(i){
	
	var topMargin;
	if(currentTextPage)

	pagingSel = document.getElementsByClassName('pageSelector_' + currentTextPage);
	for(var k=0;k<pagingSel.length;k++)
		pagingSel[k].className = 'pageSelector_' + currentTextPage;
			
	
	currentTextPage = i;
	
	pagingSel = document.getElementsByClassName('pageSelector_' + currentTextPage);
	for(var k=0;k<pagingSel.length;k++)
		pagingSel[k].className = 'pageSelector_' + currentTextPage + ' act';
	
	previousTextPage = 1;	
	nextTextPage = totalTextPages;	
		
	if(currentTextPage > 1){
		previousTextPage = currentTextPage - 1;
	}
		
	if(currentTextPage < totalTextPages){
		nextTextPage = currentTextPage + 1;
	}
	
	
	i = i*1;
	
	if(i < 1)
		i = 1;
	
		
	/*for(k = 1; k<=totalTextPages; k++){
		if(k < i-1)
			$('pageSelector_' + k).style.display = 'none';
		else
			if(k > i+3)
				$('pageSelector_' + k).style.display = 'none';
			else
				$('pageSelector_' + k).style.display = 'block';
	}
	*/	
		
		
	var croppedHeight = $('croppedContent').offsetHeight * 1 ;
	
	topMargin = (i-1) * croppedHeight;
		
	$('fullContent').style.marginTop = '-' + topMargin + 'px';
	
	
}

function displayFirstTextPage(){
	displayTextPage(1);
	
}

function displayLastTextPage(){
	displayTextPage(totalTextPages);
}

function displayPreviousTextPage(){
	displayTextPage(previousTextPage);
}

function displayNextTextPage(){
	displayTextPage(nextTextPage);
}


function req_status(text){
	$('pending_requests').innerHTML = text;
}


function hotmixGo(i){
	
	$('hotmixContent').innerHTML = URLDecode(hotmixPages[i]);
	
	if($('hotmixBullet'+selectedHotmixPage))
		$('hotmixBullet'+selectedHotmixPage).src = $('hotmixBullet'+selectedHotmixPage).src.replace('-act','-inact');
	
	$('hotmixBullet'+i).src = $('hotmixBullet'+i).src.replace('-inact','-act');
	selectedHotmixPage = i;
}

function hotmixPrev(){
	var go_page = selectedHotmixPage - 1;
	var last_page = hotmixPages.length - 1;
	
	if(go_page >= 0)
		hotmixGo(go_page);
	else
		hotmixGo(last_page);
		
	
}

function hotmixNext(){
	var go_page = selectedHotmixPage + 1;
	var last_page = hotmixPages.length -1;
	
	if(go_page <=last_page)
		hotmixGo(go_page);
	else
		hotmixGo(0);
}

var oldmark = Array();
var tmpon=0;

function displayMark(mark,id){

	if($('rating_area_value_'+id))
		$('rating_area_value_'+id).innerHTML = mark;
	
	for (i=1;i<=10;i++){
		if(i<=mark)
			$('MarkBar'+id+'_'+i).className = 'over';
		else
			$('MarkBar'+id+'_'+i).className = '';
	}
	

}

function displayMark2(mark,id){
	//confirm('test');
	if(!tmpon)
		displayMark(mark,id);
}

function rateReview(mark,id){
	oldmark[id] = mark;
	
	new Ajax.Updater('ratingArea', site_path_lang+'system/rating_area', {
		parameters: {content_id: id, mark: mark},evalScripts:true
	});
}

function rateReview2(mark,id){
	oldmark[id] = mark;
	
	new Ajax.Updater('reviewMarksZone'+id, site_path_lang+'system/rating_area_new', {
		parameters: {content_id: id, mark: mark},evalScripts:true
	});
}


function scrollingGalleryLeft(obj){
	var galleryItem = obj.parentNode.parentNode;
	if(!document.all)
	var itemContainer = galleryItem.getElementsByClassName('scrollingGalleryBottomItemContainerFull');
	else
	var itemContainer = document.getElementsByClassName('scrollingGalleryBottomItemContainerFull',galleryItem);
	
	itemContainer = itemContainer[0];
	
	if(!document.all)
	var viewerWidth = galleryItem.getElementsByClassName('scrollingGalleryBottomItemContainer');
	else
	var viewerWidth = document.getElementsByClassName('scrollingGalleryBottomItemContainer',galleryItem);
	
	viewerWidth = viewerWidth[0];
	viewerWidth = viewerWidth.offsetWidth; 
	
	
	
	var items = itemContainer.childNodes;
	
	var itemWidth = items[0].offsetWidth;
	
	var g =0;
	
	for (var l=0;l<items.length;l++){
		if(items[l].className == 'scrollingGalleryBottomItem')
			g++;
	}
	
	var itemCount = g;
	
	var maxPages = Math.ceil((itemCount * itemWidth) / viewerWidth);
	
	var offset = itemContainer.style.left.replace('px','') * -1;
	
	var currentPage = Math.floor(offset / viewerWidth);
	
	var goPage;
	
	if(currentPage > 0)
		goPage = currentPage - 1;
	else
		goPage = 0;
		
	//confirm('maxpages:' + maxPages + ' gopage:' + goPage + ' currentpage:' + currentPage);
	scrollingGalleryGo(goPage,obj);
	
	//confirm(currentPage);
	return false;
}

function scrollingGalleryRight(obj){
	var galleryItem = obj.parentNode.parentNode;
	if(!document.all)
	var itemContainer = galleryItem.getElementsByClassName('scrollingGalleryBottomItemContainerFull');
	else
	var itemContainer = document.getElementsByClassName('scrollingGalleryBottomItemContainerFull',galleryItem);
	
	itemContainer = itemContainer[0];
	
	if(!document.all)
	var viewerWidth = galleryItem.getElementsByClassName('scrollingGalleryBottomItemContainer');
	else
	var viewerWidth = document.getElementsByClassName('scrollingGalleryBottomItemContainer',galleryItem);
	
	viewerWidth = viewerWidth[0];
	viewerWidth = viewerWidth.offsetWidth; 
	
	var items = itemContainer.childNodes;
	
	var itemWidth = items[0].offsetWidth;
	
	var g =0;
	
	for (var l=0;l<items.length;l++){
		if(items[l].className == 'scrollingGalleryBottomItem')
			g++;
	}
	
	var itemCount = g;
	
	var maxPages = Math.ceil((itemCount * itemWidth) / viewerWidth);
	
	var offset = itemContainer.style.left.replace('px','') * -1;
	
	var currentPage = Math.floor(offset / viewerWidth);
	
	var goPage;
	
	
	
	if(currentPage < maxPages - 1)
		goPage = currentPage + 1;
	else
		goPage = maxPages-1;

	//confirm('maxpages:' + maxPages + ' gopage:' + goPage + ' currentpage:' + currentPage + ' itemCount:' + itemCount);
	
	scrollingGalleryGo(goPage,obj);	
	return false;
		
}

function scrollingGalleryGo(page,obj){
	var galleryItem = obj.parentNode.parentNode;
	
	if(!document.all)
	var itemContainer = galleryItem.getElementsByClassName('scrollingGalleryBottomItemContainerFull');
	else
	var itemContainer = document.getElementsByClassName('scrollingGalleryBottomItemContainerFull',galleryItem);
	
	itemContainer = itemContainer[0];
	
	if(!document.all)
	var viewerWidth = galleryItem.getElementsByClassName('scrollingGalleryBottomItemContainer');
	else
	var viewerWidth = document.getElementsByClassName('scrollingGalleryBottomItemContainer',galleryItem);
	
	viewerWidth = viewerWidth[0];
	viewerWidth = viewerWidth.offsetWidth; 
	
	new Effect.Move(itemContainer, {duration:0.5, x: -(viewerWidth * page), y: 0, mode: 'absolute',transition: Effect.Transitions.sinoidal});
	
	//itemContainer.style.marginLeft = '-' + (viewerWidth * page) + 'px';
	return false;
}



function verticalGalleryLeft(obj){

	var galleryItem = obj.parentNode.parentNode.parentNode;
	
	if(!document.all)
	var itemContainer = galleryItem.getElementsByClassName('verticalGalleryViewerContainer');
	else
	var itemContainer = document.getElementsByClassName('verticalGalleryViewerContainer',galleryItem);
	
	itemContainer = itemContainer[0];
	
	
	if(!document.all)
	var viewerHeight = galleryItem.getElementsByClassName('verticalGalleryViewer');
	else
	var viewerHeight = document.getElementsByClassName('verticalGalleryViewer',galleryItem);
	
	viewerHeight = viewerHeight[0];
	viewerHeight = viewerHeight.offsetHeight;
	
	
	
	if(!document.all)
	var pageButtons = galleryItem.getElementsByClassName('verticalGalleryNavigatorPage');
	else
	var pageButtons = document.getElementsByClassName('verticalGalleryNavigatorPage',galleryItem);
	
	
	var items = itemContainer.childNodes;
	
	var itemHeight = items[0].offsetHeight;
	
	
	
	
	//var itemCount = items.length;
	
	var g =0;
	
	for (var l=0;l<items.length;l++){
		if(items[l].className == 'verticalGalleryViewerItem')
			g++;
	}
	
	var itemCount = g;
	
	var maxPages = Math.ceil(itemContainer.offsetHeight / viewerHeight);
	
	var offset = itemContainer.style.top.replace('px','') * -1;
	
	var currentPage = Math.floor(offset / viewerHeight);
	
	var goPage;
	
	if(currentPage > 0)
		goPage = currentPage - 1;
	else
		goPage = maxPages - 1;
		
	
	verticalGalleryGo(goPage,obj);	
	return false;

}

function verticalGalleryRight(obj){

	var galleryItem = obj.parentNode.parentNode.parentNode;
	
	if(!document.all)
	var itemContainer = galleryItem.getElementsByClassName('verticalGalleryViewerContainer');
	else
	var itemContainer = document.getElementsByClassName('verticalGalleryViewerContainer',galleryItem);
	
	itemContainer = itemContainer[0];
	
	
	if(!document.all)
	var viewerHeight = galleryItem.getElementsByClassName('verticalGalleryViewer');
	else
	var viewerHeight = document.getElementsByClassName('verticalGalleryViewer',galleryItem);
	
	viewerHeight = viewerHeight[0];
	viewerHeight = viewerHeight.offsetHeight;
	
	
	
	if(!document.all)
	var pageButtons = galleryItem.getElementsByClassName('verticalGalleryNavigatorPage');
	else
	var pageButtons = document.getElementsByClassName('verticalGalleryNavigatorPage',galleryItem);
	
	
	var items = itemContainer.childNodes;
	
	var itemHeight = items[0].offsetHeight;
	
	//var itemCount = items.length;
	
	
	var g =0;
	
	for (var l=0;l<items.length;l++){
		if(items[l].className == 'verticalGalleryViewerItem')
			g++;
	}
	
	var itemCount = g;
	
	
	var maxPages = Math.ceil(itemContainer.offsetHeight / viewerHeight);
	
	var offset = itemContainer.style.top.replace('px','') * -1;
	
	var currentPage = Math.floor(offset / viewerHeight);
	
	var goPage;
	
	
	
	if(currentPage < maxPages - 1)
		goPage = currentPage + 1;
	else
		goPage = 0;
		
	
	
	verticalGalleryGo(goPage,obj);	
	return false;
	

}
var tmp;
function verticalGalleryGo(page,obj){
	
	var galleryItem = obj.parentNode.parentNode.parentNode;
	
	if(!document.all)
	var itemContainer = galleryItem.getElementsByClassName('verticalGalleryViewerContainer');
	else
	var itemContainer = document.getElementsByClassName('verticalGalleryViewerContainer',galleryItem);
	
	itemContainer = itemContainer[0];
	
	
	if(!document.all)
	var viewerHeight = galleryItem.getElementsByClassName('verticalGalleryViewer');
	else
	var viewerHeight = document.getElementsByClassName('verticalGalleryViewer',galleryItem);
	
	viewerHeight = viewerHeight[0];
	viewerHeight = viewerHeight.offsetHeight;
	
	
	
	if(!document.all)
	var pageButtons = galleryItem.getElementsByClassName('verticalGalleryNavigatorPage');
	else
	var pageButtons = document.getElementsByClassName('verticalGalleryNavigatorPage',galleryItem);
	
	
	for(i=0;i<pageButtons.length;i++){
	
		if(i == page)
			pageButtons[i].className = 'verticalGalleryNavigatorButton verticalGalleryNavigatorPage verticalGalleryNavigatorPageActive';
		else
			pageButtons[i].className = 'verticalGalleryNavigatorButton verticalGalleryNavigatorPage';
	
	}
	
	
	
	
	
	new Effect.Move(itemContainer, {duration:0.3, x: 0, y: -(viewerHeight * page), mode: 'absolute',transition: Effect.Transitions.sinoidal});
	
	//itemContainer.style.marginLeft = '-' + (viewerWidth * page) + 'px';
	return false;

}
var commonGalleryHeight = '';
function makeVerticalGalleryNavigator(){

	galleryNavigators = document.getElementsByClassName('verticalGalleryNavigator'); 
	
	for(i=0;i<galleryNavigators.length;i++){
		
		
		
		
		var galleryItem = galleryNavigators[i].parentNode.parentNode;
	
		if(!document.all)
			var itemContainer = galleryItem.getElementsByClassName('verticalGalleryViewerContainer');
		else
			var itemContainer = document.getElementsByClassName('verticalGalleryViewerContainer',galleryItem);
	
		itemContainer = itemContainer[0];
	
		//confirm (itemContainer.offsetHeight);
	
		if(!document.all)
			var viewerHeight = galleryItem.getElementsByClassName('verticalGalleryViewer');
		else
			var viewerHeight = document.getElementsByClassName('verticalGalleryViewer',galleryItem);
	
		viewerHeight = viewerHeight[0];
		var viewer = viewerHeight;
		
		if(itemContainer.offsetHeight < viewerHeight.offsetHeight){
			//commonGalleryHeight = viewer.offsetHeight;
			viewer.style.height = 'auto';
		}
		else{
			//confirm(commonGalleryHeight);
			viewer.style.height = '';
		}
		
		viewerHeight = viewerHeight.offsetHeight;
		
		
		
		
		var items = itemContainer.childNodes;
	
		var itemHeight = items[0].offsetHeight;
	
		var itemCount = items.length;
	
		
		
		
		
		
		//confirm (itemContainer.offsetHeight);
		
		var maxPages = Math.ceil(itemContainer.offsetHeight / viewerHeight);
		
		var offset = itemContainer.style.top.replace('px','') * -1;
	
		var currentPage = Math.floor(offset / viewerHeight);
		var galleryNavigatorHTML = '';
		
		
		
		if(maxPages > 1){
			galleryNavigatorHTML += '<a href=\"javascript:;\" class=\"verticalGalleryNavigatorButton verticalGalleryNavigatorLeft\" onclick=\"verticalGalleryLeft(this);\"></a>';
			
			for(k = 0; k < Math.min(maxPages,10); k++)
				galleryNavigatorHTML += '<a href=\"javascript:;\" class=\"verticalGalleryNavigatorButton verticalGalleryNavigatorPage' + (k==currentPage?' verticalGalleryNavigatorPageActive':'') + '\" onclick=\"verticalGalleryGo('+k+',this);\">';
			
			galleryNavigatorHTML += '<a href=\"javascript:;\" class=\"verticalGalleryNavigatorButton verticalGalleryNavigatorRight\"  onclick=\"verticalGalleryRight(this);\"></a>';
		}
		
		galleryNavigators[i].innerHTML = galleryNavigatorHTML;
		
	}
	
}


function switchGameArticles(game_id,mode){
	
	new Ajax.Updater('games_list_newsarticles', site_path_lang+'system/games_list_newsarticles', {
		parameters: { game_id: game_id, mode: mode},evalScripts:true
	});
	
}

function switchGameUserreviews(game_id,mode){
	
	new Ajax.Updater('games_list_userreviews', site_path_lang+'system/games_list_userreviews', {
		parameters: { game_id: game_id, mode: mode},evalScripts:true
	});
	
}

function switchGameFromusers(game_id,mode){
	
	new Ajax.Updater('games_list_fromusers', site_path_lang+'system/games_list_fromusers', {
		parameters: { game_id: game_id, mode: mode},evalScripts:true
	});
	
}


function addGameToCollection(game_id,platform_id,action){
	//confirm(game_id + ' ' + platform_id);
	
	new Ajax.Updater('add_game_to_collection', site_path_lang+'system/add_game_to_collection', {
		parameters: { game_id: game_id, platform_id: platform_id, action:action},evalScripts:true
	});
}


function filterGalleryContent(select){
	
	
		var galleryItem = select.parentNode.parentNode.parentNode;
		
		if(!document.all)
			var galleryItems = galleryItem.getElementsByClassName('verticalGalleryViewerItem');
		else
			var galleryItems = document.getElementsByClassName('verticalGalleryViewerItem',galleryItem);
	

		for (var i=0; i<galleryItems.length; i++){
		
			//confirm(galleryItems[i].className);
			
			if(galleryItems[i].className.indexOf(select.value)>0 || select.value == '')
				galleryItems[i].style.display='block';
			else
				galleryItems[i].style.display='none';
			
		}	
			
		makeVerticalGalleryNavigator();
		verticalGalleryGo(0,galleryItem);
		//confirm(galleryItem.className);
	

}

var currentHhn = 1;

function scrollHn(i){
	
	$('largeFeaturedContainer').style.marginTop = '-'+((i-1) * 273)+'px';
	currentHhn = i;
	pauseHhnShow();
}



var hhnExecuter;

function showNextHhn(){
	
	nextHhn = currentHhn * 1 + 1;
	if(nextHhn > totalHnCount)
		nextHhn = 1;
	scrollHn(nextHhn);
}

function playHhnShow(){
	clearTimeout(hhnExecuter);
	showNextHhn();
	startHhnShow();
}

function pauseHhnShow(){
	if(hhnExecuter)
		clearTimeout(hhnExecuter);
}

function startHhnShow(){
	hhnExecuter = setTimeout('playHhnShow()', 5000);
}

function checkRevPrev(){

	if(
		($($('mark_review')) && $('mark_review').checked) 
		|| ($($('is_review')) && $('is_review').checked)  
		|| ($($('is_preview')) && $('is_preview').checked)  
	){ $('rev_ownerrating_container').style.display = 'block';} else { $('rev_ownerrating_container').style.display = 'none'; }

}

var verticalGalleryAutorun = Array();

function autoRunVerticalGallery(galleryId){

		verticalGalleryAutorun[galleryId] = setTimeout('autoRunVerticalGalleryTick(\''+galleryId+'\')',5000);

}

function autoRunVerticalGalleryTick(galleryId){
	if(verticalGalleryAutorun[galleryId])
	clearTimeout(verticalGalleryAutorun[galleryId]);
	
	if($(galleryId).childNodes[1].childNodes[0])
	verticalGalleryRight($(galleryId).childNodes[1].childNodes[0]);
	
	verticalGalleryAutorun[galleryId] = setTimeout('autoRunVerticalGalleryTick(\''+galleryId+'\')',5000);
}

function cancelBubble(){
	 if( typeof(window.event)!='undefined'){window.event.cancelBubble=true;} else {event.stopPropagation();}
}

function resizeBody(){
	
	var body  = document.getElementsByClassName('pageBody');
	var bodyheader  =$('bodyheader');
	
	if(body!=''){
		body = body[0];
		
		var offset = 0;
		
		if(bodyheader)
			offset = bodyheader.offsetHeight + 20;
		
		if(body && body.style)	
			body.style.height = Math.max(body.offsetHeight,$('sidebar').offsetHeight - 50 - offset)+'px';
		
		//confirm('body:'+body.offsetHeight + 'sidebar:' +$('sidebar').offsetHeight );
		//confirm(body.style.height);
		
	}
}