  function calendarOnShow()
{
	if (typeof jscalendar_onShow=="function")
	{
		jscalendar_onShow();
	}
}
function calendarOnHide()
{
	if (typeof jscalendar_onHide=="function")
	{
		jscalendar_onHide();
	}
}


function checkboxlist_selectall(name,way)
{
	//alert(document.getElementById(name.length));
	//var rouptmp =  obj.getElementsByTagName("INPUT");
	var inp = document.getElementById(name+'_div').getElementsByTagName("INPUT");
	if (typeof(fieldscounter)!="undefined")
		if(way)fieldscounter=inp.length; else fieldscounter=0;
	for (var d=1;d<=inp.length;d++)
	{
		if (way)
		{
		document.getElementById(name+'_'+d).checked=true;
		document.getElementById(name+'_label_'+d).style.backgroundColor='#0a246a';
		document.getElementById(name+'_label_'+d).style.color='#fff';
		}
		else
		{
			document.getElementById(name+'_'+d).checked=false;
			document.getElementById(name+'_label_'+d).style.backgroundColor='';
			document.getElementById(name+'_label_'+d).style.color='';
		}
	}
	//alert(fieldscounter);
}

function checkboxlist_invert(name)
{
	var inp = document.getElementById(name+'_div').getElementsByTagName("INPUT");
	for (var d=1;d<=inp.length;d++)
	{
		if (document.getElementById(name+'_'+d).checked==true)
		{
			document.getElementById(name+'_'+d).checked=false;
			if (typeof(fieldscounter)!="undefined")fieldscounter--;
			document.getElementById(name+'_label_'+d).style.backgroundColor='';
			document.getElementById(name+'_label_'+d).style.color='';
		}
		else
		{
		document.getElementById(name+'_'+d).checked=true;
		if (typeof(fieldscounter)!="undefined")fieldscounter++;
		document.getElementById(name+'_label_'+d).style.backgroundColor='#0a246a';
		document.getElementById(name+'_label_'+d).style.color='#fff';
		}
	}
}
 function highlight_div(checkbox_node)
{
	alert(0);
	label_node = checkbox_node.parentNode;

    if (checkbox_node.checked)
	{
		label_node.style.backgroundColor='#0a246a';
		label_node.style.color='#fff';
	}
	else
	{
		label_node.style.backgroundColor='#fff';
		label_node.style.color='#000';
	}
}

function documenT_print()
	{
		window.print();
	}
function form_submit() 
	{ 
		document.forms[0].submit();
	}	
	
function form_reset()
	{
		document.forms[0].reset();
	}
