var errMessage = "";
<!--

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	} else
		var expires = "";

	document.cookie = name+"="+value+expires+"; path=/";

}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') {
			c = c.substring(1,c.length);
		}
		if (c.indexOf(nameEQ) == 0) {
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function replaceHttp(strLink) {
	if (strLink!=null) {
		strLink.replace("http", "https");
	}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  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 MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function setLangCookie(prefer_lang) {
    var nextyear = new Date();
    nextyear.setFullYear(nextyear.getFullYear() + 1);
    document.cookie = "PreferLangCookie=" + prefer_lang + "; expires=" + nextyear.toGMTString() +
                      "; domain=" + document.domain + "; path=/";
}

/*
MODIFICATIONS
6.10.2004 DT - now returns false
11.10.2004 DT - fixed top align, was using t for both top and toolbar so top was not aligning properly (default centered)

*/
function advanced_pop(pop, w, h, winalign, winvalign, s, r, windowName, toolbar, menubar, status, locationbar) {
    if (windowName == null)
        windowName = "VR_pop";

    if (s == null)
        s = "no";
    if (r == null)
        r = "no";

    var l=(screen.width-w)/2;
    var topAlign=(screen.height-h)/2;

    if (winalign == "left")
        l = 20;
    else if (winalign == "right")
        l = screen.width-w-20;

    if (winvalign == "top")
        t = 20;
    else if (winvalign == "bottom")
        t = screen.height-h-20;

	if (toolbar == "yes")
		t="yes"
	else
		t="no"

	if (menubar == "yes")
		m="yes"
	else
		m="no"

	if (status == "yes")
		bs="yes"
	else
		bs="no"

	if (locationbar == "yes")
		lb="yes"
	else
		lb="no"

    var clwidth = w;
    var clheight = h;

    var aWindow = window.open('',windowName,'width=' + clwidth +
                ',height=' + clheight + ',top=' +
                topAlign + ',left=' + l + ",scrollbars=" + s +
                ',resizable=' + r + ',toolbar=' + t + ',menubar=' + m + ',status=' + bs + ',location=' + lb);

    aWindow.location=pop;
    aWindow.focus();

    return false;

}

function isblank(val) {
  if (val == null) { return true; }
  for (var i=0; i < val.length; i++) {
    if ((val.charAt(i) != ' ') && (val.charAt(i) != "\t") && (val.charAt(i) != "\n")) { return false; }
  }
  return true;
}


function isAlphaSpecial(checkStr,extraChars) {
 var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"+extraChars;

 if (checkStr==null) return false;

 for (i = 0;  i < checkStr.length;  i++) {
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
			break;
  	if (j == checkOK.length) {

		return false;
	}
 }

 return true;
}

function advanced_pop1(windowName, pop, w, h, winalign, winvalign, s, r, pWin) {
    if (windowName == null)
        windowName = "VR_pop";

    if (s == null)
        s = "no";
    if (r == null)
        r = "no";

    var l=(screen.width-w)/2;
    var t=(screen.height-h)/2;

    if (winalign == "left")
        l = 20;
    else if (winalign == "right")
        l = screen.width-w-20;

    if (winvalign == "top")
        t = 20;
    else if (winvalign == "bottom")
        t = screen.height-h-20;

    var clwidth = w
    var clheight = h
    var aWindow = window.open('',windowName,'width=' + clwidth +
                ',height=' + clheight + ',top=' +
                t + ',left=' + l + ",scrollbars=" + s +
                ',resizable=' + r);

    aWindow.location=pop;
    aWindow.focus();

}
function pop_external(url, currentURL) {
    var extWindow;
//alert (currentURL );
    if (window.name == 'VR_SignIn') {
	alert ("Its opening VR Sign In" );
        if (!opener.closed && opener.name != null && opener.name != 'VRExternal' && opener.name != 'VR_Top') {
            extWindow = opener.top.open(url, 'VRExternal');
           // extWindow.location = url;
            extWindow.resizeTo(800,600);
        } else {
            extWindow = opener.top;
            extWindow.document.location = url;
        }
    } else {
	 //alert ("Its opening VR External" );
	document.location = currentURL;
	     extWindow = window.open(url, 'VRExternal');
       // extWindow.document.location = url;
	     if(!extWindow)
		  {alert("Your window to the store was possibly blocked by an pop up blocker on your machine. Please disable the pop up blocker by adding www.airmilesshops.ca to the trusted site. Then please try again.");
		   }

    }
    extWindow.focus();
}
function pop_external_browseRet(url) {

   VRWindow = window.open (url); 
 
}

function pop_external_browseRet_thankYou(url,currentURL) {
  
   VRWindow = window.open (url); 
    if (currentURL != null||currentURL != "") 
     if(currentURL)
       document.location = currentURL;

}

function checkRetailerCookie(retailerID) {
    if (retailerID != null) {

        var cookies = document.cookie.split(';');
        for (cookie in cookies) {

            var c = cookies[cookie].split('=');

            if (c[0] == (" VR_Retailer_" + retailerID)) {

               return true;
            }
        }
    }
}

function setPopUpCookie(sessionMarker) {
    document.cookie = sessionMarker + "=true;domain="+document.domain+"; path=/";
}
function setRetailerCookie(field, retailerID) {
    var year = new Date();
    var value = "shown";
    if (field.checked) {

        year.setFullYear(year.getFullYear() + 1);
    } else {
        value="null";

        year.setFullYear(year.getFullYear() - 1);
    }
    document.cookie = "VR_Retailer_" + retailerID + "=" + value + "; expires=" + year.toGMTString() +
                      "; domain=" + document.domain + "; path=/";
    return false;
}


function changeLocation(url) {
    var parentWindow;

window.location=url;
   
  //return true;
}

function changeLocation_old(url) {
    var parentWindow;


    if (window.top.opener.closed == false)
       {
	    parentWindow = window.top.opener
        if (url)

        { // alert("inside not url" +refererPage);
		 	parentWindow.location = url;

		}

    } else {

        if (!url)
            url = '/servlet/ContentServer?pagename=airmilesshops/Home';
		/*if(refererPage)
		    url = url + "RefererPage=" + refererPage;*/

       	 parentWindow = window.open(url,'VRParentWindow');
    }

    parentWindow.focus();
    //window.top.close();
  //return true;
}






function go_old(blnCheckCookie, retailerID, destinationID, destinationURL, invisLink, refererPage)
{
	var targetURL;
	var targetParams;
	var prefix;
	var loggedIn= 'false';
	var redirectUrl;
	var redirectApp = 'airmilesshops';
	targetParams = '&RetailerID=' + retailerID;
	//alert ("Using go function window name :" + window.name);
    if (destinationURL != null)
        targetParams += '&DestinationURL=' + escape(destinationURL);

    if (destinationID != null)
        targetParams += '&DestinationID=' + destinationID;

    if (invisLink != null && invisLink != "no")
        targetParams += '&InvisLink=' + invisLink;

    if (refererPage != null)
       targetParams += '&RefererPage=' + refererPage;

	if (window.name  != 'VR_External' && window.name != 'VR_Top' && 'null' != 'null')
	{
	   redirectUrl = '&RedirectApp=' + redirectApp+'&RedirectURL=' +'null';
	}

     //  if (loggedIn == 'false')
     //	prefix = 'https://';
     // else
		prefix = 'http://';

    targetURL =  prefix + 'www.airmilesshops.ca' + '/servlet/ContentServer?pagename=airmilesshops/StoreSplash'+ targetParams +  '&targetParams=' +escape(targetParams);

    if (window.name  == 'VR_External' || window.name == 'VR_Top')
	{
		changeLocation(targetURL);
		window.top.close();
	}
	else
	{
		//document.location = targetURL;
	    var load = window.open( targetURL , 'VRExternal');
		if(load && load.closed == false )
		 {//alert ( "Window open result" +  load.closed );
		  load.focus();
		  }
		 else
		  {alert("Your window to the store was possibly blocked by an pop up blocker on your machine. Please disable the pop up blocker by adding www.airmilesshops.ca to the trusted site. Then please try again.");
		   }

		 //window.createPopup(targetURL , 'VRExternal');

		 //  open('about:blank');
    }

    return false;
}







function go(blnCheckCookie, retailerID, destinationID, destinationURL, invisLink, refererPage)
{
	var targetURL;
	var targetParams;
	var prefix;
	var loggedIn= 'false';
	var redirectUrl;
	var redirectApp = 'airmilesshops';
	var parentWindow;
	
	targetParams = '&RetailerID=' + retailerID;
	//alert ("Using go function window name :" + window.name);
    if (destinationURL != null)
        targetParams += '&DestinationURL=' + escape(destinationURL);

    if (destinationID != null)
        targetParams += '&DestinationID=' + destinationID;

    if (invisLink != null && invisLink != "no")
        targetParams += '&InvisLink=' + invisLink;

    if (refererPage != null)
       targetParams += '&RefererPage=' + refererPage;

	if (window.name  != 'VR_External' && window.name != 'VR_Top' && 'null' != 'null')
	{
	   redirectUrl = '&RedirectApp=' + redirectApp+'&RedirectURL=' +'null';
	}

    prefix = 'http://';

   //targetURL =  prefix + 'www.airmilesshops.ca' + '/servlet/ContentServer?pagename=airmilesshops/StoreSplash'+ targetParams +  '&targetParams=' +escape(targetParams);
   targetURL =  prefix + 'www.airmilesshops.ca' + '/servlet/ContentServer?pagename=airmilesshops/StoreSplash'+targetParams;

    window.location=targetURL;
    
    return false;
}

function goBakUp(blnCheckCookie, retailerID, destinationID, destinationURL, invisLink, refererPage)
{
	var targetURL;
	var targetParams;
	var prefix;
	var loggedIn= 'false';
	var redirectUrl;
	var redirectApp = 'airmilesshops';
	targetParams = '&RetailerID=' + retailerID;

    if (destinationURL != null)
        targetParams += '&DestinationURL=' + escape(destinationURL);

    if (destinationID != null)
        targetParams += '&DestinationID=' + destinationID;

    if (invisLink != null && invisLink != "no")
        targetParams += '&InvisLink=' + invisLink;

    if (refererPage != null)
       targetParams += '&RefererPage=' + refererPage;

	if (window.name  != 'VR_External' && window.name != 'VR_Top' && 'null' != 'null')
	{
	   redirectUrl = '&RedirectApp=' + redirectApp+'&RedirectURL=' +'null';
	}

    if (loggedIn == 'false')
 		prefix = 'https://';
    else
		prefix = 'http://';

    targetURL =  prefix + 'www.airmilesshops.ca' + '/servlet/ContentServer?pagename=airmilesshops/RetailerSplash'+ targetParams +  '&targetParams=' +escape(targetParams);

    if (window.name  == 'VR_External' || window.name == 'VR_Top')
	{
		changeLocation(targetURL);
		window.top.close();
	}
	else
	{
		document.location = targetURL;
    }

    return false;
}


function checkLoginBackup(parentURL, popURL, loggedIn) {
    if (loggedIn) {
        pop_external(popURL);
    } else {
        var openerWindow = window;

        if (top.opener) {
            openerWindow = top.opener;
            parentURL = top.opener.location.href;

        }
        var redirectApp = 'airmilesshops';
        openerWindow.advanced_pop1('VR_SignIn','/servlet/ContentServer?pagename=airmilesshops/SignInPop&RedirectApp='+ redirectApp +'RedirectURL=' + escape(parentURL) + '&PopURL=' + escape(popURL),336,325);
    }
}
function refreshChild() {
    if (!document.VR_External.closed) {

        //document.VR_External.VR_Top.location.reload(false);
    }
}


function checkEmail(email,errstr) {
    // to check the length has to be more than 60
    if (email.length>60) {
	errMessage=errMessage+"\nThe "+errstr+" must not be longer than 25 characters, please use another e-mail address.";
	allValid=false;
	return false;
    }


     /*The regular expression that expresses the format goes something like this: /^.+@.+\..{2,3}$/.
     The carat (^) means the start of the string and the dollar sign ($) means the end of the string.
     By surrounding the rest of the regular expression with these characters,
     we ensure that we evaluate the entire string, rather than just a portion.
     Each .+ means "at least one character" ? the dot (.) means "any character""
     and the plus sign (+), you recall, means "one or more." The .{2,3} portion means "two or three characters."
     And when we want to match a literal dot, we need to escape the character with a backslash.
     That's why we have \. there.
     */

    var emailFilter=/^..+\@..+\...+$/;

    if (!(emailFilter.test(email))) {
        errMessage=errMessage+"\n"+errstr+" field must be of the format <something>@domainname (ie. yourname@airmiles.ca). ";
        allValid=false;
        return false;
    }

    //Again, we want to check to make sure that no forbidden characters have slipped in. For email addresses, we're forbidding the following: ( ) < > [ ] , ; : \ / "

    var illegalChars= /[\[\]\(\)\<\>\,\;\:\\\\"]/;
    if (email.match(illegalChars)) {
        errMessage=errMessage+"\nThe "+errstr+" contains unacceptable characters.";
        allValid=false;
  	return false;
    }

    // for checking if strign has "@@" or ".." or "@." or ".@"
    var emailFilter1=/^.*@.*@.*$/;
    var emailFilter2=/^.*@\..*$/;
    var emailFilter3=/^.*\.@.*$/;
    var emailFilter4=/^.*\.\..*$/;

    if ((emailFilter1.test(email) || emailFilter2.test(email) || emailFilter3.test(email) || emailFilter4.test(email))) {
        errMessage=errMessage+"\nThe "+errstr+" field must not have '@@' or '..' or '@.' or '.@'";
        allValid=false;
        return false;
    }
    return true;
}

function checkDD(ind,errstr) {
    if(ind == 0 || ind==null) {
		errMessage=errMessage+"\nPlease select the "+errstr;
   	  	allValid=false;
		return false;
    }
    return true;
}

function  checkBlank(checkStr,errstr) {
    if (isblank(checkStr)) {
	errMessage=errMessage+"\n" + errstr +" is required";
	allValid=false;
	return false;
    }
    return true;
}

function checkMinLen(checkStr,errstr,len) {
    if (checkStr.length<len) {
	errMessage=errMessage+"\n" + errstr + " has to be at least " +len+ " characters long.";
	allValid=false;
	return false;
    }
    return true;
}

function checkAlphaSpecial(checkStr,errstr,extraChars) {
   if (!isAlphaSpecial(checkStr,extraChars)) {
	errMessage=errMessage+"\n"+errstr+" field must consist of letters and numeric characters.";
	allValid=false;
	return false;
   }
   return true;
}

function shiftArray(inpArray)

{ outArray= new Array();
    for (i=1;i<inpArray.length; i++)
   {
      outArray[i-1]=inpArray[i];
	}
 return outArray;
}
function pushArray(inpArray, inpVal)

{ outArray= new Array();
    for (i=0;i<inpArray.length; i++)
   {
      outArray[i]=inpArray[i];
	}
outArray[inpArray.length] = inpVal;
 return outArray;
}

// found at http://www.jsmadeeasy.com/javascripts/Forms/Date%20Validation/template.htm
// DT 1.18.2005
function isValidDate(dateStr) {
// Checks for the following valid date formats:
// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
// Also separates date into month, day, and year variables

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

// To require a 4 digit year entry, use this line instead:
// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;

var matchArray = dateStr.match(datePat); // is the format ok?
if (matchArray == null) {
//alert("Date is not in a valid format.")
return false;
}
month = matchArray[1]; // parse date into variables
day = matchArray[3];
year = matchArray[4];
if (month < 1 || month > 12) { // check month range
//alert("Month must be between 1 and 12.");
return false;
}
if (day < 1 || day > 31) {
//alert("Day must be between 1 and 31.");
return false;
}
if ((month==4 || month==6 || month==9 || month==11) && day==31) {
//alert("Month "+month+" doesn't have 31 days!")
return false
}
if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap)) {
//alert("February " + year + " doesn't have " + day + " days!");
return false;
   }
}
return true;  // date is valid
}
/*
Checks date format.  Currently, only returns basic error message,
can be upgraded to return specific error message i.e. "Day must be between 1 and 31."

DT 1.18.2005
*/
function checkDate(date,errstr)
{
	if (!checkBlank(date, errstr))
	{
		return false;
	}
	if (!isValidDate(date) )
	{
		errMessage=errMessage+"\n"+errstr+" field must be of the format MM/DD/YYYY ";
		allValid=false;
		return false;
	}
	return true;
}

