
function GignoreSpaces(string) { 
	var temp = ""; 
	string = '' + string; 
	splitstring = string.split(" "); 
	for(i = 0; i < splitstring.length; i++) 
	temp += splitstring[i]; 
	return temp; 
} 

function GMM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.GMM_pgW=innerWidth; document.GMM_pgH=innerHeight; onresize=GMM_reloadPage; }}
  else if (innerWidth!=document.GMM_pgW || innerHeight!=document.GMM_pgH) location.reload();
}
GMM_reloadPage(true);

function GMM_findObj(n, d) { //v4.0
  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=GMM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function GMM_showHideLayers() { //v3.0
  var i,p,v,obj,args=GMM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=GMM_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 GMM_swapImgRestore() { //v3.0
  var i,x,a=document.GMM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function GMM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.GMM_p) d.GMM_p=new Array();
    var i,j=d.GMM_p.length,a=GMM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.GMM_p[j]=new Image; d.GMM_p[j++].src=a[i];}}
}

function GMM_swapImage() { //v3.0
  var i,j=0,x,a=GMM_swapImage.arguments; document.GMM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=GMM_findObj(a[i]))!=null){document.GMM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function GpreloadImages() {
	GMM_preloadImages('../../img/top/m1_it_2.gif','../../img/top/m1_bboard_2.gif','../../img/top/m1_schedule_2.gif','../../img/top/m1_collab_2.gif','../../img/top/m1_eguide_2.gif','../../img/top/m1_singa_2.gif','../../img/top/m1_info_2.gif','../../img/top/m1_innov_2.gif','../../img/top/m2_comp_cb_2.gif','../../img/top/m2_comp_ms_2.gif','../../img/top/m2_comp_ol_2.gif','../../img/top/m2_comp_ha_2.gif','../../img/top/m2_comp_po_2.gif','../../img/top/m2_comp_og_2.gif');
}

function GshowHideLayers() {
	GMM_showHideLayers('lamenu1','','hide','lamenu2','','hide','lamenu3','','hide','lamenu4','','hide','lamenu5','','hide','lamenu6','','hide','lamenu7','','hide','lamenu8','','hide','lamenu9','','hide','lamenu10','','hide','lamenu11','','hide');
}

function GrevSHspan(what,option) {
	if( option == '0' ) {							//just reverse span visible status
		if (what.style.display=='none') {
				what.style.display='';	
		} else {
				what.style.display='none';	
		}	
	} else {		
		what.style.display=option;			
	}
}

function Gclicksubmenu(t,p)	{
		var i;
//		alert(t);
		for(i = 0; i<document.anchors.length; i++) {
//			alert(i);
			if (document.anchors(i).name == t || document.anchors(i).name == p ){					
				document.anchors(i).className = "aselmen";	
			}
		}
		
}

function Gpopuplink(wname,wwidth,wheight) {
  //alert('Gpopuplink');
	//var newwin = window.open(wname,"toolbar=no,directories=no,menubar=no,scrollbars=no,width=" + wwidth + ",height=" + wheight + ",left=10,top=0,resizable=no");
	//newwin.focus();
	LeftPosition=(screen.width)?(screen.width-wwidth)/2:100; 
	TopPosition=(screen.height)?(screen.height-wheight)/2:100;
	w=window.open(wname,'EANITHING','toolbar=no,location=yes,directories=no,status=yes,menubar=yes,copyhistory=no,resizable=yes,scrollbars=yes,top='+TopPosition+',left='+LeftPosition+',width='+wwidth+',height='+wheight);
  w.focus();
}

function Gpopuplink2(wname,title,wleft,wtop,wwidth,wheight) {
  //alert('Gpopuplink');
	//var newwin = window.open(wname,"toolbar=no,directories=no,menubar=no,scrollbars=no,width=" + wwidth + ",height=" + wheight + ",left=10,top=0,resizable=no");
	//newwin.focus();
	LeftPosition=wleft; 
	TopPosition=wtop;
	w=window.open(wname,title,'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,top='+TopPosition+',left='+LeftPosition+',width='+wwidth+',height='+wheight);
  w.focus();
}

function Gpopuplink3(wname,title,wleft,wtop,wwidth,wheight) { 
	LeftPosition=wleft; 
	TopPosition=wtop;
	w=window.open(wname,title,'toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=auto,top='+TopPosition+',left='+LeftPosition+',width='+wwidth+',height='+wheight);
  w.focus();
}

function GshowMenu(seltop,selsub) {
	showTopMenu(seltop);
	showSubMenu(seltop,selsub);
}

function Ground(num, po){ 
    if(po == 1){ 
        return Math.round(num); 
    }else{ 
        var strNum = String(num); 
        var num1 = strNum.split(".")[0]; 
        var num2 = strNum.split(".")[1]; 
        var i = strNum.indexOf("."); 
        if (num2==null){
        		return num;
        }else if(po > num2.length){ 
            return num; 
        }else{ 
            var tmpNum = String(Math.round(num1+num2.substring(0,po-1)+"."+num2.substring(po-1))); 
            return num1+"."+tmpNum.substring(i); 
        } 
    } 
} 
function keyEng(){
	//  Key for English  characters  only.
	if (event.keyCode < 32 || event.keyCode > 122) event.returnValue = false;
}
function keyThai(){
	//  Key for thai characters  only
	if ((event.keyCode >= 65 && event.keyCode <= 90) || (event.keyCode >= 97 && event.keyCode <= 122))
		event.returnValue = false;
}
function keyInt(){
	//  Key for 0 - 9 only.
	if (event.keyCode < 48 || event.keyCode > 57) event.returnValue = false;
}

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_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];}}
}
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_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];}
}
