function submitRegistration(){
	alert("in submitRegistration");
	document.registration.action = "/servlet/app";
	document.registration.method = "POST";
	document.registration.submit();
}

function openWindow(pageURL, windowtab, parameters, wid, hgt, resize, tbar, scroll) {
pageURL = pageURL + "?" + parameters;
	if(windowtab == 1){
		location.replace(pageURL);	
	}else{
		popwin = window.open(pageURL, "Luvs"+windowtab, 'left=0,top=0,width=' + wid + ',height=' + hgt + ',titlebar=no,menubar=no,location=no,resizable=' + resize + ',toolbar=' + tbar + ',scrollbars=' + scroll + ',status=no');
	}
}

function isIE() {
   if (document.all) {
      return 1;      // Browser is IE
   }
   else {
      return 0;      // Browser is not IE
   }
}

function checkBrowser(frm){
	var browser = "";
	var bName = navigator.appName;
	var bVer = parseFloat(navigator.appVersion);
	if (bName == "Netscape")
	  var browser = "Netscape Navigator"
	else
	  var browser = bName;

	frm.browserName.value = browser;  

}

function isLowRes() {
  /*
  ** Check if the browser is running in a low-resolution environment
  ** try to use the screen object (in N4 or e4). If not available, try to use Java.
  ** If not available, assume low-res.
  ** returns true if in a low-resolution environment (width <= 800 pixels)
  */
  if (self.screen)
    return (screen.width <= 800);
  else 
    if (navigator.javaEnabled && navigator.javaEnabled())
      return (java.awt.Toolkit.getDefaultToolkit().getScreenSize().width <= 800);
    else
      return true;
}



function adjustButton(divId,lowLeft,lowTop,highLeft,highTop){
	var browserType;
	var elem;
	if (document.layers) {browserType = "nn4";}
	if (document.all) {browserType = "ie";}
	
	if (browserType == "ie")
     elem = eval('document.all[divId]');
  	else
     elem = eval('document.layers[divId]');
     
	if(isLowRes()){
		elem.style.left = lowLeft;
		elem.style.top = lowTop;
	}else{
		elem.style.left = highLeft;
		elem.style.top = highTop;
	}
}

function randomLogic(){
	var die = Math.round(Math.random()*4);
	die = die % 2;
	if(die == 0){
		return true;
	}else{
		return false;
	}
}

function isCookiePresent(name,value){
  var x = getCookie(name);
	if (!x) {
		return false;
	}
	return true;
}

function launchPopUp(promotionid,pageid){
	if(!isCookiePresent('promotion',promotionid)){
		openWindow("/en_US/app.cnt", 0, "pageid="+pageid+"&promoid="+promotionid,405, 600, 'no', 'no', 'yes');
		setCookie('promotion',promotionid,365);
	}
}


function getCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function setCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}


function eraseCookie(name)
{
  createCookie(name,"",-1);
}

function showFAQ(){
	window.open("/en_US/whyluvs_faq.html", "LuvsFAQ", 'left=0,top=0,width=567,height=590,titlebar=no,menubar=no,location=no,resizable=no,toolbar=no,scrollbars=yes,status=no');
//	openWindow(,0, "",567, 590, 'no', 'no', 'yes');
}

function showSchedule(){

	window.open("/en_US/whyluvs_schedule.html", "LuvsSchedule", 'left=0,top=0,width=785,height=590,titlebar=no,menubar=no,location=no,resizable=no,toolbar=no,scrollbars=yes,status=no');
//	openWindow(, 0, "",785, 590, 'no', 'no', 'yes');
}

function showRules(){
	window.open("/en_US/Why_Luvs_Official_Rules.html", "LuvsRules", 'left=0,top=0,width=567,height=590,titlebar=no,menubar=no,location=no,resizable=no,toolbar=no,scrollbars=yes,status=no');
//	openWindow("/en_US/Why_Luvs_Official_Rules.html", 0, "",567, 590, 'no', 'no', 'yes');
}

//This Function is to check if a user has crossed the max number of characters in a text area or textfield
function charAlert(textField,limit) {
	if(textField.value.length > limit){ 
/* must be > 5, not == 5 or else the substring statement on the next line will cause the function to run again if the user dismisses the alert by pressing the 'enter' key rather than clicking 'OK'. */ 

	textField.value = textField.value.substring(0,limit) ;
// set field's value equal to first five characters. 

	textField.blur() ;
/* move cursor out of form element to keep it from placing itself at position zero, causing an overwrite of the first character */

	alert("No more text can be entered") ;
	}//if
} 