function isNumericSpecial(checkStr,extraChars) {
 var checkOK = "1234567890"+extraChars;

 if (checkStr==null) return false;

 for (i = 0;  i < checkStr.length;  i++) {
	ch = checkStr.charAt(i);
	for (j = 0;  j < checkOK.length;  j++)
		if (ch == checkOK.charAt(j))
			break;
  	if (j == checkOK.length) {

		return false;
	}
 }

 return true;
}
function checkNumericSpecial(checkStr,errstr,extraChars) {
   if (!isNumericSpecial(checkStr,extraChars)) {
	errMessage=errMessage+"\n"+errstr+" field must consist of numeric characters.";
	allValid=false;
	return false;
   }
   return true;
}
function getRadioButtonValue(radioObject)
{
	for (i=0;i<radioObject.length;i++)
	{
		if (radioObject[i].checked)
		{
			return radioObject[i].value;
		}
	}
	return null;

}
function checkRadioBlank(radioObject,errstr)
{
	var radioValue = getRadioButtonValue(radioObject);
	if (radioValue==null || radioValue=="")
	{
		errMessage=errMessage+"\n" + errstr +" is required";
		allValid=false;
		return false;
	}
	return true;
}
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}
function sn_swap_image(id, src) {
	var img = document.getElementById(id);
	img.src = src;
}
/* goes to store info page if storeID passed in is valid.  otherwise returns false so action is taken.
*/
function goStoreInfoPage(storeID, refererPage)
{
	if (storeID != null && storeID != '')
	{
		document.location='/servlet/ContentServer?pagename=airmilesshops/SearchByStore&RetailerID='+ storeID + '&RefererPage=' + refererPage;
	}
	return false;
}
<!--- Airmiles login funtions-->


