	var noAccess = GetCookie("noAccess")
	if ((noAccess!=null) && (noAccess=='true')) 
	{
      document.location = "/kids/";
	}
	var loginSessionCookie=GetCookie("loginSession");

	var allParams;

	var userInfo;
    function doThisFirst()
	{
		
		var iU=false;
		if (allParams!=null)
		{
			fillParams(allParams);
	 	}
		
		if (userInfo!=null)
		{
			fillParams(userInfo);
            iU=true;
			userInfo='';
			checkCountryOnLoad();
		}	
		//checkIfCell(iU);	
		
		
		
		
		handleGermanCheck();
		
	}
	
	
	function handleGermanCheck()
	{
	
	
		var gc=document.getElementById("germantext");
		
		if(gc ==null  ){
		
		}else{
			///var v1=document.getElementById("EML").value;
		 
			if(
					getdeIndex(document.getElementById("EML").value) || 
					(isEqual(document.getElementById("CNTRY").value,"Germany"))
			  ){
			  //checkbox is visible now
				 gc.style.display = 'block'; 
				 		  
				  
				 document.getElementById("NGT").style.display ='none';
				
				
			}else{
			//checkbox is hidden now
				gc.style.display='none' ;
				
				document.getElementById("NGT").style.display='block';
			}
		}
	
	}
		
	function handleGermanCheckRegistration()
	{
		var gc=document.getElementById("germantext");
		
		if(gc !=null  ){
			///var v1=document.getElementById("EML").value;
		 
			if(
					getdeIndex(document.getElementById("EML").value) || 
					(isEqual(document.getElementById("CNTRY").value,"Germany"))
			  ){
			  //checkbox is visible now
				 gc.style.display = 'block'; 
				
				 
				  document.getElementById("NGT").style.display = 'none';
				 
				  document.getElementById("germanycheck").checked= true;
				
								
			}else{
			//checkbox is hidden now
			
				gc.style.display='none' ;
				 document.getElementById("NGT").style.display = 'block';
			}
		}
	
	}
	function isEqual(text1, text2){
		text2='Germany';
		if(text1 == text2){ return true;
		}else{
		 return false;
		}
		
	
	
	}
	function precheckNewsletters()
	{
		for (j=0; j<document.userinfo.elements.length; j++) 
		{
//			if (document.userinfo.elements[j].name.indexOf("29|29|")>-1)
			if (document.userinfo.elements[j].name.indexOf("29|29|NBAOffers")>-1 ||
				document.userinfo.elements[j].name.indexOf("29|29|NBASpecialDelivery")>-1 ||
				document.userinfo.elements[j].name.indexOf("29|29|WNBAOffers")>-1 ||
				document.userinfo.elements[j].name.indexOf("29|29|WNBAWhatsNext")>-1)
				document.userinfo.elements[j].checked = true;	
		}		
	}
	
	
	function fillParams(zFillStr) 
	{
//alert(zFillStr);
	  var param=zFillStr.split('!');
	  var a1;
	  var a0;
	  for (i=0; i<param.length; i++) 
	  {			
		var answer=param[i].split(':');
		
		var foundit=false;
		var index=0;
		
		answer[0]=answer[0].toLowerCase();

		a1=answer[0]+'|1';
		a0=answer[0]+'|0';
		
		
		for (j=0; j<document.userinfo.elements.length; j++) 
		{
			
	
			if ((document.userinfo.elements[j].tagName != 'FIELDSET')&& document.userinfo.elements[j].type!='hidden'){		
		
			if (document.userinfo.elements[j].name.toLowerCase()==answer[0] ||
			document.userinfo.elements[j].name.toLowerCase()==a1 || document.userinfo.elements[j].name.toLowerCase()==a0
			)
			{

				foundit=true;
				index=j;
				j=document.userinfo.elements.length+1;
			}
		
			}
			
		}		

		if (foundit) 
		{		
			var thiselement = document.userinfo.elements[index];
			var inputType = thiselement.type;
 			//alert("NAME :"+thiselement.name+"-- Value-:"+answer[1]+" again name:"+answer[0]+"   TYPE:"+thiselement.type);
 			//alert("NAME :"+thiselement.name+"-- Value-:"+answer[1]+" again name:"+answer[0]);	
			if (inputType=='text')
			{ //alert("NAME :"+thiselement.name+"-- Value-:"+answer[1]+" again name:"+answer[0]);
				if (answer[1]=='null')
					thiselement.value = '';
				else
					thiselement.value = answer[1];
			}
			else if (inputType=='checkbox') 
			{
				if ((answer[1]=='true') || (answer[1]=='on')) 
				{ 
					thiselement.checked=true; 
				}
			} 
			else if (inputType=='select-one') 
			{   //alert("1 WENT INTO THE SELECT:"+thiselement.name+"   :: inputType"+inputType);
			
			//alert(" select NAME :"+thiselement.name+"-- Value-:"+answer[1]+" again name:"+answer[0]);

				//thiselement.value=answer[1];
				//alert("length of :"+thiselement.length);

thiselement.options.selected = answer[1];
				
				for (k=0; k<thiselement.length; k++)
				{   //alert("value"+ thiselement[k].value+" :"+answer[1]);
					
				  if (thiselement[k].value==answer[1]) 
				  {   //alert("good set the value as true"+thiselement[k].value);
					thiselement[k].selected=true;
				  }
				}
				
			} 
			else if (inputType=='password') 
			{ //alert("inside password");
				thiselement.value=answer[1];
			} 
			else if (inputType=='radio') 
			{ 
				if (thiselement.value==answer[1]) 
				{ 
					thiselement.checked=true; 
				}

				thiselement = document.userinfo.elements[index+1];
				if (thiselement.value==answer[1]) 
				{ 
					thiselement.checked=true; 
				}
				
			} 
			else if (thiselement.length>1) 
			{
				for (j=0; j<thiselement.length; j++) 
				{
					if (thiselement[j].value==answer[1]) 
					{ 
						thiselement[j].checked=true; 
					}
				}
			}
		}

		
	  }
    }

