

//split the string based on delimiter and location
//location start from 0 and refer to first portion of string to be returned
function SplitString (stringToSplit, separator, location) {  
	arrayOfStrings = stringToSplit.split(separator)
	for (var i=0; i < arrayOfStrings.length; i++) {
		return arrayOfStrings[location];
	}
}

function popUp() {
props=window.open('PopUp.html', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=425, height=435, left = 0, top =0');
}


//Create a string (separated by commas) from the multiselect listbox
function MakeString(SelectCtrl) {
	var i;
	var j = 0;
	var outlist = "";

	for (i = 0; i < SelectCtrl.options.length; i++) {
		if (j > 0) {
			outlist = outlist + ", ";
		}
		outlist = outlist + SelectCtrl.options[i].value;
		j++;
	}
	return outlist;
}

//Create a text string (separated by commas) from the multiselect listbox
function MakeTextString(SelectCtrl) {
	var i;
	var j = 0;
	var outlist = "";

	for (i = 0; i < SelectCtrl.options.length; i++) {
		if (j > 0) {
			outlist = outlist + ", ";
		}
		outlist = outlist + SelectCtrl.options[i].text;
		j++;
	}
	return outlist;
}

//Create a string (separated by commas) from the multiselect listbox
function MakeSelectedString(SelectCtrl) {
	var i;
	var j = 0;
	var outlist = "";

	for (i = 0; i < SelectCtrl.options.length; i++) {
		if (SelectCtrl.options[i].selected) {
			if (j > 0) {
				outlist = outlist + ", ";
			}
			outlist = outlist + SelectCtrl.options[i].value;
			j++;
		}
	}
	return outlist;
}

//Add item(s) from multiselect listbox to another one (supports mutiselect)
function AddItems(fromCtrl, toCtrl) {
	var i;
	var j;
	var itemexists;
	var nextitem;

	// step through all items in fromCtrl
	for (i = 0; i < fromCtrl.options.length; i++) {
		if (fromCtrl.options[i].selected) {
			// search toCtrl to see if duplicate
			j = 0;
			itemexists = false;
			while ((j < toCtrl.options.length) && (!(itemexists))) {
				if (toCtrl.options[j].value == fromCtrl.options[i].value) {
					itemexists = true;
					alert(fromCtrl.options[i].value + " found and will be removed!");
				}
				j++;
			}
			if (!(itemexists)) {
				// add the item
				nextitem = toCtrl.options.length;
				toCtrl.options[nextitem] = new Option(fromCtrl.options[i].text);
				toCtrl.options[nextitem].value = fromCtrl.options[i].value;
			}
		}
	}
	SortD(toCtrl);
}

//Add or remove all items from a multiselect listbox
function AddRemoveAllItems(fromCtrl, toCtrl)
{
	var nLength = fromCtrl.options.length;

	for (i = 0; i < (fromCtrl.options.length); i++) {
		j = toCtrl.options.length;
		toCtrl.options[j] = new Option(fromCtrl.options[i].text);
		toCtrl.options[j].value = fromCtrl.options[i].value;
	}

	for (i = 0; i < nLength; i++) {
		fromCtrl.options[0] = null;
	}
	SortD(toCtrl);
}

//Remove item(s) from a multiselect listbox
function RemoveItems(fromCtrl) {
	var i = 0;
	var j;
	var k = 0;

	while (i < (fromCtrl.options.length - k)) {
		if (fromCtrl.options[i].selected) {
			// remove the item
			for (j = i; j < (fromCtrl.options.length - 1); j++) {
				fromCtrl.options[j].text = fromCtrl.options[j+1].text;
				fromCtrl.options[j].value = fromCtrl.options[j+1].value;
				fromCtrl.options[j].selected = fromCtrl.options[j+1].selected;
			}
			k++;
		} else {
			i++;
		}
	}
	for (i = 0; i < k; i++) {
		fromCtrl.options[fromCtrl.options.length - 1] = null;
	}
}

//Sort the multiselect listbox in ascending order
function SortD(box)  {
	var temp_opts = new Array();o
	var temp = new Object();

	for(var i=0; i<box.options.length; i++)  {
		temp_opts[i] = box.options[i];
	}
	
	for(var x=0; x<temp_opts.length-1; x++)  {
		for(var y=(x+1); y<temp_opts.length; y++)  {
			if(temp_opts[x].text > temp_opts[y].text)  {
				temp = temp_opts[x].text;
				temp_opts[x].text = temp_opts[y].text;
				temp_opts[y].text = temp;
				temp = temp_opts[x].value;
				temp_opts[x].value = temp_opts[y].value;
				temp_opts[y].value = temp;
			}
		}
	}
	
	for(var i=0; i<box.options.length; i++)  {
		box.options[i].value = temp_opts[i].value;
		box.options[i].text = temp_opts[i].text;
	}
}

function OpenWindow(theURL, winName, features)
{
	newWin = window.open(theURL, winName, features);
	newWin.focus();
}

function GetRandom(r1, r2) {
  if (r2 > r1) return (Math.round(Math.random()*(r2-r1))+r1);
  else return (Math.round(Math.random()*(r1-r2))+r2);
}

function round(number,X) {
	// rounds number to X decimal places, defaults to 2
	X = (!X ? 2 : X);
	//alert(Math.round(number*Math.pow(10,X))/Math.pow(10,X));
	return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function RoundOff(value, precision)
{
	value = "" + value //convert value to string
	precision = parseInt(precision);

	var whole = "" + Math.round(value * Math.pow(10, precision));

	var decPoint = whole.length - precision;

	if(decPoint != 0)
	{
	    result = whole.substring(0, decPoint);
	    result += ".";
	    result += whole.substring(decPoint, whole.length);
	}
	else
	{
	    result = whole;
	}
	return result;
}

function RoundUp(object)
{
object.value = Math.round(object.value);
return object.value;
}

// This next little bit of code tests whether the user accepts cookies.
var WM_acceptsCookies = false;
if(document.cookie == '') {
    document.cookie = 'WM_acceptsCookies=yes'; // Try to set a cookie.
    if(document.cookie.indexOf('WM_acceptsCookies=yes') != -1) {
	WM_acceptsCookies = true; 
    }// If it succeeds, set variable
} else { // there was already a cookie
  WM_acceptsCookies = true;
}

function WM_setCookie (name, value, hours, path, domain, secure) {
    if (WM_acceptsCookies) { // Don't waste your time if the browser doesn't accept cookies.
	var not_NN2 = (navigator && navigator.appName 
		       && (navigator.appName == 'Netscape') 
		       && navigator.appVersion 
		       && (parseInt(navigator.appVersion) == 2))?false:true;

	if(hours && not_NN2) { // NN2 cannot handle Dates, so skip this part
	    if ( (typeof(hours) == 'string') && Date.parse(hours) ) { // already a Date string
		var numHours = hours;
	    } else if (typeof(hours) == 'number') { // calculate Date from number of hours
		var numHours = (new Date((new Date()).getTime() + hours*3600000)).toGMTString();
	    }
	}
	document.cookie = name + '=' + escape(value) + ((numHours)?(';expires=' + numHours):'') + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:'') + ((secure && (secure == true))?'; secure':''); // Set the cookie, adding any parameters that were specified.
    }
}


function WM_readCookie(name) {
    if(document.cookie == '') { // there's no cookie, so go no further
	return false; 
    } else { // there is a cookie
	var firstChar, lastChar;
	var theBigCookie = document.cookie;
	firstChar = theBigCookie.indexOf(name);	// find the start of 'name'
	var NN2Hack = firstChar + name.length;
	if((firstChar != -1) && (theBigCookie.charAt(NN2Hack) == '=')) { // if you found the cookie
	    firstChar += name.length + 1; // skip 'name' and '='
	    lastChar = theBigCookie.indexOf(';', firstChar); // Find the end of the value string (i.e. the next ';').
	    if(lastChar == -1) lastChar = theBigCookie.length;
	    return unescape(theBigCookie.substring(firstChar, lastChar));
	} else { // If there was no cookie of that name, return false.
	    return false;
	}
    }	
}

function WM_killCookie(name, path, domain) {
  var theValue = WM_readCookie(name); // We need the value to kill the cookie
  if(theValue) {
      document.cookie = name + '=' + theValue + '; expires=Fri, 13-Apr-1970 00:00:00 GMT' + ((path)?';path=' + path:'') + ((domain)?';domain=' + domain:''); // set an already-expired cookie
  }
}


function gotopage(pgNum){
	document.forms(0).PageNo.value = pgNum;
	document.forms(0).submit();
}

// calling function for qty changed
function OpenWin(winName, newURL, borderSize)
{
  win = window.open(newURL, winName, borderSize);
}

function cmdDel_OnClick()
{
	var blnSubmitted;
	blnSubmitted = false;

	blnSubmitted = window.confirm("Delete the selected record(s)?");
	if (blnSubmitted) {
		document.forms(0).bCheck.value = 'Del';
		document.forms(0).submit();
        }        
}

function cmdAdd_OnClick(sASPFName)
{
	document.forms(0).action=sASPFName;
	document.forms(0).submit();
}


// calling function for add
function cmdAddEditDtl_OnClick(winName, newURL, borderSize)
{    
  win = window.open(newURL, winName, borderSize);

}


// calling function for delete
function cmdDelDtl_OnClick(sConfirmMsg)
{
	blnSubmitted = window.confirm(sConfirmMsg);
	if (blnSubmitted) {
		document.forms(0).bCheck.value = 'Del'
		document.forms(0).submit();
	}
	
}

function SortD(box)  {
	var temp_opts = new Array();
	var temp = new Object();
	for(var i=0; i<box.options.length; i++)  {
		temp_opts[i] = box.options[i];
	}
	for(var x=0; x<temp_opts.length-1; x++)  {
		for(var y=(x+1); y<temp_opts.length; y++)  {
			if(temp_opts[x].text > temp_opts[y].text)  {
				temp = temp_opts[x].text;
				temp_opts[x].text = temp_opts[y].text;
				temp_opts[y].text = temp;
	      }
   	}
	}
	for(var i=0; i<box.options.length; i++)  {
		box.options[i].value = temp_opts[i].value;
		box.options[i].text = temp_opts[i].text;
   }
}

function cmdMove_OnClick(fbox,tbox) {
	for(var i=0; i<fbox.options.length; i++) {
		if(fbox.options[i].selected && fbox.options[i].value != "") {
			var no = new Option();
			no.value = fbox.options[i].value + "~" + document.BOMAdd.txtQty.value + "~" + document.BOMAdd.txtStdCost.value;
			no.text = fbox.options[i].text;
			tbox.options[tbox.options.length] = no;
			fbox.options[i].value = "";
			fbox.options[i].text = "";
	   }
	}
	BumpUp(fbox);
	if (sortitems) SortD(tbox);
}

function BumpUp(box)  {
	for(var i=0; i<box.options.length; i++) {
		if(box.options[i].value == "")  {
			for(var j=i; j<box.options.length-1; j++)  {
			box.options[j].value = box.options[j+1].value;
			box.options[j].text = box.options[j+1].text;
			}
		var ln = i;
		break;
		}
	}
	if(ln < box.options.length)  {
		box.options.length -= 1;
		BumpUp(box);
   }
}

function RoundNum(value, precision)
{
	value = "" + value   //convert value to string
	precision = parseInt(precision);

	var whole = "" + Math.round(value * Math.pow(10, precision));

	var decPoint = whole.length - precision;

	if(decPoint != 0)
	{
	  result = whole.substring(0, decPoint);
	  result += ".";
	  result += whole.substring(decPoint, whole.length);
	}
	else
	{
	  result = whole;
	}
        
	return result;
}


function CBit(bCheckValue) {
  var bBit = new Boolean;

  if (bCheckValue) {
     bBit = 1;
  }
  else {
     bBit = 0;
  }
  
  return bBit;
}

//====== Format the currency
function FormatCcy(curAmount)
{
	var intDecPos;
	
	intDecPos = curAmount.toString().indexOf(".");
	//alert(intDecPos);
	if (intDecPos == -1){
		return curAmount.toString() + ".00";
	}
	else if(curAmount.toString().length >= (intDecPos + 3)){
		return curAmount.toString().substring(0, intDecPos + 3);
	}
	else{
		return curAmount.toString().substring(0, intDecPos + 3) + "0";
	}
}

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_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_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;
}

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];}
}

