﻿//Nav script
sfHover = function () {
    var sfEls = document.getElementById("topnav").getElementsByTagName("LI");
    for (var i = 0; i < sfEls.length; i++) {
        sfEls[i].onmouseover = function () {
            this.className += " sfhover";
        }
        sfEls[i].onmouseout = function () {
            this.className = this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

$(function () {
    if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
        $(".divFixedCallout").css({ "top":"0px"});
    }

});
//****************************//

function hover(obj) {
    $(obj).removeClass("btnArrow");
    $(obj).addClass("btnArrow_hover");
}
function hoverout(obj) {
    $(obj).removeClass("btnArrow_hover");
    $(obj).addClass("btnArrow");
}

function confirmEmail(e) {
    var targ;
    if (!e) var e = window.event;
    targ = (e.target) ? e.target : e.srcElement;
    if (targ.nodeType == 3) targ = targ.parentNode;
    if (targ.id.toLowerCase().indexOf("email") >= 0) {
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        var email_id = document.getElementById("hdlic-hdlic").value;
        if (reg.test(email_id)) {
            return true;
        } else {
            document.getElementById("email_error").style.display = "block";
            return false;
        }
    }
};

document.onclick = confirmEmail;
function WatermarkFocus(txtElem, strWatermark) {
    if (txtElem.value == strWatermark) txtElem.value = '';
}
function WatermarkBlur(txtElem, strWatermark) {
    if (txtElem.value == '') txtElem.value = strWatermark;
}
function submitform(obj, destination, idvalid) {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    var email_id = document.getElementById(idvalid).value;
    if (reg.test(email_id)) {
        obj.form.action = destination; obj.form.submit();
    } else {
        document.getElementById("email_error").style.display = "block"; return false;
    }
}


$.fn.equalHeights = function (px) {
    $(this).each(function () {
        var currentTallest = 0;
        $(this).children().each(function (i) {
            if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
        });
        currentTallest += 30;
        if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
        // for ie6, set height since min-height isn't supported
        if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({ 'height': currentTallest }); }
        $(this).children().css({ 'height': currentTallest, 'overflow': 'hidden' });
    });
    return this;
};

Number.prototype.pxToEm = String.prototype.pxToEm = function (settings) {
    //set defaults
    settings = jQuery.extend({
        scope: 'body',
        reverse: false
    }, settings);

    var pxVal = (this == '') ? 0 : parseFloat(this);
    var scopeVal;
    var getWindowWidth = function () {
        var de = document.documentElement;
        return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    };


    if (settings.scope == 'body' && $.browser.msie && (parseFloat($('body').css('font-size')) / getWindowWidth()).toFixed(1) > 0.0) {
        var calcFontSize = function () {
            return (parseFloat($('body').css('font-size')) / getWindowWidth()).toFixed(3) * 16;
        };
        scopeVal = calcFontSize();
    }
    else { scopeVal = parseFloat(jQuery(settings.scope).css("font-size")); };

    var result = (settings.reverse == true) ? (pxVal * scopeVal).toFixed(2) + 'px' : (pxVal / scopeVal).toFixed(2) + 'em';
    return result;
};

function showValue(link) { document.location = link; }
