﻿
function hov(loc, cls) {
    if (loc.className) {
        loc.className = cls;
    }
}

function toggle(div_id) {
    var el = document.getElementById(div_id);
    if (el.style.display == 'none') {
        el.style.display = 'block';
    }
    else {
        el.style.display = 'none';
    }
}

function blanket_size(popUpDivVar, blanket) {
    if (typeof window.innerWidth != 'undefined') {
        viewportheight = window.innerHeight;
    }
    else {
        viewportheight = document.documentElement.clientHeight;
    }
    if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
        blanket_height = viewportheight;
    }
    else {
        if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
            blanket_height = document.body.parentNode.clientHeight;
        }
        else {
            blanket_height = document.body.parentNode.scrollHeight;
        }
    }

    if (typeof window.innerWidth != 'undefined') {
        blanket_width = window.innerWidth;
    } else {
        blanket_width = document.documentElement.clientWidth;
    }

    var blanket = document.getElementById(blanket);
    blanket.style.height = blanket_height + 'px';
    blanket.style.width = blanket_width + 'px';
    var popUpDiv = document.getElementById(popUpDivVar);
    popUpDiv_height = blanket_height / 2.5 - 150; //150 is half popup's height
    popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar, blanket) {
    if (typeof window.innerWidth != 'undefined') {
        viewportwidth = window.innerHeight;
    } else {
        viewportwidth = document.documentElement.clientHeight;
    }
    if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
        window_width = viewportwidth;
    } else {
        if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
            window_width = document.body.parentNode.clientWidth;
        } else {
            window_width = document.body.parentNode.scrollWidth;
        }
    }
    var popUpDiv = document.getElementById(popUpDivVar);
    window_width = window_width / 2.5 - 105; //150 is half popup's width
    popUpDiv.style.left = window_width + 'px';
}
function popup() {
    blanket_size('popUpDiv', 'blanket');
    window_pos('popUpDiv', 'blanket');
    toggle('blanket');
    toggle('popUpDiv');
}


function toggleDropDownLists() {
    var dControls = document.getElementsByTagName('select');
    for (var i = 0; i < dControls.length; i++) {
        dControls[i].style.display = (dControls[i].style.display != 'none' ? 'none' : '');
    }
}



function ValidateZipcode2(sender, e) {

    var zipcode = document.getElementById(sender.id + '_txtZipCode');
    if (isValidZipCode(zipcode.value)) {
        popup();
        pBar.showBar();
        e.IsValid = true;
    }
}

function isValidZipCode2(value) {
    var re = /^\d{5}([\-]\d{4})?$/;
    return (re.test(value));
}   