function default_handle(callback_element, strText) {    document.getElementById(callback_element).innerHTML = strText;}function defaultPopupHandle(strText) {displayPopup(objPopup, strText, false, 250);}function defaultPopupHandleCentered(strText) {displayPopup(objPopup, strText, true, 250);}function hideElement(callback_element, strText) {document.getElementById(callback_element).style.display = 'none';}function updateElementRunJS(callback_element, strText) {var objReturn = eval('(' + strText + ')');default_handle(callback_element,objReturn.strHTML); eval(objReturn.strJS); }function setAlertMessage(strResponse) {if(strResponse) {var objRecords = eval('(' + strResponse + ')');showHoverAlert(objRecords.strAlertMessage, objRecords.strSuccErr, 5);}}function AjaxRequest(url, callback_element, callback_function, method_type ) {    var http_request = false;    if (window.XMLHttpRequest) {        http_request = new XMLHttpRequest();        if (http_request.overrideMimeType) {           http_request.overrideMimeType('text/xml');        }    } else if (window.ActiveXObject) {         try {           http_request = new ActiveXObject("Msxml2.XMLHTTP");        } catch (e) {            try {                http_request = new ActiveXObject("Microsoft.XMLHTTP");            } catch (e) {}        }    }    if (!http_request) {        return false;    }    http_request.onreadystatechange = function() {        if (http_request.readyState == 4) {            if (http_request.status == 200) {var strResponseEnding = 'Text';if (callback_function) {if(callback_element == null) {  callback_function(eval('http_request.response'+strResponseEnding));} else {var strTemp = eval('http_request.response'+strResponseEnding);if(typeof callback_function == 'string') { eval(callback_function+'("'+callback_element+'",strTemp);');} else { callback_function(callback_element,strTemp);}}} else {if( callback_element ) {default_handle(callback_element, eval('http_request.response'+strResponseEnding) );}}            } else {                           }        }    };    if( method_type == 'POST') {urlparams = url.split('?');url = urlparams[0];params = urlparams[1];http_request.open('POST', url, true);http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");http_request.setRequestHeader("Content-length", params.length );http_request.setRequestHeader("Connection", "close");http_request.setRequestHeader("Authorization", "Basic bXVjaGdhbWVzOnhldDU1am9j" );    http_request.send( params );} else {    http_request.open('GET', url, true);    http_request.send(null);}}var arrPhotos 				= new Array();

var intX;
var intY;

var strLastField			= '';
var strVisitedURL 			= '';
var blnAnimation			= false;
var blnReceiverDropdownOpen = false;
var blnDropdownOpen 		= false;
var blnSending 				= false;
var blnLoader				= false;

/* Initialized the Loading icon */
var imgLoader = new Image(66,66);
imgLoader.src = 'http://www.muchgames.com/images/loading.gif';

var arrStaticTabs 		= new Object();

document.onmouseup = mouseUp;

/*
*	Function is fired when mouse is moved. It calls the calculation of mouse coordinates
*	Return: none, sets intX and intY global mouse coordinate variables
*/
function mouseUp(e){
	e			= e || window.event;

	intX = mousePosX(e);
	intY = mousePosY(e);
	
	if(blnReceiverDropdownOpen) {
		closeMessageReceiverDropdown();
	}
}

function mousePosX(e) {
	var intXPosition=0;
	
	if(!e) {
		var e=window.event;
	}
	if(e.pageX) {
		intXPosition=e.pageX;
	} else if(e.clientX&&document.body.scrollLeft) {
		intXPosition=e.clientX+document.body.scrollLeft;
	} else if(e.clientX&&document.documentElement.scrollLeft) {
		intXPosition=e.clientX+document.documentElement.scrollLeft;
	} else if(e.clientX) {
		intXPosition=e.clientX;
	}
	return intXPosition;
}

function mousePosY(e) {
	var intYPosition=0;
	
	if(!e) {
		var e=window.event;
	}
	if(e.pageY) {
		intYPosition=e.pageY;
	} else if(e.clientY&&document.body.scrollTop) {
		intYPosition=e.clientY+document.body.scrollTop;
	} else if(e.clientY&&document.documentElement.scrollTop) {
		intYPosition=e.clientY+document.documentElement.scrollTop;
	} else if(e.clientY) {
		intYPosition=e.clientY;
	}
	return intYPosition;
}

function setWindowWidth() {
	intWindowWidth = getWindowWidth();
	intXOffset = getScrollLeft();
}

function setWindowHeight() {
	intWindowHeight = getWindowHeight();
	intYOffset = getScrollTop();
}

/****** Tooltips ******/

function getElementPosition( objThis ) {
	var intPosLeft = intPosTop = 0;
	if (objThis.offsetParent) {
		do {
			intPosLeft += objThis.offsetLeft;
			intPosTop += objThis.offsetTop;
		} while (objThis = objThis.offsetParent);
	}

	if( navigator.appName == 'Safari' ){
		intPosTop += 4;
	}

	return [intPosLeft, intPosTop];
}

function initToolTip() {
	var objToolTip				= document.createElement('div');
	objToolTip.id 				= 'tooltip';
	objToolTip.className		= 'vNo';

	var objToolTipInfo 			= document.createElement('div');
	objToolTipInfo.id			= 'tooltip_info';
		
	var objToolTipArrow 		= document.createElement('div');
	objToolTipArrow.id			= 'tooltip_arrow';
	
	objToolTip.appendChild(objToolTipInfo);
	objToolTip.appendChild(objToolTipArrow);
	
	document.body.appendChild( objToolTip );
}

function initFade() {

	var objFade		= document.createElement('div');
	objFade.id 		= 'fade_alert_container';

	var objFadeWrapper	= document.createElement('div');
	objFadeWrapper.id	= 'fade_alert_wrapper';

	objFadeWrapper.innerHTML = '<div id="fade_alert_box"></div>';

	objFade.appendChild( objFadeWrapper );
	
	objTop			= document.getElementById('top');

	document.getElementById('container').insertBefore( objFade, objTop );
}

function showToolTip( objThis, strCaption ) {
	if( blnAnimation == false ) {
		arrPosition = getElementPosition( objThis );
		
		intPosLeft = arrPosition[0]-2;
		intPosTop = arrPosition[1] - 34;

		intCaptionLength = strCaption.length;

		var objToolTip 				= document.getElementById('tooltip');
		var objToolTipInfo 			= document.getElementById('tooltip_info');
		var objToolTipArrow 		= document.getElementById('tooltip_arrow');
		objToolTip.className 		= 'vYes';

		objToolTipArrow.className 			= 'tooltip_left';
		objToolTip.style.left 				= '0px';
		objToolTip.style.top 				= intPosTop+ 'px';
		
		if ( navigator.appName == 'Microsoft Internet Explorer' ) {
			if( parseFloat(navigator.appVersion.split("MSIE")[1]) == 6 ) {
				objToolTip.style.width='180px';
			}
		}

		objToolTipInfo.innerHTML 			= strCaption;

		if( intPosLeft > getWindowWidth() / 2 ){
			intFlippedPosition 			= ( intPosLeft - objToolTip.offsetWidth + objThis.offsetWidth ) + 'px';
			objToolTip.style.left 		= intFlippedPosition;
			objToolTipArrow.className 	= 'tooltip_right';
		} else {
			objToolTip.style.left 		= intPosLeft+ 'px';
		}

	}
}

function hideToolTip( ) {
	if( blnAnimation == false ) {
		document.getElementById('tooltip').className = 'vNo';
	}
}


/** Removes carriage returns and new lines and tabs ***/

function removeNL(strRemove) {
	var strClean = '';
	for (i=0;i<strRemove.length;i++) {
		if (strRemove.charAt(i) != '\n' && strRemove.charAt(i) != '\r' && strRemove.charAt(i) != '\t') {
			strClean += strRemove.charAt(i);
		}
	}
	return strClean;
}



/*** Get Scroll Positioning ***/

function getScrollTop() {
	var intScrollTop = null;
	if(window.innerHeight) {
		intScrollTop = window.pageYOffset;
	} else if(document.documentElement.clientHeight) {
		intScrollTop = document.documentElement.scrollTop;
	} else {
		intScrollTop = document.body.scrollTop;
	}
	return intScrollTop;
}

function getScrollLeft() {
	var intScrollLeft = null;
	if(window.innerWidth) {
		intXOffset = window.pageXOffset;
	} else if(document.documentElement.clientWidth) {
		intXOffset = document.documentElement.scrollLeft;
	} else {
		intXOffset = document.body.scrollLeft;
	}
	return intScrollLeft;
}

function getWindowHeight() {
	var intHeight = null;
	if(window.innerHeight) {
		intHeight = window.innerHeight;
	} else if(document.documentElement.clientHeight) {
		intHeight = document.documentElement.clientHeight;
	} else {
		intHeight = document.body.clientHeight;
	}
	return intHeight;
}

function getWindowWidth() {
	var intWidth = null;
	if(window.innerWidth) {
		intWidth = window.innerWidth - 17;
	} else if(document.documentElement.clientWidth) {
		intWidth = document.documentElement.clientWidth;
	} else {
		intWidth = document.body.clientWidth;
	}
	return intWidth;
}

function fadeElement(strElementId, intTimeInSeconds ) {

	if( intTimeInSeconds == undefined ) {
		intTimeInSeconds = 4;
	}
	if( intTimeInSeconds != 0 ) {
		setTimeout( function() { document.getElementById( strElementId ).style.display = 'none'; }, intTimeInSeconds*1000);
	}
}

/* Loads contents for a panel. Ajax can be turned off / on . */
function loadPage( intPage, strPageURL , strParams, blnAjax, strInto ) {

	var strURL = 'http://www.muchgames.com/' + strPageURL + '?' + strParams + 'intPage=' + intPage;

	if( strURL != strVisitedURL ){
		if( blnAjax ) {

			displayLoading();

			var fncCallback = function( strElementId, strResponse ){
				document.getElementById( strElementId ).innerHTML = strResponse;
				hideLoading();
			};
			AjaxRequest( strURL, strInto, fncCallback );

		} else {
			location.href = strURL;
		}
	}

	strVisitedURL = strURL;
}


/* Fills all the specified selection fields with specified values on the page */

function fillSelections( objSelects ) {
	for (var i in objSelects) {
		if(objSelects[i] != '' && parseInt(objSelects[i], 10) != 0) {
			document.getElementById(i).value = objSelects[i];
		}
	}
}


/* Fills all the specified check fields with specified values on the page */

function fillChecks( objChecks ) {
	for (var i in objChecks) {
		if( objChecks[i] == '1' || objChecks[i] == 'yes' ) {
			var objCheck = document.getElementById(i);

			objCheck.checked = true;
			toggleCheck( objCheck );
		}
	}
}

/* Toggles checkbox */

function toggleCheck( objCheck ) {

	if( objCheck.checked ) {
		strClassName = 'fBo';
		blnCheck = true;
	}
	else {
		strClassName = '';
		blnCheck = false;
	}

	if (objCheck.parentNode.nodeName == 'LABEL') {
		objCheck.parentNode.className = strClassName;
	}
	objCheck.checked = blnCheck;
}


/* Search */

function searchGames( strMode, strView ) {

	var strGameName = '';
	var strCategory = '';
	var strOrderBy = '';
	var strHot = '';
	var strMultiplayer = '';
	var strOnline = '';
	var blnTopRated = '';
	var blnPopular = '';
	var strHighscores = '';
	var strGameView = ( strView == undefined ) ? '' : strView;

	var strGameName = document.getElementById( 'strQuery'+strMode ).value;

	if( strMode == 'Advanced' ) {

		strCategory = document.frmAdvancedSearch.strCategory.value;
		strOrderBy = document.getElementById('strOrderBy').value;

		if(document.frmAdvancedSearch.strHot.checked) 			{ strHot = 'yes'; }
		if(document.frmAdvancedSearch.strMultiplayer.checked) 	{ strMultiplayer = 'yes'; }
		if(document.frmAdvancedSearch.strOnline.checked) 		{ strOnline = 'yes'; }
		if(document.frmAdvancedSearch.blnTopRated.checked) 		{ blnTopRated = 'yes'; }
		if(document.frmAdvancedSearch.blnPopular.checked) 		{ blnPopular = 'yes'; }
		if(document.frmAdvancedSearch.strHighscores.checked) 	{ strHighscores = 'yes'; }

	}

	if( strGameName == 'search games' || strGameName == '' ) {
		strGameName = '';
	}
	location.href =' http://www.muchgames.com/searchgames.php?strView='+strGameView+'&strGameName='+strGameName+'&strCategory='+strCategory+'&strHot='+strHot+'&strMultiplayer='+strMultiplayer+'&strOnline='+strOnline+'&blnTopRated='+blnTopRated+'&blnPopular='+blnPopular+'&strHighscores='+strHighscores+'&strOrderBy='+strOrderBy;
}

/* search gamers on gamers page and search gamers page */
function searchGamers( strMode ) {

	var strUserName 	= document.getElementById( 'strQuery'+strMode ).value;

	var strCountryCode 	= '';
	var intAgeFrom 		= '';
	var intAgeTo		= '';
	var strGender		= '';
	var strOnline		= '';
	var strPhoto		= '';
	var strOrderBy 		= '';

	if( strMode == 'Advanced' ) {

		if( document.getElementById('strOrderBy') ) {
			strOrderBy = document.getElementById('strOrderBy').value
		}

		strCountryCode 	= document.frmAdvancedSearch.strCountryCode.value;
		intAgeFrom 		= document.frmAdvancedSearch.intAgeFrom.value;
		intAgeTo 		= document.frmAdvancedSearch.intAgeTo.value;
		strGender 		= document.frmAdvancedSearch.strGender.value;

		strOnline = (document.frmAdvancedSearch.strOnline.checked) ? 'yes' : '';
		strPhoto = (document.frmAdvancedSearch.strPhoto.checked) ? 'yes' : '';
		
	}

	location.href =' http://www.muchgames.com/searchgamers.php?&strUserName='+strUserName+'&strCountryCode='+strCountryCode+'&intAgeFrom='+intAgeFrom+'&intAgeTo='+intAgeTo+'&strGender='+strGender+'&strOnline='+strOnline+'&strPhoto='+strPhoto+'&strOrderBy='+strOrderBy;

}


function toggleElement( strElementId ) {
	var objElement = document.getElementById( strElementId );
	objElement.className = objElement.className.indexOf( 'vNo' ) ? objElement.className.replace( 'vYes', 'vNo' ) : objElement.className.replace( 'vNo', 'vYes' );
}

function expandElement( strElementId ) {
	var objElement = document.getElementById( strElementId );
	objElement.className = objElement.className.indexOf( strElementId ) ? objElement.className.replace( 'expanded', strElementId ) : objElement.className.replace( strElementId, 'expanded' );
}

/* Showding hiding drop downs at the top */
function showDropDown( strElementId ) {
	document.getElementById( strElementId ).style.display = 'block';
	blnDropdownOpen = true;
}

function hideDropDown( strElementId ) {
	blnDropdownOpen = false;
	setTimeout( 'hideDropDownNow( \''+strElementId+'\')', 750);
}

function hideDropDownNow( strElementId ) {
	if( !blnDropdownOpen ) {
		var divDropDown = document.getElementById( strElementId );
		divDropDown.style.display = 'none';
	}
}

/* Displays a loading icon in the center of the page */
function displayLoading() {
	setWindowWidth();
	setWindowHeight();
	if( !blnLoader ) {
		objLoader = document.createElement('div');
		objLoader.className = 'loading';
		objLoader.id = 'loading';
		
		objLoader.appendChild( imgLoader );
		
		document.body.appendChild( objLoader );

		blnLoader = true;
	} else {
		objLoader = document.getElementById('loading');
	}
	objLoader.style.top = (intWindowHeight / 2) - (objLoader.clientHeight / 2) + intYOffset + 'px';
	objLoader.style.left = (intWindowWidth / 2) - (objLoader.clientWidth / 2) + intXOffset + 'px';
	objLoader.style.visibility = 'visible';
}

function hideLoading() {
	if(objLoader) {
		objLoader.style.visibility = 'hidden';
	}
}

function contact( intGameId, strGameName ) {
	window.open( 'http://www.muchgames.com/report.php?intGameId='+intGameId+'&strGameName='+strGameName, 'Contact', 'left=100,top=100,status=no,toolbar=no,menubar=no,scrollbars=yes,width=800,height=440,location');
}

function forgotLoginInfo() {
	window.open( 'http://www.muchgames.com/report.php', 'Contact', 'left=100,top=100,status=no,toolbar=no,menubar=no,scrollbars=yes,width=800,height=400,location');
}

function smilies() {
	window.open( 'http://www.muchgames.com/smilies.php', 'Smilies', 'left=100,top=100,status=no,toolbar=no,menubar=no,scrollbars=yes,width=300,height=600,location');
}

function coins() {
	objPopup = showPopup('Coins, Items and Random Events');

    var strHTML = '<div class="wL">'
    +	'<div class="fBo">What are coins used for?</div><div>- Coins are used for purchasing items from the item shop.</div>'
    +	'<div class="fBo">What are items?</div><div>- You can collect items, give them to your friends and sell them.</div>'
    +	'<div class="fBo">What are random events?</div><div>- When you perform activities on the site such as rating games, commenting or just surfing the site, you always have a small chance of finding new items, sometimes even rare ones.</div>'
	+	'<br />'
	+	'<div class="fBo">How can I get more coins?</div>'
	+	'<hr /><div class="flL wSSM fs4 fBo">+100 coins</div><div class="flL wMLM">You invite a friend to join the site. To invite your friends now, please go to the <a href="http://www.muchgames.com/account/invite">Invite Friends</a> page.</div>'
	+	'<div class="clL"></div>'
	+	'<hr /><div class="flL wSSM fs4 fBo">+100 coins</div><div class="flL wMLM">You upload an avatar for the first time.</div>'
	+	'<div class="clL"></div>'
	+	'<hr /><div class="flL wSSM fs4 fBo">+50 coins</div><div class="flL wMLM">You report something that is helpful to us. It could be a bug on the site, abuse or a helpful suggestion. We read it all and evaluate your feedback.</div>'
	+	'<div class="clL"></div>'
	+	'<hr /><div class="flL wSSM fs4 fBo">+50 coins</div><div class="flL wMLM">You advance to a new level. To advance levels, you can play games, rate them and write useful comments on them. This will get you points and coins at the same time.</div>'
	+	'<div class="clL"></div>'
	+	'<hr /><div class="flL wSSM fs4 fBo">+25 coins</div><div class="flL wMLM">You sign up to the site.</div>'
	+	'<div class="clL"></div>'
	+	'<hr /><div class="flL wSSM fs3 fBo">+5 coins</div><div class="flL wMLM">You comment on a game. <b>Important Note</b>: If your comments are not precise and related to the game, we will first deduct your points, then ban you from the site. Do <b>NOT</b> write comments JUST to earn more points!</div>'
	+	'<div class="clL"></div>'
	+	'<hr /><div class="flL wSSM fs3 fBo">+5 coins</div><div class="flL wMLM">You rate a game.</div>'
	+	'<div class="clL"></div>'
	+	'<hr /><div class="flL wSSM fs3 fBo">+1 coins</div><div class="flL wMLM">You play a game. <b>Hint</b>: Refreshing a game page a thousand times is NOT going to give you 1000 coins!</div>'
	+	'</div>';

	displayPopup(objPopup, strHTML, false, 600);
}

function getElementsByClass( strClass, strNode, strTag ) {
	var objClassElements = new Array();
	if (strNode == null) {
		strNode = document;
	}
	if (strTag == null) {
		strTag = '*';
	}

	var arrEls = strNode.getElementsByTagName(strTag);
	var intElsCount = arrEls.length;

	var strPattern = new RegExp("(^|\\s)"+strClass+"(\\s|$)");
	for (i = 0, j = 0; i < intElsCount; i++) {
		if (strPattern.test(arrEls[i].className) ) {
	    	objClassElements[j] = arrEls[i];
	    	j++;
	    }
	}
	return objClassElements;
}

function parseXML( strXML ) {
	try { /* Internet Explorer */
		objXML=new ActiveXObject("Microsoft.XMLDOM");
		objXML.async="false";
		objXML.loadXML(strXML);
		return objXML;
	} catch(e) {
		objParser=new DOMParser();
		objXML=objParser.parseFromString(strXML,"text/xml");
		return objXML;
	}
}


if (!Array.prototype.indexOf) {
	Array.prototype.indexOf = function (obj, fromIndex) {
		if (fromIndex == null) {
			fromIndex = 0;
		} else if (fromIndex < 0) {
			fromIndex = Math.max(0, this.length + fromIndex);
		}
		for (var i = fromIndex; i < this.length; i++) {
			if (this[i] === obj) {
				return i;
			}
		}
		return -1;
	};
}var strShadowBoxContent = 'pop_content_content';var strShadowBoxContentWrap = 'pop_content';var blnDarkenInit= false;function initPopup( strTitle, strNewDiv ) {var objPopup;objPopup = document.createElement('div');objPopup.innerHTML = '<div class="pop_box" id="pop_box">	<table id="pop_dialog_table" class="pop_dialog_table">		<tbody>		<tr>			<td class="pop_topleft"/>			<td class="pop_border"/>			<td class="pop_topright"/>		</tr>		<tr>			<td class="pop_border"/>			<td id="pop_content" class="pop_content">			</td>			<td class="pop_border"/>		</tr>		<tr>			<td class="pop_bottomleft"/>			<td class="pop_border"/>			<td class="pop_bottomright"/>		</tr>		</tbody>	</table></div>';document.body.appendChild(objPopup);objPopup = document.getElementById('pop_box');objPopupContent = document.getElementById(strShadowBoxContentWrap);objPopup.style.visibility = 'hidden'; if(strTitle != undefined) {strTitleHeader = '<div class="pop_title"><b>'+strTitle+'</b><div class="pop_close" onclick="javascript: hidePopup();"></div></div>';} else {strTitleHeader = '';}objPopupContent.innerHTML = strTitleHeader+'<div class="pop_content_content" id="'+strShadowBoxContent+'"></div>';return objPopup;}function showPopup( strTitle, strNewDiv ) {darkenBackground( true );var objPopup = initPopup(strTitle, strNewDiv);displayLoading();return objPopup;}function displayPopup( objPopup, strHTML, blnCentered, intWidth, intHeight ) {if(strHTML) {objContent = document.getElementById(strShadowBoxContent);objContent.innerHTML = strHTML;}var intScrollBarWidth = 20;var intLeft = 0; var intTop = 0; objPopup.style.height = '';objPopup.style.width = '';setWindowWidth();setWindowHeight();if(intHeight) {objPopup.style.height = intHeight + 'px';}if(intWidth) {objPopup.style.width = intWidth + 'px';}objPopup.style.display = 'block';intBoxWidth = objPopup.clientWidth;intBoxHeight = objPopup.clientHeight;if(intHeight) {objPopup.style.height = intBoxHeight + 'px';}if(intWidth) {objPopup.style.width = intBoxWidth + 'px';}if(blnCentered) {intLeft = intXOffset + (intWindowWidth - intBoxWidth) / 2;intTop = intYOffset + (intWindowHeight - intBoxHeight) / 2;} else {intLeft = intX;intTop = intY;}var intPadding = 14;var intYOverlap = intTop + intBoxHeight + intScrollBarWidth + intPadding - intWindowHeight - intYOffset;if(intYOverlap > 0) {intTop -= intYOverlap;}var intXOverlap = intLeft + intBoxWidth + intScrollBarWidth + intPadding - intWindowWidth - intXOffset;if(intXOverlap > 0) {intLeft -= intXOverlap;}if(intTop - intYOffset < 0) {intTop = intYOffset + 3;}if(intLeft - intXOffset < 0) {intLeft = intXOffset + 3;}objPopup.style.left = intLeft + 'px';objPopup.style.top = intTop + 'px';if(objLoader) {objLoader.style.visibility = 'hidden';}objPopup.style.visibility = 'visible';blnPopupOpen = true;}function hidePopup() {objPopup.style.visibility = 'hidden';if( document.getElementById('gamewrapper') ) {document.getElementById('gamewrapper').style.display = 'block';}blnPopupOpen = false;darkenBackground( false );}function notLoggedIn( strParameter ) {var strParameter = ( !strParameter ) ? '' : strParameter;location.href='http://www.muchgames.com/register/'+strParameter;}function blockedPopup(){objPopup = showPopup('Browser Error');var strHTML = ''+'Your browser blocked the popup. You need to <b>enable popups</b> on this site in order to use this feature. '+'<a class="fBo" href="http://www.muchgames.com/faq.php#15">Click here</a> to learn how to enable popups for your browser.'+'<div class="aC">'+'<br />'+'<input class="button" type="button" value="Close" onclick="javascript: hidePopup();" />'+ '</div>';displayPopup(objPopup, strHTML, false, 240);}function darkenBackground( blnDarken ) {if( !blnDarkenInit ) {objBackground = document.createElement('div');objBackground.id = 'darkbackground';document.body.appendChild( objBackground );blnDarkenInit = true;} else {objBackground = document.getElementById('darkbackground');}if( blnDarken ) {objBackground.style.display = 'block';} else {objBackground.style.display = 'none';}}function showFade( blnPositive, strTitle, strHTML, intFadeTime ) {positionFadeAlert();var strType = blnPositive ? 'up' : 'down';var strTitle = blnPositive ? '<span class="ccG fs3">'+strTitle+'</span>' : '<span class="ccR fs3">'+strTitle+'</span>';var objFadeBox = document.getElementById('fade_alert_box');var objFadeContainer= document.getElementById('fade_alert_container');var intFadeSeconds= ( intFadeTime == undefined ) ? '4' : 0;objFadeBox.className = 'fade_alert_box fade_alert_success';objFadeBox.innerHTML = ''+'<div class="fade_alert_close" onclick="javascript: closeFadeAlert();"></div>'+'<img src="http://www.muchgames.com/images/icons/thumb_'+strType+'_dark.gif" alt="" /> '+strTitle+''+'<div class="fs1 p7tb ccW">'+strHTML+'</div>';objFadeContainer.style.display = 'block';fadeElement( 'fade_alert_container', intFadeSeconds );}function closeFadeAlert() {document.getElementById('fade_alert_container').style.display = 'none';}function positionFadeAlert() {setWindowHeight();var objHoverAlert = document.getElementById('fade_alert_container');if(objHoverAlert) {objHoverAlert.style.top = ( ( ( intWindowHeight - 100 ) / 2 ) ) + 'px';}}function recoverLogin() {var strEmail = document.getElementById( 'strRecoveryEmail' ).value;location.href = 'http://www.muchgames.com/process_recovery.php?&strEmail='+strEmail;}function signup( strFormType ) {document.getElementById('frm'+strFormType+'Registration').submit();}function checkUserName() {var objInput = document.getElementById('strRegisterUserName');var objUserName = document.getElementById('strUserName_check');if( validateUserName( objInput.value ) ) {if( objInput.value != '' ) {AjaxRequest('http://www.muchgames.com/x_checkUserName.php?strUserName='+objInput.value, 'strUserName_check');} else {objUserName.innerHTML = '';}} else {objUserName.innerHTML = ' <img src="http://www.muchgames.com/images/icons/x.gif" /> <b>No Spaces! Only letters and numbers!</b>';}if( objUserName.innerHTML == '' ) {return true;} else {return false;}}function validateUserName( strUserName ) {var strAllowedChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-';var intUsernameLength = strUserName.length;for (i = 0; i < intUsernameLength; i++) {        if ( strAllowedChars.indexOf( strUserName.charAt(i) ) == -1 ){return false;}}return true;}function checkPassword() {var strPassword = document.getElementById('strRegisterPassword').value;var strPasswordConfirm = document.getElementById('strPasswordConfirm').value;if( strPassword != '' && strPasswordConfirm != '' ) {if( strPassword != strPasswordConfirm ) {strPasswordMessage = ' <img src="http://www.muchgames.com/images/icons/x.gif" /> <b>Passwords do not match!</b>';} else {strPasswordMessage = '';}} else {strPasswordMessage = '';}document.getElementById('strPassword_check').innerHTML = strPasswordMessage;document.getElementById('strPasswordConfirm_check').innerHTML = strPasswordMessage;if( strPasswordMessage == '' ) {return true;} else {return false;}}function checkEmail() {var objInput = document.getElementById('strEmail');var objEmail = document.getElementById('strEmail_check');if( objInput.value != '' ) {AjaxRequest('http://www.muchgames.com/x_checkEmail.php?strEmail='+objInput.value, 'strEmail_check');} else {objEmail.innerHTML = '';}if( objEmail.innerHTML == '' ) {return true;} else {return false;}}function quickSwap( strType ) {if( strType == 'quickregister' ) {document.getElementById( strType ).className = '';document.getElementById( 'quicklogin' ).className = 'vNo';document.getElementById('quickmessage').innerHTML = 'Already have an account? <a href="javascript: quickSwap(\'quicklogin\');">Login Now ..</a>';} else {document.getElementById( strType ).className = 'signupbox';document.getElementById( 'quickregister' ).className = 'vNo';document.getElementById('quickmessage').innerHTML = 'Dont have an account yet? <a href="javascript: quickSwap(\'quickregister\');">Sign Up Now ..</a>';}}function fileInfo( strFilePath ) {if(strFilePath != '') {    var arrFileInfo = new Array();    arrFileParts = strFilePath.split("\\");    strFileName = arrFileParts[arrFileParts.length - 1];    arrFileParts = strFileName.split('.');if(arrFileParts[arrFileParts.length - 2]) {strName = arrFileParts[arrFileParts.length - 2].toLowerCase();    strExt = arrFileParts[arrFileParts.length - 1].toLowerCase();} else if(arrFileParts[arrFileParts.length - 1]) {strName = arrFileParts[arrFileParts.length - 1].toLowerCase();}}}function uploadPhotos( intUploadCount, blnForce ) {var blnSubmit = false;    var objForm = document.frmPhotoUpload;        var intPhotoCount = ( !intUploadCount ) ? 10 : intUploadCount;        for( i=1; i <= intPhotoCount; i++ ) {if( objForm.elements['strPhoto_'+i].value != '' ) {document.getElementById('status'+i).innerHTML = '';document.getElementById('statusloading'+i).className = '';blnSubmit = true;}}if( blnSubmit ) {if( !blnForce ) {objForm.btnUpload.disabled = true;}objForm.submit();}}var blnRegister = false;function loginregister( strType ) {if( strType == 'login') {document.getElementById('logintab').className = 'loginbox_button loginbox_button_selected';document.getElementById('registertab').className = 'loginbox_button';document.getElementById('loginsection').className = '';document.getElementById('registersection').className = 'vNo';} else {document.getElementById('logintab').className = 'loginbox_button';document.getElementById('registertab').className = 'loginbox_button loginbox_button_selected';document.getElementById('loginsection').className = 'vNo';document.getElementById('registersection').className = '';}}function addFriend(){ notLoggedIn( 'addfriend' ); }function addFavorite(){ notLoggedIn( 'addfavorite' ); }function openMessages(){ notLoggedIn( 'sendmessage' ); }function openFriends(){ notLoggedIn( 'openfriends' ); }function openFavorites(){ notLoggedIn( 'openfavorites' ); }function startPrivateChat(){ notLoggedIn( 'privatechat' ); }function postSketch(){ notLoggedIn( 'postsketch' ); }