
function initArray() {
 for(i=0;i<initArray.arguments.length; i++)
  this[i] = initArray.arguments[i];
}

//display time
function getFullYear(d) { // d is a date object
 yr = d.getYear();
 if (yr < 1000)
  yr+=1900;
 yr+=+543;
 return yr;
}

function showTime(d)// d is a date object
{
 hrs=d.getHours();
 min=d.getMinutes();
 sec=d.getSeconds();
 clckh=""+((hrs>12)?hrs-12:hrs); 
 clckm=((min<10)?"0":"")+min;
 clcks=((sec<10)?"0":"")+sec;
 clck=(hrs>=12)?"p.m.":"a.m.";
 return ", "+clckh+":"+clckm+" "+clck;
}

function showDate(d)// d is a date object
{
 var isnMonths=new initArray("มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤษจิกายน","ธันวาคม");
 var isnDays= new initArray("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
 return " "+d.getDate()+" "+isnMonths[d.getMonth()]+getFullYear(d);
}

function displaydatetime() {
if (!document.layers && !document.all)	return;
  var today;
  var timeLocal;
  today = new Date();
  today.setSeconds(today.getSeconds()-offset);
  timeLocal = today.toLocaleString();
  timeLocal = showDate(today)+showTime(today); 
  if (document.layers) {
    document.layers.clockLocal.document.write(timeLocal);
    document.layers.clockLocal.document.close();}
  else if (document.all) {
  clockLocal.innerHTML = timeLocal}
  setTimeout("displaydatetime()", 500)
}
//rollover function
//set up layer call
var isIE, isNS, isNS6, isDOM, lR, sR, vis, invis, myTimeOut, goName;
	if (document.all) {isIE= true;lR="document.all.";sR="style.";vis="visible";invis="hidden";}
	if (document.layers){isNS = true;lR="document.layers.";sR="";vis="show";invis="hide";}
	if (document.getElementById &&!isIE) {isDOM=true;lR = "document.getElementById('";sR = "').style";invis ="hidden";vis = "visible"}
	if (isDOM == true && navigator.appName =="Netscape") isNS6 = true;
	
var oldwhich = 0;
var  firstimage;
var oldwhich2 = 0;
var x=0;
var layerTimer;

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_changeProp(objName,x,theProp,theValue) { //v3.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");
}
	
//turn on layer and rollover

	function layOver(which,newimage,oldimage)
	{
	x=0;
	if (oldwhich != which)
	{
		MM_showHideLayers("l"+oldwhich,'','hide');
		MM_showHideLayers("l"+oldwhich+oldwhich,'','hide');
	//	MM_showHideLayers("l"+oldwhich2,'','hide');
	//	MM_showHideLayers('musthide','','show');
		MM_changeProp("td"+oldwhich,'','background',oldimage,'TD');
//		MM_changeProp("m"+oldwhich,'','style.color','#FFFFFF','FONT');
//		MM_changeProp("sub1_td"+oldwhich2,'','style.background','#C7F0F3','TD');
//		MM_changeProp("sub1_m"+oldwhich2,'','style.color','#FFFFFF','SPAN');
	}
	MM_showHideLayers("l"+which,'','show');
	MM_showHideLayers("l"+which+which,'','show');
//	MM_showHideLayers('musthide','','hide');
	MM_changeProp("td"+which,'','background',newimage,'TD');
//	MM_changeProp("m"+which,'','style.color','#FFFFFF','FONT');
	oldwhich = which;
	firstimage = oldimage
  	clearTimeout(layerTimer);
	return;
	}

	
//turn off layer and rollover if user is completely off nav 
	function stopOver()
	{
		if (x<1) x++;
		else
		{
		MM_showHideLayers("l"+oldwhich,'','hide');
		MM_showHideLayers("l"+oldwhich+oldwhich,'','hide');
	//	MM_showHideLayers("l"+oldwhich2,'','hide');
	//	MM_showHideLayers('musthide','','show');
		MM_changeProp("td"+oldwhich,'','background',firstimage,'TD');
//		MM_changeProp("m"+oldwhich,'','style.color','#FFFFFF','FONT');
	//	MM_changeProp("sub1_td"+oldwhich2,'','style.background','#C7F0F3','TD');
//		MM_changeProp("sub1_m"+oldwhich2,'','style.color','#FFFFFF','FONT');
		x=0;
		}
	layerTimer = setTimeout("stopOver()",150)
	}
	
//reset the timer
	function startOver()
	{
	x=0
	clearTimeout(layerTimer);
	}

//change subnav background color (ie5+ ns6+)
	function changebg(item, color)
{
	if (document.getElementById)
	{
	theone = eval("document.getElementById('"+item+"')")
	theone.style.background = color
	}	

}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
