
//Clock
var timer = null;

//Rotating Banner
var tick = 1;
var rotoFlg = true;
var timer2 = null;

var win = new Image();
win.src = "../images/links/windows-logo.jpg";
var tux = new Image();
tux.src = "../images/links/tux.gif";
var mac = new Image();
mac.src = "../images/links/apple-logo.jpg";
var bsd = new Image();
bsd.src = "../images/links/bsd_daemon.gif";
var sun = new Image();
sun.src = "../images/links/solaris_logo.gif";


function stop()
{
	clearTimeout(timer);
	clearTimeout(timer2);
}

function start()
{
	var flg = "am";
	var time = new Date();
	var hours = time.getHours();
	if ( hours > 12 )
	{
		flg = "pm";
		hours = hours - 12;
	}
	if ( hours == 12 )
	{
		flg = "pm";
	}
	if ( hours == 0 )
	{
		hours = 12;
	}	  	
	var minutes = time.getMinutes();
	minutes=((minutes < 10) ? "0" : "") + minutes;
	var seconds = time.getSeconds();
	seconds=((seconds < 10) ? "0" : "") + seconds;
	var clock = hours + ":" + minutes + ":" + seconds + " " + flg;
	document.forms[0].clock.value = clock;
	timer = setTimeout("start()",1000);
	if (rotoFlg == true)
	{
		timer2 = setTimeout("startRoto()",1000);
	}
}


function stopRoto()
{
	rotoFlg = false;
	clearTimeout(timer2);
}

function startRoto()
{
	rotoFlg = true;	
	document.getElementById("rotoBox1").style.height = "110px";
	document.getElementById("rotating").style.visibility = "visible";
	if ( tick == 1 )
	{
		document.getElementById("rotating").src = win.src;	
		document.getElementById("rotoAnchor").href = "http://microsoft.com/windows/";
	}
	if ( tick == 2 )
	{
		document.getElementById("rotating").src = tux.src;	
		document.getElementById("rotoAnchor").href = "http://www.linux.org/";
	}
	if ( tick == 3 )
	{
		document.getElementById("rotating").src = mac.src;	
		document.getElementById("rotoAnchor").href = "http://apple.com/macosx/";
	}
	if ( tick == 4 )
	{
		document.getElementById("rotating").src = bsd.src;	
		document.getElementById("rotoAnchor").href = "http://bsdcentral.com";
	}
	if ( tick == 5 )
	{
		document.getElementById("rotating").src = sun.src;	
		document.getElementById("rotoAnchor").href = "http://sun.com/solaris/";
	}
	tick =  tick += 1;
	if ( tick > 5 )
	{
		tick = 1;
	}
	
}

function setPos()
{
	var bVer = parseFloat(navigator.appVersion);
	var bIsNS = (navigator.userAgent.indexOf ("MSIE") == -1); //check if IE or Netscape
	if ( bIsNS && bVer >= 4 )
	{
		var a = window.innerWidth;
		if ( a < 758 )
		{		
		document.getElementById("content").style.marginLeft = "0px";	
		}
		else		
		{					
		document.getElementById("content").style.marginLeft = "auto";
		}
	}
}
