d = new Date();
var timeUnique = d.getTime();

function createCookie(name,sidX,days) //function createCookie(cname,sid,days)
{
	
    
       var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		 if(days!=-1)

					document.cookie = name+'=    '+sidX+';   expires=' + expires+'; path=/;domain=.acclaim.com'
         else
 		 	      	document.cookie = name+'=    '+sidX+';   expires=; path=/ ;domain=.acclaim.com'
  
}


function readCookie(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);
           
                      }
               
                // reading key value retuning  
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function signout1()
{


      var str=readCookie("acclaim");
		

      var val_arr=str.split(",");  

			var url="SignOut.jsp?t="+timeUnique+"&uname="+val_arr[0]+"&sesID="+val_arr[1];	
					
			xmlHttp=GetXmlHttpObject()
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);

                        xmlHttp.onreadystatechange=function(){	
		
			if (xmlHttp.readyState==4)// ajax return value on the process status. 4 is success.
			{ 
                             
                        }
eraseCookie("acclaim");

                   }
}



function parser(referalstr)
{
var str="";
i=referalstr.indexOf("//");

if(i!=-1)
  i=i+2;
 else
  i=0;

  j=referalstr.indexOf("/",i);
  if(j==-1)
    str=referalstr.substr(i,referalstr.length-i);
  else
     str=referalstr.substr(i,j-i);

   str=str.substr(0,149);

 return str;

}




function setURL()
{

var t= readCookie("refurl");
var refurl="none";
if (document.referrer&&document.referrer!="")
   refurl=document.referrer;

refurl=parser(refurl);

if(t==null || t==-1 || t=='none')
{
  
    createCookie("refurl",refurl,90);
 

}
}
setURL();








function cc()
{
 /* check for a cookie */
  if (document.cookie == "") 
  {
    //alert("COOKIES need to be enabled!");
	window.location='cookie.htm';	
  } 
 
}

document.cookie = 'killme' + escape('nothing')

cc();




<!--          FORM VALIDATOR        -->

function isEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		//alert(helperMsg);
//		elem.focus(); // set the focus to this input
		return true;
	}
	return false;
}


function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		//alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		//alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		//alert(helperMsg);
		elem.focus();
		return false;
	}
}


function isSpecChar(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z_@]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		//alert(helperMsg);
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max, mesg){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		//alert("Please enter b/w " +min+ " and " +max+ " characters for "+mesg);
		elem.focus();
		return false;
		
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == "Please Choose"){
		//alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	//alert("email value "+elem.value)
	if(elem.value.match(emailExp)){
		return true;
	}else{
		//alert(helperMsg);
//		elem.focus();
		return false;
	}
}


function frnEmailValidator(elem, helperMsg){
	var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
	//alert("email value "+elem.value)
	if(elem.match(emailExp)){
		return true;
	}else{
		//alert(helperMsg);
//		elem.focus();
		return false;
	}
}




function forGotID()
			{	
			
			var err=0;
					
						
					document.getElementById('errID').innerHTML="";	
					var emailChk=document.getElementById('inputID_ID');		
							
					if(isEmpty(emailChk, "-----------")==true){	
					document.getElementById('errID').innerHTML="Email address should not be empty";					
					err =1;					
					}else if(emailValidator(emailChk, "Enter a valid email address")==false){	
					document.getElementById('errID').innerHTML="Enter a valid email address";			
					err =1;					
					}
					
					
			if(err==0){						
			
								forID2=document.getElementById("inputID_ID").value;
								tempforID2=forID2;
								
								//alert("forgot email id "+forID2)
									
								xmlHttp=GetXmlHttpObject()
										
								if (xmlHttp==null)
								{
								alert ("Your browser does not support AJAX!");
								return;
								} 
								
								var url="SendMail.jsp?username="+tempforID2+"&t="+timeUnique;
								//alert("email adddress input "+tempforID2)
								xmlHttp.onreadystatechange=FIDResponse;  
								xmlHttp.open("GET",url,true);
								xmlHttp.send(null);
					} 
			}
	
	
		function FIDResponse() 
		{ 
			if (xmlHttp.readyState==4)// ajax return value on the process status. 4 is success.
				{ 
								
					var  resultFID=xmlHttp.responseText;
					// -----parse result
					
					var caX = resultFID.split('&');				
					var j=0;
					var b 
					var mycars =new Array
					for(var i=1;i <caX.length;i++)
					{
					  
					  b= caX[i].split('=');
					  mycars[j]=b[1];  
					
					  j++;
					
					}
					resultFID=mycars[0];
					//sidX=mycars[1];
					//-----parse result

					
					
					
					//alert("forgot id  result  "+resultFID)
					
					//document.getElementById("errID").innerHTML= "";
					
										
					if (resultFID=="0")
						{ 
													
							openForgotUSerIDSuccess();				
						
						}else if (resultFID=="1"){
						document.getElementById("errID").innerHTML= "Your email server was not found.";
						}else if (resultFID=="2"){
						document.getElementById("errID").innerHTML= "Email address was not found.";
						}else if (resultFID=="3"){
						document.getElementById("errID").innerHTML= "Status not active.";
						}else {
						document.getElementById("errID").innerHTML= "The Service is down.Try again later.";
						}
				}
			
		}





