/* Common Function Start */

$('#addDelivery').click(function(){
	$("#displayDeliveryPoints").css("display", "block");	
});
function checkItem1()
{
		$("#viewItem1").css("display", "block");
		$("#viewItem2").css("display", "none");
		$("#viewItem3").css("display", "none");
}
function checkItem2()
{
		$("#viewItem2").css("display", "block");
		$("#viewItem1").css("display", "none");
		$("#viewItem3").css("display", "none");
}
function checkItem3()
{
		$("#viewItem3").css("display", "block");
		$("#viewItem2").css("display", "none");
		$("#viewItem1").css("display", "none");
}
function relatedButtonClick(evt, btn) {
    var isNav, isIE
    if (parseInt(navigator.appVersion) >= 4) {
        if (navigator.appName == "Netscape") isNav = true
        else isIE = true
    }
    var keyValue
    if (isNav) {
        keyValue = evt.which
    }
    else {
        keyValue = window.event.keyCode
    }
    if (keyValue == 13) {
        if (btn == "") {
            return false;
        }
        else {
            objbtn = document.getElementById(btn)
            objbtn.click()
            return false;
        }
    }
}

function validateEmail(strEmail) {

    reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    if (!reg.test(strEmail)) {
        return false;
    }
    return true;

}

function reloadIframe(ifrmCaptcha) {
    window.frames[ifrmCaptcha].location.reload();
}

function texttrim(str) {
    var strObj = RemoveTabSpace(str);
    return rtrim(ltrim(strObj));
}

/* Javascript function is used to remove if tab spaces entered by user.*/
function RemoveTabSpace(objField) {
    var strField = objField.replace(/\t/g, '')
    return strField;
}

function ltrim(str) {
    while (str.length > 0) {
        if (str.substr(0, 1) == " ")
            str = str.substr(1);
        else break;
    }

    return str;
}

function rtrim(str) {
    while (str.length > 0) {
        if (str.substr(str.length - 1, 1) == " ")
            str = str.substr(0, str.length - 1);
        else break;
    }

    return str;
}

function trim(str) {
    return rtrim(ltrim(str));
}

function openPopup(urlLoc) {
    var win;
    win = window.open(urlLoc, "", "");
}
function GetXmlHttpObject() {
    var xmlHttp = null;
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
    }

    return xmlHttp;
}

function getNodeValue(obj, tag) {
    if (obj.getElementsByTagName(tag))
        if (obj.getElementsByTagName(tag)[0]) {
            if (obj.getElementsByTagName(tag)[0].firstChild)
                if (obj.getElementsByTagName(tag)[0].firstChild.nodeValue)
                    return obj.getElementsByTagName(tag)[0].firstChild.nodeValue;
        }
        else {
            if (obj.getElementsByTagName(tag).firstChild)
                if (obj.getElementsByTagName(tag).firstChild.nodeValue)
                    return obj.getElementsByTagName(tag).firstChild.nodeValue;
        }

    return "";
}

function evalTextInput(e) {
    var allow = '1234567890';
    var k;
    if ((e.keyCode == 46 && !document.all) || (e.keyCode == 8) || (e.keyCode == 9) || (e.keyCode == 37 && !document.all) || (e.keyCode == 39 && !document.all) || (e.keyCode == 35 && !document.all) || (e.keyCode == 36 && !document.all)) {
        return true;
    }
    k = document.all ? parseInt(e.keyCode) : parseInt(e.which);
    return (allow.indexOf(String.fromCharCode(k)) != -1);
}

function addOption(selectbox, text, value) {
    //alert("text:" + text);
    var optn = document.createElement("OPTION");
    optn.text = text;
    optn.value = value;
    selectbox.options.add(optn);
}


/* Common Function End */
var xmlHttp;
var objLink;
var objDisplayInSameWindow;
function AddBannerClick(link,infoid, infotype, bannerurl, displayInSameWindow) {
   
    xmlHttp = GetXmlHttpObject();
    objLink = link;
    objDisplayInSameWindow = displayInSameWindow;
    if (xmlHttp == null) {
        return;
    }
    var url = objPageRootURL + "../templates/default/designs/hdlAddBannerClick.ashx";
    url = url + objPerameters;
    url = url + '&bannerid=' + infoid + '&bannertype=' + infotype + '&bannerurl=' + bannerurl;

    if (xmlHttp == null) {
        //alert("Your browser does not support AJAX!");
        return;
    }
    //alert(url);
    xmlHttp.open("GET", url, true);
    xmlHttp.onreadystatechange = SetBannerCount;
    xmlHttp.send(null);

    //var passdata = objPerameters +'&bannerid=' + infoid + '&bannertype=' + infotype + '&bannerurl=' + bannerurl;
    //xmlHttp.open("POST", url, true);
    //xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    //xmlHttp.onreadystatechange = null;
    //xmlHttp.send(passdata);
}

function SetBannerCount() {
    if (xmlHttp.readyState == 4) {
        if (objLink != null) {if (objDisplayInSameWindow != null && objDisplayInSameWindow == 'Y') {window.location.href = objLink.href;} else {window.open(objLink.href);} }
        objDisplayInSameWindow = null; objLink = null;
    }
}


function removeShadowValue(strDefaultValue, strTextBoxId) { var obj1 = document.getElementById(strTextBoxId); if (obj1.value == strDefaultValue) { obj1.value = "";} }
function assignShadowValue(strDefaultValue, strTextBoxId) { var obj1 = document.getElementById(strTextBoxId); if (obj1.value == "") { obj1.value = strDefaultValue; } }

function setCookie(c_name, value, exdays) {
    var exdate = new Date();
    var c_value;
    exdate.setDate(exdate.getDate() + exdays);
    if (exdays == 0) {
        c_value = escape(value);
    }
    else {
         c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
    }
    document.cookie = c_name + "=" + c_value;
}
function getCookie(c_name) {
    var c_value = document.cookie;
    var c_start = c_value.indexOf(" " + c_name + "=");
    if (c_start == -1) {
        c_start = c_value.indexOf(c_name + "=");
    }
    if (c_start == -1) {
        c_value = null;
    }
    else {
        c_start = c_value.indexOf("=", c_start) + 1;
        var c_end = c_value.indexOf(";", c_start);
        if (c_end == -1) {
            c_end = c_value.length;
        }
        c_value = unescape(c_value.substring(c_start, c_end));
    }
    return c_value;
}