function checkValue(from, to, event) {
	var pattern = /[^0-9]/g;
    errMsg = document.getElementById("errorMessage");
  	if (from.value.match(pattern)) {
    	if (from.name != "collectorPIN")
      		errMsg.innerHTML = "Your collector number may only contain numbers!";
    	else
      		errMsg.innerHTML = "Your PIN may only contain numbers!";
    		from.value = from.value.replace(pattern, "");
  	} else {
		if ((event.keyCode != null && event.keyCode != 13) || (event.which != null && event.which != 13))
       	errMsg.innerHTML = "";
    }
  	if (from.value.length != from.maxLength) {
    	from.focus();
    	return false;
  	}
  if (from.value.length == from.maxLength) {
	 /*		if (to != null)
        		to.focus();
     */
	 		return true;
  	}
  	return false;
}

function validateForm(form, event) {

	var mess = "";
	var rvalue = true;

	if ((errMsg = document.getElementById("errorMessage"))) {

  	if (!checkValue(form.collectorNumber, form.collectorPIN, event)) {
    	form.collectorNumber.focus();
      mess = "The AIR MILES&reg; Collector Card number you have entered is invalid because it contains too few or too many digits. Please try again.";
    	rvalue = false;
  	} else if (!checkValue(form.collectorPIN, null, event)) {
     	form.collectorPIN.focus();
      mess = "The PIN you have entered is invalid because it contains too few or too many digits. Please try again.";
     	rvalue = false;
  	}

  	if (rvalue == false) {
	    errMsg.innerHTML = mess;
	    return false;
  	}

  }
  	return true;
}
function submitForm(form, event) {

  if (validateForm(form, event)) {
     form.submit();
  }
}


