
var alertTimerId = 0;

//5/11/2011 ~ THIS APPEARS TO BE OBSOLETE OR JUST NEVER USED. VERIFY WITH GENERATED JAVA TAGS 
function openLightWindow(link, width, height, title, loadingAnimation, type){
	if(!type) {
		type = "page";
	}
	
	clearTimeout ( alertTimerId );

	if(myLightWindow) {
		myLightWindow.activateWindow({
	    	href: link,
	        width: width,
	        height: height, 
	        iframeEmbed: null, 
	        title: title,  
	        loadingAnimation : false,
	        type: type});
	} else {
		alertTimerId = setTimeout ( "openLightWindow('"+link+"', "+width+", "+height+", '"+title+"', "+loadingAnimation+", '"+type+"')", 500 );
	}
}

//5/11/2011 ~ THIS APPEARS TO BE OBSOLETE OR JUST NEVER USED. VERIFY WITH GENERATED JAVA TAGS 
function switchBackground(divId, isOver) {
	try {
		if (isOver==true) {
			document.getElementById(divId).className='selected';
		} else {
			document.getElementById(divId).className='';
		}
	
	} catch(err) {
		/* Hide these error messages before launch */
		alert('switchBackground(isOver) in switchMenuItemBackground.js failed: ' + err);
	}
}

//5/11/2011 ~ THIS APPEARS TO BE OBSOLETE OR JUST NEVER USED. VERIFY WITH GENERATED JAVA TAGS 
function passwordCheck() {
	var x = $("pw1").value == $("pw2").value;
	if(!x) {
		alert("Passwords don't match");
	}
	return x;
}

//5/11/2011 ~ THIS APPEARS TO BE OBSOLETE OR JUST NEVER USED. VERIFY WITH GENERATED JAVA TAGS 
function registrationBack() {
	//$("forgotLink").style.display = "none";
	//$("loginFail").style.display = "none";
	$("loginMishap").style.display = "none";
	$("reg_connectIntro").style.display = "block";
	//$("loginWelcome").style.display = "block";
	gotoRegistrationPage(2);
}

// 5/11/2011 ~ called from live.js
function incorrectPassword() {
	$jq("#loginPassword").val("");
	
	//show / hide
	//$("reg_loginOrRegister").style.display = "block";
	//$("forgotLink").style.display = "block";
	//$("loginFail").style.display = "block";
	$jq("#loginMishap").css("display", "block");
	$jq("#loginWelcome").css("display", "none");
	//$("reg_skoutRegistration").style.display = "none";
}

//5/11/2011 ~ THIS APPEARS TO BE OBSOLETE OR JUST NEVER USED. VERIFY WITH GENERATED JAVA TAGS 
function newMsgs(number) {
	if(number > 0) {
		$jq("#menuNewMsgs").text(number);
		$jq("#menuNewMsgs").css("visibility", "visible");
	} else {
		$jq("#menuNewMsgs").css("visibility", "hidden");
	}
}


function addNewMsg(ts) {
	Freya.data.unreadChatMessages++;
	$jq(".chatCounter").text(Freya.data.unreadChatMessages).show();	
}


//5/11/2011 ~ THIS APPEARS TO BE OBSOLETE OR JUST NEVER USED. VERIFY WITH GENERATED JAVA TAGS 
/* available from the search settings popup - should it be put somewhere else? */
function setSearchSettingsFormAction(openedFrom) {
	//alert('set form action');
	if (openedFrom + '' == 'grid') {
		$('searchSettingsForm').action = '/matches/online.jsp';
	} else {
		$('searchSettingsForm').action = '/matches/';
	}
	//alert('form action set according to openedFrom (=' + openedFrom + ')');
}

// 5/11/2011 ~ called from live
function gotoRegistrationPage(pageNumber) {	
	//get an array of all pages of the registration
	var childrenArray = $('registrationPageHolder').select('[name="registrationPage"]');
	
	for (var index=0; index<childrenArray.length; ++index) {
		var child = childrenArray[index];
		child.style.display = 'none';
	}
	
	/*
	1: reg_loginOrRegister    - original login or register
	2: reg_connectIntro		  - connect with FB or not?
	3: reg_skoutRegistration  - original skout register
	4: reg_fbAlmostThere	  - Email prompt after FB
	5: reg_fbFinally		  - More info after FB
	6: reg_fbMessage		  - Message recieved from FB
	7: reg_fbSecretGift		  - Secret Gift recieved from FB
	8: reg_fbift		  	  - Gift recieved from FB
	*/ 
	$("registerForm").onsubmit = function() {};
	switch(pageNumber) {
		case 1: 
			$("reg_connectIntro").style.display = 'block';
			break;
		case 2: 
			$("reg_loginOrRegister").style.display = 'block';
			updateStep(204);
			break;
		case 3:
			$("reg_fbGift").style.display = 'none';
			$("reg_fbMessage").style.display = 'none';
			$("registerForm").onsubmit = function() {register();};
			$("reg_skoutRegistration").style.display = 'block';
			updateStep(205);
			break;
		case 4: 
			resizeLW(370, 270);
			$("reg_fbAlmostThere").style.display = 'block';
			if(_step < 100) {
				updateStep(5);
			} else {
				updateStep(105);
			}
		break;
		case 5:
			resizeLW(370, 270);
			$("reg_fbFinally").style.display = 'block';
			if(_step < 100) {
				updateStep(8);
			} else {
				updateStep(108);
			}
		break;
		case 6:
			$("reg_fbMessage").style.display = 'block';
		break;
		case 7:
			$("reg_fbSecretGift").style.display = 'block';
		break;
		case 8:
			$("reg_fbGift").style.display = 'block';
		break;
	}
}

//5/11/2011 ~ THIS APPEARS TO BE OBSOLETE OR JUST NEVER USED. VERIFY WITH GENERATED JAVA TAGS 
function feedbackButtonHover(isOver) {
	if (isOver=='true') {
		$('feedbackButtonNormal').style.visibility = 'hidden';
		$('feedbackButtonOver').style.visibility = 'visible';
	} else {
		$('feedbackButtonOver').style.visibility = 'hidden';
		$('feedbackButtonNormal').style.visibility = 'visible';
	}
}

