﻿Date.prototype.addHours = function(n) { this.setHours(this.getHours() + n) }

var currentDate = new Date();

function refreshAd()
{
    document.getElementById('bannerAd').contentWindow.location.href = document.getElementById('bannerAd').contentWindow.location.href;
}

function getMovie()
{
	var movieName = 'homePageFlash';
    
    if (window.document[movieName]) 
    {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet") == -1) 
    {
        if (document.embeds && document.embeds[movieName])
        {
            return document.embeds[movieName];
        }
    }
    else
    {
        return document.getElementById(movieName);
    } 
} 

function setToken(value, hours)
{
    var expiresOn = currentDate;
    expiresOn.addHours(hours);
    
    document.cookie = "RedkenEODSession=" + value + ";Expires=" + expiresOn.toGMTString() + ";path=/";
}

function setUser(value, hours) 
{
    var expiresOn = currentDate;
    expiresOn.addHours(hours);

    document.cookie = "RedkenEODEmail=" + value + ";Expires=" + expiresOn.toGMTString() + ";path=/";
}

function getToken() {

    var retVal = getCookie("RedkenEODSession=");
    try
    {
        getMovie().getTokenHit(retVal);
    }
    catch(err)
    {
    }
    
    return retVal;
}

function getUser() 
{
    var retVal = getCookie("RedkenEODEmail=");
    try
    {
        getMovie().getUserHit(retVal);
    }
    catch(err)
    {
    }
    
    return retVal;
}

function trace(val) 
{
    alert(val);
}

function getCookie(name)
{
    var cookieAttributes = document.cookie.split(';');

    for (var i = 0; i < cookieAttributes.length; i++) 
    {
        var attribute = cookieAttributes[i];
        while (attribute.charAt(0) == ' ') 
        {
            attribute = attribute.substring(1, attribute.length);
        }

        if (attribute.indexOf(name) == 0) 
        {
            return attribute.substring(name.name, attribute.length).split('=')[1];
        }
    }
    return null;
}

function openNewWindow(URL) 
{
    eval("popUpWindow = window.open(URL, 'popUpWindow', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=800');");
}

function openPrintWindow(URL) {
    eval("popUpWindow = window.open(URL, 'popUpPrintWindow', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=1000,height=800');");
}

function openCCCode(URL) {
    eval("popUpWindow = window.open(URL, 'popUpCCCWindow', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=525,height=200');");
}