//to show or hide layer
//isDisplay = false or true
//ControlName = Span Name
var ie4=(document.all) ? true:false;
var ie5=(document.getElementById && document.all);
//var ns6=(document.getElementById && !document.all);

<!-- Hide script from old browsers
document.WM = new Object();
document.WM.hirelist = new Object();
document.WM.hirelist.expandos = new Array();
document.WM.hirelist.heights = new Array();
document.WM.hirelist.names = new Array();

function WM_toggle(id) {
  if (document.all){
    if(document.all[id].style.display == 'none'){
      document.all[id].style.display = '';
    } else {
      document.all[id].style.display = 'none';
    }
  } else if (document.getElementById){
    if(document.getElementById(id).style.display == 'none'){
      document.getElementById(id).style.display = 'block';
    } else {
      document.getElementById(id).style.display = 'none';
    }
  } else if(document.layers) {
      if(parseInt(id + 1)){
	  ditem = id + 1;
      } else {
	  ditem = document.WM.hirelist.names[id];
      }
      if(document.WM.hirelist.expandos[ditem].clip.bottom == 0) {
	     document.WM.hirelist.expandos[ditem].clip.bottom = document.WM.hirelist.heights[ditem];
      } else {
	  document.WM.hirelist.expandos[ditem].clip.bottom = 0;
      }
      WM_align();
  }
}