function newwin(url,w,h,scrl)
	{
	screenleft=(screen.width/2)-(w/2);
	screentop=(screen.height/2)-(h/2);
				
	if (window.win!=null)
		{
	 		window.win.close();
			win=window.open(url,"winnd","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scrl+",resizeable=0,width="+w+",height="+h+",top="+screentop+",left="+screenleft)
		} 
			else
		{
				win=window.open(url,"winnd","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+scrl+",resizeable=0,width="+w+",height="+h+",top="+screentop+",left="+screenleft)
	 	}
	}
			
			
function newimagewin(image,w,h,title)
			{
				screenleft=(screen.width/2)-(w/2);
				screentop=(screen.height/2)-(h/2);
				

						win=window.open("","winnd","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizeable=0,width="+w+",height="+h+",top="+screentop+",left="+screenleft);
						window.win.document.writeln("<TITLE>"+title+"</TITLE>");
						window.win.document.writeln("<BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>");
						window.win.document.writeln("<DIV ID='Layer1' STYLE='position:absolute; left:0; top:0; width:100%; height:10; z-index:1'>");
  						window.win.document.writeln("<DIV ALIGN='RIGHT' CLASS='Text-Regular'><img STYLE='cursor:hand' SRC='../ew_images/close.gif' WIDTH='44' HEIGHT='20' onClick='window.close();'></DIV>");
						window.win.document.writeln("</DIV>");
						window.win.document.writeln("<img src=../ew_images/"+image+">");
						window.win.document.writeln("</BODY>");
						
			}
			
function Validator(f,otitle,re,eMsg,ru,r,divid){// Internal function for 'validate'
	//var f = eval("document.forms[0]."+f);
	var myErr="";
	var fv=f.value;
	var rex=new RegExp(unescape(re));
	var t=eval(ru+rex.test(fv));

		if(f.value.length <=0 ||!t)
		{
			document.getElementById(divid).innerHTML = "<FONT COLOR='#FF0000'>"+ eMsg+"</FONT>";
			document.forms[0].haserror.value = parseInt(document.forms[0].haserror.value) - 1;
			//alert("HasError - 1: "+ErrorMessage);
			ErrorMessage=(ErrorMessage+"\n - "+otitle+": "+eMsg);
		}
	else 
			document.getElementById(divid).innerHTML ='';
			//document.forms[0].haserror.value = parseInt(document.forms[0].haserror.value) + 1;
			//alert("HasError + 1: "+document.forms[0].haserror.value);
	
	}
<!--

function validate (obj,type,objtitle,req,ErrMsg)
{
//alert('Validate');

var form = document.forms[0];
var	obj = obj;							//Object name
var	type = type;						//Object Type
var	divid = "div_"+obj.name;			//Div Name where error message will be shoun
var	req = req;							//Object Required (Y/N)
var objtitle = objtitle; 				//Object Title for error message
var	ErrMsg = ErrMsg;					//Error Message	

	
if (type == 'email')
	{
	if (!ErrMsg)
		{
			ErrMsg='Enter a valid email address';
		}
	if (req == 'y')
		{
			Validator(obj,objtitle,'%5E%5B%5Cw%5C.=-%5D%2B@%5B%5Cw%5C.-%5D%2B%5C.%5Ba-z%5D%7B2,3%7D$',ErrMsg,'','1',divid);
		}
		else
		{
			if (obj.value != "")
				{
					Validator(obj,objtitle,'%5E%5B%5Cw%5C.=-%5D%2B@%5B%5Cw%5C.-%5D%2B%5C.%5Ba-z%5D%7B2,3%7D$',ErrMsg,'','1',divid);
				}
				else
				{
					document.getElementById(divid).innerHTML ='';
				}
		}
	}
	
	
if (type == 'phone')
	{
	if (!ErrMsg)
		{
			ErrMsg='Enter a valid phone number';
		}
	if (req == 'y')
		{
			Validator(obj,objtitle,'%5E(%5Cd%7B10%7D|%5Cd%7B3%7D-%5Cd%7B3%7D-%5Cd%7B4%7D|%5C(%5Cd%7B3%7D%5C)%5Cs*%5Cd%7B3%7D-%5Cd%7B4%7D)$',ErrMsg,'','1',divid);	

		}
		else
		{
			if (obj.value != "")
				{
					Validator(obj,objtitle,'%5E(%5Cd%7B10%7D|%5Cd%7B3%7D-%5Cd%7B3%7D-%5Cd%7B4%7D|%5C(%5Cd%7B3%7D%5C)%5Cs*%5Cd%7B3%7D-%5Cd%7B4%7D)$',ErrMsg,'','1',divid);	

				}
				else
				{
					document.getElementById(divid).innerHTML ='';
				}
		}
	}
	
	
if (type == 'password')
	{
	var re = /^[A-Za-z]\w{6,}[A-Za-z]$/; // Version 1 - password must be at least 8 characters long and start and end with a letter
	//var re = /^\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*$/	// Version 2 - length doesn't matter, but the password must contain at least 1 number, at least 1 lower case letter, and at least 1 upper case letter. 

	if (!ErrMsg)
		{
			ErrMsg='Enter a valid password';
		}
		if (!re.test(obj.value)) 
			{  
				document.getElementById(divid).innerHTML = "<FONT COLOR='#FF000'>"+ ErrMsg+"</FONT>";
				document.forms[0].haserror.value = parseInt(document.forms[0].haserror.value) - 1;
				ErrorMessage=(ErrorMessage+"\n - "+objtitle+": "+ErrMsg);
			}
		else
			{
				document.getElementById(divid).innerHTML ='';			
			}	
	}

if (type == 'any')
	{
//	alert('any');
	if (!ErrMsg)
		{
			ErrMsg=objtitle+" must not be empty";
		}
		if (obj.value == "") 
			{  
				document.getElementById(divid).innerHTML = "<FONT COLOR='#FF0000'>"+ ErrMsg+"</FONT>";
				document.forms[0].haserror.value = parseInt(document.forms[0].haserror.value) - 1;
				ErrorMessage=(ErrorMessage+"\n - "+objtitle+": "+ErrMsg);
			}
		else
			{
				document.getElementById(divid).innerHTML ='';			
			}	
	}

}// And of the Validate


function documenT_back()
{
	window.history.back();
}
function documenT_forward()
{
	window.history.forward();
}	
function documenT_refresh()
{
	var sURL = unescape(window.location.pathname);
    window.location.replace( sURL );
}		
function fullscreen()
{
	window.moveTo(0,0);
	window.resizeTo(screen.width,screen.height);
}

var dat = "";
var error="none";
var days = new Array(31,29,31,30,31,30,31,31,30,31,30,31);
function errorMessage(message)
{
	if (message != "none")
	{
		document.getElementById('dateerror').innerHTML = "<FONT COLOR='#ff000'>"+ message+"</FONT>";
		error = "yes";
	}else{
		document.getElementById('dateerror').innerHTML = "";
		error = "none";
	}
}
function DateMask (key, obj)
{
dat = obj.value;
//alert("Dat: "+dat);
	if (key==9)return true; // Tab
	else if (key==220 || key==32 || key==191 || key==189 || key==190 || key==16) // Delimetr
		{
			if (dat.length == 1)dat="0"+dat+"-";
			if (dat.length == 4)
				{
		   			dat1 = dat.substring(0,2);dat2 = dat.substring(3,4);dat=dat1+"-0"+dat2+"-";
				}	  
			obj.value = dat;
			}
        else if (key==8&&dat.length!=0)
			{
				
				dat = dat.substring(0,dat.length-1);//BackSpace
				obj.value = dat;
			}
		else if (((key>47&&key<58)||(key>95&&key<106))&& dat.length<10)
			{
				(key<58)?(keyf = key):(keyf = key-48);
				(dat.length != 2 && dat.length != 5)?dat=dat+String.fromCharCode(keyf):dat=dat+"-"+String.fromCharCode(keyf);
				if (dat.length <=2 && dat >12)
				{
					errorMessage("Month should be between 1 and 12");
					dat = dat.substring(0,1);
				}else errorMessage("none");
				if (dat.length ==5 && dat.substring(3,dat.length)>days[dat.substring(0,2)-1])
				{
					errorMessage("Day should be between 1 and "+days[dat.substring(0,2)-1]);
					dat = dat.substring(0,4);
				}
				if (dat.length == 2 )dat = dat+"-";
				if (dat.length == 5)dat = dat+"-";
				obj.value = dat;
          	}
		return false;
}
function log_out(way,backto)
{
	if (way == 'ie')
	{
	if (backto == null)var backto = 'index.cfm';
	ht = document.getElementsByTagName("body");
	ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
	if (confirm('Are you sure?'))
	{
		window.location='logout.cfm?returnto='+backto;
	}
	else
	{
		ht[0].style.filter = "";
		//return false;
	}
	}
	else
	{
		window.location='logout.cfm';
	}
}
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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}
    
	// DIV.JS Must be connected first
function ServiceMessage(title,context)
	{
		ht = document.getElementsByTagName("table");
		ht[0].style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
		Over.className = "Obj-Show";
		Over.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='ew_images/opacity20.png');";
		document.body.scroll = "no";
		DHTMLService.UpdateTitleBarHTML(title);
		var message = "<TABLE WIDTH=270 BORDER=0 CELLSPACING=1 CELLPADDING=1><TR><TD WIDTH=1>";
		message +='<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" WIDTH="110" HEIGHT="90">';
  		message +='	<PARAM NAME="movie" VALUE="ew_swf/services.swf">';
  		message +='	<PARAM NAME="quality" VALUE="high">';
 		message +='	<EMBED SRC="ew_swf/services.swf" QUALITY="high" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" TYPE="application/x-shockwave-flash" WIDTH="110" HEIGHT="90"></EMBED>';
		message +='	</OBJECT>';
		message +="</TD><TD WIDTH=269><DIV ALIGN='CENTER' CLASS='Text-Regular'>";
		message += context;
		message += "</DIV></TD></TR></TABLE>";
		DHTMLService.UpdateContentHTML(message);
		DHTMLService.OpenWindow();
    }
	
