﻿function redirectExternalLink(pageLocation) {
    if (pageLocation != "") {
        var ExternalSiteWindow = "ChicksOnPicksReferral";
        window.open(pageLocation, ExternalSiteWindow);
        ExternalSiteWindow.focus();
    }
}

function redirectInternalLink(pageLocation) {
    if (pageLocation != "") {
        document.location.href=pageLocation;
    }
}

function newsSignup() {
    var newsletterEmailAddress = document.getElementById("ctl00_content_DataList3_ctl00_tbxNewsletterSignup").value;
    if (newsletterEmailAddress != "") {
        var signupUrl = "http://visitor.r20.constantcontact.com/d.jsp?";
        signupUrl += "llr=9wxssnfab&";
        signupUrl += "m=1105336032986&";
        signupUrl += "p=oi&";
        signupUrl += "ea=" + newsletterEmailAddress + "&";
        signupUrl += "go=Go";
        redirectExternalLink(signupUrl);
        //document.write(newsletterEmailAddress);
    }
}

/*PCA*/
   var selCountryIT = document.getElementById("selCountryIT");

   function isSupportedCountry(code) {
   	var _supported = false;

   	for (var i in tools.supportedCountries) {
   		if (tools.supportedCountries[i] == code)
   			_supported = true;
   	}

   	return _supported;
   }

   for (var i in tools.countryData) {
   	if (isSupportedCountry(tools.countryData[i].i3))
   		selCountryIT.options[selCountryIT.options.length] = new Option(tools.countryData[i].n, tools.countryData[i].i3);

   	if (tools.countryData[i].i3 == "GBR")
   		selCountryIT.options[selCountryIT.options.length - 1].selected = true;
   }

   var objFinder = new PCAInternationalAutoComplete("GBR", "ENG", document.getElementById("txtPostcodeIT"), document.getElementById("txtLine1IT"), simpleformCallback);
   objFinder.UseRoyalMailPremiseData = false;

   function simpleformCallback() {
   	document.getElementById("txtLine1IT").value = objFinder.Line1;
   	document.getElementById("txtLine2IT").value = objFinder.Line2;
   	document.getElementById("txtCityIT").value = objFinder.City;
   	document.getElementById("txtStateIT").value = objFinder.State;
   	document.getElementById("txtPostcodeIT").value = document.getElementById("txtPostcodeIT").value.toUpperCase();
   }
/**/
