
//this code requires there is the below at the top of the <html>
//<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
function OpenWarrantyWindow() 
{     
var path = '/warranty_information.htm' ;     
window.open (path, 'Warranty_Information', config='width=550, height=730, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=no') 
}

function OpenInstallationWindow() 
{     
var path = '/installations.aspx' ;     
window.open (path, 'Installation', config='width=1000, height=850, toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=no')
}

/* Pass the name of the div to hide */
function hideDiv(divName) {
    var elem = document.getElementById(divName);
    if (elem) { elem.style.display = 'none'; }
}

/* Pass the name of the div to show*/
function showDiv(divName) {
    var sDiv = document.getElementById(divName)
    if (sDiv) { sDiv.style.display = 'block'; }
}

var _dialogueBox;
var _dialogueBackground;
var _opacityDirection;
var _opacityValue = 0;

function showWindow(div, Positioning) {
    showDialogue(div, Positioning);
}

function hideWindow() {
    window.onresize = null;

    if (_dialogueBox) {
        _opacityDirection = 1;
        hideWindowSlowly();
    }
}

function CheckPrivacy(chk, btn) {
    var check = document.getElementById(chk);
    var button = document.getElementById(btn);

    if (check && button) {
        button.disabled = (check.checked != true);
    }
}

function CheckVisibility(hdn) {
    var hidden = document.getElementById(hdn);
    var div = document.getElementById('divRegister');
}


function showDialogue(obj, Positioning) {
    if (obj) {
        if (typeof (obj) == 'string')
            obj = document.getElementById(obj);
        if (obj) {
            hideDropDowns();

            cArea = new ClientArea();

            if (!_dialogueBackground) {
                _dialogueBackground = document.createElement('div');
                _dialogueBackground.id = 'dialogueBackground';
                cArea.docBody.appendChild(_dialogueBackground);
            }
            _dialogueBackground.className = 'divDialogBackground';
            _dialogueBackground.style.position = 'absolute';
            _dialogueBackground.style.left = '0px';
            _dialogueBackground.style.top = '0px';
            _dialogueBackground.style.width = cArea.TotalWidth + 'px';
            _dialogueBackground.style.height = cArea.TotalHeight + 'px';
            _dialogueBackground.style.display = 'inline';
            _dialogueBackground.zIndex = 9999;
            setOpacity(80, _dialogueBackground);

            obj.style.position = 'absolute';
            obj.style.display = 'inline';

            ls = new LocationSize(obj);
            setOpacity(0, obj);

            if (!Positioning) {
                obj.style.left = (cArea.left + (cArea.width / 2)) - (ls.width / 2) + 'px';
                obj.style.top = (cArea.top + (cArea.height / 2)) - (ls.height / 2) + 'px';
                window.onresize = resizeDialogue;
            } else if (Positioning == 1) {
                obj.style.left = (cArea.left + (cArea.width / 2)) - (ls.width / 2) + 'px';
                obj.style.top = (cArea.top + (cArea.height / 2)) - (ls.height / 2) + 'px';
                window.onresize = resizeDialogue;
            } else if (Positioning == 2) {
                obj.style.left = '0px';
                obj.style.top = '0px';
                window.onresize = resizeDialogueToTop;
            } else {
                obj.style.left = '0px';
                obj.style.top = cArea.top + 'px';
                window.onresize = resizeDialogueToScroll;
            }

            obj.style.zIndex = _dialogueBackground.style.zIndex + 1;

            _dialogueBox = obj;



            _opacityDirection = 0;
            showWindowSlowly();
            //setOpacity(100, obj);
        }
    }
}

function showWindowSlowly() {

    //var op = getOpacity(_dialogueBox);

    _opacityValue = _opacityValue + 25;

    if (_opacityValue > 100)
        _opacityValue = 100;

    setOpacity(_opacityValue, _dialogueBox);

    if (_opacityDirection == 0) {
        if (_opacityValue < 100) {
            setTimeout(showWindowSlowly, 100);
        } else {
            if (_dialogueBox.getElementsByTagName('input')) {
                if (_dialogueBox.getElementsByTagName('input')[0])
                    if (_dialogueBox.getElementsByTagName('input')[0].visible)
                    _dialogueBox.getElementsByTagName('input')[0].focus();
            }
        }
    }
}

function hideWindowSlowly() {
    //var op = getOpacity(_dialogueBox);

    _opacityValue = _opacityValue - 25;
    if (_opacityValue < 0)
        _opacityValue = 0;

    setOpacity(_opacityValue, _dialogueBox);

    if (_opacityValue > 0) {
        if (_opacityDirection == 1) {
            setTimeout(hideWindowSlowly, 100);
        }
    } else {
        if (_dialogueBox) {
            _dialogueBox.style.display = 'none';
        }
        if (_dialogueBackground) {
            _dialogueBackground.style.display = 'none';
            _dialogueBackground.style.top = '0px';
            _dialogueBackground.style.left = '0px';
            _dialogueBackground.style.height = '0px';
            _dialogueBackground.style.width = '0px';

            showDropDowns();
        }
    }
}



