﻿function start() {
    if (document.getElementById) {
        ns6marquee(document.getElementById('slider'));
        //alert('ns');
    }
    else if (document.all) {
        iemarquee(slider);
        //alert('ie');
    }
    else if (document.layers) {
        ns4marquee(document.slider1.document.slider2);
        //alert('ns4');
    }
}

function iemarquee(whichdiv) {
    iediv = eval(whichdiv);
    iediv.style.pixelTop = sheight + "px";
    iediv.innerHTML = wholemessage;
    sizeup = iediv.offsetHeight;
    ieslide();
}

function ieslide() {
    if (iediv.style.pixelTop >= sizeup * (-1)) {
        iediv.style.pixelTop -= sspeed + "px";
        setTimeout("ieslide()", 100);
    }
    else {
        iediv.style.pixelTop = sheight + "px";
        ieslide();
    }
}

function ns4marquee(whichlayer) {
    ns4layer = eval(whichlayer);
    ns4layer.top = sheight;
    ns4layer.document.write(wholemessage);
    ns4layer.document.close();
    sizeup = ns4layer.document.height;
    ns4slide();
}

function ns4slide() {
    if (ns4layer.top >= sizeup * (-1)) {
        ns4layer.top -= sspeed;
        setTimeout("ns4slide()", 100);
    } else {
        ns4layer.top = sheight;
        ns4slide();
    }
}

function ns6marquee(whichdiv) {
    ns6div = eval(whichdiv);
    ns6div.style.top = sheight + "px";
    ns6div.innerHTML = wholemessage;
    sizeup = ns6div.offsetHeight;
    ns6slide();
}

function ns6slide() {
    if (parseInt(ns6div.style.top) >= sizeup * (-1)) {
        ns6div.style.top = parseInt(ns6div.style.top) - sspeed + "px";
        setTimeout("ns6slide()", 100);
    } else {
        ns6div.style.top = sheight + "px"; ns6slide();
    }
}

var BrowserDetect = {
    init: function() {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
    },
    searchString: function(data) {
        for (var i = 0; i < data.length; i++) {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString) {
                if (dataString.indexOf(data[i].subString) != -1)
                    return data[i].identity;
            }
            else if (dataProp)
                return data[i].identity;
        }
    },
    searchVersion: function(dataString) {
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
    },
    dataBrowser: [
		{ string: navigator.userAgent,
		    subString: "OmniWeb",
		    versionSearch: "OmniWeb/",
		    identity: "OmniWeb"
		},
		{
		    string: navigator.vendor,
		    subString: "Apple",
		    identity: "Safari"
		},
		{
		    prop: window.opera,
		    identity: "Opera"
		},
		{
		    string: navigator.vendor,
		    subString: "iCab",
		    identity: "iCab"
		},
		{
		    string: navigator.vendor,
		    subString: "KDE",
		    identity: "Konqueror"
		},
		{
		    string: navigator.userAgent,
		    subString: "Firefox",
		    identity: "Firefox"
		},
		{
		    string: navigator.vendor,
		    subString: "Camino",
		    identity: "Camino"
		},
		{		// for newer Netscapes (6+)
		    string: navigator.userAgent,
		    subString: "Netscape",
		    identity: "Netscape"
		},
		{
		    string: navigator.userAgent,
		    subString: "MSIE",
		    identity: "Explorer",
		    versionSearch: "MSIE"
		},
		{
		    string: navigator.vendor,
		    subString: "Google",
		    identity: "Google"
		},
		{
		    string: navigator.userAgent,
		    subString: "Gecko",
		    identity: "Mozilla",
		    versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
		    string: navigator.userAgent,
		    subString: "Mozilla",
		    identity: "Netscape",
		    versionSearch: "Mozilla"
		}
	],
    dataOS: [
		{
		    string: navigator.platform,
		    subString: "Win",
		    identity: "Windows"
		},
		{
		    string: navigator.platform,
		    subString: "Mac",
		    identity: "Mac"
		},
		{
		    string: navigator.platform,
		    subString: "Linux",
		    identity: "Linux"
		}
	]

};


function countdown_clock(year, month, day, hour, minute, format) {
    //I chose a div as the container for the timer, but
    //it can be an input tag inside a form, or anything
    //who's displayed content can be changed through
    //client-side scripting.
    html_code = '<div id="countdown" style="border:1px solid #CCCCCC;width:400px; text-align:center" class="counter"></div>';

    document.write(html_code);

    countdown(year, month, day, hour, minute, format);
}

function countdown(year, month, day, hour, minute, format) {
    Today = new Date();
    Todays_Year = Today.getFullYear() - 2000;
    Todays_Month = Today.getMonth();

    //Convert both today's date and the target date into miliseconds.                           
    Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
                                 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
    Target_Date = (new Date(year, month - 1, day, hour, minute, 00)).getTime();

    //Find their difference, and convert that into seconds.                  
    Time_Left = Math.round((Target_Date - Todays_Date) / 1000);

    if (Time_Left < 0)
        Time_Left = 0;

    switch (format) {
        case 0:
            //The simplest way to display the time left.
            document.getElementById('countdown').innerHTML = Time_Left + ' seconds';
            break;
        case 1:
            //More datailed.
            days = Math.floor(Time_Left / (60 * 60 * 24));
            Time_Left %= (60 * 60 * 24);
            hours = Math.floor(Time_Left / (60 * 60));
            Time_Left %= (60 * 60);
            minutes = Math.floor(Time_Left / 60);
            Time_Left %= 60;
            seconds = Time_Left;

            dps = 's'; hps = 's'; mps = 's'; sps = 's';
            //ps is short for plural suffix.
            if (days == 1) dps = '';
            if (hours == 1) hps = '';
            if (minutes == 1) mps = '';
            if (seconds == 1) sps = '';

            document.getElementById('countdown').innerHTML ='' + days + ' day' + dps + ' ';
            document.getElementById('countdown').innerHTML += hours + ' hour' + hps + ' ';
            document.getElementById('countdown').innerHTML += minutes + ' minute' + mps +' and ';
            document.getElementById('countdown').innerHTML += '<span style="color:#D92A2A">' + seconds + '</span>' + ' second' + sps;
            break;
        default:
            document.getElementById('countdown').innerHTML = Time_Left + ' seconds';
    }

    //Recursive call, keeps the clock ticking.
    setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
}