//Reg1 Form control Values------

function checkCookie() {
	
	//formReg1.reset();
	var key=readCookie("acclaim");
	var temp=key;
	//alert(key);
	if(key==null||key==""){
	openLogin();
	}
	else {	


	
        a = key.split(",");   
	
	sidX= a[1];
	cookieUserId=a[0];
	cname=cookieUserId;
	//alert("sidx+cname "+sidX+'|'+cookieUserId)
	//sidX

	   var k, sk = 0;
	   td = a[3].split("|");
	   for (k=0; k<td.length && sk == 0; ++k) 
		if (td[k] == "ps") 
			sk = 1;
    
   	if(sk==1)
          loginSuccessLayer(a[0]);
	else
          botsexistform(a[0]);

	
	}
	
}







function eraseCookie(name)
{
      
	   createCookie(name,"",-1);
createCookie("fromAddress","",-1);

	   sidX=null;
	   
		//formReg1.reset();
		 
	   refreshLogin();
	   
	  // RefreshRegister();
	    
	   openLogin();
	    
 
}
function hideInviteLayer(){
toggleBox('inviteLayer',0);
//formReg1.reset();
hideBoth()

}

function hideInviteLayer2(){
toggleBox('inviteLayerSuccess',0);
//formReg1.reset();
hideBoth()

}

function showPopRules(){
toggleBox('popRules',1);

}
function hidePopRules(){
toggleBox('popRules',0);

}
function  showHelp1(){

toggleBox('whatThis',1);
}
function  hideHelp1(){

toggleBox('whatThis',0);
}


function openForgotUSerIDSuccess()
{
closeAll();
toggleBox('apDivForgotID2',1);
toggleBox('apDivForgotID1',0);
document.getElementById("useremailDisp").innerHTML= tempforID2;
document.getElementById("inputID_ID").value	="";
}					


function showNews(){
	
		toggleBox('news',1);
	}
	
	function hideNews(){
			
		toggleBox('news',0);		
	}

	function showAbout(){
	
		toggleBox('about',1);
	}
	
	function hideAbout(){
			
		toggleBox('about',0);		
	}
		function showGuide(){
	
		toggleBox('guide',1);
	}
	
	function hideGuide(){
			
		toggleBox('guide',0);		
	}
		function showCommunity(){
	
		toggleBox('community',1);
	}
	
	function hideCommunity(){
			
		toggleBox('community',0);		
	}
		function showSupport(){
	
		toggleBox('support',1);
	}
	
	function hideSupport(){
			
		toggleBox('support',0);		
	}
	
	function openSuccessInvitation(){
	toggleBox('inviteLayer',0);
	toggleBox('inviteLayerSuccess',1);
	toggleBox('InviteEmailInviteLink',0);
	
	
			}
	
	
	

function closeAll(){
	
	//toggleBox('apDivForgotPW1',1);
	//toggleBox('apDivForgotPW2',0);
	toggleBox('apDivForgotID1',1);
	toggleBox('apDivForgotID2',0);

	
	

	}
	
	
	function hideBoth(){
		closeAll();
		checkCookie();
	}

	


function openForgotUI(){
toggleBox('apDivForgotID1',1);
toggleBox('apDivForgotID2',0);
toggleBox('apDivLogin1',0);
toggleBox('apDivLogin2',0);
document.getElementById("inputID_ID").value="";
document.getElementById("errID").innerHTML	="";


}



		

function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
	
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}



	
	
	// test the browser for AJAX. May be to call when pag eloads.




			function GetXmlHttpObject()
					{
					var xmlHttp=null;
					try
					  {
					  // Firefox, Opera 8.0+, Safari
					  xmlHttp=new XMLHttpRequest();
					  }
					catch (e)
					{	
					// Internet Explorer
					try
					{
					xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
					catch (e)
					{
					xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					}
					return xmlHttp;
			}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