function syspause(Amount)
{
d = new Date() //today's date
while (1)
{
mill=new Date() // Date Now
diff = mill-d //difference in milliseconds
if( diff > Amount ) {break;}
}
}

//////////////////////////////  DEBUG
// Show the debug window

var debugMessagesCounter = 0;

function EncodeHTML(str) { 
str = str.replace(/&/g, "&amp;"); 
str = str.replace(/</g, "&lt;"); 
str = str.replace(/>/g, "&gt;"); 
str = str.replace(/\x22/g, "&quot;"); 
str = str.replace(/\x27/g, "&#39"); 
str = str.replace(/\x2c/g, "&#44"); 
str=str.replace(/\xA0/g, "&nbsp;"); 
str=str.replace(/\xA1/g, "&iexcl;"); 
str=str.replace(/\xA2/g, "&cent;"); 
str=str.replace(/\xA3/g, "&pound;"); 
str=str.replace(/\xA4/g, "&curren;"); 
str=str.replace(/\xA5/g, "&yen;"); 
str=str.replace(/\xA6/g, "&brvbar;"); 
str=str.replace(/\xA7/g, "&sect;"); 
str=str.replace(/\xA8/g, "&uml;"); 
str=str.replace(/\xA9/g, "&copy;"); 
str=str.replace(/\xAA/g, "&ordf;"); 
str=str.replace(/\xAB/g, "&laquo;"); 
str=str.replace(/\xAC/g, "&not;"); 
str=str.replace(/\xAD/g, "&shy;"); 
str=str.replace(/\xAE/g, "&reg;"); 
str=str.replace(/\xAF/g, "&macr;"); 
str=str.replace(/\xB0/g, "&deg;"); 
str=str.replace(/\xB1/g, "&plusmn;"); 
str=str.replace(/\xB2/g, "&sup2;"); 
str=str.replace(/\xB3/g, "&sup3;"); 
str=str.replace(/\xB4/g, "&acute;"); 
str=str.replace(/\xB5/g, "&micro;"); 
str=str.replace(/\xB6/g, "&para;"); 
str=str.replace(/\xB7/g, "&middot;"); 
str=str.replace(/\xB8/g, "&cedil;"); 
str=str.replace(/\xB9/g, "&sup1;"); 
str=str.replace(/\xBA/g, "&ordm;"); 
str=str.replace(/\xBB/g, "&raquo;"); 
str=str.replace(/\xBC/g, "&frac14;"); 
str=str.replace(/\xBD/g, "&frac12;"); 
str=str.replace(/\xBE/g, "&frac34;"); 
str=str.replace(/\xBF/g, "&iquest;"); 
str=str.replace(/\xC0/g, "&Agrave;"); 
str=str.replace(/\xC1/g, "&Aacute;"); 
str=str.replace(/\xC2/g, "&Acirc;"); 
str=str.replace(/\xC3/g, "&Atilde;"); 
str=str.replace(/\xC4/g, "&Auml;"); 
str=str.replace(/\xC5/g, "&Aring;"); 
str=str.replace(/\xC6/g, "&AElig;"); 
str=str.replace(/\xC7/g, "&Ccedil;"); 
str=str.replace(/\xC8/g, "&Egrave;"); 
str=str.replace(/\xC9/g, "&Eacute;"); 
str=str.replace(/\xCA/g, "&Ecirc;"); 
str=str.replace(/\xCB/g, "&Euml;"); 
str=str.replace(/\xCC/g, "&Igrave;"); 
str=str.replace(/\xCD/g, "&Iacute;"); 
str=str.replace(/\xCE/g, "&Icirc;"); 
str=str.replace(/\xCF/g, "&Iuml;"); 
str=str.replace(/\xD0/g, "&ETH;"); 
str=str.replace(/\xD1/g, "&Ntilde;"); 
str=str.replace(/\xD2/g, "&Ograve;"); 
str=str.replace(/\xD3/g, "&Oacute;"); 
str=str.replace(/\xD4/g, "&Ocirc;"); 
str=str.replace(/\xD5/g, "&Otilde;"); 
str=str.replace(/\xD6/g, "&Ouml;"); 
str=str.replace(/\xD7/g, "&times;"); 
str=str.replace(/\xD8/g, "&Oslash;"); 
str=str.replace(/\xD9/g, "&Ugrave;"); 
str=str.replace(/\xDA/g, "&Uacute;"); 
str=str.replace(/\xDB/g, "&Ucirc;"); 
str=str.replace(/\xDC/g, "&Uuml;"); 
str=str.replace(/\xDD/g, "&Yacute;"); 
str=str.replace(/\xDE/g, "&THORN;"); 
str=str.replace(/\xDF/g, "&szlig;"); 
str=str.replace(/\xE0/g, "&agrave;"); 
str=str.replace(/\xE1/g, "&aacute;"); 
str=str.replace(/\xE2/g, "&acirc;"); 
str=str.replace(/\xE3/g, "&atilde;"); 
str=str.replace(/\xE4/g, "&auml;"); 
str=str.replace(/\xE5/g, "&aring;"); 
str=str.replace(/\xE6/g, "&aelig;"); 
str=str.replace(/\xE7/g, "&ccedil;"); 
str=str.replace(/\xE8/g, "&egrave;"); 
str=str.replace(/\xE9/g, "&eacute;"); 
str=str.replace(/\xEA/g, "&ecirc;"); 
str=str.replace(/\xEB/g, "&euml;"); 
str=str.replace(/\xEC/g, "&igrave;"); 
str=str.replace(/\xED/g, "&iacute;"); 
str=str.replace(/\xEE/g, "&icirc;"); 
str=str.replace(/\xEF/g, "&iuml;"); 
str=str.replace(/\xF0/g, "&eth;"); 
str=str.replace(/\xF1/g, "&ntilde;"); 
str=str.replace(/\xF2/g, "&ograve;"); 
str=str.replace(/\xF3/g, "&oacute;"); 
str=str.replace(/\xF4/g, "&ocirc;"); 
str=str.replace(/\xF5/g, "&otilde;"); 
str=str.replace(/\xF6/g, "&ouml;"); 
str=str.replace(/\xF7/g, "&divide;"); 
str=str.replace(/\xF8/g, "&oslash;"); 
str=str.replace(/\xF9/g, "&ugrave;"); 
str=str.replace(/\xFA/g, "&uacute;"); 
str=str.replace(/\xFB/g, "&ucirc;"); 
str=str.replace(/\xFC/g, "&uuml;"); 
str=str.replace(/\xFD/g, "&yacute;"); 
str=str.replace(/\xFE/g, "&thorn;"); 
str=str.replace(/\xFF/g, "&yuml;"); 
str=str.replace(/\x20AC/g, "&euro;"); 
//document.forms[0].memo.value=str;
return str;
}


