// Set Window Status
if(pgStat.length == 0) {
	window.status='BizLink';
} else {
	window.status=pgStat;
}
// Change Window Status
function stat(x) {
	if(x) {
		window.status=x;
	} else {
		window.status=pgStat;
	}
}
// Load Page In New Window
function submitForm() {
	window.location=window.location;
}
function openWin() { 
	window.open('/Help/EWSHelp.htm','help','scrollbars=yes,resizable=yes,width=760,height=400'); 
} 
// Show Hide Layers
function findObj(n) { 
	var x; 
	var ns6 = document.getElementById ? 1 : 0 ;
	var ie = document.all ? 1 : 0 ;
	var ns = document.layers ? 1 : 0 ;
	if(ns6){x = document.getElementById(n) } 
	if(ie){x = document.all[n] } 
	if(ns){x = document[n] } 
	return x; 
} 
function showHideLayers() { //v3.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=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 showHideLayer() { //v3.0
  var i,p,v,obj,args=showHideLayer.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'':(v='hide')?'none':v; }
    obj.display=v; }
}
function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
  if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
timedlayer = setTimeout("", 1)
clearTimeout(timedlayer)
function timedrestore() { //v3.0
	timedlayer = setTimeout("showHideLayers('menu-nav-drop','','hide','menu-nav-drop1','','hide','menu-nav-drop2','','hide','menu-nav-drop3','','hide','menu-nav-drop4','','hide','menu-nav-drop5','','hide')", 600)
}
function timeout() { //v3.0
	timedlayer = setTimeout("showHideLayer('nav-d0','','show','nav-d1','','hide','nav-d2','','hide','nav-d3','','hide','nav-d4','','hide','nav-d5','','hide','nav-d6','','hide')", 5000)
}
function stoptime() { //v3.0
	clearTimeout(timedlayer)
}
// OnLoad
function loaded() {
	if(document.Insert.elements) {
		for(var x=0;x<document.Insert.length;x++) {
			if(document.Insert.elements[x].disabled == false) {
				if(document.Insert.elements[x].type == "button") {
                } else {
                  	document.Insert.elements[x].focus();
                  	return;
				}
       		}
    	}
  	}
}
// Site Tools Nav
function cLinkOvr( cLOvrId, stat ){
  if (document.getElementById){
  		cLOvr = document.getElementById( cLOvrId );
  		if (cLOvr.style.backgroundColor == "#CEE7FF"){
  			cLOvr.style.backgroundColor = "#F8F8F8";
  		} else {
  			cLOvr.style.backgroundColor = "#CEE7FF";
			window.status = stat;
		}
  	}
}
function cLinkOut( cLinkId, stat ){
  if (document.getElementById){
  		cLOut = document.getElementById( cLinkId );
  		if (cLOut.style.backgroundColor == "#F8F8F8"){
  			cLOut.style.backgroundColor = "#CEE7FF";
  		} else {
  			cLOut.style.backgroundColor = "#F8F8F8";
			if (stat) {
				window.status = stat;
			} else {
				window.status = pgStat;
			}
  		}
  	}
}
function cBoxOvr( cLOvrId, stat ){
  if (document.getElementById){
  		cLOvr = document.getElementById( cLOvrId );
  		if (cLOvr.style.backgroundColor == "#CEE7FF"){
  			cLOvr.style.backgroundColor = "#FFFFFF";
  		} else {
  			cLOvr.style.backgroundColor = "#CEE7FF";
			window.status = stat;
		}
  	}
}
function cBoxOut( cLinkId, stat ){
  if (document.getElementById){
  		cLOut = document.getElementById( cLinkId );
  		if (cLOut.style.backgroundColor == "#FFFFFF"){
  			cLOut.style.backgroundColor = "#CEE7FF";
  		} else {
  			cLOut.style.backgroundColor = "#FFFFFF";
			if (stat) {
				window.status = stat;
			} else {
				window.status = pgStat;
			}
  		}
  	}
}
// String Left Function
function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
// String Right Function
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
// Strip WhiteSpace
var nWS;
var n1WS;
var n2WS;
function ValidateWs() {
  nWS=n1WS.value;
  zWS=n2WS;
  var ValidCharsWS = " `'\"";
  var IsNumberWS=true;
  var CharWS;
  var ChrWS;
  ChrWS = "";
  for (i = 0; i < nWS.length && IsNumberWS == true; i++) { 
    CharWS = nWS.charAt(i); 
    if (ValidCharsWS.indexOf(CharWS) == -1) {
	  ChrWS = ChrWS+CharWS;
	} else {
	  zWS.value = ChrWS;
      IsNumberWS = false;
    }
  }
  setTimeout(ValidateWs,100);
}
function chkWs(m,z){
  n1WS=m;
  n2WS=z;
  ValidateWs();
}
function valNum(f,e,t)
{
	var key;
	var keyChr;
	var cursor = getSelectionStart(f);
	if ( window.event )
	{
		key = window.event.keyCode;
	}
	else if ( e )
	{
		key = e.which;
	}
	keyChr = String.fromCharCode(key);
	if ( ("0123456789").indexOf(keyChr) > -1 || (key==null) || (key==0) || (key==3) || (key==8) || (key==9) || (key==13) || (key==27) || (key==63272) || (key==63234) || (key==63235) )
	{
		if ( t == "dec" )
		{
			if ( f.value.indexOf(".") > -1 )
			{
				if ( (cursor-f.value.indexOf(".")) > 2 && !(key==8) )
				{
					return false;
				}
			}
		}
		else
		{
			return true;
		}
	}
	else if ( t == "dec" )
	{
		if ( key==46 )
		{
			if ( f.value.lastIndexOf(".") > -1 )
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
	else if ( t == "emp" )
	{
		if ( cursor == 0 )
		{
			return ( ("BbDdIi").indexOf(keyChr) > -1 )
		}
		else if ( cursor == 1 )
		{
			if ( f.value.substring(0,1) == "I" )
			{
				return ( ("Ss").indexOf(keyChr) > -1 )
			}
			else
			{
				return ( ("Ii").indexOf(keyChr) > -1 )
			}
		}
		else if ( cursor == 2 )
		{
			if ( f.value.substring(0,1) == "I" )
			{
				return ( ("Aa").indexOf(keyChr) > -1 )
			}
			else if ( f.value.substring(0,1) == "B" )
			{
				return ( ("Zz").indexOf(keyChr) > -1 )
			}
			else
			{
				return ( ("Ss").indexOf(keyChr) > -1 )
			}
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}
function chkNum(f,e,t){
	var key;
	var keyChr;
	var fValue;
	var reg;
	var cursor = getSelectionStart(f);
	if ( window.event )
	{
		key = window.event.keyCode;
	}
	else if ( e )
	{
		key = e.which;
	}
	if ( key!=8 && key!=9 && key!=16 && key!=37 && key!=39 && key!=46 )
	{
		reg = /-/g;
		fValue = f.value.replace(reg, "");
		cursor = getSelectionStart(f);
		f.value = '';
		if ( t == "phn" )
		{
			if ( fValue.length < 3 )
			{
				f.value=fValue;
			}
			else if ( cursor == 3 )
			{
				cursor=4;
				f.value=fValue.substring(0,3)+"-"+fValue.substring(3,6);
			}
			else if ( fValue.length < 6 )
			{
				f.value=fValue.substring(0,3)+"-"+fValue.substring(3,6);
			}
			else if ( cursor == 7 )
			{
				cursor=8;
				f.value=fValue.substring(0,3)+"-"+fValue.substring(3,6)+"-"+fValue.substring(6,10);
			}
			else
			{
				f.value=fValue.substring(0,3)+"-"+fValue.substring(3,6)+"-"+fValue.substring(6,10);
			}
		}
		else if ( t == "soc" )
		{
			if ( fValue.length < 3 )
			{
				f.value=fValue;
			}
			else if ( cursor == 3 )
			{
				cursor=4;
				f.value=fValue.substring(0,3)+"-"+fValue.substring(3,5);
			}
			else if ( fValue.length < 5 )
			{
				f.value=fValue.substring(0,3)+"-"+fValue.substring(3,5);
			}
			else if ( cursor == 6 )
			{
				cursor=7;
				f.value=fValue.substring(0,3)+"-"+fValue.substring(3,5)+"-"+fValue.substring(5,9);
			}
			else
			{
				f.value=fValue.substring(0,3)+"-"+fValue.substring(3,5)+"-"+fValue.substring(5,9);
			}
		}
		else if ( t == "dob" )
		{
			if ( fValue.length < 2 )
			{
				f.value=fValue;
			}
			else if ( cursor == 2 )
			{
				cursor=3;
				f.value=fValue.substring(0,2)+"-"+fValue.substring(2,4);
			}
			else if ( fValue.length < 4 )
			{
				f.value=fValue.substring(0,2)+"-"+fValue.substring(2,4);
			}
			else if ( cursor == 5 )
			{
				cursor=6;
				f.value=fValue.substring(0,2)+"-"+fValue.substring(2,4)+"-"+fValue.substring(4,8);
			}
			else
			{
				f.value=fValue.substring(0,2)+"-"+fValue.substring(2,4)+"-"+fValue.substring(4,8);
			}
		}
		else if ( t == "emp" )
		{
			if ( cursor == 1 || cursor == 2 || cursor == 3 )
			{
				f.value=fValue.toUpperCase();
			}
			else
			{
				f.value=fValue;
			}
		}
		moveSelection(f,cursor);
	}
}
function setNum(f,t){
	if ( f.value )
	{
		if ( t == "phn" )
		{
			var reg = /\d\d\d-\d\d\d-\d\d\d\d/;
			if ( f.value.length != 12 )
			{
				alert("Please use proper format for Phone #\n\n111-111-1111");
				f.select();
			}
			else if ( ! f.value.match(reg) )
			{
				alert("Please use proper format for Phone #\n\n111-111-1111");
				f.select();
			}
		}
		else if ( t == "soc" )
		{
			var reg = /\d\d\d-\d\d-\d\d\d\d/;
			if ( f.value.length != 11 )
			{
				alert("Please use proper format for Social #\n\n111-11-1111");
				f.select();
			}
			else if ( ! f.value.match(reg) )
			{
				alert("Please use proper format for Social #\n\n111-11-1111");
				f.select();
			}
		}
		else if ( t == "dob" )
		{
			var reg = /\d\d-\d\d-\d\d\d\d/;
			if ( f.value.length != 10 )
			{
				alert("Please use proper format for Date of Birth\n\n11-11-1111");
				f.select();
			}
			else if ( ! f.value.match(reg) )
			{
				alert("Please use proper format for Date of Birth\n\n11-11-1111");
				f.select();
			}
		}
		else if ( t == "zip" )
		{
			if ( f.value.length != 5 )
			{
				alert("Please use proper format for Zip\n\n11111");
				f.select();
			}
		}
		else if ( t == "emp" )
		{
			var reg = /\D\D\D\d{6,}/;
			if ( ! f.value.match(reg) )
			{
				f.value="";
			}
		}
		else if ( t == "dec" )
		{
			var reg = /[0-9]+\.[0-9][0-9]/;
			if ( f.value.indexOf(".") > -1 )
			{
				if ( ! f.value.match(reg) )
				{
					alert("Please use proper format");
					f.select();
				}
			}
			else
			{
				f.value=f.value+".00";
			}
		}
	}
}
function moveSelection(o,n)
{
	o.focus()
	var V = o.value
	o.value = ''
	o.value = V
	var L = n
	if ( o.setSelectionRange )
	{
		o.setSelectionRange(L, L)
	}
	else if ( o.createTextRange )
	{
		var range = o.createTextRange()
		range.collapse(true)
		range.moveEnd('character', L)
		range.moveStart('character', L)
		range.select();
	}
}
function getSelectionStart(o)
{
	if (o.createTextRange)
	{
		var r = document.selection.createRange().duplicate()
		r.moveEnd('character', o.value.length)
		if (r.text == '') return o.value.length
		return o.value.lastIndexOf(r.text)
	}
	else
	{
		return o.selectionStart
	}
}

function getSelectionEnd(o)
{
	if (o.createTextRange) {
		var r = document.selection.createRange().duplicate()
		r.moveStart('character', -o.value.length)
		return r.text.length
	}
	else
	{
		return o.selectionEnd
	}
}
function showDetail(val,id)
{	
	if(val.innerHTML == "+")
	{
		val.innerHTML = "-";
		document.getElementById(id).style.display="block";
	}
	else
	{
		val.innerHTML = "+";
		document.getElementById(id).style.display="none";
	}
	
}