function processForm() 
	{
	 
		if(document.userinfo.rmcountry.value=='null' || (document.userinfo.rmcountry.value).length==0){
			document.userinfo.rmcountry.value="United States";
		}
		if (isBlank(document.userinfo.rmfirstname.value)) 
		{
			alert('First Name cannot be blank!');
			document.userinfo.rmfirstname.focus();
			return false;
		}
		
		
		if (isBlank(document.userinfo.rmlastname.value)) 
		{
			alert('Last Name cannot be blank!');
			document.userinfo.rmlastname.focus();
			return false;
		}
		
		

		if (isBlank(document.userinfo.rmzip.value)) 
		{
			alert('Zip/Postal code cannot be blank!');
			document.userinfo.rmzip.focus();
			return false;
		}

		if (isBlank(document.userinfo.rmemail.value)) 
		{
			alert('E-mail Address cannot be blank!');
			document.userinfo.rmemail.focus();
			return false;
		}
		
		
		if (isBlank(document.userinfo.rmemailconfirm.value)) 
		{
			alert('Confirm E-mail Address cannot be blank!');
			document.userinfo.rmemail.focus();
			return false;
		}		

		if (!isValidEmail(document.userinfo.rmemail.value)) 
		{
			alert('E-mail Address is not in a valid format!');
			document.userinfo.rmemail.focus();
			return false;
		}

		if (!isAscii(document.userinfo.rmemail.value))
		{
			alert('E-mail Address contains invalid character(s)!');
			document.userinfo.rmemail.focus();
			return false;
		}
	
		
		if (!isValidEmail(document.userinfo.rmemailconfirm.value)) 
		{
			alert('E-mail Address is not in a valid format!');
			document.userinfo.rmemail.focus();
			return false;
		}

		if (!isAscii(document.userinfo.rmemailconfirm.value))
		{
			alert('E-mail Address contains invalid character(s)!');
			document.userinfo.rmemail.focus();
			return false;
		}

		if ((document.userinfo.rmemail.value) != (document.userinfo.rmemailconfirm.value))
		{
			alert('E-mail Address and Confirm Email Address are not same!');
			document.userinfo.rmemail.focus();
			return false;
		}


		var login = checkSingleQuote(document.userinfo.rmemail.value);
		if (login != document.userinfo.rmemail.value)
		{
			alert('User Name cannot contain single quote character(s)!');
			document.userinfo.rmemail.focus();
			return false;		
		}
		var mIndex = document.userinfo.dobMonth.selectedIndex;
		var dIndex = document.userinfo.dobDay.selectedIndex;
		var yIndex = document.userinfo.dobYear.selectedIndex;
		var dob = document.userinfo.dobMonth[mIndex].value + "/" 
				+ document.userinfo.dobDay[dIndex].value + "/" 
				+ document.userinfo.dobYear[yIndex].value;

		if (dateValid(dob)) 
		{
			document.userinfo.rmdob.value=dob;
		} 
		else 
		{
			alert('Date of Birth is not a valid date!');
			document.userinfo.dobMonth.focus();
			return false;
		}

		// if the user is under the age of 13, kick them out
		today = new Date();
		birth = new Date();
		birth.setMonth(document.userinfo.dobMonth[mIndex].value-1);
		birth.setDate(document.userinfo.dobDay[dIndex].value);
		birth.setYear(document.userinfo.dobYear[yIndex].value);			

		age = today.getFullYear() - birth.getFullYear();		

		testBirth = new Date();
		testBirth.setMonth(document.userinfo.dobMonth[mIndex].value-1);
		testBirth.setDate(document.userinfo.dobDay[dIndex].value);
		testDay = today.getTime() - testBirth.getTime();
		testDay = Math.floor(testDay / (1000*60*60*24));			

		if (testDay<0) { age = age - 1; }						

		if (age<13) {
			SetCookie("noAccess", "true", null, "/");
			document.location = "/kids/";
			return false;
		}

		/*if (isBlank(document.userinfo.rmaddress1.value)) 
		{
			alert('Address 1 cannot be blank!');
			document.userinfo.rmaddress1.focus();
			return false;
		}

		if (isBlank(document.userinfo.rmcity.value)) 
		{
			alert('City cannot be blank!');
			document.userinfo.rmcity.focus();
			return false;
		}


		var sIndex = document.userinfo.rmstate.selectedIndex;
		if (document.userinfo.rmstate[sIndex].value=="XX") 
		{
			alert('Select a State!');
			document.userinfo.rmstate.focus();
			return false;
		}*/

		


/*
		var cIndex = document.userinfo.rmcountry.selectedIndex;
		if (document.userinfo.rmcountry[cIndex].value=="XX") 
		{
			alert('Select a Country!');
			document.userinfo.rmcountry.focus();
			return false;
		}

		*/
		
		
		
			  //starts cookies related validation
	  //if (loginSessionCookie==null) 
	 // { 
			/*if (isBlank(document.userinfo.rmlogin.value)) 
			{
				alert('User Name cannot be blank!');
				document.userinfo.rmlogin.focus();
				return false;
			}
	
			if (!isAscii(document.userinfo.rmlogin.value))
			{
				alert('User Name contains invalid character(s)!');
				document.userinfo.rmlogin.focus();
				return false;
			}		*/
	
	
			// added by Tak 5/2/02 check for single quote values.
			// rmlogin doesn't allow single quote values.
			/*var login = checkSingleQuote(document.userinfo.rmlogin.value);
			if (login != document.userinfo.rmlogin.value)
			{
				alert('User Name cannot contain single quote character(s)!');
				document.userinfo.rmlogin.focus();
				return false;		
			}
			*/
			
			
			if (isBlank(document.userinfo.rmpassword.value))
			{
				alert('Password cannot be blank!');
				document.userinfo.rmpassword.focus();
				return false;
			}
	
			if (document.userinfo.rmpassword.value.length<6)
			{
				alert('Password must be 6 characters or more!');
				document.userinfo.rmpassword.focus();
				return false;
			}
	
			if (document.userinfo.rmpassword.value!=document.userinfo.rmpasswordconfirm.value) 
			{
				alert('The passwords you entered do not match!');
				document.userinfo.rmpassword.focus();
				return false;
			}
			
			if((document.userinfo.rmcountry.value=="United States" || document.userinfo.rmcountry.value=="Canada") && isBlank(document.userinfo.rmzip.value) ){
			alert('Please enter zip code!');
			document.userinfo.rmcountry.focus();
			return false;
			
		}
		
		if((document.userinfo.rmcountry.value=="United States" || document.userinfo.rmcountry.value=="Canada") && !isBlank(document.userinfo.rmzip.value) && 
			(document.userinfo.rmzip.value).length !=5){
			alert('Please enter the correct zip code!');
			document.userinfo.rmcountry.focus();
			return false;			
		}
	 // }//ends cookies related validation
		for (j=0; j<document.userinfo.elements.length; j++) 
		{
			var thiselement = document.userinfo.elements[j];

			if (thiselement.type=='checkbox') 
			{
			    if(thiselement.name != 'rmcellemail')
				{
				if (!thiselement.checked) 
				{
					if (document.userinfo.uncheckedboxes.value=='') 
					{
						document.userinfo.uncheckedboxes.value = thiselement.name;
					} 
					else 
					{
						document.userinfo.uncheckedboxes.value += '!' + thiselement.name;
					}
				}
				}			
			}
			
		}
			
		document.userinfo.submit();
    }

	
	
	//New validation method added
	function processFormPage2() 
	{
	

	for (j=0; j<document.userinfo.elements.length; j++) 
		{ 
			var thiselement = document.userinfo.elements[j];
			
			
			
			if (thiselement.type=='checkbox') 
			{ 
			    if(thiselement.name != 'rmcellemail')
				{
				
				if (!thiselement.checked) 
				{	alert("before setting the value of "+thiselement.name );
					if (document.userinfo.uncheckedboxes.value=='') 
					{ 
						document.userinfo.uncheckedboxes.value = thiselement.name;
						alert("inside if finally value is: "+document.userinfo.uncheckedboxes.value);
					} 
					else 
					{ 
						document.userinfo.uncheckedboxes.value += '!' + thiselement.name;
						
					}
				}
				}			
			}
			
		}
					
		document.userinfo.submit();
    }