function checkLength(field) {
   if (field.createTextRange != null) {
	   if (field.value.length == field.maxLength)
    	  field.select();
   		else {
      	var range = field.createTextRange();
      	range.moveStart('character', field.value.length);
      	range.collapse();
      	range.select();
   		}
	}

}

function refreshParentWindow()
{
  if(!opener.closed)
     {
	   window.opener.location.href = window.opener.location.href;
	  }

}

function goToLinkWithParam(linkUrl, param, param2)
{
	if (param2) {
		linkUrl = linkUrl.replace("param2", param2);
	}
	document.location=linkUrl.replace("param", param);
}

function goToLinkWithParamAddParam(linkUrl, param, param2)
{
	var newLinkUrl = linkUrl + "_" + param;

	if (param2) {
		newLinkUrl += "-" + param2;
		newLinkUrl = newLinkUrl.replace("param2", param2);
	}
	
	document.location=newLinkUrl.replace("param", param);
}

//------------------------------------------------
//	Get Object for usage
//------------------------------------------------
function getObject(id){
	//	retrieve object
	//------------------------------
	if (document.getElementById){OBJ = document.getElementById(id);}
	else if (document.all){OBJ = document.all[id];}
	else if (document.layers){if (document.layers[id]){OBJ = document.layers[id];}}
	
	//	return object to caller
	//------------------------------
	return OBJ;
}

