//NOTE:  This one is for SHC.  It's done differently than CCSD and CA right now because if
//forwards to another site with the source code and phone number.
var currSite;
var source;
var currLocation = window.location.href.toUpperCase();	
var phonenum ;	
var bForward ;
//STEP 1:  function getWindowHREF() calls getCurrentSite() to find the root site.
//STEP 2:  Depending on the root site, the function redirectXXXX() is called.
//STEP 3:  The sub domain is found in the function redirectXXXX() , a code, phone number, and forwrading URL are identified.
//determins which website this is pointing to.
function getCurrentSite()
{
		//set the test code
	if(currLocation.indexOf("STEVENSHENAGER") > -1 )
		currSite = "SHC";
	if(currLocation.indexOf("COLLEGEAMERICA") > -1 )
		currSite = "CA";
	if(currLocation.indexOf("CC-SD") > -1 )
		currSite = "CCSD";
	if(currLocation.indexOf("INDEPENDENCE") > -1 )
		currSite = "IU";	
}
function getWindowHREF()
{		
	//which of the websites is this pointing to?
	getCurrentSite();
	
	if(currSite == "SHC")
		redirectSHC();
	if(currSite == "CA")
		redirectCA();
	if(currSite == "CCSD")
		redirectCCSD();
	if(currSite == "IU")
		redirectIU();

}

function redirectSHC()
{		
	//set to the default SHC
		source = "1231";
	//set to the default
		phonenum = "(800) 321-1019";
	//set the test code
	if(currLocation.indexOf("TESTING") > -1 )
	{
		phonenum = "TEST SHC";
		source = "0000";
		bForward = true;
	}	
	//set the code
	if(currLocation.indexOf("KYMZ") > -1 )
	{
		//KYMZ Radio Web Leads
		source = "1405";		
		bForward = true;
	}	
	//set the code
	if(currLocation.indexOf("KXRK") > -1 )
	{
		//KXRK Radio Web Leads
		source = "1406";	
		bForward = true;		
	}	
	//set the code
	if(currLocation.indexOf("KEGA") > -1 )
	{
		//KEGA Radio Web Leads
		source = "1408";		
		bForward = true;
	}	
	//set the code
	if(currLocation.indexOf("KEGA") > -1 )
	{
		//KEGA Radio Web Leads
		source = "1408";	
		bForward = true;		
	}	
	//set the code
	if(currLocation.indexOf("KJQN") > -1 )
	{
		// KJQN Radio Web Leads
		source = "1409";	
		bForward = true;
	}	
	//set the code
	if(currLocation.indexOf("KZNS") > -1 )
	{
		//KZNS Radio Web Leads
		source = "1410";	
		bForward = true;		
	}	
	//set the code
	if(currLocation.indexOf("KUUU") > -1 )
	{
		// KUUU Radio Web Leads
		source = "1411";
		bForward = true;		
	}	
	//set the code
	if(currLocation.indexOf("KUDD") > -1 )
	{
		// KUDD Radio Web Leads
		source = "1412";		
		bForward = true;
	}	
	//set the code
	if(currLocation.indexOf("KZMG") > -1 )
	{
		// Radio Web Leads
		source = "1414";
		bForward = true;		
	}
//set the code
	if(currLocation.indexOf("KYMZ") > -1 )
	{
		//KYMZ Radio Web Leads
		source = "1405";		
		bForward = true;
	}
//set the code
	if(currLocation.indexOf("KYMZ") > -1 )
	{
		//KYMZ Radio Web Leads
		source = "1405";		
		bForward = true;
	}
//set the code
	if(currLocation.indexOf("KYMZ") > -1 )
	{
		//KYMZ Radio Web Leads
		source = "1405";		
		bForward = true;
	}
	
//set the code
	if(currLocation.indexOf("WWW.13.STE") > -1 )
	{
		// KNIN CW
		source = "1419";		
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("WWW.7.STE") > -1 )
	{
		// KTVB CW
		source = "1421";		
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("WWW.12.STE") > -1 )
	{
		// KTRX CW
		source = "1422";		
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("WWW.6.STE") > -1 )
	{
		// KIVI CW
		source = "1423";		
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("WWW.2.STE") > -1 )
	{
		// KBCI CW
		source = "1424";		
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("WWW.999.STE") > -1 )
	{
		// Cable TV Web Leads
		source = "1425";		
		bForward = true;
	}
	
	if(bForward)
	{
		window.location = "http://info.stevenshenager.edu?source=" + source + "&phone=" + phonenum;
	}
	/*else if(bForwardSHC)
	{
		window.location = "http://www.stevenshenager.edu/request-college-information.html?source=" + source;	

	}
*/	
}

function redirectCA()
{
	//set to the default
		source = "1273";//COLLEGEAMERICA DEFAULT CODE
	//set the test code
	if(currLocation.indexOf("TESTING") > -1 )
	{
		phonenum = "TEST CA";
		source = "0000";
		bForward = true;
	}
	if(currLocation.indexOf("COLLEGEAMERICA.COM") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1273";//David to provide source code. 8/25/09
		bForward = true;
	}	
		//set the code
	if(currLocation.indexOf("KSME") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1404";
		bForward = true;
	}	
	//set the code
	if(currLocation.indexOf("53.COLLEGEAMERICA.EDU") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1247";
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("51.COLLEGEAMERICA.EDU") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1248";
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("30.COLLEGEAMERICA.EDU") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1249";
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("KPTT.COLLEGEAMERICA.EDU") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1488";
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("KBPI.COLLEGEAMERICA.EDU") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1487";
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("KTCL.COLLEGEAMERICA.EDU") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1489";
		bForward = true;
	}
	if(bForward)
	{
		window.location = "http://www.collegeamerica.edu/request-information.html?source=" + source;
	}
	
}

function redirectCCSD()
{
	
	//set to the default
		source = "1274";//CCSD DEFAULT CODE
	//set the test code
	if(currLocation.indexOf("TESTING") > -1 )
	{
		phonenum = "TEST CCSD";
		source = "0000";
		bForward = true;
	}
	//set the code
	if(currLocation.indexOf("COX.") > -1 )
	{
		//www.ksme.collegeamerica.edu
		source = "1415";
		bForward = true;
	}	
	if(bForward)
	{
		window.location = "http://www.cc-sd.edu/request-college-information.html?source=" + source;
	}
}
//used by the individual request pages to see if there is another source code.
//By using the forms collection, we can make this function universal.  The only consideration is that the form must be the first on the pages (forms[0])
function getReferringSite()
{		
	var frm = document.forms[0];//this way, we don't care what the form name is.  
	
	//set the default source code for the forms
	//which of the websites is this pointing to?
	getCurrentSite();
	
	if(currSite == "SHC")		
		source = "1173";//set to the default SHC
	if(currSite == "CA")
		source = "1273" //set to the default CA
	if(currSite == "CCSD")
		source = "1274" //set to the default CCSD
	//if(currSite == "IU")
		//source = XXXXXX; NOT USED YET
	//IS IT A SOURCE CODE OTHER THAN THE DEFAULT?
	if(currLocation.indexOf("?SOURCE=") > -1)
	{
		begin = currLocation.indexOf("?SOURCE=") + 8;
		source = currLocation.substring(begin,begin + 4);
	}		
	//NOTE: all of the forms must have a hidden field named "source". - CASE SENSITIVE
	frm.source.value = source;

}