function resizeDialogue() {
    if (_dialogueBox) {
        var cArea = new ClientArea();
        var ls = new LocationSize(_dialogueBox);

        if (!_dialogueBackground)
            _dialogueBackground = document.getElementById('dialogueBackground');

        if (_dialogueBackground) {
            _dialogueBackground.style.width = cArea.TotalWidth + 'px';
            _dialogueBackground.style.height = cArea.TotalHeight + 'px';
        }
        _dialogueBox.style.left = (cArea.left + (cArea.width / 2)) - (ls.width / 2) + 'px';
        _dialogueBox.style.top = (cArea.top + (cArea.height / 2)) - (ls.height / 2) + 'px';
    }
}

function resizeDialogueToTop() {
    if (_dialogueBox) {
        var cArea = new ClientArea();
        var ls = new LocationSize(_dialogueBox);

        _dialogueBox.style.left = '0px';
        _dialogueBox.style.top = '0px';

        if (!_dialogueBackground)
            _dialogueBackground = document.getElementById('dialogueBackground');

        if (_dialogueBackground) {
            _dialogueBackground.style.width = cArea.TotalWidth + 'px';
            _dialogueBackground.style.height = cArea.TotalHeight + 'px';
        }
    }
}

function resizeDialogueToScroll() {
    if (_dialogueBox) {
        var cArea = new ClientArea();
        var ls = new LocationSize(_dialogueBox);

        _dialogueBox.style.left = '0px';
        _dialogueBox.style.top = cArea.top + 'px';

        if (!_dialogueBackground)
            _dialogueBackground = document.getElementById('dialogueBackground');

        if (_dialogueBackground) {
            _dialogueBackground.style.width = cArea.TotalWidth + 'px';
            _dialogueBackground.style.height = cArea.TotalHeight + 'px';
        }
    }
}





function ClientArea() {
    var docBody = document.getElementsByTagName('body')[0];

    //get total area
    this.TotalWidth = 0;
    this.TotalHeight = 0;
    this.TotalWidth = docBody.scrollWidth;
    this.TotalHeight = docBody.scrollHeight;


    if (document.documentElement) {
        if (document.documentElement.scrollWidth > this.TotalWidth)
            this.TotalWidth = document.documentElement.scrollWidth;
        if (document.documentElement.scrollHeight > this.TotalHeight)
            this.TotalHeight = document.documentElement.scrollHeight;
    }
    //END: get total area



    //get clientArea width, height
    var w = 0, h = 0;
    if (document.documentElement) {
        if (document.documentElement.clientWidth) {
            w = document.documentElement.clientWidth;
            h = document.documentElement.clientHeight;
        }
    }

    /*
    if(navigator.vendor){
    if(navigator.vendor.toLowerCase().indexOf('apple') > -1){
    w = window.innerWidth;
    h = window.innerHeight;
    }else{
    w = docBody.clientWidth;
    h = docBody.clientHeight;
    }
    }else{
    w = docBody.clientWidth;
    h = docBody.clientHeight;
    }
    */

    //END:get clientArea width, height

    //get left, top
    var l = -1, t = -1;
    if (navigator.vendor) {
        if (navigator.vendor.toLowerCase().indexOf('apple') > -1) {
            l = docBody.scrollLeft;
            t = docBody.scrollTop;
        }
    }
    if (l == -1 || t == -1) {
        if (document.documentElement) {
            l = document.documentElement.scrollLeft;
            t = document.documentElement.scrollTop;
        }
    }
    if (l == -1) l = 0;
    if (t == -1) t = 0;
    //END:get left, top


    this.left = l;
    this.top = t;
    this.width = w;
    this.height = h;
    this.docBody = docBody;
}

function LocationSize(obj) {
    if (obj == null) {
        this.top = 0;
        this.left = 0;
        this.width = 0;
        this.height = 0;
    } else {
        var objTemp;
        var l, t, w, h;

        objTemp = obj;
        t = objTemp.offsetTop;
        l = objTemp.offsetLeft;

        while (objTemp.offsetParent) {
            objTemp = objTemp.offsetParent;
            t += objTemp.offsetTop;
            l += objTemp.offsetLeft;
        }

        this.left = l;
        this.top = t;
        this.width = obj.offsetWidth;
        this.height = obj.offsetHeight;
    }
}



function setOpacity(percent, obj) {
    obj.style.opacity = (percent / 100);  //Opera
    obj.style.MozOpacity = (percent / 100);  //Mozilla
    obj.style.KhtmlOpacity = (percent / 100);  //??
    obj.style.filter = 'alpha(opacity=' + percent + ')';  //ie
}

function getOpacity(obj) {
    var o = null;

    if (obj.style.opacity)
        o = obj.style.opacity;
    if (obj.style.MozOpacity)
        o = obj.style.MozOpacity;
    if (obj.style.KhtmlOpacity)
        o = obj.style.KhtmlOpacity;
    if (!o) {
        o = obj.style.filter;
        o = o.substring('alpha(opacity='.length);
        o = o.substring(0, o.length - 1);
    } else {
        o = o * 100;
    }
    return o;
}

function hideDropDowns() {
    // hide all select drop downs
    try {
        var selects = document.getElementsByTagName("select");
        for (i = 0; i < selects.length; i++) {
            selects[i].style.display = 'none';
        }
    }
    catch (e) { }
}

function showDropDowns() {
    // hide all select drop downs
    try {
        var selects = document.getElementsByTagName("select");
        for (i = 0; i < selects.length; i++) {
            selects[i].style.display = '';
        }
    }
    catch (e) { }
}