//------------------------------------------------
//	image swapper
//------------------------------------------------
function imgChange(id, src){
	//	retrieve object
	//------------------------------
	OBJ	= getObject(id);	

	//	set new src
	//------------------------------
	OBJ.src	= src;
}

<!-- user code here -->

<!-- eyeReturn function start -->

<!--
function eye_redir(strRefererPage){
var redirectJS = '/servlet/ContentServer?pagename=airmilesshops/Redirect&AdID=1116341269607';
redirectJS = redirectJS + '&RefererPage=' + strRefererPage ;
var contestWin = window.open(redirectJS , 'er_collectWindow1452','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,height=655,width=820');
contestWin.focus;
}
// -->


// Stuff for ads
var RN = new String (Math.random());
var RNS = RN.substring (2, 11);

var protocol = document.location.href.substring(0,document.location.href.indexOf(":")+3);
var oas = protocol + "adserver.airmiles.ca/RealMedia/ads/"; 

var _version = 11;
if (navigator.userAgent.indexOf('Mozilla/3') != -1){
	_version=10;
}

function DisplayAds (position, width, height, sitepage, qs, productid) {
	var oaspage = sitepage + '/1' + RNS + '@' + position + "?" + qs + "&paid=" + productid;

	if (_version < 11) {
		document.write ('<A HREF="' + oas + 'click_nx.ads/'+ oaspage + '" TARGET="_top" ><IMG SRC="' + oas + 'adstream_nx.cgi/' + oaspage + '" BORDER="0" WIDTH="' + width + '" HEIGHT="' + height + '"></a>');
	} 
	else {
		document.write ('<SCR' + 'IPT LANGUAGE="JavaScript1.1" SRC="' + oas + 'adstream_jx.ads/' + oaspage + '">');
		document.write ('\<\!-- --\>');
		document.write ('\<\/SCR' + 'IPT\>');
		document.write ('\<\!-- --\>');
	}
}

