function preloadImages()
{
	var iDir = "/images/";
	MM_preloadImages(iDir + "hLogoBg.jpg", iDir + "hLogo.gif", iDir + "hButterflyTop.gif", iDir + "Bgo.gif", iDir + "hTopBg.jpg", iDir + "hBottomBg.gif", iDir + "hButterflyBottom.gif");
}
	
function MM_preloadImages() {
  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 getCookieValue(cookieName)
{
	var cookieValue = document.cookie;
	var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "=");
	if (cookieStartsAt == -1)
	{
		cookieStartsAt = cookieValue.indexOf(cookieName + "=");
	}
		
	if (cookieStartsAt == -1)
	{
		cookieValue = null;
	}
	else
	{
		cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1;
		var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt);
		if (cookieEndsAt == -1)
		{
			cookieEndsAt = cookieValue.length;
		}
		cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt));
	}
	return cookieValue;
}
	
function leavePopUp()
{
	var registerCookie = getCookieValue("PopAd");
	if (registerCookie == null)
	{
		//Show the popup
		var width = 400;
		var height = 400;
		var left = (screen.width / 2) - (width / 2);
		var top = (screen.height / 2) - (height / 2);
		var lPopUp = window.open("/popups/1/default.asp", 'lPopUp','width=' + width + ', height=' + height + ', left=' + left + ', top=' + top + ', resizable');
		lPopUp.blur();
	}
}

function openPop(url,winName,width,height)
{
	var left = (screen.width/2) - (width/2);
	var top = (screen.height/2) - (height/2);
	var popWin = window.open(url, winName, 'left=' + left + ', top=' + top + ', width=' + width + ', height=' + height + ', scrollbars, resizable');
}

function submitSurvey(resultsPopUp)
{
	var theForm = document.forms.surveyForm;
	var surveyId = theForm.survey_id.value;
	var surveyQuestion = theForm.strQuestion.value;
	var companyName = theForm.company_name.value;
	var i;
	var surveyAnswer;
	for(i=0; i<theForm.elements.length; ++i)
	{
		if(theForm.elements[i].checked)
		{
			surveyAnswer = theForm.elements[i].value;
		}
	}
	var surveyResultsUrl = '/includes/recordSurvey.asp?survey_id=' + surveyId + '&strQuestion=' + surveyQuestion + '&surveyAnswer=' + surveyAnswer + '&company_name=' + companyName + '&resultsPopUp=' + resultsPopUp;
	if (resultsPopUp == 'true')
	{
		openPop(surveyResultsUrl,'surveyWin',300,250);
	}
	else
	{
		document.location = surveyResultsUrl;
	}
}
