/***********************************************
* HawkOwl javascript utilities
*
* Copyright HawkOwl.net 2008,2009   
************************************************/

var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function setstylesheet(sheet) {
  var ptr, sht, main;
  for(ptr=0; (sht = document.getElementsByTagName("link")[ptr]); ptr++) {
    if(sht.getAttribute("rel").indexOf("style") != -1 && sht.getAttribute("title")) {
      sht.disabled = true;
      if(sht.getAttribute("title") == sheet) sht.disabled = false;
    }
  }
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function screendims() {
	var myWidth = 0, myHeight = 0, scrdims = "*";
	if( typeof( window.innerWidth ) == 'number' ) {
		myWidth = window.innerWidth; myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
		myWidth = document.documentElement.clientWidth; myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		myWidth = document.body.clientWidth; myHeight = document.body.clientHeight;
	};
	
    scrdims = "w="+screen.width+"&h="+screen.height+"&mw="+myWidth+"&mh="+myHeight;
    return scrdims;  
} 

function screenwidth() {
    var widthband = "w750nj";
    var scrdims = screendims();
    var ca = scrdims.split('&');
    var param = ca[2]
    var myWidth = param.substring(param.indexOf("=")+1);
    if ( myWidth < 10 ) {
      myWidth = screen.width;
    };
    if ( myWidth > 1200 ) {
      widthband = "w1200";
    } else if ( myWidth > 1100 ) {
      widthband = "w1100";
    } else if ( myWidth > 1000 ) {
      widthband = "w1000";
    } else if ( myWidth > 900 ) {
      widthband = "w900";
    } else if ( myWidth > 800 ) {
      widthband = "w800";
    } else {
      widthband = "w750";
    };   
    return widthband;
}

function getdate() {
    var mydate = new Date()
    var year = mydate.getYear()
    if (year < 1000) {
      year += 1900;
    }
    var day = mydate.getDay()
    var month = mydate.getMonth()
    var daym = mydate.getDate()
    if (daym < 10) {
      daym = "0" + daym;
    }
    var hours = mydate.getHours()
    var minutes = mydate.getMinutes()
    var seconds = mydate.getSeconds()
    var dn = "AM"
    if (hours >= 12) {
      dn = "PM";
    }
    if (hours > 12) {
      hours = hours - 12;
    }
    if (hours == 0) {
      hours = 12;
    }
    if (minutes <= 9) {
      minutes = "0" + minutes;
    }
    if (seconds <= 9) {
      seconds = "0" + seconds;
    }
    var cdate=daym+" "+montharray[month]+" "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
    if (document.all) {
      document.all.clock.innerHTML = cdate;
    } else if (document.getElementById) {
      document.getElementById("clock").innerHTML = cdate;
    } else {
      document.write(cdate);
    }
    if (!document.all&&!document.getElementById) {
      getdate();
    }
}
   
function startclock(){
    if (document.all||document.getElementById) {
      setInterval("getdate()",1000);
    }
}