//
	function processFormPage2() 
	{
		
	}


//New validation method added

	function processFormPage3() 
	{
	  alert("processFormPage3 got called");
	  
	
	  
		document.userinfo.MobileServiceParticipant.value=document.userinfo.MobileServiceParticipant1.value+
										document.userinfo.MobileServiceParticipant2.value+
										document.userinfo.MobileServiceParticipant3.value;
		 
	for (j=0; j<document.userinfo.elements.length; j++) 
		{ 
			var thiselement = document.userinfo.elements[j];
			

			
			if (thiselement.type=='checkbox' ) 
			{ alert("::::"+(thiselement.type=='checkbox'));
			
			    if(thiselement.name != 'MobileServiceParticipant1' && thiselement.name != 'MobileServiceParticipant2' && thiselement.name != 'MobileServiceParticipant3' )
				{ 
				
				if (!thiselement.checked) 
				{  alert("before setting the value of "+thiselement.name );
					if (document.userinfo.uncheckedboxes.value=='') 
					{
						document.userinfo.uncheckedboxes.value = thiselement.name;
						alert("inside if finally value is: "+document.userinfo.uncheckedboxes.value);
					} 
					else 
					{
						document.userinfo.uncheckedboxes.value += '!' + thiselement.name;
						alert("inside if inside else finally value is :"+document.userinfo.uncheckedboxes.value);
					}
				}
				}			
			}
			
		}
		
			
		//document.userinfo.submit();
    }

	
	function userProfileForm1() 
	{
	
		if (isBlank(document.userinfo.rmfirstname.value)) 
		{
			alert('First Name cannot be blank!');
			document.userinfo.rmfirstname.focus();
			return false;
		}
		
		
		if (isBlank(document.userinfo.rmlastname.value)) 
		{
			alert('Last Name cannot be blank!');
			document.userinfo.rmlastname.focus();
			return false;
		}
		
		

		/*if (isBlank(document.userinfo.rmzip.value)) 
		{
			alert('Zip/Postal code cannot be blank!');
			document.userinfo.rmcity.focus();
			return false;
		}*/

		if (isBlank(document.userinfo.rmemail.value)) 
		{
			alert('E-mail Address cannot be blank!');
			document.userinfo.rmemail.focus();
			return false;
		}
		
		
		if (isBlank(document.userinfo.rmemailconfirm.value)) 
		{
			alert('Confirm E-mail Address cannot be blank!');
			document.userinfo.rmemail.focus();
			return false;
		}		

		if (!isValidEmail(document.userinfo.rmemail.value)) 
		{
			alert('E-mail Address is not in a valid format!');
			document.userinfo.rmemail.focus();
			return false;
		}

		if (!isAscii(document.userinfo.rmemail.value))
		{
			alert('E-mail Address contains invalid character(s)!');
			document.userinfo.rmemail.focus();
			return false;
		}
	
		
		if (!isValidEmail(document.userinfo.rmemailconfirm.value)) 
		{
			alert('Confirm E-mail Address is not in a valid format!');
			document.userinfo.rmemail.focus();
			return false;
		}

		if (!isAscii(document.userinfo.rmemailconfirm.value))
		{
			alert('E-mail Address contains invalid character(s)!');
			document.userinfo.rmemail.focus();
			return false;
		}
		var login = checkSingleQuote(document.userinfo.rmemail.value);
		if (login != document.userinfo.rmemail.value)
		{
			alert('Email cannot contain single quote character(s)!');
			document.userinfo.rmemail.focus();
			return false;		
		}
		if ((document.userinfo.rmemail.value) != (document.userinfo.rmemailconfirm.value))
		{
			alert('E-mail Address and Confirm Email Address are not same!');
			document.userinfo.rmemail.focus();
			return false;
		}

		var mIndex = document.userinfo.dobMonth.selectedIndex;
		var dIndex = document.userinfo.dobDay.selectedIndex;
		var yIndex = document.userinfo.dobYear.selectedIndex;
		var dob = document.userinfo.dobMonth[mIndex].value + "/" 
				+ document.userinfo.dobDay[dIndex].value + "/" 
				+ document.userinfo.dobYear[yIndex].value;

		if (dateValid(dob)) 
		{
			document.userinfo.rmdob.value=dob;
		} 
		else 
		{
			alert('Date of Birth is not a valid date!');
			document.userinfo.dobMonth.focus();
			return false;
		}

		// if the user is under the age of 13, kick them out
		today = new Date();
		birth = new Date();
		birth.setMonth(document.userinfo.dobMonth[mIndex].value-1);
		birth.setDate(document.userinfo.dobDay[dIndex].value);
		birth.setYear(document.userinfo.dobYear[yIndex].value);			

		age = today.getFullYear() - birth.getFullYear();		

		testBirth = new Date();
		testBirth.setMonth(document.userinfo.dobMonth[mIndex].value-1);
		testBirth.setDate(document.userinfo.dobDay[dIndex].value);
		testDay = today.getTime() - testBirth.getTime();
		testDay = Math.floor(testDay / (1000*60*60*24));			

		if (testDay<0) { age = age - 1; }						

		if (age<13) {
			SetCookie("noAccess", "true", null, "/");
			document.location = "/kids/";
			return false;
		}

		if (isBlank(document.userinfo.rmaddress1.value)) 
		{
			alert('Address 1 cannot be blank!');
			document.userinfo.rmaddress1.focus();
			return false;
		}

		if (isBlank(document.userinfo.rmcity.value)) 
		{
			alert('City cannot be blank!');
			document.userinfo.rmcity.focus();
			return false;
		}


		var sIndex = document.userinfo.rmstate.selectedIndex;
		if (document.userinfo.rmstate[sIndex].value=="XX") 
		{
			alert('Select a State!');
			document.userinfo.rmstate.focus();
			return false;
		}

		



		var cIndex = document.userinfo.rmcountry.selectedIndex;
		if (document.userinfo.rmcountry[cIndex].value=="XX") 
		{
			alert('Select a Country!');
			document.userinfo.rmcountry.focus();
			return false;
		}
		
		if((document.userinfo.rmcountry[cIndex].value=="United States" || document.userinfo.rmcountry[cIndex].value=="Canada") && isBlank(document.userinfo.rmzip.value) ){
			alert('Please enter zip code!');
			document.userinfo.rmcountry.focus();
			return false;
			
		}
		if((document.userinfo.rmcountry[cIndex].value=="United States" || document.userinfo.rmcountry[cIndex].value=="Canada") && !isBlank(document.userinfo.rmzip.value) && 
			(document.userinfo.rmzip.value).length !=5){
			alert('Please enter the correct zip code!');
			document.userinfo.rmcountry.focus();
			return false;			
		}
		//if(document.userinfo.rmcountry[cIndex].value== document.userinfo.rmcountry[cIndex].value=="United States"){
		//alert("just alert");
		//}
		/*if((document.userinfo.rmcountry[cIndex].value=="United States" || document.userinfo.rmcountry[cIndex].value=="Canada") && isBlank(document.userinfo.rmzip.value) ){
			alert('Please enter zip code!');
			document.userinfo.rmcountry.focus();
			return false;
			
		}*/
		
		/*if((document.userinfo.rmcountry[cIndex].value =="United States" || document.userinfo.rmcountry[cIndex].value=="Canada") ){
			alert('Please enter five digit zip code!');
			document.userinfo.rmcountry.focus();
			return false;
			
		}*/
			  //starts cookies related validation
	//  if (loginSessionCookie==null) 
	 // { 
			/*if (isBlank(document.userinfo.rmlogin.value)) 
			{
				alert('User Name cannot be blank!');
				document.userinfo.rmlogin.focus();
				return false;
			}
	
			if (!isAscii(document.userinfo.rmlogin.value))
			{
				alert('User Name contains invalid character(s)!');
				document.userinfo.rmlogin.focus();
				return false;
			}		*/
	
	
			// added by Tak 5/2/02 check for single quote values.
			// rmlogin doesn't allow single quote values.
			/*var login = checkSingleQuote(document.userinfo.rmlogin.value);
			if (login != document.userinfo.rmlogin.value)
			{
				alert('User Name cannot contain single quote character(s)!');
				document.userinfo.rmlogin.focus();
				return false;		
			}
			*/
			
			
			if (isBlank(document.userinfo.rmpassword.value))
			{
				alert('Password cannot be blank!');
				document.userinfo.rmpassword.focus();
				return false;
			}
	
			if (document.userinfo.rmpassword.value.length<6)
			{
				alert('Password must be 6 characters or more!');
				document.userinfo.rmpassword.focus();
				return false;
			}
	
			if (document.userinfo.rmpassword.value!=document.userinfo.rmpasswordconfirm.value) 
			{
				alert('The passwords you entered do not match!');
				document.userinfo.rmpassword.focus();
				return false;
			}
	 // }//ends cookies related validation
		for (j=0; j<document.userinfo.elements.length; j++) 
		{
			var thiselement = document.userinfo.elements[j];

			if (thiselement.type=='checkbox') 
			{
			    if(thiselement.name != 'rmcellemail')
				{
				if (!thiselement.checked) 
				{
					if (document.userinfo.uncheckedboxes.value=='') 
					{
						document.userinfo.uncheckedboxes.value = thiselement.name;
					} 
					else 
					{
						document.userinfo.uncheckedboxes.value += '!' + thiselement.name;
					}
				}
				}			
			}
			
		}	
		
		
		document.userinfo.submit();
    }
    
    function userProfileFormSaveExit(){
    document.userinfo.exitpage.value='Y';
   
    
    userProfileForm1(document.userinfo);
	}
	
function	processFormPage2Exit(){
	document.userinfo.exitpage.value='Y';
	document.userinfo.submit();
}

function getdeIndex(email){
	
	if(email != null || email !='null' || email.length >0)
	{
		if(
		(email.charAt(email.length -1) =='e' || email.charAt(email.length -1) =='E' ) &&
		(email.charAt(email.length -2) =='d' || email.charAt(email.length -2) =='d' ) &&
		 email.charAt(email.length -3) =='.' 
		){
		  return true;
		}else{
		return false;
		}
	}
	else{
	  return false;
	}

}