function WM_align() {
    var i,j,stupid_netscape_array_infinate_loop_error;
    stupid_netscape_array_infinate_loop_error = document.WM.hirelist.expandos.length;
    for(i=0; i<stupid_netscape_array_infinate_loop_error; i++) {
		j = i + 1;
		if(document.WM.hirelist.expandos[j]){
	    	if(document.layers) {
				document.WM.hirelist.expandos[j].top = document.WM.hirelist.expandos[i].top + document.WM.hirelist.expandos[i].clip.bottom;
	   		}
		}
    }
}

function WM_initialize_toolbar(Cover,Hidden){
    if(document.layers) {
		for(i=0; i<document.layers[Cover].document.layers.length; i++){
	    	document.WM.hirelist.expandos[i] = document.layers[Cover].document.layers[i];
	    	document.WM.hirelist.names[document.layers[Cover].document.layers[i].name] = i;
	    	document.WM.hirelist.heights[i] = document.WM.hirelist.expandos[i].clip.bottom;
		}
		for (p=0;p<document.WM.hirelist.expandos.length;p=p+2){
	    	WM_toggle(p);
		}
		document.layers[Cover].visibility = 'visible';
    } else if (document.all){
		for(i = 0; i < document.all(Cover).all.length; i++){
		    document.all(Cover).all[i].style.position = 'relative';
		    if(document.all(Cover).all[i].className == Hidden){
			document.all(Cover).all[i].style.display = 'none';
		    }
		}
		document.all(Cover).style.visibility = 'visible';
    } else if (document.getElementsByTagName && document.getElementById){
		var contained = document.getElementById(Cover).getElementsByTagName('div');
		for(i = 0; i < contained.length; i++){
		    contained[i].style.position = 'relative';
		    if(contained[i].getAttribute('class') == Hidden){
			contained[i].style.display = 'none';
		    }
		}
		document.getElementById(Cover).style.visibility = 'visible';
    }
}

