
/* "pre assuranthealth cookie code"


	function GetQueryVariable(variable)
	{
		var query = window.location.search.substring(1);
		var vars = query.split("&");
		for (var i=0;i<vars.length;i++)
		{
			var pair = vars[i].split("=");
			if (pair[0] == variable)
			{
				return pair[1].split("?")[0];
			}
		}
	}
*/



function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return "none"
}


	function GetConsumerWebSiteBaseUrl()
	{
		var match = null;
		var destination = null;
		var current = new String(window.location);
		//alert('Current Location: ' + current);

		var regExLoc = new RegExp('localhost');
		var regExDev = new RegExp('dev2\.');
		var regExQa = new RegExp('pp2\.');
		var regExProd = new RegExp('www\.');

		match = regExProd.exec(current);
		if (match == null)
		{
			match = regExQa.exec(current);
		}
		if (match == null)
		{
			match = regExDev.exec(current);
		}
		if (match == null)
		{
			match = regExLoc.exec(current);
		}
	
		//alert('match: ' + match);

		if ((match == null) || (match == 'www.'))
		{
			destination = 'https://consumer.eassuranthealth.com/';
		}
		else if (match == 'pp2.')
		{
			destination = 'https://int2.consumer.eassuranthealth.com/';
		}
		else if ((match == 'dev2.') || (match == 'localhost'))
		{
			destination = 'http://int2.consumer.eassuranthealth.com/';
		}
		
		//alert('Destination: ' + destination);

		return destination;
	}


	function RedirectIMDirectCreate()
	{
		var createUrl = GetConsumerWebSiteBaseUrl() +  "IM2/Consumer/EASE/ConsumerLandingPage.aspx?CEASECampaignId=" + getCookie('CEASECampaignTracker') + "&CEASEReferrerInfo=" + document.referrer;
		//alert(createUrl)
		window.location = createUrl ;
	}

	function RedirectIMDirectSaved()
	{
		var savedUrl = GetConsumerWebSiteBaseUrl() + "IM/Consumer/ease/Apply/SavedQuotes.aspx?CEASECampaignId=" + getCookie('CEASECampaignTracker') + "&CEASEReferrerInfo=" + document.referrer;
		window.location = savedUrl ;
	}

//parse in the query parameters to retrieve the cid  "pre assuranthealth cookie code"
//?CEASECampaignId=" + GetQueryVariable('cid')
//?CEASECampaignId=" + GetQueryVariable('cid')

// STM URL re-write functions

function GetStmBaseUrl()
	{
		var match = null;
		var destination = null;
		var current = new String(window.location);
		//alert('Current Location: ' + current);

		var regExLoc = new RegExp('localhost');
		var regExDev = new RegExp('development\.');
		var regExQa = new RegExp('qa\.');
		var regExProd = new RegExp('www\.');

		match = regExProd.exec(current);
		if (match == null)
		{
			match = regExQa.exec(current);
		}
		if (match == null)
		{
			match = regExDev.exec(current);
		}
		if (match == null)
		{
			match = regExLoc.exec(current);
		}
	
		//alert('match: ' + match);

		if ((match == null) || (match == 'www.'))
		{
			destination = 'http://www.';
		}
		
		else if ((match == 'qa.') || (match == 'development.') || (match == 'localhost'))
		{
			destination = 'http://qa.';
		}
		
		
		//alert('Destination: ' + destination);

		return destination;
	}

// stm redirect functions

function transferToSTI()
{
var cName = getCookie('CEASECampaignTracker')
var regxAfl = new RegExp(/^afl\w*$/i)
var regxOrg = new RegExp(/^org\w*$/i)

if ((cName!= null) && (cName.match(regxAfl)))
	{
	//alert(cName )
	window.location = GetStmBaseUrl() + 'assurantshorttermmed.com'
	}
else if ((cName!= null) && (cName.match(regxOrg)))
	{
	//alert(cName )
	window.location = GetStmBaseUrl() + 'myassuranthealthstm.com'
	}
else 
	{
	//alert("No Match: " + cName  )
	window.location = GetStmBaseUrl() + 'shortterminsurance.net'
	}
}


function transferToATI()
{
var cName = getCookie('CEASECampaignTracker')
var regxAfl = new RegExp(/^afl\w*$/i)
var regxOrg = new RegExp(/^org\w*$/i)

if ((cName!= null) && (cName.match(regxAfl)))
	{
	//alert(cName )
	window.location = GetStmBaseUrl() + 'assurantshorttermmed.com'
	}
else if ((cName!= null) && (cName.match(regxOrg)))
	{
	//alert(cName )
	window.location = GetStmBaseUrl() + 'myassuranthealthstm.com'
	}
else
	{
	//alert("No Match: " + cName  )
	window.location = GetStmBaseUrl() + 'assuranttemporaryinsurance.com'
	}
}




//Webtrends function for tracking sales site link conversions

//Function for OnClick event
function fireHit(PageName) {
	var gDomain="statse.webtrendslive.com";
	var gDcsId="dcszhxyz000000w4pnp2qmsbt_1f7d";
	//old var dcsztt22l21e5h274autteoob_5g2s


	var iSrc = "http:\/\/" + gDomain + "/" + gDcsId + "/njs.gif?dcsuri=/" + PageName + "&WT.js=Yes";
	var img = "<IMG BORDER=\"0\" NAME=\"DCSIMG\" WIDTH=\"1\" HEIGHT=\"1\" SRC=\"" + iSrc + "\">";
	if (document.images) {
		gImages[gIndex]=new Image;
		gImages[gIndex].src=iSrc;
		gIndex++;
	}
}