function showDebug() {
  window.top.debugWindow = window.open("","Debug","left=0,top=0,width=350,height=700,scrollbars=yes,status=yes,resizable=yes");
  window.top.debugWindow.opener = self;
  // open the document for writing
  window.top.debugWindow.document.open();
  window.top.debugWindow.document.write("<HTML><HEAD><TITLE>Debug Window</TITLE></HEAD><BODY><PRE>\n");
}

// If the debug window exists, then write to it
function jsdebug(text,color) {
	debugMessagesCounter++;
	if(debugMessagesCounter<10)debugMessagesCounter_STR = "000"+debugMessagesCounter;
	if(debugMessagesCounter>10 && debugMessagesCounter<100)debugMessagesCounter_STR = "00"+debugMessagesCounter;
	if(debugMessagesCounter>100 && debugMessagesCounter<1000)debugMessagesCounter_STR = "0"+debugMessagesCounter;
	if(debugMessagesCounter>1000)debugMessagesCounter_STR = debugMessagesCounter;
	if(color)text="<FONT COLOR='"+color+"'>"+text+"</FONT>";
  	if (window.top.debugWindow && ! window.top.debugWindow.closed) {
    window.top.debugWindow.document.write("<FONT COLOR='#999999'>"+EncodeHTML(debugMessagesCounter_STR)+"</FONT>   "+text+"\n");
	window.top.debugWindow.scroll(0,window.top.debugWindow.document.body.scrollHeight);
	
  }
}