function ShowLayers(IsTrue,id) {
  if (document.all){		  
    if(IsTrue){    
      document.all[id].style.display = '';
    } else {
      document.all[id].style.display = 'none';
    }
    
  } else if (document.getElementById){		
    if(IsTrue){
      document.getElementById(id).style.display = 'block';
    } else {
      document.getElementById(id).style.display = 'none';
    }
  } else if(document.layers) {			
      if(parseInt(id + 1)){
	  ditem = id + 1;
      } else {
	  ditem = document.WM.hirelist.names[id];
      }
      if(IsTrue) {
	     document.WM.hirelist.expandos[ditem].clip.bottom = document.WM.hirelist.heights[ditem];
      } else {
	  document.WM.hirelist.expandos[ditem].clip.bottom = 0;
      }
      WM_align();
  }
}
// End the hiding -->

function ShowLayer(IsTrue,id) {
  if (document.all){		
    if(IsTrue){
      document.all[id].style.display = '';
    } else {
      document.all[id].style.display = 'none';
    }
  } else if (document.getElementById){		
    if(IsTrue){
      document.getElementById(id).style.display = 'block';
    } else {
      document.getElementById(id).style.display = 'none';
    }
  } else if(document.layers) {			
      if(parseInt(id + 1)){
	  ditem = id + 1;
      } else {
	  ditem = document.WM.hirelist.names[id];
      }
      if(IsTrue) {
	     document.WM.hirelist.expandos[ditem].clip.bottom = document.WM.hirelist.heights[ditem];
      } else {
	  document.WM.hirelist.expandos[ditem].clip.bottom = 0;
      }
      WM_align();
  }
  
}

function ActivateTxt(ctrl)	{
	ctrl.style.backgroundColor = '#f6f6f6'<!---'#DFF4FF''#99CCFF'--->;
	return;
}

function DeActivateTxt(ctrl)	{
	ctrl.style.backgroundColor = '#FFFFFF';
	return;
}

