var myFont = '<link href="/include/css/styles.css" rel="stylesheet" type="text/css">';
var myLargerFont = '<link href="/include/css/stylesLarge.css" rel="stylesheet" type="text/css">';

if ( getStyle("myStyle") == "large" ) {
	myFont = myLargerFont;
}

document.write(myFont);

function getStyle(name) {

    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length + 1;
    if ((!start) && (name != document.cookie.substring(0,name.length)))
    	return null;
    if (start == -1)
    	return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1)
    	end = document.cookie.length;

    return unescape(document.cookie.substring(len,end));
}

function setStyle(value) {
	var name = "myStyle";
	var path = "/";
	var domain = "www.serbbar.org";
	var secure;
	var today = new Date();
	var expires = new Date(today.getTime() + (56 * 86400000));

    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
    window.location.reload();
}


//		Opens external site windows without location bar and 
//		eliminates other features to keep visitor focus. 
	function xWindow(site) {

		var xWidth = 750;
		var yHeight = 550;
		var x = window.screenLeft + document.body.clientWidth - xWidth + 10;
		var y = window.screenTop;
		
		if (site == null ) {  // gives this method the ability to call it with or wihout a url param
			site = "http://www.serbbar.org"
		}
		
		var xWin = window.open(site, "external" , "width="+xWidth+  ",height="+yHeight+ ",top="+y+  ",left="+x + ", toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes");
		xWin.focus();
	}
	
	

	function MakeArray(n) 
	{
	   this.length = n
	   return this
	}
	monthNames = new MakeArray(12)
	monthNames[1] = "Jan."
	monthNames[2] = "Feb."
	monthNames[3] = "Mar."
	monthNames[4] = "Apr."
	monthNames[5] = "May"
	monthNames[6] = "Jun."
	monthNames[7] = "Jul."
	monthNames[8] = "Aug."
	monthNames[9] = "Sep."
	monthNames[10] = "Oct."
	monthNames[11] = "Nov."
	monthNames[12] = "Dec."
	dayNames = new MakeArray(7)
	dayNames[1] = "Sunday"
	dayNames[2] = "Monday"
	dayNames[3] = "Tuesday"
	dayNames[4] = "Wednesday"
	dayNames[5] = "Thursday"
	dayNames[6] = "Friday"
	dayNames[7] = "Saturday"
	
	function customDateString(oneDate) 
	{
	    var version = 0;
	    var theDay = dayNames[oneDate.getDay() + 1]
	    var theMonth = monthNames[oneDate.getMonth() + 1]
	    var theYear = oneDate.getYear()
	
		//test browser version for date display.  This is due Netscape and IE having different values for the final theYear variable
		if (document.all&&navigator.userAgent.indexOf("Opera")==-1)
			var theYear = oneDate.getYear();
		else if (navigator.userAgent.indexOf("MSIE 5") != -1)
			var theYear = oneDate.getYear();
		else if (navigator.userAgent.indexOf("MSIE 4") != -1)
			var theYear = oneDate.getYear();
		else if (navigator.userAgent.indexOf("MSIE 4.5") != -1)
			var theYear = oneDate.getYear();
		else if (navigator.userAgent.indexOf("Mozilla/4.61") != -1)
			var theYear = oneDate.getYear() + 1900;
		else if (navigator.userAgent.indexOf("Mozilla") != -1)
			var theYear = oneDate.getYear() + 1900;
	
		else version = 8;
	
	    return theDay + " " + theMonth + " " + oneDate.getDate() + ", " + theYear
}

	function clockTicker() {
	
	  var hours, minutes, ap;
	  var intHours, intMinutes;
	  var today;
	
	  today = new Date();
	  intHours = today.getHours();
	  intMinutes = today.getMinutes();
	
	  if (intHours == 0) {
	     hours = "12:";
	     ap = "AM";
	  } else 
	  if (intHours < 12) {
	     hours = intHours+":";
	     ap = "AM";
	  } else if (intHours == 12) {
	     hours = "12:";
	     ap = "PM";
	  } else {
	     intHours = intHours - 12
	     hours = intHours + ":";
	     ap = "PM";
	  }
	
	  if (intMinutes < 10) {
	     minutes = "0"+intMinutes+" ";
	  } else {
	     minutes = intMinutes+" ";
	  }
	
	  return timeString = hours+minutes+ap;
}


	function clockTicker() {
	
	if (document.all&&navigator.userAgent.indexOf("Opera")==-1) {
	  var hours, minutes, seconds, ap;
	  var intHours, intMinutes, intSeconds;
	  var today;
	
	  today = new Date();
	  intHours = today.getHours();
	  intMinutes = today.getMinutes();
	  intSeconds = today.getSeconds();
	
	  if (intHours == 0) {
	     hours = "12:";
	     ap = "AM";
	  } else 
	  if (intHours < 12) {
	     hours = intHours+":";
	     ap = "AM";
	  } else if (intHours == 12) {
	     hours = "12:";
	     ap = "PM";
	  } else {
	     intHours = intHours - 12
	     hours = intHours + ":";
	     ap = "PM";
	  }
	
	  if (intMinutes < 10) {
	     minutes = "0"+intMinutes+":";
	  } else {
	     minutes = intMinutes+":";
	  }
	
	  if (intSeconds < 10) {
	     seconds = "0"+intSeconds+" ";
	  } else {
	     seconds = intSeconds+" ";
	  }
	  timeString = hours+minutes+seconds+ap;
	  myClock.innerHTML = timeString;
	  window.setTimeout("clockTicker();", 100);
	 }
}


var ticker="/include/sound/soundticker.wav"
function soundTicker(ticker){
	if (document.all && document.getElementById){
		document.getElementById("sound").src=""
		document.getElementById("sound").src=ticker
	}
}


function myBackground(){

	var myBackImg ="";

  today = new Date();
  intHours = today.getHours();
	switch (intHours) {
		case 9:case 12:case 15:case 18:case 21:
			myBackImg ="/images/top-1.jpg";
		break

		case 8:case 11:case 14:case 17:case 20:case 23:
			myBackImg ="/images/top-12.jpg";
		break

		case 7:case 10:case 13:case 16:case 19:case 22:
			myBackImg ="/images/top-123.jpg";
		break

		default:
		myBackImg ="/images/top-1.jpg";
	}

  return myBackImg;
}

//		Opens external site windows without location bar and 
//		eliminates other features to keep visitor focus. 
	function xWindow(site) {

			var xWidth = 600;
			var yHeight = 450;
		var x = window.screenLeft + document.body.clientWidth - xWidth + 10;
		var y = window.screenTop;
		
		if (site == null ) {  // gives this method the ability to call it with or wihout a url param
			site = "http://www.serbbar.org"
		}
		
		var xWin = window.open(site, "external" , "width="+xWidth+  ",height="+yHeight+ ",top="+y+  ",left="+x + ", toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes");
		xWin.focus();
	}