
function showHideSpan(target){
	if (document.getElementById(target).style.display=="")
		document.getElementById(target).style.display="none";
	else
		document.getElementById(target).style.display="";
}


function trim(strText) {
   return ltrim(rtrim(strText));
}

function ltrim(strText) { 
    
    while (strText.substring(0,1) == ' ') 
        strText = strText.substring(1, strText.length);   
   
   return strText;
}

function rtrim(strText) { 	
    
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);
        
   return strText;
}

function replaceAll(str1,str2,str3){
	str1 = str1.split(str2).join(str3);
	return str1;
}


function validateNumeric(eventObj, obj)
{
	var keyCode;

	// Check For Browser Type
	if (document.all){ 
		keyCode=eventObj.keyCode;
	}
	else{
		keyCode=eventObj.which;
	}

	var str=obj.value;

	if(keyCode==45){ 
		if (str.indexOf("-")==-1){
			return true;
		}
	}

	// keyCode==43 +
	// keyCode==46 .
	
	if(keyCode==46){ 
		if (str.indexOf(".")==-1){
			return true;
		}
	}

	/*if(keyCode==32){ 
		if (str.indexOf(".")>0){
			return false;
		}
	}*/

	if((keyCode<48 || keyCode >58)  ){ // Allow only integers and decimal points
		//alert("It accepts only 'numbers',  '+',  '-' and  'space'.")
		return false;
	}
	return true;
}


function checkValidEmail(adr,dispWarning){
	
	var myAtSymbolAt = adr.indexOf('@');
	var myLastDotAt = adr.lastIndexOf('.');	
	var myLength = adr.length;
	
	
	if(myLength <1){
		if (dispWarning) alert("Email address is required!");
		return false;
	}

	if (myAtSymbolAt < 1 ){
		if (dispWarning) alert("Email address needs an '@' sign! Please correct this.");
		return false;
	}

	if (myLastDotAt < myAtSymbolAt){
		if (dispWarning) alert("Invalid email address! Please use format jane@doe.com.");
		return false;
	}

	if (myLength - myLastDotAt <= 2){
		if (dispWarning) alert("Invalid email address! Please use format jane@doe.com.");
		return false;
	}
	return true;
}

function newWindow(URL, W, H, wName)
{
	window.open(URL, "Sub", "scrollbars=no,width=" + W + ",height=" + H + ", menubar=no,toolbar=no,titlebar=no,status=no");
}


function printit(){  
	if (window.print) 
	{
		window.print() ;  
	} 
	else 
	{
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    
		WebBrowser1.outerHTML = "";  
	}
}

var curMenu = null;
var mouseX;
var mouseY;

if (!document.all) 
{
    window.captureEvents(Event.MOUSEMOVE);
    window.onmousemove=mouse_move;
}

function MouseOverChangeClass(elem,strColor) 
{
	if (elem.className != strColor + "_click") 
	{
		elem.className = strColor + "_over";
	}

}

function MouseOutChangeClass(elem, strColor) 
{

	if (elem.className != strColor + "_click") 
	{
		elem.className = strColor + "_off";
	}
}

function drop_menu(oMenu)
{
	var IE = document.all?true:false
	
	if (curMenu != null)
		curMenu.style.display = "none";
		
	oMenu.style.display = "block";
	curMenu = oMenu;
}

function mouse_move(e)
{
	mouseX = e.pageX;
	mouseY = e.pageY;
}

function change_class(oElm, tClass, fClass)
{

	var iX = 0;
	var iY = 0;
	var ibX1, ibX2, ibY1, ibY2;
	var IE = document.all?true:false
	
	if (IE) 
	{
		iX = event.clientX + document.body.scrollLeft
		iY = event.clientY + document.body.scrollTop
	}
	else 
	{
		iX = mouseX;
		iY = mouseY;
	}  
	
	if (oElm != null)
	{
		ibX1 = parseInt(oElm.style.left);
		ibX2 = ibX1 + parseInt(oElm.style.width);
		ibY1 = parseInt(oElm.style.top);
		ibY2 = ibY1 + parseInt(oElm.style.height);
		
		if (((iX < ibX1 + 3 || iX > ibX2 - 3) || (iY < ibY1 + 3  || iY > ibY2 - 5)) || (isNaN(ibX1) || isNaN(ibY1)))
		{
			//window.status = iX + ":" + iY + "-" + ibX1 + "," + ibY1 + ":" + ibX2 + "," + ibY2;
			oElm.className = tClass;
		}
		else
		{
			oElm.className = fClass;
		}
	}
}

function hide_menu(oMenu)
{	

	var iX = 0;
	var iY = 0;
	var ibX1, ibX2, ibY1, ibY2;
	var IE = document.all?true:false
	
	if (IE) 
	{
		iX = event.clientX + document.body.scrollLeft
		iY = event.clientY + document.body.scrollTop
	}
	else 
	{
		iX = mouseX;
		iY = mouseY;
	}  
	
	if (oMenu != null)
	{
		ibX1 = parseInt(oMenu.style.left);
		ibX2 = ibX1 + parseInt(oMenu.style.width);
		ibY1 = parseInt(oMenu.style.top);
		ibY2 = ibY1 + parseInt(oMenu.style.height);

		//alert(iX + ":" + iY);
		//alert(ibX1 + "," + ibY1 + ":" + ibX2 + "," + ibY2);
		if ((iX < ibX1 + 3 || iX > ibX2 - 3) || (iY < ibY1 - 5  || iY > ibY2 - 3))
		{
			oMenu.style.display = "none";
		}
	}	
}