// If the debug window exists, then close it
function hideDebug() {
  if (window.top.debugWindow && ! window.top.debugWindow.closed) {
    window.top.debugWindow.close();
    window.top.debugWindow = null;
  }
}

 if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function browser_detect() {
   var ua = navigator.userAgent.toLowerCase(); 

   // browser engine name
   this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
   this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

   // browser name
   this.isKonqueror   = (ua.indexOf('konqueror') != -1); 
   this.isSafari      = (ua.indexOf('safari') != - 1);
   this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
   this.isOpera       = (ua.indexOf('opera') != -1); 
   this.isIcab        = (ua.indexOf('icab') != -1); 
   this.isAol         = (ua.indexOf('aol') != -1); 
   this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) ); 
   this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
   this.isFirebird    = (ua.indexOf('firebird/') != -1);
   this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
   
   // spoofing and compatible browsers
   this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
   this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);
   
   // rendering engine versions
   this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
   this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
   this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );
   
   // browser version
   this.versionMinor = parseFloat(navigator.appVersion); 
   
   // correct version number
   if (this.isGecko && !this.isMozilla) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
   }
   else if (this.isMozilla) {

      this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
   }
   else if (this.isIE && this.versionMinor >= 4) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
   }
   else if (this.isKonqueror) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
   }
   else if (this.isSafari) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
   }
   else if (this.isOmniweb) {
      this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
   }
   else if (this.isOpera) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
   }
   else if (this.isIcab) {
      this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
   }
   
   this.versionMajor = parseInt(this.versionMinor); 
   
   // dom support
   this.isDOM1 = (document.getElementById);
   this.isDOM2Event = (document.addEventListener && document.removeEventListener);
   
   // css compatibility mode
   this.mode = document.compatMode ? document.compatMode : 'BackCompat';

   // platform
   this.isWin    = (ua.indexOf('win') != -1);
   this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
   this.isMac    = (ua.indexOf('mac') != -1);
   this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
   this.isLinux  = (ua.indexOf('linux') != -1);
   
   // specific browser shortcuts
   this.isNS4x = (this.isNS && this.versionMajor == 4);
   this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
   this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
   this.isNS4up = (this.isNS && this.versionMinor >= 4);
   this.isNS6x = (this.isNS && this.versionMajor == 6);
   this.isNS6up = (this.isNS && this.versionMajor >= 6);
   this.isNS7x = (this.isNS && this.versionMajor == 7);
   this.isNS7up = (this.isNS && this.versionMajor >= 7);
   
   this.isIE4x = (this.isIE && this.versionMajor == 4);
   this.isIE4up = (this.isIE && this.versionMajor >= 4);
   this.isIE5x = (this.isIE && this.versionMajor == 5);
   this.isIE55 = (this.isIE && this.versionMinor == 5.5);
   this.isIE5up = (this.isIE && this.versionMajor >= 5);
   this.isIE6x = (this.isIE && this.versionMajor == 6);
   this.isIE6up = (this.isIE && this.versionMajor >= 6);
   
   this.isIE4xMac = (this.isIE4x && this.isMac);
}
var browser = new browser_detect();



 // Function for highlight selected line in the checkbox list.
 function highlight_div(checkbox_node)
{
	label_node = checkbox_node.parentNode;

    if (checkbox_node.checked)
	{
		label_node.style.backgroundColor='#0a246a';
		label_node.style.color='#fff';
	}
	else
	{
		label_node.style.backgroundColor='#fff';
		label_node.style.color='#000';
	}
}



