
//  ------------------------ frames --------------------------------------------

if (window!= top) top.location.href = location.href;

//  ------------------------ run page  -----------------------------------------

function runPage() {
    ticToc(1);
    writePageFooter();
    return true;
}

// ------------------------- meta information --------------------------------

var thisSiteDomain = "clsc.net";

// ------------------------- time and date -------------------------------------

function ticToc(status) {
    var Now = new Date();
    var Hr = Now.getHours();
    var Mn = Now.getMinutes();
    var Dd = Now.getDate();
    var Mm = Now.getMonth();
    var Yy = Now.getFullYear();

    var DateNow = Yy + ".";
    DateNow +=  ((Mm < 9) ? "0" : "") + (Mm + 1) + ".";
		DateNow += ((Dd < 10) ? "0" + Dd : Dd);

    var TimeNow = ((Hr < 10) ? "0" + Hr : Hr) + ":";
    TimeNow += ((Mn < 10) ? "0" : "") + Mn;

    if (status == 1){
        var fetchedDate = DateNow;
        var fetchedTime = TimeNow;
    }

    document.getElementById("dd").innerHTML = DateNow + " ";
    document.getElementById("tt").innerHTML = TimeNow;

    document.getElementById("dd").style.color = "rgb(25,75,204)";
    document.getElementById("tt").style.color = "rgb(0,75,204)";

    document.getElementById("timeStamp").onmouseover = showTheTime;
    document.getElementById("dd").onmouseover = showTheTime;
    document.getElementById("tt").onmouseover = showTheTime;

    var ticTocTimer = setTimeout('ticToc(2)', 1000);
}

function showTheTime(){

    clearTimeout(ticTocTimer);

    document.getElementById("dd").style.color = "rgb(75,150,225)";
    document.getElementById("tt").style.color = "rgb(102,175,255)";

    var ticTocTimer = setTimeout('ticToc(2)', 2000);
}

// ------------------------- footer -------------------------------------------

function writePageFooter(){

    var footerLinks1 = '<li><a href=\"http:\/\/' + thisSiteDomain + '\/about/\">About This Site<\/a><\/li>';

    var footerLinks2 = '<li><a href="javascript:window.external.AddFavorite(location.href,document.title);">Bookmark page<\/a><\/li>';
    footerLinks2 += '<li><a href="#" onClick="setNewHomePage(this);">Make start page<\/a><\/li>';

    var footerLinks3 = '<li><a href=\"http:\/\/' + thisSiteDomain + '\/about\/contact.php\">Contact<\/a><\/li>';

    var agt = navigator.userAgent.toLowerCase();
    var ieAgent = agt.indexOf('msie');

		var thePageFooter = '<ul id="footerNav">';

    if (ieAgent != -1) {
        thePageFooter += footerLinks1 + footerLinks2 + footerLinks3;
    } else {
        thePageFooter += footerLinks1 + footerLinks3;
    }
		thePageFooter += '</ul>';

    document.getElementById("footerNavContainer").innerHTML = thePageFooter;
}

// ------------------------- add bookmark for IE -------------------------------

function addBookMark(){
    var IEstring = '<li><a href="#bookmark"';
    IEstring +=  'onClick="javascript:window.external.AddFavorite(location.href,document.title)\;">';
    IEstring +=  'Bookmark<\/a><\/li>';

/*    IEstring +=  '<li><a href="#start"';
    IEstring +=  'onClick="this.style.behavior=\'url(#default#homepage)\'\;this.setHomePage(location.href)\;">';
    IEstring +=  'Start<\/a><\/li>';
*/

    var agt = navigator.userAgent.toLowerCase();
    var ieAgent = agt.indexOf('msie');

    if (ieAgent != -1) {
        document.write(IEstring);
    }
}


// ------------------------- set home page -------------------------------------

function setNewHomePage(page) {
    page.style.behavior="url(#default#homepage)";
    page.setHomePage(location.href);
}

// -------------------------------------------------------------------------------------------------------------------------------------

// ------------------------- change stylesheets -------------------------------

function newStyle(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}

// ------------------------- greek letters --------------------------------------

function doGreek(x)
{

    var r_greekalpha = new Array ('alpha', 'beta' , 'gamma' , 'delta' , 'epsilon' , 'zeta' , 'eta' , 'theta' , 'iota' , 'kappa' , 'lambda' , 'mu' , 'nu' , 'xi' , 'omicron' , 'pi' , 'rho' , 'sigma' , 'tau' , 'upsilon' , 'phi' , 'chi' ,'psi' , 'omega' , 'alpha', 'beta' );

    ascend = x;
    descend = (25-x);

    document.getElementById("daGreek").innerHTML = "(" + r_greekalpha[ascend] + ")";

    x++;

    // self-referencing call
	doItString = "doGreek(" + x + ")";

    if (x < 26)
    {
        setTimeout(doItString,1200);
    }
}

// ------------------------- page bottom banner rotation ------------------

function showBanner()
{
	var whichBanner = new Array ();
	whichBanner[0] = "";

	var whichLink = new Array ();
	whichLink[0] = "";

	var whichText = new Array ();
	whichText[0] = "";

	var i = Math.round(1*Math.random());

	var theBannerHTML = '<a href="';
	theBannerHTML += whichLink[i];
	theBannerHTML += '"><img src="';
	theBannerHTML += whichBanner[i];
	theBannerHTML += '" width="728" border="0" alt="';
	theBannerHTML += whichText[i];
	theBannerHTML += '"><\/a>';

//	document.getElementById("pageBottomBanner").innerHTML = theBannerHTML;
}

