function setup(){
	document.getElementById('timeHolder').innerHTML=calcTime();
	setInterval('timer()',5000);
	navRollover=new Image;
	navRollover.src='images/nav-bullet-over.gif';
}

var month=new Array('January','February','March','April','May','June','July','August','September','October','November','December');
	
function timer(){
		document.getElementById('timeHolder').innerText=calcTime();
}

function calcTime(){
	var now=new Date();
//	var seconds=now.getSeconds()<10?'0'+now.getSeconds():now.getSeconds();
	var minutes=now.getMinutes()<10?'0'+now.getMinutes():now.getMinutes();
	var timeStr=now.getHours()>11?((now.getHours()==12?12:now.getHours()-12))+':'+minutes+' PM':(now.getHours()==0?12:now.getHours())+':'+minutes+' AM';
/*	minPos=minutes*40;
	hrPos=(now.getHours()>11?(now.getHours()==12?0:now.getHours()-12):now.getHours())*200+Math.floor(minutes/12)*40;
	document.getElementById('minHand').style.left=-minPos + 'px';
	document.getElementById('hrHand').style.left=-hrPos+'px';*/
	var dayStr=month[now.getMonth()]+' '+now.getDate()+', '+now.getFullYear();
	return timeStr;
}

function swap(obj){
	document.getElementById('underNav'+obj.id).style.backgroundImage='url(images/nav-btnBackOver.jpg)';
}

function swapBack(obj){
	document.getElementById('underNav'+obj.id).style.backgroundImage='url(images/nav-btnBack.jpg)';
}

function swDisplay(id){
	if (document.getElementById('code').className=='displayNo'){
		document.getElementById('sub-'+id).className=document.getElementById('sub-'+id).className=='xpandr'?'xpandrShow':'xpandr';
		document.getElementById('exp-'+id).src=document.getElementById('exp-'+id).src.indexOf('contract')!=-1?'images/list-expand.gif':'images/list-contract.gif';
	}
	return false;
}

function swSubDisplay(sid){
	if (document.getElementById('code').className=='displayNo'){
//		document.getElementById('ssub-'+sid).style.display=document.getElementById('ssub-'+sid).style.display=='block'?'none':'block';
		document.getElementById('ssub-'+sid).className=document.getElementById('ssub-'+sid).className=='xpandr'?'xpandrShow':'xpandr';
		document.getElementById('sbexp-'+sid).style.listStyleImage=document.getElementById('ssub-'+sid).style.display=='block'?'url(images/list-contract.gif)':'url(images/list-expand.gif)';
	}
}

function highlightWord(node,word) {
  // Iterate into this nodes childNodes
  if (node.hasChildNodes) {
    var hi_cn;
    for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++) {
      highlightWord(node.childNodes[hi_cn],word);
    }
  }

  // And do this node itself
  if (node.nodeType == 3) { // text node
    tempNodeVal = node.nodeValue.toLowerCase();
    tempWordVal = word.toLowerCase();
    if (tempNodeVal.indexOf(tempWordVal) != -1) {
      pn = node.parentNode;
      if (pn.className != "searchword") {
        // word has not already been highlighted!
        nv = node.nodeValue;
        ni = tempNodeVal.indexOf(tempWordVal);
        // Create a load of replacement nodes
        before = document.createTextNode(nv.substr(0,ni));
        docWordVal = nv.substr(ni,word.length);
        after = document.createTextNode(nv.substr(ni+word.length));
        hiwordtext = document.createTextNode(docWordVal);
        hiword = document.createElement("span");
        hiword.className = "searchword";
        hiword.appendChild(hiwordtext);
        pn.insertBefore(before,node);
        pn.insertBefore(hiword,node);
        pn.insertBefore(after,node);
        pn.removeChild(node);
      }
    }
  }
}

function magnify(imgFile){
	var a=new Image()
	a.src=imgFile;
	document.getElementById('bigImage').src=imgFile;
	document.getElementById('imageHolder').style.display='block';
	if (a.width > a.height){
	 if (a.width > screen.availWidth){
	 		document.getElementById('bigImage').width=screen.availWidth-100;
			document.getElementById('bigImage').height=document.getElementById('bigImage').width*a.height/a.width
	 }
	} else {
	 if (a.height > screen.availHeight){
	 		document.getElementById('bigImage').height=screen.availHeight-200;
			document.getElementById('bigImage').width=document.getElementById('bigImage').height*a.width/a.height;
	 }
	}
	document.getElementById('imageHolder').style.top=Math.max((document.body.clientHeight-document.getElementById('bigImage').height)/2,10)+(document.all?document.body.scrollTop:window.pageYOffset);
	document.getElementById('imageHolder').style.left=Math.max((document.body.clientWidth-document.getElementById('bigImage').width)/2,0);
}


window.onload=function() {setup()};