/*
Show/Hide, Enable/Disable dependent on checkbox objects
obj 		- Checkbox to check
targetlist 	- List of ID's of dependent objects
status		- Switch function to Enable/Disable mode. Defult is Show/Hide mode. Value 'false' for Show/Hide and 'true' for Enable/Disable
way			- Validate if IS or ISNOT (true|false)
focusto		- if checked send focus to #focusto#

Example:	
	<INPUT 
	TYPE='checkbox' 
	NAME = 'chkbox' 
	ID='chkbox' 
	onClick = 'e_chkbox_showhide(this,'First_Name,Last_Name',1,true,'First_Name')'>
	<INPUT TYPE="text" NAME="First_Name" ID="First_Name">
	<INPUT TYPE="text" NAME="Last_Name" ID="Last_Name">
*/
function e_chkbox_showhide(obj,targetlist,status,way,focusto)
{
	var form = window.document.forms[0];
	var objlist = targetlist.split(",");
	if (way==null) way = true;
	if (status==null) status = false;
	for (var a =0;a<objlist.length;a++)
	_applyChanges(document.getElementById(objlist[a]),way,status,obj.checked)
	if (focusto && obj.checked)_setFocus(focusto)
}


/*
Show/Hide, Enable/Disable dependent on radiogroup objects
obj 		- Current Radiobutton
values		- List of values to check for.
targetlist 	- List of ID's of dependent objects
status		- Switch function to Enable/Disable mode. Defult is Show/Hide mode. Value 'false' for Show/Hide and 'true' for Enable/Disable
way			- Validate if IS or ISNOT (true|false)
focusto		- if checked send focus to #focusto#


Example:	
    <INPUT TYPE="radio" NAME="but1" ID="but1" VALUE="Yes" onClick="e_radio_showhide(this,'yes','First_Name,Last_Name',false,true)" >
    <INPUT TYPE="radio" NAME="but2" ID="but2" VALUE="No" onClick="e_radio_showhide(this,'yes','First_Name,Last_Name',false,true)" CHECKED>

	<INPUT TYPE="text" NAME="First_Name" ID="First_Name">
	<INPUT TYPE="text" NAME="Last_Name" ID="Last_Name">
*/
function e_radio_showhide(obj,values,targetlist,status,way,focusto)
{
	var id = obj.id;
	var value = values.split(",");
	var target = targetlist.split(",");
	var mCounter = false;
	if (way==null) way = true;
	if (status==null) status = false;
	if (!obj.id) id = obj.name;
	for (var i=0;i < eval("document.forms[0]."+obj.name).length; i++)
		for (var s=0;s<value.length;s++)
			if(eval("document.forms[0]."+obj.name)[i].value.toUpperCase() == value[s].toUpperCase() && eval("document.forms[0]."+obj.name)[i].checked)
				mCounter=true;
	for (var a=0;a<target.length;a++)
		_applyChanges(document.getElementById(target[a]),way,status,mCounter)
	if (focusto && mCounter)_setFocus(focusto)
}


