﻿function showPhone() {
    if (getQstringValue('phn') == 1 || ReadCookie('laserNum') == 1) {
        document.write('1-866-371-8489')
        mwSetCookie('laserNum', 1, 5);
    }
    else if (getQstringValue('phn') == 2 || ReadCookie('laserNum') == 2) {
        document.write('1-866-551-7480')
        mwSetCookie('laserNum', 2, 5);
    }
    else {

        document.write('<script language="Javascript">DisplayPhoneText("NNN-NNN-NNNN");<\/script><noscript>1-800-968-0649<\/noscript>');
        mwSetCookie('laserNum', 0, 5);
    }
}

function getQstringValue(keyName) {
    var query = window.location.search.substring(1);
    var pairs = query.split("&");
    for (var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');
        if (pos >= 0) {
            var argname = pairs[i].substring(0, pos);

            if (argname == keyName)
                return pairs[i].substring(pos + 1);
        } //end if
    } //end for
    return -10;
}

function ReadCookie(cookieName) {
    var theCookie = "" + document.cookie;
    var ind = theCookie.indexOf(cookieName);
    if (ind == -1 || cookieName == "") return "";
    var ind1 = theCookie.indexOf(';', ind);
    if (ind1 == -1) ind1 = theCookie.length;
    return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
}

function mwSetCookie(cookieName, cookieValue, nDays) {
    var today = new Date();
    var expire = new Date();
    if (nDays == null || nDays == 0) nDays = 1;
    expire.setTime(today.getTime() + 3600000 * 24 * nDays);
    document.cookie = cookieName + "=" + escape(cookieValue) + ";path=/" + ";expires=" + expire.toGMTString();
}
