//-------------------------------------------------------------------------------//
// Functions to Open Window
//-------------------------------------------------------------------------------//
function Start(page) 
{
	var today = new Date();
	var height = (screen.height - 500);
	var width  = 656;
	eval('ws = window.open("' + page + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}
function full_window(page) 
{
	var today = new Date();
	var height = (screen.height - 200);
	var width  = 656;
	eval('ws = window.open("' + page + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}

function full_window2(page) 
{
	var today = new Date();
	var height = (screen.height - 200);
	var width  = 656;
	eval('ws = window.open("' + page + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}
function full_window3(page) 
{
	var today = new Date();
	var height = (screen.height - 200);
	var width  = 656;
	eval('ws = window.open("' + page + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}
function full_window4(page) 
{
	var today = new Date();
	var height = (screen.height - 200);
	var width  = 656;
	eval('ws = window.open("' + page + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}
function full_window5(page) 
{
	var today = new Date();
	var height = (screen.height - 200);
	var width  = 656;
	eval('ws = window.open("' + page + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}
function full_window6(page) 
{
	var today = new Date();
	var height = (screen.height - 200);
	var width  = 656;
	eval('ws = window.open("' + page + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}

function small_window(myurl) 
{
	var today = new Date();
	var height = 280;
	var width  = 656;
	eval('ws = window.open("' + myurl + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}
function small_window3(myurl) 
{
	var today = new Date();
	var height = 350;
	var width  = 700;
	eval('ws = window.open("' + myurl + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}

//-------------------------------------------------------------------------------//
// Functions to Close Window
//-------------------------------------------------------------------------------//

function CloseWindow()
{
	if (AreYouSure) 
	{
		window.close()
	}
}
//-------------------------------------------------------------------------------//
// Functions AreYouSure 
//-------------------------------------------------------------------------------//
var intalrdychkd
intalrdychkd = 0
function AreYouSure(itmstoignore, functionorevent) {
   var		intnumitms
   var		stritemtype
   var		elementname
   intnumitms = 0
   stritembad = ""
   thatstr = ""
   ignrdelements = itmstoignore.split(",");
   intnumitms = document.forms[0].length
   for (i=0; i < intnumitms ; i++) {
     elementname = eval("document.forms[0].elements[" + i + "].name");
     disableYorN = 0;
     for (g=0 ; g < ignrdelements.length ; g++) {
   	if (elementname == ignrdelements[g] ) { disableYorN = 1; }
     }
     if (disableYorN == 0) {
       switch (document.forms[0].elements[i].type) {
   		case "text":
   			if (document.forms[0].elements[i].value != document.forms[0].elements[i].defaultValue) {
   				stritembad = "Items have changed on this page without being updated.";
   				}
   			break;
   		case "select-one":
   			intgetcurrselindex = document.forms[0].elements[i].selectedIndex
   			intgetdefselindex = 0
   			for (x=0; x < document.forms[0].elements[i].options.length ; x++) {
   				if (document.forms[0].elements[i].options[x].defaultSelected) {
   					intgetdefselindex = x;
   				}
   			}
   			if (intgetdefselindex != intgetcurrselindex) {
   				stritembad = "Items have changed on this page without being updated.";
   				}
   			break;
   		case "checkbox":
   			if (document.forms[0].elements[i].checked != document.forms[0].elements[i].defaultChecked) {
   				stritembad = "Items have changed on this page without being updated.";
   				}
   			break;
   		default:
   		thisstr = thatstr;
							
   	}
     }
   }
   if ((stritembad != "") && (functionorevent == 1) && (intalrdychkd == 0)) {
   	if (confirm("You are about to close the window without saving changes to this page.\nClick Okay to close this window or Cancel to stay and update current page.")) {
   		return true
   	} else {
   		return false
   		intalrdychkd = 0
   	}
   } else {
   	if ((stritembad == "") && (functionorevent == 1) && (intalrdychkd == 0)) {
   		return true
   	}
   }
   if ((stritembad != "") && (functionorevent == 0) && (intalrdychkd == 0)) {
   	return stritembad
   } else {
   intalrdychkd =0
   }
}
//alert(intalrdychkd)
//-------------------------------------------------------------------------------//
//Print from a page
//-------------------------------------------------------------------------------//
function Print() {
  if (window.print) {
    window.print();
  } else {
    alert('To print this page, click the Print icon on top of the window');
  }
}
//-------------------------------------------------------------------------------//
//refresh a page
//-------------------------------------------------------------------------------//
function refresh() {
	eval("document." + document.forms[0].name + ".submit();");
}
//-------------------------------------------------------------------------------//
//reallen
//-------------------------------------------------------------------------------//

function reallen(s)
{
  var count = 0;
  count = count * 1;
  for( var i = 0 ; i < s.length ; i++)
  {
    var c = s.charAt(i)
    if ( c != ' ' )
      count = count + 1;
  }
  return count;
}
function isBlank(s)
{
	for( var i = 0 ; i < s.length ; i++)
	{
		var c = s.charAt(i)
		if( (c != ' ') && ( c != '\n') && (c != '\t')) return false
	}
	return true
}

// check if a field is changed in a form.
function Modified(ignorelist) {
	var bChanged = false;
	var iNoItems = document.forms[0].length
	ignoreEl = ignorelist.split(",");
	for (i=0; i<iNoItems; i++) {
		elName = eval("document.forms[0].elements[" + i + "].name");
		bPass = 0
		if ( bChanged == true ) {
			break;
		}else {
			for (g=0; g<ignoreEl.length; g++){
			if (elName == ignoreEl[g] ) { bPass = 1; }
			if (bPass == 0 ) {
			switch (document.forms[0].elements[i].type) {
				case "text":
					if (document.forms[0].elements[i].value != document.forms[0].elements[i].defaultValue) {
					bChanged = true;
					}
					break;
				case "select-one":
					var iCurIndex = document.forms[0].elements[i].selectedIndex
					var iDefaultIndex = 0
					for (x=0; x < document.forms[0].elements[i].options.length ; x++) {
						if (document.forms[0].elements[i].options[x].defaultSelected) {
							iDefaultIndex = x;
						}
					}
					if (iDefaultIndex != iCurIndex) {
						bChanged = true;
					}
					break;
				case "checkbox":
					if (document.forms[0].elements[i].checked != document.forms[0].elements[i].defaultChecked) {
						bChanged = true;
					}
					break;
				}		
			}
			}
		}
	}		
	return bChanged;
}

// This function is for check/uncheck all the checkbox below this self checkbox, by HBY
function checkall(self){
	var dml=document.forms[0].box;
	if (dml!=null){
		var len = dml.length;		
		if (len==null)
		  dml.checked = self.checked;
		else				
		  for(var i=0 ; i<len ; i++) {
		  	dml[i].checked=self.checked;
		  } 
	}
	else
        alert("No data at all!")   	  
} 

function WiderStart(page) 
{
	var wint = (screen.height - 200);
	var option = "toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,top=65,left=125,width=720,height="+ wint;
	OpenWin = window.open(page, "CtrlWindow", option);
}

// open a window as given size, location is file path and parameters transfered there, By HBY
function openwindowlink(location,h,w){          
  var property = "height=" +h+ ",width="+w+",scrollbars,resizable"	          
  window.open(location,"Make",property);
}

function NarrowStart(page) 
{
	var today = new Date();
	var height = (screen.height - 300);
	var width  = 420;
	eval('ws = window.open("' + page + '","Intranet'+today.getTime()+'","scrollbars,resizable,status,width=' + width + ',height=' + height + '")');
}


//-------------------------------------------------------------------------------//
// Functions IsChecked 
// Return true if at least one box is checked, false otherwise.
//-------------------------------------------------------------------------------//
function IsChecked() {
	dml=document.forms(0);
	len = dml.elements.length;
	var i=0;
	for( i=0 ; i<len ; i++) {
		if (dml.elements[i].name=='box' && dml.elements[i].checked) {
			return true;
		}
	}
	return false;
}

//-------------------------------------------------------------------------------//
// Functions HasChecked (strname)
// Return true if at least one box is checked, false otherwise.
//-------------------------------------------------------------------------------//
	function HasChecked(strname) {
		dml=document.forms(0);
		len = dml.elements.length;
		var i=0;
		for( i=0 ; i<len ; i++) {
			if (eval("dml.elements[i].name=='" + strname + "' && dml.elements[i].checked")) {
				return true;
			}
		}
		return false;
	}

//-------------------------------------------------------------------------------//
// Ask sure for closing the window, HBY, 03/20/03
//-------------------------------------------------------------------------------//
 
function AskClosing(){
  if(confirm('Are you sure? Unsaved data will be discarded.')) CloseWindow();
}