function ActivateBtn(ctrl)	{
	ctrl.style.backgroundColor = '#99CCFF';
	return;
}

function DeActivateBtn(ctrl)	{
//	ctrl.style.backgroundColor = '#CCCCCC';
	ctrl.style.backgroundColor = '';
	return;
}

function ActivateButton(ctrl)	{
	ctrl.style.backgroundColor = '#99CCFF';
	return;
}

function DeActivateButton(ctrl)	{
//	ctrl.style.backgroundColor = '#6580a2';	
	ctrl.style.backgroundColor = '';	
	return;
}

NS4 = (document.layers) ? true : false;

function CheckEnter(event,form,ctrl)
{ 
var code = 0;

	if (NS4)
		code = event.which;
	else
		code = event.keyCode;
	if (code==13)
		eval(form + '.' + ctrl + '.focus()');		
	return;	
}

//to check and uncheck all checkbox in the form
function CheckAll(form,ctrl,status)	{
	for (var i=0;i<form.elements.length;i++)	{
		var e = form.elements[i];
		if ((e.name != ctrl) && (e.type=='checkbox'))
			e.checked = status;
	}	
	return;	

}

//return true if one of the checkbox is checked else false
function IsChecked(form,ctrl)	{		
	for (var i=0;i<form.elements.length;i++)	{				
		var e = form.elements[i];
		if ((e.name != ctrl) && (e.type=='checkbox'))
			if(e.checked)	
				return true;			
	}		
	return false;
}

function PageBreak(obj)	{
	if (msieversion() == 6)	{
//		alert("ie6");
		return;
	}	
	else if (msieversion() == 5)	{
//		alert("ie5");
		document.getElementById(obj).style.pageBreakAfter="always";	
	}	
	else if (msieversion() < 5)
		document.all(obj).style.pageBreakAfter = "";			

	return;
}

function msieversion() { 
	var ua = window.navigator.userAgent 
	var msie = ua.indexOf ( "MSIE " ) 
//	if (msie==-1) return false; // not IE 
	if (msie != -1)
		v = parseInt (ua.substring(msie+5,ua.indexOf (".",msie ))) ;
//	if (v<5) return false; // not v5 or higher 
//	if (ua.toLowerCase().indexOf(2000)) return false; 
	return v;
} 
<!---Windows PopUp --->
function popwin(url,s,w,h)
{
window.open(url, 'popupnav', 'toolbar=0,menubar=0,resizable=0,scrollbars='+s+',width='+w+',height='+h);
}
function popwinCollector(url,s,w,h)
{
window.open(url, 'popupnav', 'toolbar=0,menubar=0,resizable=0,scrollbars='+s+',width='+w+',height='+h);
}<!---URL calling --->
function gotourl(value)
        {
        url=value
        location.href=url
        }
//-->
<!---Windows PopUp --->
function popwin1(url,win,s,w,h)
{
window.open(url, win, 'toolbar=0,menubar=0,resizable=0,scrollbars='+s+',width='+w+',height='+h);
}
<!---Windows PopUp --->
function popwinMenu(url,m,s,w,h)
{
window.open(url, 'popupnav1','toolbar=0,menubar='+m+',resizable=0,scrollbars='+s+',width='+w+',height='+h);
}
<!---Windows popupTitle- statement of account --->
function popwinMenuSOA(url,m,s,w,h)
{
window.open(url, 'popupnav1','toolbar=0,fullscreen=no,menubar='+m+',resizable=1,titlebar=no,scrollbars='+s+',width='+w+',height='+h);

}
<!---Windows PopUp --->
function popwinMenuchecker(url,m,s,w,h)
{
window.open(url, 'popupnav2','toolbar=0,menubar='+m+',resizable=0,scrollbars='+s+',width='+w+',height='+h);
}
<!---URL calling --->
function gotourl(value)
        {
        url=value
        location.href=url
        }