function getCookie(sName)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0])
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function confirm_browse(msg, url, url2) {
	
	if (confirm(msg)) {
		pop_external_browseRet_thankYou(url, url2);
	}	
}
function checkRetailerCookie(retailerID) {
    if (retailerID != null) {

        var cookies = document.cookie.split(';');
        for (cookie in cookies) {

            var c = cookies[cookie].split('=');

            if (c[0] == (" VR_Retailer_" + retailerID)) {

               return true;
            }
        }
    }
}

function getObject(id){
	//	retrieve object
	//------------------------------
	if (document.getElementById){OBJ = document.getElementById(id);}
	else if (document.all){OBJ = document.all[id];}
	else if (document.layers){if (document.layers[id]){OBJ = document.layers[id];}}
	
	//	return object to caller
	//------------------------------
	return OBJ;
}
	function addFlash(id,w,h,src){
	OBJ		= getObject(id);

	OBJ.innerHTML	= "";

		flashOBJ	= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
		flashOBJ	+= 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"';
		flashOBJ	+= 'width="'+w+'"';
		flashOBJ	+= 'height="'+h+'">';
		flashOBJ	+= '<param name="wmode" value="transparent" />';
		flashOBJ	+= '<param name="movie"';
		flashOBJ	+= 'value="'+src+'"/>';
		flashOBJ	+= '<param name="quality" value="high" />';
		flashOBJ	+= '<param name="menu" value="false" />';
		flashOBJ	+= '<embed src="'+src+'"';
		flashOBJ	+= 'quality="high"';
		flashOBJ	+= 'pluginspage="https://www.macromedia.com/go/getflashplayer"';
		flashOBJ	+= 'type="application/x-shockwave-flash"';
		flashOBJ	+= 'width="'+w+'"';
		flashOBJ	+= 'height="'+h+'"';
		flashOBJ	+= 'menu="false"';
		flashOBJ	+= 'WMODE="transparent">';
		flashOBJ	+= '</embed>';
		flashOBJ	+= '</object>';

	OBJ.innerHTML	= flashOBJ;
}

var formbusy = false;
function disableForm() {
	if(formbusy) {
		return false;
	} else {
		formbusy = true;
		return true;
	}
}

function changeLocale(newLocale){
	var before = null;
	var after = null;
	var newUrl = null;
	
	var currentUrl = location.href;

	// Remove sessionid if present
	var offset = currentUrl.indexOf(';');
	if (offset != - 1) {
		currentUrl = currentUrl.substring(0, offset);
	}

	// Remove '#' sign
	offset = currentUrl.indexOf('#');
	if (offset != - 1) {
		currentUrl = currentUrl.substring(0, offset);
	}

	// Remove, if found, 'changeLocale=...' string from URL
	offset = currentUrl.indexOf('?changeLocale=');
	if (offset == -1) {
		offset = currentUrl.indexOf('changeLocale=');	
	}
	if (offset != -1) {
		newUrl = currentUrl.substring(0, offset);		
	} 	else {
		newUrl = currentUrl;
	}
	
	// Add 'changeLocale' to the clean URL
	offset = newUrl.indexOf('?');	
	newUrl = newUrl + ((offset == -1) ? '?' : '&') + 'changeLocale=' + newLocale;
	
	
	location.href = newUrl;
	
}