﻿function GetStartedChoice() {
    var fName = document.getElementById("fName").value;
    var lName = document.getElementById("lName").value;
    var zipCode = document.getElementById("zipCode").value;

    var typeTC = document.getElementById("typeTC").checked;
    var typePC = document.getElementById("typePC").checked;

    var promoCode = document.getElementById("PromoCodeHiddenField");

    var queryString = "FirstName=" + trim(fName) + "&LastName=" + trim(lName) + "&ZipCode=" + trim(zipCode) + "&adid=" + ((promoCode == null) ? "" : promoCode.Value);

    if (typeTC)
        document.location = "http://signup.orkin.com/orkin/res/tc-Standard-ph_sch.aspx?" + queryString;
    else if (typePC)
        document.location = "http://signup.orkin.com/orkin/res/pc-Standard-ph_cb.aspx?" + queryString;
    else
        document.location = "http://signup.orkin.com/orkin/res/fun-Standard-pph_pcb_tph_tsch.aspx?" + queryString;
}

// For the new names of the inputs from the PSDtoHTML slicers
function GetStartedChoice2() {
    var fName = document.getElementById("first").value;
    var lName = document.getElementById("last").value;
    var zipCode = document.getElementById("code").value;

    var typeTC = document.getElementById("inspection").checked;
    var typePC = document.getElementById("control").checked;

    var promoCode = document.getElementById("PromoCodeHiddenField");

    var queryString = "FirstName=" + trim(fName) + "&LastName=" + trim(lName) + "&ZipCode=" + trim(zipCode) + "&adid=" + ((promoCode == null) ? "" : promoCode.Value);

    if (typeTC)
        document.location = "http://signup.orkin.com/orkin/res/tc-Standard-ph_sch.aspx?" + queryString;
    else if (typePC)
        document.location = "http://signup.orkin.com/orkin/res/pc-Standard-ph_cb.aspx?" + queryString;
    else
        document.location = "http://signup.orkin.com/orkin/res/fun-Standard-pph_pcb_tph_tsch.aspx?" + queryString;
}


// remove multiple, leading or trailing spaces
function trim(s) {
    s = s.replace(/(^\s*)|(\s*$)/gi, "");
    s = s.replace(/[ ]{2,}/gi, " ");
    s = s.replace(/\n /, "\n");
    return s;
}

function GetStartedCOM() {
    var fName = document.getElementById("fName").value;
    var lName = document.getElementById("lName").value;
    var zipCode = document.getElementById("zipCode").value;
    var industry = document.getElementById("industry").value;
    var promoCode = document.getElementById("PromoCodeHiddenField");

    var queryString = new Array();
    queryString.push("FirstName=" + trim(fName));
    queryString.push("LastName=" + trim(lName));
    queryString.push("ZipCode=" + trim(zipCode));
    queryString.push("industry=" + industry);
    
    if(promoCode != null)
        queryString.push("&adid=" + promoCode.Value);

    document.location = "http://signup.orkin.com/orkin/com/pc-standard-ph_cb.aspx?" + queryString.join('&');
}

//Common Pests 
// TODO: This shouldn't be here, CLEAN UP THE JAVASCRIPT DIRECTORY AND MOVE THIS
var showPopup = function(pest) {
    var popup = document.getElementById(pest + 'Popup');
    popup.style.display = 'block';
}
var hidePopup = function(pest) {
    var popup = document.getElementById(pest + 'Popup');
    popup.style.display = 'none';
}