﻿// Set i = 1 if cookies exist
/* setCookie("ihavecookies", '1', '', '/', document.domain, null);
*/

/**
* Sets a Cookie with the given name and value.
*
* name       Name of the cookie
* value      Value of the cookie
* [expires]  Expiration date of the cookie (default: end of current session)
* [path]     Path where the cookie is valid (default: path of calling document)
* [domain]   Domain where the cookie is valid
*              (default: domain of calling document)
* [secure]   Boolean value indicating if the cookie transmission requires a
*              secure transmission
*/
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
* Gets the value of the specified cookie.
*
* name  Name of the desired cookie.
*
* Returns a string containing value of specified cookie,
*   or null if cookie does not exist.
*/
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
* Deletes the specified cookie.
*
* name      name of the cookie
* [path]    path of the cookie (must be same as path used to create cookie)
* [domain]  domain of the cookie (must be same as domain used to create cookie)
*/
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function FixCookieDate(date) {
    var base = new Date(0);
    var skew = base.getTime();
    if (skew > 0)
        date.setTime(date.getTime() - skew);
}

function SiteSeal(img, type) {
    if (window.location.protocol.toLowerCase() == "https:") { var mode = "https:"; } else { var mode = "http:"; }
    var host = location.host;
    var baseURL = mode + "//seals.networksolutions.com/siteseal_seek/siteseal?v_shortname=" + type + "&v_querytype=W&v_search=" + host + "&x=5&y=5";
    document.write('<a href="#" onClick=\'window.open("' + baseURL + '","' + type + '","width=450,height=500,toolbar=no,location=no,directories=no,\
status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=no")\'>\
<img src="' + img + '" style="border:none;" oncontextmenu="alert(\'This SiteSeal is protected\');return false;"></a>');
}

// Credits Eric Okorie [http://www.primezero.com]

function startHelpMenu(urlToStartHelp) {
    var helpStartPage = urlToStartHelp;
    var helpMenuWidth = "640";
    var helpMenuHeight = "480";
    var helpMenuTop = 25;
    var helpMenuLeft = 50;
    var browserWidth = window.screen.availWidth;
    var browserHeight = window.screen.availHeight;
    var browserUpperEdge = window.screen.y;
    var browserLeftEdge = window.screen.x;

    //we know the height and width of the help menu.  now calc the position
    if (browserHeight > helpMenuHeight) {
        //halve the difference
        helpMenuTop = (browserHeight - helpMenuHeight) / 2;
    }
    if (browserWidth > helpMenuWidth) {
        //halve the difference
        helpMenuLeft = (browserWidth - helpMenuWidth) / 2;
    }
    winProperties = 'height=' + helpMenuHeight + ',width=' + helpMenuWidth + ',top=' + helpMenuTop + ',left=' + helpMenuLeft + ',scrollbars=1,status=0,resizable=1'
    myHelpWindow = window.open(helpStartPage, "helpWindow", winProperties);
    myHelpWindow.focus();
}

function closeByClickingLink() {
    var w = window.screen.availWidth;
    var h = window.screen.availHeight;

    self.close();
    opener.window.resizeTo(w, h);
}

function jumpingJiving(urlToGo, urlToHelp) {
    opener.location.href = urlToGo;
    self.location.href = urlToHelp;
}

function findControl(ControlName) {
    var retVal = null;
    var aControls = document.getElementsByTagName("input");

    if (aControls) {
        for (var i = 0; i < aControls.length; i++) {
            if (aControls[i].id.lastIndexOf(ControlName) == (aControls[i].id.length - ControlName.length)
			&& (aControls[i].id.length != ControlName.length) && (aControls[i].id.lastIndexOf(ControlName) > 0)) {
                retVal = aControls[i];
                break;
            }
        }
    }

    return retVal;
}

// Check if value is a number
function IsNumeric(sText) {
    var ValidChars = "0123456789.";
    var IsNumber = true;
    var Char;

    for (i = 0; i < sText.length && IsNumber == true; i++) {
        Char = sText.charAt(i);
        if (ValidChars.indexOf(Char) == -1) IsNumber = false;
    }
    return IsNumber;
}

function popupWindowC(cURL, cName, iWidth, iHeight, cScroll) {
    var iLeft = (screen.width - iWidth) / 2;
    var iTop = (screen.height - iHeight) / 2;
    popupWindow(cURL, cName, iLeft, iTop, iWidth, iHeight, cScroll);
}

function popupWindow(cURL, cName, iLeft, iTop, iWidth, iHeight, cScroll) {
    var winProp;

    winProp = 'width=' + iWidth;
    winProp += ', height=' + iHeight;
    winProp += ', left=' + iLeft;
    winProp += ', top=' + iTop;
    winProp += ', scrollbars=' + cScroll;
    winProp += ', locationbar=no, menubar=yes, personalbar=no, statusbar=no, toolbar=yes, resizable=yes';

    Win = window.open(cURL, cName, winProp);
    Win.window.focus();
}