function anyMask(event, sMask) 
{
	//var sMask = "**?##?####";
	var KeyTyped = String.fromCharCode(getKeyCode(event));
	var targ = getTarget(event);
	
	keyCount = targ.value.length;
	//alert(sMask.charAt(keyCount));
	
	if (sMask.charAt(keyCount) == '*')
 	   	return true;
 
	if (sMask.charAt(keyCount) == KeyTyped)
    	{
		return true;
	}
	
	if ((sMask.charAt(keyCount) == '#') && isNumeric(KeyTyped)) 
	   return true; 
	
	if ((sMask.charAt(keyCount) == 'A') && isAlpha(KeyTyped))
         return true; 
    
      if ((sMask.charAt(keyCount) == '?') && isPunct(KeyTyped))
         return true; 
	if (KeyTyped.charCodeAt(0) < 32) return true;
    
    return false;	   
   
	
}

 function getTarget(e) {
  // IE5
   if (e.srcElement) {
   	return e.srcElement;
   }
    if (e.target) {
   	return e.target;
   }	
 }

  function getKeyCode(e) {
 //IE5
 if (e.srcElement) {
 	return e.keyCode
 }
  // NC5
  if (e.target) {
   return e.which
  }
 }

 function isNumeric(c)
{
	var sNumbers = "01234567890";
	if (sNumbers.indexOf(c) == -1)
		return false;
	else return true;
	
}  

function isAlpha(c)
{
	var lCode = c.charCodeAt(0);
	if (lCode >= 65 && lCode <= 122 )
 	  {	
		return true;
         }
	else 
	return false;
}  

function isPunct(c)
{
	var lCode = c.charCodeAt(0);
	if (lCode >= 32 && lCode <= 47 )
 	  {	
		return true;
         }
	else 
	return false;

}
 
/*
function phoneMask()
 {
	var sMask = "01234567890";
	var KeyTyped = String.fromCharCode(window.event.keyCode);
	var srcObject = window.event.srcElement;
	//alert(window.event.keyCode);
	if (window.event.keyCode != 8)
	{
	 if (sMask.indexOf(KeyTyped.toString()) == -1)
		{
		 		window.event.keyCode = 0;
				_ret = false;
		}
	}	 

   frigger = document.getElementById(window.event.srcElement.id);
   keyCount = frigger.value.length;
    var tmpStr = "(";
    
    keyEntered = KeyTyped;
    keyCount++;
    switch (keyCount)
    {
    case 2: 
      tmpStr += srcObject.value;
      srcObject.value = tmpStr;
      break;
    case 5:
      srcObject.value += ")";
      break;
    case 9:
      srcObject.value += "-";
      break;
      }
 }



function dateMask()
 {
	var sMask = "01234567890";
	var KeyTyped = String.fromCharCode(window.event.keyCode);
	var srcObject = window.event.srcElement;
	//alert(window.event.keyCode);
	if (window.event.keyCode != 8)
	{
	 if (sMask.indexOf(KeyTyped.toString()) == -1)
		{
		 		window.event.keyCode = 0;
				_ret = false;
		}
	}	 

   frigger = document.getElementById(window.event.srcElement.id);
   keyCount = frigger.value.length;
    var tmpStr = "";
    
    keyEntered = KeyTyped;
    keyCount++;
    switch (keyCount)
    {
    case 3: 
      srcObject.value += "/";
      break;
    case 6:
      srcObject.value += "/";
      break;
      }
 } 
 
 
 
 function ssnMask()
  {
	var sMask = "01234567890";
	var KeyTyped = String.fromCharCode(window.event.keyCode);
	var srcObject = window.event.srcElement;
	//alert(window.event.keyCode);
	if (window.event.keyCode != 8)
	{
	 if (sMask.indexOf(KeyTyped.toString()) == -1)
		{
		 		window.event.keyCode = 0;
				_ret = false;
		}
	}	 

   frigger = document.getElementById(window.event.srcElement.id);
   keyCount = frigger.value.length;
   
   if (keyCount>10)
		window.event.keyCode = 0;
   
    var tmpStr = "";
    
    keyEntered = KeyTyped;
    keyCount++;
    switch (keyCount)
    {
    case 2: 
      tmpStr += srcObject.value;
      srcObject.value = tmpStr;
      break;
    case 4:
      srcObject.value += "-";
      break;
    case 7:
      srcObject.value += "-";
      break;
      }
 }

function showHide(obj, oControl) 
{
		flipObj = document.getElementById(obj);
		if(flipObj.style.display=="" || flipObj.style.display=="show")
		{			
			flipObj.style.display="none";			
			oControl.innerText = "[+] Expand to view details";			
		}
		else
		{			
			flipObj.style.display="";
			oControl.innerText = "[-] Hide details";									
		}
}
*/
