// Functions that handle show - hide layers. //
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_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=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) 
  x=document.getElementById(n); 
  return x;
}

//reloads the window if Nav4 resized
function MM_reloadPage(init) {  
  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);


//Resize Page for maximum view area//
function maxview(){
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth, screen.availHeight);
}

//HIDE THE INFO IN THE STATUS BAR
function nstat(){
	status='';
	return true;
}

function tstat(b_clear, sttext) {
	window.setTimeout('window.status="' + (b_clear ? 'Done' : sttext) + '"', 10);
}

function dstat(){
	status='Done';
	return true;
}


//---------------------------------------------------------

//VERIFY FORMS 0 (form 0)
function fchk0(data){
	for(i=0;i<document.forms[0].length;i++){
		var elname = document.forms[0].elements[i].name;
		var elsArray = elname.split("__");
		if(elsArray[0] == "R"){
			if(document.forms[0].elements[i].value == "" || document.forms[0].elements[i].value == "-"){
				alert ("\nInvalid Entry. Please Revise.")
				if(document.loader){
					loader.style.visibility='hidden';
				}
				document.forms[0].elements[i].focus();
				return false;
			}
		}
	}
	document.forms[0].vdo.value='1';
	document.forms[0].target='_self';
	document.forms[0].submit();
	return true;

}

//VERIFY FORMS 1 (form 1)
function fchk1(data){
	for(i=0;i<document.forms[1].length;i++){
		var elname = document.forms[1].elements[i].name;
		var elsArray = elname.split("__");
		if(elsArray[0] == "R"){
			if(document.forms[1].elements[i].value == "" || document.forms[1].elements[i].value == "-"){
				alert ("\nInvalid Entry. Please Revise.")
				if(document.loader){
					loader.style.visibility='hidden';
				}
				document.forms[1].elements[i].focus();
				return false;
			}
		}
	}
	document.forms[1].vdo.value='1';
	document.forms[1].action='<?php print $vBASEURL; ?>/<?php print $vSELF; ?>?area=<?php print $vAREA; ?>&act=<?php print $vACT; ?>&tbl=<?php print $vTBL; ?>&rec=<?php print $vREC; ?>&refco=<?php print $vREFCO; ?>';
	document.forms[1].target='_self';
	document.forms[1].submit();
	return true;

}

//VERIFY FORMS 2 (form 2)
function fchk2(data){
	for(i=0;i<document.forms[2].length;i++){
		var elname = document.forms[2].elements[i].name;
		var elsArray = elname.split("__");
		if(elsArray[0] == "R"){
			if(document.forms[2].elements[i].value == "" || document.forms[2].elements[i].value == "-"){
				alert ("\nInvalid Entry. Please Revise.")
				if(document.loader){
					loader.style.visibility='hidden';
				}
				document.forms[2].elements[i].focus();
				return false;
			}
		}
	}
	document.forms[2].vdo.value='1';
	document.forms[2].target='_self';
	document.forms[2].submit();
	return true;

}

//VERIFY FORMS 3 (form 3)
function fchk3(data){
	for(i=0;i<document.forms[3].length;i++){
		var elname = document.forms[3].elements[i].name;
		var elsArray = elname.split("__");
		if(elsArray[0] == "R"){
			if(document.forms[3].elements[i].value == "" || document.forms[3].elements[i].value == "-"){
				alert ("\nInvalid Entry. Please Revise.")
				if(document.loader){
					loader.style.visibility='hidden';
				}
				document.forms[3].elements[i].focus();
				return false;
			}
		}
	}
	document.forms[3].vdo.value='1';
	document.forms[3].target='_self';
	document.forms[3].submit();
	return true;

}

//CONFIRMATION FORM 0 (form 0)
function fver0(){
	if(confirm("\nAre you certain about this action?.")){
		document.forms[0].vdo.value='1';
		document.forms[0].target='_self';
		document.forms[0].submit();
		return true;
	}
	else{
		return false;
	}	

}

