function openWin( windowURL, windowName, windowFeatures ) {
        return window.open( windowURL, windowName, windowFeatures ) ;
}
function getCookieValue(name){
    var cookie = Get_Cookie("ISP_SF");
    if(cookie != null){
        var rtrnVal = "";
        cookieStr = cookie.substring(1);
        pairs = cookieStr.split("&");
        for (i = 0; i < pairs.length; i++){
            pos = pairs[i].indexOf('=');
            if (pos == -1){ continue; }
            argname = pairs[i].substring(0,pos);
            argvalue = pairs[i].substring(pos+1);
            if(argname == name){ rtrnVal = argvalue; break; }
        }
        return rtrnVal;
    }
}
function validateData(thisForm, msg){
    if(!msg) msg = 'We\'re sorry; we couldn\'t find the ZIP code entered. Please try again.';

    //if value is not 5 digits
    if (!/\d{5}/.test(thisForm.address.value)) {
        alert(msg);
        return false;
    }
    else {
        return true;
    }
}

// End CR 31042

// CR 31736. Remove after CR 31736 testing is complete.
function validMarketZip(zipField, zipErrorField) {
    var callback = function (data) {
      if( data.zipCode == null) {
            zipErrorField.value = "true";
        } else {
           zipErrorField.value = "false";
        }
    }
    var zip = zipField.value;

    if (zip != null) {
      MarketManager.getMarketByZipCode(zip, callback);
   }
}

var last_zip = "";
function validateZipForm(form){
    var zip = $("syc_zip");
    var zipError = $("marketZipError");
    
    if(zipError.value == "wait")
    {
        setTimeout(function(){validateZipForm(form)}, 250);
        return false;
    }
    var this_zip = $F("syc_zip");
    if(this_zip != last_zip)
    {
        last_zip = this_zip;
        changeVehicleZip();
        setTimeout(function(){validateZipForm(form)}, 250);
        return false;
    }
    if(zipError.value == 'true' || zip.value == "") {
        window.alert('We\'re sorry; we couldn\'t find the ZIP code entered. Please try again.');
        return false;
    }
        form.submit();
        return true;
}
