function SelectAllCheckboxes(Boxes2Check,FormName) {
	for (a=0;a<document.forms[FormName].length;a++) {//cycle through passed arguments
        if (document.forms[FormName].elements[a].name==Boxes2Check && document.forms[FormName].elements[a].type=='checkbox') {
			document.forms[FormName].elements[a].checked=true;//only using form[1] because the search form exists already
		}
	}
}

function validateIntegerNumbers(textBox) {//Allow only integers
	string=textBox.value;//get value of passed field
    if (!string) return false;//if nothing fail
    var Chars = "0123456789-";//allowable characters
	SLength=string.length;//get field length

    for (i=0;i<SLength;i++) {//go through chars one at a time
       	if (Chars.indexOf(string.charAt(i)) == -1) {//if character not found in allowable characters
		  textBox.value=string.substring(0,SLength-1);//delete the last entered character
          alert("Please use ONLY integers.\n12,500 should be entered as 12500.\nExamples: 5, 94, 54327");//warning
		  return false;//fail
		}
    }
    return true;//if all ok exec
}

function validateFPNumbers(textBox) {//Allow only floating point numbers
	string=textBox.value;//get value of passed field
    if (!string) return false;//if nothing fail
    var Chars = "0123456789.-";//allowable characters '.' for floating point numbers
	SLength=string.length;//get field length

    for (i=0;i<SLength;i++) {//go through chars one at a time
       	if (Chars.indexOf(string.charAt(i)) == -1) {//if character not found in allowable characters
		  textBox.value=string.substring(0,SLength-1);//delete the last entered character
          alert("Please use ONLY floating point numbers.\nExamples: 1.3, 5, 29.34");//warning
		  return false;//fail
		}
    }
    return true;//if all ok exec
}

function PopWin(URL,H,W) {
	window.open(URL,'Popped',"Height="+H+",Width="+W+",scrollbars,resizable,status");
}

function Expand(Did) {
	if (document.getElementById) {
		document.getElementById(Did).style.display=(document.getElementById(Did).style.display=='none')?'block':'none';
	}
	else if (document.all) {
		document.all[Did].style.display=(document.all[Did].style.display=='none')?'block':'none';
	}
}

function ExpandO(Did) {
	if (document.getElementById) {
		document.getElementById(Did).style.display='block';
	}
	else if (document.all) {
		document.all[Did].style.display='block';
	}
}

function ExpandC(Did) {
	if (document.getElementById) {
		document.getElementById(Did).style.display='none';
	}
	else if (document.all) {
		document.all[Did].style.display='none';
	}
}

//preloadImages('file.gif', 'http://www.x.com/y.gif');
function preloadImages() {
  if(document.images) {
    if(!document.imageArray) document.imageArray = new Array();
    var i,j = document.imageArray.length, args = preloadImages.arguments;
    
    for(i=0; i<args.length; i++) {
      if (args[i].indexOf("#")!=0) {
        document.imageArray[j] = new Image;
        document.imageArray[j++].src = args[i];
      }
    }
  }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/*INDEX POP*/
function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
			return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function amt(){
	var count = GetCookie('count')
	if(count == null) {
		SetCookie('count','1')
		return 1
	} else {
		var newcount = parseInt(count) + 1;
		DeleteCookie('count')
		SetCookie('count',newcount,exp)
		return count
   }
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
	var count = GetCookie('count');
	if (count == null) {
		count=1;
		SetCookie('count', count, exp);
		window.open(page, "", windowprops);
	} else {
		count++;
		SetCookie('count', count, exp);
   }
}