//CONFIRMATION FORM 1 (form 1)
function fver1(){
	if(confirm("\nAre you certain about this action?.")){
		document.forms[1].vdo.value='1';
		document.forms[1].target='_self';
		document.forms[1].submit();
		return true;
	}
	else{
		return false;
	}	

}

//CONFIRMATION FORM 2 (form 2)
function fver2(){
	if(confirm("\nAre you certain about this action?.")){
		document.forms[2].vdo.value='1';
		document.forms[2].target='_self';
		document.forms[2].submit();
		return true;
	}
	else{
		return false;
	}	

}

//CONFIRMATION FORM 3 (form 3)
function fver3(){
	if(confirm("\nAre you certain about this action?.")){
		document.forms[3].vdo.value='1';
		document.forms[3].target='_self';
		document.forms[3].submit();
		return true;
	}
	else{
		return false;
	}	

}

//BANNER CODE
function loadBanner(){

        var time= new Date();
        hours= time.getHours();
        mins= time.getMinutes();
        secs= time.getSeconds();
        closeTime=hours*3600+mins*60+secs;
        closeTime+=4;	/* Change this number to increase decrease the rotation speed */
        Timer();

}

function Timer(){
        var time= new Date();
        hours= time.getHours();
        mins= time.getMinutes();
        secs= time.getSeconds();
        curTime=hours*3600+mins*60+secs
        if (curTime>=closeTime){
		if (i < bannercount){
			i++;
			document.banner.src = eval("banner" + i + ".src");
		}
		else{
			i = 1;
			document.banner.src = eval("banner" + i + ".src");
		}
		loadBanner();
	}
        else{
                window.setTimeout("Timer()",1000)}

}

function clickLink(){
	top.location = links[i]
}

function descript(){
	window.status = description[i]
}

function nothing() {
	window.status=""
}


//OPEN WINDOW
function OpenWindow(file,n,h,w){
	window.open(file,n,'height='+h+',width='+w+',scrollbars=auto,location=no,menubar=no,toolbar=no,resizable=no');
}

//OPEN WINDOW 2
function OpenWindow2(file,n,h,w){
	window.open(file,n,'height='+h+',width='+w+',scrollbars=yes,location=no,menubar=no,toolbar=no,resizable=no');
}

//MOVE DIRECTION SCRIPT
function ClearList(OptionList, TitleName){
	OptionList.length = 0;
}
			
function movedirection(side,vel1,vel2){
	var temp1 = new Array();
	var temp2 = new Array();
	var tempa = new Array();
	var tempb = new Array();
	var current1 = 0;
	var current2 = 0;
	var y=0;
	var attribute;
				
	//assign what select attribute treat as attribute1 and attribute2
	if (side == "right"){
		attribute1 = document.getElementById(vel1);
		attribute2 = document.getElementById(vel2);
	}
	else{
		attribute1 = document.getElementById(vel2);
		attribute2 = document.getElementById(vel1);
	}
				
	//fill an array with old values
	for (var i = 0; i < attribute2.length; i++){
		y=current1++
		temp1[y] = attribute2.options[i].value;
		tempa[y] = attribute2.options[i].text;
	}
			
	//assign new values to arrays
	for (var i = 0; i < attribute1.length; i++){
		if ( attribute1.options[i].selected ){
			y=current1++
			temp1[y] = attribute1.options[i].value;
			tempa[y] = attribute1.options[i].text;
		}
		else{
			y=current2++
			temp2[y] = attribute1.options[i].value; 
			tempb[y] = attribute1.options[i].text;
		}
	}
				
	//generating new options 
	for (var i = 0; i < temp1.length; i++){
		attribute2.options[i] = new Option();
		attribute2.options[i].value = temp1[i];
		attribute2.options[i].text =  tempa[i];
		attribute2.options[i].selected = true;
	}
				
	//generating new options
	ClearList(attribute1,attribute1);
	if (temp2.length>0){
		for (var i = 0; i < temp2.length; i++){
			attribute1.options[i] = new Option();
			attribute1.options[i].value = temp2[i];
			attribute1.options[i].text =  tempb[i];
		}
	}
}		