var mg,
currSpot='',
currNav=0,
currScoreList=2,
fadeDur=.4,
filterName='DXImageTransform.Microsoft.AlphaImageLoader',
playerAlias,
loadingGIF = '<img src="http://gwap.cachefly.net/gwap-web-016/img/buttons/loading.gif" width="22px" height="22px"/>',
spotlightTimer=new Date().getTime(),
getGameList = function() {
    var gameList = new Array();
    gameList[0]="espgame";
    gameList[1]="tagatune";
    gameList[2]="verbosity";
    gameList[3]="squigl";
    gameList[4]="matchin";
    gameList[5]="popvideo";

    return gameList;
},
invoke = function (form, event, container, completeFn) {
	var params = Form.serialize(form);
	if (event != null) params = event + '&' + params;
	new Ajax.Updater(container, form.action, {method:'post', postBody:params, onComplete:completeFn});
},
viewPreviewProfile = function (id) {
	this.playerID = id;
	this.previewHTML = $('preview_button').innerHTML;
	$('preview_button').innerHTML = loadingGIF;
	invoke(document.forms['update_form'], 'previewChanges', 'result', popupProfile);
	return false;
},
ae = function (a, d, b) {
	var c = "on" + d;
	if (a.addEventListener) {
		a.addEventListener(d, b, false);

	} else if(a.attachEvent) {
		a.attachEvent(c, b);

	} else {
		var e = a[c];
		a[c] = function() {
			var f = e.apply(this, arguments), n = b.apply(this,arguments);
			return f == undefined ? n : (n == undefined ? f : n && f);
		}
	}
},
tg = function (a) {
	a = a ? a : window.event;
	a.cancelBubble = true;
	mg.display = mg.display == "block" ? "none" : "block";
},
close = function (a) {
	mg && mg.display == "block" && tg(a);
},
activate = function (index) {
	tabs = $('pref_tabs').getElementsByTagName('div');
	contents = $('pref_content').getElementsByTagName('div');
	
	for (var i = 0; i < tabs.length; i++) {
		if (i == index) {
			tabs[i].className = 'h s';
			contents[i].className = 'tab';
		
		} else {
			tabs[i].className = 'h';
			contents[i].className = 'tab i';
		}
	}
},
okf = function () {
	if ($('errors_ok')) {
		$('errors_ok').focus();
	}
},
ce = function () {
	fixSelects();
	$('errors').className='i';
},
setFont = function () {
	return;
	var d = document.createElement('div');
	var s = document.createElement('span');
	d.appendChild(s);
	d.style.fontFamily = 'sans-serif';
	s.style.fontFamily = 'sans-serif';
	s.style.fontSize = '72px';
	s.innerHTML = 'mmmmmmmmmml';
	document.body.appendChild(d);
	var defaultWidth = s.offsetWidth;
	var defaultHeight = s.offsetHeight;
	s.style.fontFamily = 'arial rounded mt bold';
	if (s.offsetWidth != defaultWidth || s.offsetHeight != defaultHeight) {
		//alert('ha!');
	} else {
		//alert('~pause~');
		document.body.style.fontWeight = 'bold';
	}
},
init = function () {
	setTimeout('try {initImpl();} catch(e){}', 10);
},
initImpl = function () {
	try {
		if ($('errors_okButton')) {
			setFocus('errors_okButton');
		
		} else if (document.forms && document.forms[0]) {
			setFocus(document.forms[0].id);
		}
	} catch (e) {/* ignore - IE6 is throwing a bizarre error here @ gP */ }

    var games = getGameList();
    var displayIndex = Math.floor((Math.random() * games.length) % games.length);

    for (var i = 0; i < games.length; i++) {
        var game = games[i];
        if (i == displayIndex) {
			new Effect.Opacity(game + '_glyph', {duration:0.0, from:0.0, to:1.0});
			new Effect.Opacity(game + '_preview', {duration:0.0, from:0.0, to:1.0});
			new Effect.Opacity('game_summary_content_description_' + game, {duration:0.0, from:0.0, to:1.0});
			$('playnow_a').href = '/gwap/gamesPreview/' + game;
			currSpot = game;
        } else {
			new Effect.Opacity(game + '_glyph', {duration:0.0, from:1.0, to:0.0});
			new Effect.Opacity(game + '_preview', {duration:0.0, from:1.0, to:0.0});
            new Effect.Opacity('game_summary_content_description_' + game, {duration:0.0, from:1.0, to:0.0});
        }
    }
	new Effect.Opacity('game_summary_nav',{duration:0.0, from:0.0, to:1.0});
/*
	mg = $("more_games").style;
	ae(document, "click", close);
*/
},
d = function (s, i) {
	var endS = s.substring(s.lastIndexOf('.'))
	var beginS = s.substring(0, (s.lastIndexOf('.') - 1));
	return beginS + i + endS;
},
dSpan = function (el, i) {
	var newSpan = el.cloneNode(true);
	newSpan.style.filter = d(newSpan.style.filter, i);
	if (el.onmouseover)
		newSpan.onmouseover = el.onmouseover;
	if (el.onmouseout)
		newSpan.onmouseout = el.onmouseout;
	var pNode = el.parentNode;
	pNode.insertBefore(newSpan, el);
	pNode.removeChild(el);
},
act = function (i) {
	var els = $('info_nav_els').getElementsByTagName('img');
	if (els && els.length) {
		els[i].src = d(els[i].src, new String(1));
		switch(i) {
		case(0):
			els[1].src = d(els[1].src, new String(0));
			els[2].src = d(els[2].src, new String(0));
			break;
		case(1):
			els[0].src = d(els[0].src, new String(0));
			els[2].src = d(els[2].src, new String(0));
			break;
		case(2):
			els[0].src = d(els[0].src, new String(0));
			els[1].src = d(els[1].src, new String(2));
			break;
		default:
			break;
		}
	}
},
sGame = function (i) {
	if (i == currNav) return false;
	
	var n = $('game_summary_nav').getElementsByTagName('img'); 
	
	if (n[0]) {
		n[i].src = n[i].src.replace('Off', 'On');
		n[(i+1)%2].src = n[(i+1)%2].src.replace('On', 'Off');
	
	} else {
		el = $('game_summary_nav').getElementsByTagName('span')[i];
		var newSpan = el.cloneNode(true);
		newSpan.style.filter = newSpan.style.filter.replace('Off', 'On');
		var pNode = el.parentNode;
		pNode.insertBefore(newSpan, el);
		pNode.removeChild(el);
		
		el = $('game_summary_nav').getElementsByTagName('span')[(i+1)%2];
		var newSpan = el.cloneNode(true);
		newSpan.style.filter = newSpan.style.filter.replace('On', 'Off');
		var pNode = el.parentNode;
		pNode.insertBefore(newSpan, el);
		pNode.removeChild(el);
	}

	var descID = 'game_summary_content_description_' + currSpot;
	var top5ID = 'game_summary_content_top5_' + currSpot;
	if (i == 0) {
		/*$(top5ID).style.display = 'none';
		$(descID).style.display = 'block';
		/*/
		new Effect.Opacity(top5ID, {duration:fadeDur, from:1.0, to:0.0});
		new Effect.Opacity(descID, {duration:fadeDur, from:0.0, to:1.0});
		$(top5ID).style.zIndex = 3;
		$(descID).style.zIndex = 50;
		currNav = 0;

	} else {
		/*$(descID).style.display = 'none';
		$(top5ID).style.display = 'block';
		/*/
		new Effect.Opacity(descID, {duration:fadeDur, from:1.0, to:0.0});
		new Effect.Opacity(top5ID, {duration:fadeDur, from:0.0, to:1.0});
		$(top5ID).style.zIndex = 50;
		$(descID).style.zIndex = 3;
		currNav = 1;
	}
	return false;
},
sWelcome = function (i) {/*
	var x = ['left','center'];
	var y = ['profile','scores'];
	$('welcome_pointer').className = 'welcome_pointer_' + x[i];
	$('welcome_' + y[i]).className = '';
	$('welcome_' + y[(i+1)%2]).className = 'i';*/
},
sScores = function (i) {
	var x = ['left','right'];
	var y = ['profile','scores'];
	var z = ['Profile','Scores'];
	$('profile_pointer').className = 'profile_pointer_' + x[i];
	$('profile_' + y[i] + '_content').className = '';
	$('profile_' + y[(i+1)%2] + '_content').className = 'i';
	$('profile_pointer_img').src = $('profile_pointer_img').src.replace(y[(i+1)%2] + 'ArrowUp', y[i] + 'ArrowUp');
	document.title = document.title.replace(z[(i + 1) %2], z[i]);
	fixPNGs(false);
},
sProfile = function (i) {
	var x = $('profile_profile_content_nav').getElementsByTagName('td');
	for (var j = 0; j < x.length; j++) {
		if (j == (i))
			x[j].className = 'profile_profile_content_nav_item_selected';
		else
			x[j].className = 'profile_profile_content_nav_item';
	}
	var y = document.getElementsByClassName('profile_content_tab');
	for (var j = 0; j < y.length; j++) {
		y[j].className = 'profile_content_tab' + 
			((j != i) ? ' i' : '');
	}
	var z = ['update','matching','password','picture'];
	$('profile_redirectPage').value = z[i];
	if (i != 0)
		$('preview_button').className = 'i';
	else
		$('preview_button').className = '';
},
dim = function (i) {
	$('header_dim').style.zIndex = 2;
	$('header_dim').className = '';
	var x = $('button_' + i);
	x.style.zIndex = 3;
	x.innerHTML += '<div id="header_buttons_x"><a href="#" onclick="confirmExit()"><img src="http://gwap.cachefly.net/gwap-web-016/img/buttons/launcherCloseBox.png" width="14px" height="15px" alt="Exit"/></a></div>';
	return false;	//+ x.childNodes[0].innerHTML;
},
confirmExit = function (url) {
	$('header_button_dim_selected').className = '';
	$('header_exitWarning').className = '';
	$('confirmExit_yesButton_a').href = url;
	fixPNGs(false);
	return false;
},
denyExit = function () {
	$('header_button_dim_selected').className = 'i';
	$('header_exitWarning').className = 'i';
	return false;
},
undim = function (i) {
	$('header_dim').style.zIndex = -1;
	var x = $('header').getElementsByTagName('div')[i + 2];
	x.style.zIndex = 1;
	x.removeChild(x.childNodes[0]);
},
sPreview = function () {
	var x = $('gamesPreview_content_leftPane_instructions');
	var y = $('gamesPreview_content_leftPane_topScores');
	var z = $('gamesPreview_content_rightPane_switchButton_img');
	if (x.className == 'i'){//gamesPreview_content_leftPane_unselected') {
		//new Effect.Opacity('gamesPreview_content_leftPane_instructions', {duration:fadeDur, from:0.0, to:1.0});
		//new Effect.Opacity('gamesPreview_content_leftPane_topScores', {duration:fadeDur, from:1.0, to:0.0});
		x.className = '';
		y.className = 'i';//gamesPreview_content_leftPane_unselected';
		if (z) {
			z.src = z.src.replace('Instructions', 'TopScores');
		
		} else {
			el = $('gamesPreview_content_rightPane_switchButton').getElementsByTagName('span')[0];
			var newSpan = el.cloneNode(true);
			newSpan.style.filter = newSpan.style.filter.replace('Instructions', 'TopScores');
			var pNode = el.parentNode;
			pNode.insertBefore(newSpan, el);
			pNode.removeChild(el);
		}
		
	} else {
		//new Effect.Opacity('gamesPreview_content_leftPane_instructions', {duration:fadeDur, from:1.0, to:0.0});
		//new Effect.Opacity('gamesPreview_content_leftPane_topScores', {duration:fadeDur, from:0.0, to:1.0});
		x.className = 'i';//gamesPreview_content_leftPane_unselected';
		y.className = '';
		
		if (z) {
			z.src = z.src.replace('TopScores', 'Instructions');
			
		} else {
			el = $('gamesPreview_content_rightPane_switchButton').getElementsByTagName('span')[0];
			var newSpan = el.cloneNode(true);
			newSpan.style.filter = newSpan.style.filter.replace('TopScores', 'Instructions');
			var pNode = el.parentNode;
			pNode.insertBefore(newSpan, el);
			pNode.removeChild(el);
		}
		sPreviewScoreboard(currScoreList);
	}
	fixPNGs(false);
},
sSpotlight = function (s) {
	alert('/gwap/javascript/main/sSpotlight');
	if (s == currSpot)
		return;
	try {
		new Effect.Opacity(currSpot + '_glyph', {duration:fadeDur, from:1.0, to:0.0});
		new Effect.Opacity(currSpot + '_preview', {duration:fadeDur, from:1.0, to:0.0});
		
		if (currNav == 0) {
			//$('game_summary_content_description_' + currSpot).style.display = 'none';
			new Effect.Opacity('game_summary_content_description_' + currSpot, {duration:fadeDur, from:1.0, to:0.0});
			$('game_summary_content_description_' + currSpot).style.zIndex = 3;
		
		} else {
			//$('game_summary_content_top5_' + currSpot).style.display = 'none';
			new Effect.Opacity('game_summary_content_top5_' + currSpot, {duration:fadeDur, from:1.0, to:0.0});
			$('game_summary_content_top5_' + currSpot).style.zIndex = 3;
		}		
		new Effect.Opacity(s + '_glyph', {duration:fadeDur, from:0.0, to:1.0});
		new Effect.Opacity(s + '_preview', {duration:fadeDur, from:0.0, to:1.0});
		if (currNav == 0) {
			//$('game_summary_content_description_' + s).style.display = 'block';
			new Effect.Opacity('game_summary_content_description_' + s, {duration:fadeDur, from:0.0, to:1.0});
			$('game_summary_content_description_' + s).style.zIndex = 50;
		
		} else {
			//$('game_summary_content_top5_' + s).style.display = 'block';
			new Effect.Opacity('game_summary_content_top5_' + s, {duration:fadeDur, from:0.0, to:1.0});
			$('game_summary_content_top5_' + s).style.zIndex = 50;
		}
		currSpot = s;
		$('playnow_a').href = '/gwap/gamesPreview/' + s;
	} catch (e) {
	
	}
	
	spotlightTimer = new Date().getTime();
},
sAutoSpotlight = function () {
	if ((new Date().getTime() - spotlightTimer) > 10000) {

		var gameList = getGameList();
        var previewGame = currSpot;

		while (previewGame == currSpot) {
			previewGame = gameList[Math.floor(Math.random()*100) % gameList.length]; 
		};

		sSpotlight(previewGame);
	}
},
sPreviewScoreboard = function (i) {
	var x = $('gamesPreview_content_leftPane_topScores_nav').getElementsByTagName('div');
	
	x[i].className = x[i].className.replace('unselected', 'selected');
	if (x[(i + 1) % 3].className.indexOf('unselected') < 0)
		x[(i + 1) % 3].className = x[(i + 1) % 3].className.replace('selected', 'unselected');
	if (x[(i + 2) % 3].className.indexOf('unselected') < 0)
		x[(i + 2) % 3].className = x[(i + 2) % 3].className.replace('selected', 'unselected');
	var y = document.getElementsByClassName('gamesPreview_content_leftPane_topScores_scoreboard_items');
	var imgs = y[i].getElementsByClassName('gamesPreview_content_leftPane_topScores_scoreboard_item_img_src');
	if (!(imgs && imgs[0] && imgs[0].src.length > 0)) {
		for (var j = 0; j < imgs.length; j++) {
			imgs[j].src = imgs[j].alt;
			imgs[j].alt = '';
		}
	}
	y[i].className = 'gamesPreview_content_leftPane_topScores_scoreboard_items';
	y[(i + 1) % 3].className = 'gamesPreview_content_leftPane_topScores_scoreboard_items i';
	y[(i + 2) % 3].className = 'gamesPreview_content_leftPane_topScores_scoreboard_items i';
	currScoreList = i;
	fixPNGs(false);
},
filt = function (el, s, m) {
	if (el.filters[filterName]) {
		el.filters[filterName].enabled = s ? true : false;
		if (s) with (el.filters[filterName]) {
			el.src = s;
			el.sizingMethod = m;
		}	
	} else if (s)
		el.style.filter = 'progid:' + filterName + '(src="' + s + '",sizingMethod="' + m + '")';
},
checkDisplay = function (img) {
  	var el = img;
  	while (el.parentNode != document.body) {
  		if ((el.currentStyle && el.currentStyle.display == 'none') ||
  			(document.defaultView && document.defaultView.getComputedStyle && document.defaultView.getComputedStyle(el, null).getPropertyValue('display') == 'none') ||
  			(el.className == 'i')) {
  			return false;
  		}
  		el = el.parentNode;
  	}
  	return true;
},
fixPNGs = function (shouldInit) {
	//return init();
	/* i.e. if we're not running IE < 7.0, ignore */
	if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent)) {
  		if (arguments.length == 0 || shouldInit)
  			return init();
  		else return;
  	}
  	var divs = document.getElementsByTagName('div');
  	for (var i = 0; i < divs.length; i++) {
  		var cDiv = divs[i];
  		var bgImg = (cDiv.currentStyle) ? cDiv.currentStyle.backgroundImage
  						: cDiv.style.backgroundImage;
  		if (bgImg && bgImg != 'none') {
  			if (bgImg.match(/^url[("']+(.*\.png)[)"']+$/i)) {
  				var s = RegExp.$1;
  				//if (cDiv.currentStyle && cDiv.currentStyle.width == 'auto' && cDiv.currentStyle.height == 'auto') {
				//	alert('hi: ' + cDiv.id);
				//	cDiv.style.width = cDiv.offsetWidth + 'px';
				//}
				cDiv.style.backgroundImage = 'none';
				var toCrop = (cDiv.currentStyle.backgroundRepeat == 'no-repeat') ?
								'crop' : 'scale';
				filt(cDiv, s, toCrop);
				// IE link fix.
				//for (var n = 0; n < childNodes.length; n++)
				//if (childNodes[n].style) childNodes[n].style.position = 'relative';
  			}
  		}
  	}
  	var imgs = document.getElementsByTagName('img');
  	for (var i = 0; i < imgs.length; i++) {
  		var cImg = imgs[i];
  		var imgSrc = cImg.src;
  		if (imgSrc.match(/^(.*\.png)$/i) && checkDisplay(cImg) && (!isProfileImage(cImg))) {
			imgSrc = RegExp.$1;
			var pNode = cImg.parentNode;
			var newNode = document.createElement('span');
			newNode.style.width = (cImg.parentNode.id=='profile_general_readOnly_photo' ? getImgWidth(cImg) : cImg.width) + 'px';
			newNode.style.height = (cImg.parentNode.id=='profile_general_readOnly_photo' ? getImgHeight(cImg) : cImg.height) + 'px';
			if (cImg.onmouseover)
				newNode.onmouseover = cImg.onmouseover;
			if (cImg.onmouseout)
				newNode.onmouseout = cImg.onmouseout;
			newNode.style.display = 'inline-block';
			newNode.style.filter = 'progid:' + filterName + '(src=\'' + imgSrc + '\',sizingMethod=\'scale\')';
			if (pNode.href)
				newNode.style.cursor = 'hand';
			pNode.insertBefore(newNode, cImg);
			pNode.removeChild(cImg);
			i--;
		}
  	}
  	if ($('errors') && $('errors').className != 'i') {
  		var selects = document.getElementsByTagName('select');
  		for (var i = 0; i < selects.length; i++) {
  			var cSelect = selects[i];
  			var newSelect = document.createElement('span');
  			newSelect.width = cSelect.currentStyle.width;
  			newSelect.height = cSelect.currentStyle.height;
  			newSelect.style.border = '1px solid black';
  			newSelect.innerHTML = 'y';
  			newSelect.className = 'temp_select_replacer';
  			
  			cSelect.parentNode.insertBefore(newSelect, cSelect);
  			cSelect.className = 'i';
  		}
  	}
  	if ((arguments && arguments.length == 0) || shouldInit)
  		init();
},
isProfileImage = function (img) {
	return (img.id == 'welcome_profile_image_img');
},
getImgWidth = function (img) {
	return parseInt(img.parentNode.offsetWidth) - 30;
},
getImgHeight = function (img) {
	$('debug').innerHTML = img.parentNode.offsetHeight;
	return parseInt(img.parentNode.offsetHeight) - 30;
},
sLogout = function (i) {
	var lText = $('header_logout_text_inner');
	if (i == 0) {
		lText.innerHTML = playerAlias;
	
	} else {
		if (document.defaultView && document.defaultView.getComputedStyle) {
			lText.parentNode.style.width =
				document.defaultView.getComputedStyle(lText, null).getPropertyValue('width') + ' !important';
			//alert(document.defaultView.getComputedStyle(lText, null).getPropertyValue('width'));
				
		} else if (lText.offsetWidth) {
			lText.parentNode.style.width = lText.offsetWidth;
			
		} else if (lText.currentStyle) {
			lText.parentNode.style.width = lText.currentStyle.width; 
		}
		playerAlias = lText.innerHTML;
		lText.innerHTML = 'sign out';
	}
},
checkLogin = function () {
	if ($('gamesPreview_login')) {
		$('gamesPreview_login').className = '';
		new Effect.Opacity('gamesPreview_login', {duration:(fadeDur / 4), from:0.0, to:1.0});
		setFocus('username');
		fixPNGs(false);
		return false;
		
	} else {
		return true;
	}
},
setFocus = function (id) {
	if ($(id)) {
		setTimeout('try {' +
			'var v = $("' + id + '");' +
			'if (v && v.getElementsByTagName("input")[0]) {v = v.getElementsByTagName("input")[0];}' +
			'if (v && v.focus) {v.focus();' +
			'} else if (v && v.select) {v.select();}} catch(e) {}', 1);
	}
},
sBirthdayMonth = function (month) {
	var months = ['NULL','JANUARY','FEBRUARY','MARCH','APRIL','MAY','JUNE','JULY',
					'AUGUST','SEPTEMBER','OCTOBER','NOVEMBER','DECEMBER'];
	var days = [-1,31,28,31,30,31,30,31,31,30,31,30,31];
	for (var i = 0; i < months.length; i++) {
		if (months[i] == month) return sBirthdayDay(days[i]);
	}
},
sBirthdayDay = function (dayNum) {
	if (dayNum == -1) return false;
	var birthdayDayOptions = $('input_birthday_day').getElementsByTagName('option');
	if (birthdayDayOptions) {
		
		for (var i = birthdayDayOptions.length - 1; i > dayNum; i--) {
			$('input_birthday_day').removeChild(birthdayDayOptions[i]);
		}
		for (var i = birthdayDayOptions.length - 1; i < dayNum; ) {
			var newOption = document.createElement('option');
			newOption.value = ++i;
			newOption.innerHTML = i;
			$('input_birthday_day').appendChild(newOption);
		}
	}
	return true;
},
popupProfile = function () {//id, popup) {
	if ($('result')) {
		if ($('result').innerHTML != 'success') {
			//alert('yes: ' $('result').innerHTML);
			var errors = document.createElement('div');
			errors.id='errors';
			errors.innerHTML = $('result').innerHTML;
			$('wholeBody').insertBefore(errors, $('header'));
			fixPNGs(false);
		} else { 
			window.open('/gwap/profile?id=' + this.playerID + '&popup', 'profile' + this.playerID, 'width=745, height=480, toolbar=0, menubar=0, resizable=0, status=0, scrollbars=1');
		}
		$('preview_button').innerHTML = this.previewHTML;
	} else {
		return true;
	}
	/*
	if (arguments.length == 2 && popup) {
		window.open('/profile?id=' + id + '&popup', 'profile' + id, 'width=740, height=480, toolbar=0, menubar=0, resizable=0, status=0, scrollbars=1');
	}
	return (arguments.length == 1 || !popup);*/
},
fixSelects = function () {
	if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent))
		return;
	var replacers = document.getElementsByClassName('temp_select_replacer');
	
	for (var i = 0; i < replacers.length; i++) {
		var r = replacers[i];
		r.nextSibling.className = '';
		r.className = 'i';
	}
},
initPref = function () {
	var x = document.getElementsByClassName('preference');
	var y = document.getElementsByName('matchingPreferences');
	for (var i = 0; i < x.length; i++) {
		if(!y[i].checked)
			x[i].getElementsByTagName('td')[1].className = 'profile_content_matching_left_unselected';
	}
},
clickPref = function (i) {
	var prefBox = $('matchingPreferences_p' + i);
	if (prefBox)
		prefBox.checked = !prefBox.checked;
	var prefText = document.getElementsByClassName('preference')[i].getElementsByTagName('td')[1];
	prefText.className = (prefText.className == 'profile_content_matching_left_selected') ?
		'profile_content_matching_left_unselected' :
		'profile_content_matching_left_selected'; 
},
toggleMask = function (b) {
	var c = b ? '' : 'i';
	$('profile_general_photo_holder_mask').className = 
		$('profile_content_general_photo_cancelText').className = c;
},
getFileName = function (s) {
	if (s.indexOf('/') >= 0)
		return s.substring(s.lastIndexOf('/') + 1);
	else if (s.indexOf('\\') >= 0)
		return s.substring(s.lastIndexOf('\\') + 1);
	return s;
},
cancelUpload = function () {
	toggleMask(false);
	$('profile_content_general_photo_path').value = 'no file selected';
	$('profile_content_general_photo_file').value = '';
},
disableSplash = function() {
	$('splashOverlayBG').style.display = "none";
	$('splashOverlay').style.display = "none";
},
openPopup = function(url, wWin, hWin) {
            window.open(url, 'newWindow', 'toolbar=no,location=no,scrollbars=no,status=no,menubar=no,resizable=no,width=' + wWin + ',height=' + hWin);
            return false;
}        
;
