﻿var m_vSelectedSip = "MINcharge";
var m_arrSipAlt = new Array("1-2LOAD","1-3LOAD","1-4LOAD","1-6LOAD","1-8LOAD","2-3LOAD","3-4LOAD","3-8LOAD","5-6LOAD","5-8LOAD","7-8LOAD","FULLload","MINcharge");
var m_arrSipPrice = new Array("1-2LOAD","1-3LOAD","1-4LOAD","1-6LOAD","1-8LOAD","2-3LOAD","3-4LOAD","3-8LOAD","5-6LOAD","5-8LOAD","7-8LOAD","FULLload","MINcharge");
function loadSipImage(vVol){
    var o = document.getElementById(m_bIsZipValid).value;
    if (o == "false") return;
    var w, wp;
    w = document.getElementById(m_vWebUrlID);
    if (w) { wp = w.value; }
    if (wp.length == 0) wp = "/ca_fr/";
    var oImg = document.getElementById("sipImage");
    if (oImg) oImg.src = wp + "images/sip/SIP_" + vVol + ".jpg";
    var oPrevButton = document.getElementById(m_vSelectedSip);
    if (oPrevButton) oPrevButton.className = "volButton";
    highlightButton(vVol);
    loadSipDesc(vVol);
    if (o == "True") {
        var price = document.getElementById(m_vPrice);
        if (price) {
            price.innerHTML = "<strong>Estimation du prix de débarras</strong>: " + m_arrSipPrice[vVol] + "$";
        }
    }
}
function highlightButton(vVol){
    var oButton = document.getElementById(vVol);
    if (oButton) oButton.className = "volButtonSelected";
    m_vSelectedSip = vVol;
}
function loadSipDesc(vVol){
    var oImg = document.getElementById("sipImage");
    if (oImg) oImg.alt = m_arrSipAlt[vVol];
}
function loadData(){
    loadImages();
    loadAltText();
    loadPrice();
}
function loadAltText(){
    m_arrSipAlt["1-2LOAD"] = "1/2 de la boîte";
    m_arrSipAlt["1-3LOAD"] = "1/3 de la boîte";
    m_arrSipAlt["1-4LOAD"] = "1/4 de la boîte";
    m_arrSipAlt["1-6LOAD"] = "1/6 de la boîte";
    m_arrSipAlt["1-8LOAD"] = "1/8 de la boîte";
    m_arrSipAlt["2-3LOAD"] = "2/3 de la boîte";
    m_arrSipAlt["3-4LOAD"] = "3/4 de la boîte";
    m_arrSipAlt["3-8LOAD"] = "3/8 de la boîte";
    m_arrSipAlt["5-6LOAD"] = "5/6 de la boîte";
    m_arrSipAlt["5-8LOAD"] = "5/8 de la boîte";
    m_arrSipAlt["7-8LOAD"] = "7/8 de la boîte";
    m_arrSipAlt["FULLload"] = "Pleine capacité";
    m_arrSipAlt["MINcharge"] = "Tarif minimum";
}
function loadImages() {
    var w, wp;
    w = document.getElementById(m_vWebUrlID);
    if (w) { wp = w.value; }
    if (wp.length == 0) wp = "/ca_fr/";
    
    var aImages = new Array(13);
    var iWidth, iHeight;
    iWidth = 526;
    iHeight = 266;
    for (var i=0; i<13; i++){
        aImages[i] = new Image(iWidth, iHeight);
        aImages[i].src = wp + "images/sip/SIP_" + m_arrSipAlt[i] + ".jpg";
    }    
}

function loadPrice(){
    m_arrSipPrice["1-2LOAD"] = document.getElementById(m_vp12Load).value;
    m_arrSipPrice["1-3LOAD"] = document.getElementById(m_vp13Load).value;
    m_arrSipPrice["1-4LOAD"] = document.getElementById(m_vp14Load).value;
    m_arrSipPrice["1-6LOAD"] = document.getElementById(m_vp16Load).value;
    m_arrSipPrice["1-8LOAD"] = document.getElementById(m_vp18Load).value;
    m_arrSipPrice["2-3LOAD"] = document.getElementById(m_vp23Load).value;
    m_arrSipPrice["3-4LOAD"] = document.getElementById(m_vp34Load).value;
    m_arrSipPrice["3-8LOAD"] = document.getElementById(m_vp38Load).value;
    m_arrSipPrice["5-6LOAD"] = document.getElementById(m_vp56Load).value;
    m_arrSipPrice["5-8LOAD"] = document.getElementById(m_vp58Load).value;
    m_arrSipPrice["7-8LOAD"] = document.getElementById(m_vp78Load).value;
    m_arrSipPrice["FULLload"] = document.getElementById(m_vpFullLoad).value;
    m_arrSipPrice["MINcharge"] = document.getElementById(m_vpMinCharge).value;
}
function initSipPage(){
    loadData();
    if (document.getElementById(m_bIsZipValid).value == "True"){
        var oImg = document.getElementById("sipImage");
        oImg.style.opacity = "";
        oImg.style.filter = "";
        
        document.getElementById("zip").value = document.getElementById(m_vZipCode).value;
        document.getElementById("franchiseID").value = document.getElementById(m_vFranchiseID).value;
        document.getElementById("zoneID").value = document.getElementById(m_vZoneID).value;
        document.getElementById("scheduleID").value = document.getElementById(m_vScheduleID).value;
        document.getElementById("jobStartTime").value = document.getElementById(m_vJobStartTimeID).value;
        document.getElementById("isDiscount").value = document.getElementById(m_bIsDiscount).value;
        document.getElementById("jobDate").value = document.getElementById(m_vJobDate).value;
    }else{
        var oImg = document.getElementById("sipImage");
        oImg.style.opacity = "0.4";
        oImg.style.filter = "alpha(opacity=40)";
        
        document.getElementById("zip").value = "";
        document.getElementById("franchiseID").value = 0;
        document.getElementById("zoneID").value = 0;
        document.getElementById("scheduleID").value = 0;
        document.getElementById("jobStartTime").value = 0;
        document.getElementById("isDiscount").value = false;
        document.getElementById("jobDate").value = "";
        var price = document.getElementById(m_vPrice);
        price.value = "";
    }
    
}

function goToStep(step) {
    var w,wp;
    w = document.getElementById(m_vObeUrlID);
    if (w) { wp = w.value; } else { wp = "https://request.1800gotjunk.com/WEBCLIENT/"; }
    var frm = document.getElementById("formSubmit");
    if (step == 2)
        frm.action = wp + "forms/wfBook10.aspx?banr=1&c=ca&r=na_fr"
    else if(step == 3)
        frm.action = wp + "forms/wfBook1.aspx?banr=1&c=ca&r=na_fr"
    frm.submit();
}
if(window.attachEvent) window.attachEvent("onload",initSipPage);
else window.addEventListener("load",initSipPage,false);