﻿function OpenWindow(mypage, myname, w, h, scroll, pos) 
{
        if (pos == "random") {
            LeftPosition = (screen.width) ? Math.floor(Math.random() * (screen.width - w)) : 100; TopPosition = (screen.height) ? Math.floor(Math.random() * ((screen.height - h) - 75)) : 100; 
        }
        if (pos == "center") {
            LeftPosition = (screen.width) ? (screen.width - w) / 2 : 100; TopPosition = (screen.height) ? (screen.height - h) / 2 : 100; 
        }
        else if ((pos != "center" && pos != "random") || pos == null) {
            LeftPosition = 0; TopPosition = 20 
        }
        settings = 'width=' + w + ',height=' + h + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
        win = window.open(mypage, myname, settings);
}
function closeWindow() {
    window.parent.hideItem();
    window.opener = "";
    window.close();
}
function Color() {
    document.bgColor = '#ECEDED';
}
 //tracking and cookie
function setTrackingCookie() {
    setCookie('tracking', true, 1);
};
function getTrackingCookie() {
    return getCookie('tracking');
};
function deleteTrackingCookie() {
    setCookie('tracking', '', 0);
};
function insertTrackingImg(src, id) {
    var img = new Image();
    img.src = src;
    img.width = 1;
    img.height = 1;
    $(id).insert(img);
};
function setCookie(name, value, days) {
    var date = new Date();
    date.setDate(date.getDate() + days);
    document.cookie = name + '=' + escape(value) + ((days == null) ? '' : ';expires=' + date.toGMTString());
};
function getCookie(name) {
    if (document.cookie.length > 0) {
        var start = document.cookie.indexOf(name + '=');
        if (start != -1) {
            start = start + name.length + 1;
            var end = document.cookie.indexOf(';', start);
            if (end == -1) {
                end = document.cookie.length;
            };
            return unescape(document.cookie.substring(start, end));
        }
    }
    return '';
};
function bookmarkPage(pageTitle, url) {
    if (window.sidebar) // Firefox
        window.sidebar.addPanel(pageTitle, url, "");
    else if (window.opera && window.print) { // Opera
        var element = document.createElement('a');
        element.setAttribute('href', url);
        element.setAttribute('title', pageTitle);
        element.setAttribute('rel', 'sidebar');
        element.click();
    }
    else if (document.all)// Internet Explorer
        window.external.AddFavorite(url, pageTitle);
}


			


