var csmnFormNumber = -1;

function csmnForm()
{
	if(csmnFormNumber == -1)
	{
		for(var f=0 ;f < document.forms.length ; f++)
		{
			for(var e=0 ; e<document.forms[f].elements.length ; e++)
			{
				if(document.forms[f][e].name == "CSMNForm")
					csmnFormNumber = f;

				if(csmnFormNumber != -1)
					break;
			}

			if(csmnFormNumber != -1)
				break;
		}		

	}

	return(csmnFormNumber);
}

function makeNewWindow(page, name, x, y)
{
	popupWin=eval("window.open('"+page+"','" + name + "','toolbar=0,scrollbars=1,location=0,status=0,menubars=0,resizable=0,width=" + x + ",height=" + y + "')")
	//popupWin.focus()
}
function makeFullWindow(page, name)
{
	popupWin=eval("window.open('"+page+"','" + name + "','toolbar=1,scrollbars=1,location=1,status=1,menubars=1,resizable=1')")
	//popupWin.focus()
}


function gotoLogin()
{
	document.forms[csmnForm()].action = switchToHttp(document.URL);
	document.forms[csmnForm()].act.value = "login";
	document.forms[csmnForm()].submit();
}
function gotoSSLRegistration()
{
	document.forms[csmnForm()].action = switchToHttps(document.URL);
	document.forms[csmnForm()].act.value = "enterSSLRegistration";
	document.forms[csmnForm()].submit();
}
function disableSSLRegistration()
{
	document.forms[csmnForm()].action = switchToHttp(document.URL);
	document.forms[csmnForm()].act.value = "enterRegistration";
	document.forms[csmnForm()].submit();
}
function emailSignUp()
{
	document.forms[csmnForm()].action = switchToHttp(document.URL);
	document.forms[csmnForm()].act.value = "emailSignUp";
	document.forms[csmnForm()].submit();
}

function target()
{
	document.forms[csmnForm()].action = switchToHttp(document.URL);
	document.forms[csmnForm()].act.value = "target";
	document.forms[csmnForm()].submit();
}

function nyny()
{
	document.forms[csmnForm()].action = switchToHttp(document.URL);
	document.forms[csmnForm()].act.value = "nyny";
	document.forms[csmnForm()].submit();
}

function summerBlastOff()
{
	document.forms[csmnForm()].action = switchToHttp(document.URL);
	document.forms[csmnForm()].act.value = "summerBlastOff";
	document.forms[csmnForm()].submit();
}
function backToSchool()
{
	document.forms[csmnForm()].action = switchToHttp(document.URL);
	document.forms[csmnForm()].act.value = "backToSchool";
	document.forms[csmnForm()].submit();
}

function switchToHttp(url)
{
	if(url.indexOf("https://") == 0)
		url = "http://" + url.slice(8);
	
	return(url);
}

function switchToHttps(url)
{
	if(url.indexOf("http://") == 0)
		url = "https://" + url.slice(7);
	
	return(url);
}

var separator = "_";

function RangeSelectedValidatorEvaluateIsValid(objSource, objArgs)
{	
	var b = objSource.id.substring(0, objSource.id.lastIndexOf(separator)+1) + objSource.idbasename;
	
	var index = 0;
	var numselected = 0;
	
	var inputcontrol = document.all[b + separator + index];
	
	while(typeof(inputcontrol) != "undefined" && (inputcontrol.type == "radio" || inputcontrol.type == "checkbox"))
	{
		if(inputcontrol.checked)
			numselected++;
		
		index++;
		inputcontrol = document.all[b + separator + index];
	}
	
	objArgs.IsValid = (((numselected >= objSource.minselected) || (objSource.minselected < 0))  &&  ((numselected <= objSource.maxselected) || (objSource.maxselected <0)));
}

var randDARTNumber=0;
function genSetRandDARTNumber()
{
 randDARTNumber = Math.round(Math.random()*1000000000000);
}
genSetRandDARTNumber();

//Email Sign Up
	function ValidateOptIn(source, args)
    {
		args.IsValid = (document.getElementById('_ctl2_NCA').checked || document.getElementById('_ctl2_TPE').checked);
    } 
    
    function ValidateEmail(source, args)
    {
		args.IsValid = ((document.getElementById('_ctl2_EmailAddress').value)!= "");
	}
	
	function checkEmailSyntax(source, args)
	{
		if ((document.getElementById('_ctl2_EmailAddress').value)!= "")
		{
			var x = document.forms[0]._ctl2_EmailAddress.value;
			
			var filter  = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			if (filter.test(x)) 
				args.IsValid = true;
			else 
				args.IsValid = false;
		}
	}
	
	function ValidateGender(source, args)
    {
		args.IsValid = (document.getElementById('_ctl2_Gender_0').checked || document.getElementById('_ctl2_Gender_1').checked);
    }
    
    function ValidateZip(source, args)
    {
		args.IsValid = ((document.getElementById('_ctl2_Zip').value)!= "");
	}
	
    function checkZipSyntax(source, args)
	{
		if ((document.getElementById('_ctl2_Zip').value)!= "")
		{
			var x = document.forms[0]._ctl2_Zip.value;
			
			var filter  = (/(^\d{5}$)|(^\d{5}-\d{4}$)/);
			if (filter.test(x)) 
				args.IsValid = true;
			else 
				args.IsValid = false;
		}
	}
	
    
//Email Sign Up