function openme() 
{
props=window.open('highlight.htm', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=600, height=330, left = 70, top = 70');
}
function openme1() 
{
props=window.open('blue1.htm', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=1000, height=148, left = 30, top = 20');
}
function openme2() 
{
props=window.open('easypay.htm', 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=650, height=390, left = 70, top = 70');
}
//-->

<!--- Close Function --->
function closewin()
{
window.close();
}

<!--- DoPrint --->
function doprint() {
	//save existing user's info
	var h = factory.printing.header;
	var f = factory.printing.footer;
	
	//set header and footer to blank
	factory.printing.header = "";
	factory.printing.footer = "";
	//Page Orientation 
	factory.printing.portrait = true;
	//print page prompt
	factory.printing.leftMargin = 0.01
	factory.printing.topMargin = 0.01;
	factory.printing.bottomMargin = 0.01;
	factory.printing.rightMargin = 0.02;  
	factory.printing.Print(true)
	//Set page margins
	//restore user's info
	factory.printing.header = h;
	factory.printing.footer = f;
	factory.printing.portrait = true;

}
<!-- auto popwup--> 
function fwLoadCard()
{
window.open('http://hla25/aportaluat/asp/tools/MA_Annouce1.asp', 'popupnav', 'toolbar=0,menubar=0,scrollbars=no,width=300,height=260,resizable=0,screenX=80,screenY=80,top=200,left=400');
}

<!--- Print all Frames--->

function printAll() 
{   
    for (var i=1; i<frames.length; i++) {
        if (window.print) {
            frames[i].print();
        }
    }
}

function TrimNumber(sNumber)	{

  var retVal = "";
  var start = 0;
  while ((start < sNumber.length) && (sNumber.charAt(start) == '0')) {
    ++start;
  }
  var end = sNumber.length;
  retVal = sNumber.substring(start, end);
  return retVal;	

}

function Max(a,b)	{
	if (a>b)	{	
		max = a;
	}
	else	{
		max = b;
	}			
	return max;
}


function Min(a,b)	{
	if (a < b)	{	
		min = a;
	}
	else	{
		min = b;
	}			
	return min;
}

function Mod(No,Modulus)	{
	return parseFloat(No) % parseFloat(Modulus);
}

function CheckSite(Parameter)	{

	window.open(Parameter,'newwindow','width=790,height=550,left=0,top=0,resizable=yes,scrollbars=yes,location=no');			

}

<!--
/* 
Browser sniffer. Written by PerlScriptsJavaScripts.com
Copyright http://www.perlscriptsjavascripts.com 
Free and commercial Perl and JavaScripts     
*/

v3 = 0; op = 0; ie4  = 0; ie5 = 0; nn4 = 0; nn6 = 0; isMac = 0; aol = 0;
/*
op= opera
ie4 = Internet Explorer 4
ie 5 = Internet Exploere 5 and above
nn4 = Netscape 4
nn6 = Netscape 6
aol= AOL Browser
v3 = pre version 4 browser
*/
if(document.images){
    if(navigator.userAgent.indexOf("Opera") != -1){
        op = 1;
    } else {
        if(navigator.userAgent.indexOf("AOL") != -1){
            aol = 1;
        } else {
            ie4 = (document.all && !document.getElementById);
            nn4 = (document.layers);
            ie5 = (document.all && document.getElementById);
            nn6 = (document.addEventListener);
        }
    }
} else {
    v3 = 1;	
}


if(navigator.userAgent.indexOf("Mac") != -1){
    isMac = 1;
}

// -->


/*
if(op){ // do this
    alert("You are using Opera");
} 
if(ie4){ // do this
    alert("You are using Internet Explorer 4");
} 
if(ie5){ // do this
    alert("You are using Internet Explorer 5 or higher");
} 
if(nn4){ // do this
    alert("You are using Netscape 4");
} 
if(nn6){ // do this
    alert("You are using Netscape 6");
} 
if(aol){ // do this
    alert("You are using an AOL browser");
}
if(v3){ // do this
    alert("You are using a pre version 4 browser");
}
*/



<!---Center PopUp Window--->
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}

//Convert a Number To String and Format it "_12" if NumberToString ("12",3) whereby _ is space
function NumberToString(iNumber, iDigits)		{
	var iNumberLength,iDifference;
	var sNumberToString;
	iNumberLength = iNumber.length;
	
	sNumberToString = Trim(iNumber);
	if (iNumberLength > iDigits)	{
		iDigits = iNumberLength;
	}
	
	iDifference = iDigits - iNumberLength;	
	
	if (iDifference > 0)	{		
		for (var i =0; i< iDifference;i++)	{			
			sNumberToString = sNumberToString + '  ';
		}
	}
	
	//sNumberToString = sNumberToString + iNumber.toString();	
	return sNumberToString;
	
}

function nextNearest(value, number) {
  var ceil = Math.ceil(value);
  var remainder = value % number;
  if (remainder > 0)
    value = value - remainder + number;
  return value;
}