function e_select_showhide(obj,values,targetlist,status,way,focusto)
{
	var id = obj.id;
	var value = values.split(",");
	var target = targetlist.split(",");
	var mCounter = false;
	if (way==null) way = true;
	if (status==null) status = false;
	if (!obj.id) id = obj.name;
		for (var s=0;s<value.length;s++)
			if(obj.options[obj.selectedIndex].value.toUpperCase() == value[s].toUpperCase())
				mCounter=true;
	for (var a=0;a<target.length;a++)
		_applyChanges(document.getElementById(target[a]),way,status,mCounter)
	if (focusto && mCounter)_setFocus(focusto)
}


function jumpswitch(obj,value,target,func,way)
// obj- Object
// value- value to compare with
// target- list of dependent objects
// func- show - Show/Hide dependent object | Enabled- Enabled/Disabled dependent object
// way- is/isnot To run object. value = value or object. value != value
{
//alert(obj.options[obj.selectedIndex].value);
var objlist = target.split(",");
var form = window.document.forms[0];
(way == 'is' || way == null)?pass="==":pass="!=";
	if (func == "show" || func == null){
		for (var i =0;i<objlist.length;i++){
		//(eval("obj.options[obj.selectedIndex].value "+pass+" value"))?eval(objlist[i]).className = "obj-Show":eval(objlist[i]).className = "obj-Hide";
		if(eval("obj.options[obj.selectedIndex].value "+pass+" value"))
		eval(objlist[i]).className = "obj-Show";
		else
		{		
		eval(objlist[i]).className = "obj-Hide";
	     //nField.value ="";		
		}		
		}
	}
	else
	{
		for (var a =0;a<objlist.length;a++)
		{
		if (eval("obj.options[obj.selectedIndex].value "+pass+" value"))
			{
				eval("document."+window.document.forms[0].name+"."+objlist[a]).disabled = false;
			}
			else
			{
				eval("document."+window.document.forms[0].name+"."+objlist[a]).disabled = true;
			}
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal Function
function _applyChanges(obj,way,status,onoff)
{
	var disp , vis , css , dis;
	(way)?mark = "":mark="!";
	if	(browser.isIE)
		(eval(mark+"onoff"))?disp = "block":disp = "none";
	else
		(eval(mark+"onoff"))?disp = "table-row":disp = "none";
	(eval(mark+"onoff"))?vis = "visible":vis = "hidden";
	(eval(mark+"onoff"))?css = "Obj-Show":css = "Obj-Hide";
	(eval(mark+"onoff"))?dis = false:dis = true;
	
	if (!status)
		if (obj.className.toUpperCase() == 'OBJ-HIDE' || obj.className.toUpperCase() == 'OBJ-SHOW')
			obj.className = css;
		else
			{
			document.getElementById(obj.id).style.visibility=vis;
			document.getElementById(obj.id).style.display = disp;
			}
	else obj.disabled = dis;
}

// Internal Function, set focus for an Object
function _setFocus(obj)
{
	var passTest = true;
	if(obj.offsetWidth) passTest = false;
	if(document.getElementById(obj).disabled) passTest = false;
	if (passTest)document.getElementById(obj).focus();
}