function MM_reloadPage(init)
{
	//reloads the window if Nav4 resized
	if (init==true) with (navigator) 
	{
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) 
		{
			document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; 
		}
	}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
		location.reload();
}
MM_reloadPage(true);


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_showHideLayers() 
{ //v3.0
	var i,p,v,obj,args=MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3)
	{
		if ((obj=MM_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 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_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];}
}

function P7_autoLayers() 
{ //v1.1 PVII
	var g,b,k,f,args=P7_autoLayers.arguments;
	if(!document.p7setc) {p7c=new Array();document.p7setc=true;}
	for(k=0; k<p7c.length; k++) {
	if((g=MM_findObj(p7c[k]))!=null) {
	b=(document.layers)?g:g.style;b.visibility="hidden";}}
	for(k=0; k<args.length; k++) {
	if((g=MM_findObj(args[k])) != null) {
	b=(document.layers)?g:g.style;b.visibility="visible";f=false;
	for(j=0;j<p7c.length;j++) {
	if(args[k]==p7c[j]) {f=true;}}
	if(!f) {p7c[p7c.length++]=args[k];}}}
}

function MM_nbGroup(event, grpName)
{ //v3.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
	if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
	  img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
	  if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
	  nbArr[nbArr.length] = img;
	  for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
		if (!img.MM_up) img.MM_up = img.src;
		img.src = img.MM_dn = args[i+1];
		nbArr[nbArr.length] = img;
	} }
  } else if (event == "over") {
	document.MM_nbOver = nbArr = new Array();
	for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
	  if (!img.MM_up) img.MM_up = img.src;
	  img.src = (img.MM_dn && args[i+2]) ? args[i+2] : args[i+1];
	  nbArr[nbArr.length] = img;
	}
  } else if (event == "out" ) {
	for (i=0; i < document.MM_nbOver.length; i++) {
	  img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
	if ((nbArr = document[grpName]) != null)
	  for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
	document[grpName] = nbArr = new Array();
	for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
	  if (!img.MM_up) img.MM_up = img.src;
	  img.src = img.MM_dn = args[i+1];
	  nbArr[nbArr.length] = img;
  } }
}

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) 
{
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];

	if((input.value.length >= len && !containsElement(filter,keyCode)))
	{
		input.value = input.value.slice(0, len);
		input.form[(FUN_JSC_V00_GET_Index_01_01(input)+1) % input.form.length].focus();
	}

	function containsElement(arr, ele) 
	{
		var found = false, index = 0;
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
		return found;
	}
	
	function FUN_JSC_V00_GET_Index_01_01(input) 
	{
		var index = -1, i = 0, found = false;
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)
				index = i;
			else i++;
		return index;
	}
	return true;
}




function MM_validateForm() 
{ 	
	//v4.0
	var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3)
	{ 
		test=args[i+1]; 
		val=MM_findObj(args[i]);
		if (val) 
		{
			nm=val.name; 
			if ((val=val.value)!="") 
			{
	  			if (test.indexOf('E')!=-1)
				{
					p=val.indexOf('@');
					if (p<1 || p==(val.length-1))
					{
						errors+='- '+args[i+2]+' must contain a valid e-mail address.\n';
					}
					else
					{
						p = val.indexOf('.')
						if (p<1 || p==(val.length-1))
						{
							errors+='- '+args[i+2]+' must contain a valid e-mail address.\n';
						}
					}										
	  			}
	  			if (test.indexOf('S')!=-1)
				{
	  				if (val.indexOf('As Above') ==-1)
					{
						p=val.indexOf('@');
						if (p<1 || p==(val.length-1))
						{
							errors+='- '+args[i+2]+' must contain a valid e-mail address.\n';
						}
						else
						{
							p = val.indexOf('.')
							if (p<1 || p==(val.length-1))
							{
								errors+='- '+args[i+2]+' must contain a valid e-mail address.\n';
							}
						}										
					}
	  			}
				else if (test=='TN') 
				{
					if (isNaN(val))
						errors+='- '+args[i+2]+' must contain a number.\n';
					if (test.indexOf('inRange') != -1)
					{ 
						p=test.indexOf(':');
		  				min=test.substring(8,p);
						max=test.substring(p+1);
		  				
						if (val<min || max<val) 
							errors+='- '+args[i+2]+' must contain a value between '+min+' and '+max+'.\n';
				  	} 
				}
				else if(test=='T')	// TAW contains '<br>' by default which leads to failed vailidation even if left empty
				{
					if((val=='<br>') || (val=='<br />') || (val=='<br/>') || (val=='<p><br mce_bogus="1"></p>'))
						errors += '- ' + args[i+2] + ' is required.\n';
				}
			}
			else if (test.charAt(0) == 'T')		// 'T' stands for text
			{
				errors += '- ' + args[i+2] + ' is required.\n';
			}
			else if (test.charAt(0) == 'E')		// 'E' stands for email
			{
				errors += '- ' + args[i+2] + ' is required.\n';
			}
			else if (test.charAt(0) == 'S')		// 'S' stands for special
			{
				errors += '- ' + args[i+2] + ' is required.\n';
			}
		}
	}
	if (errors)
	{
		alert('The following error(s) occurred:\n'+errors);
	}
	document.MM_returnValue = (errors == '');
}




function FUN_JSC_V00_PRC_Select_All_01_01(st_Field) 
{
    var st_Temp_Val = eval("document."+st_Field);
    //alert(st_Field);
    //alert(st_Temp_Val);
    
    st_Temp_Val.focus();
    st_Temp_Val.select();
}




function FUN_JSC_V00_PRC_Toggle_BGColor_01_01 (st_ID, st_BGColor)
{
	document.getElementById(st_ID).style.backgroundColor = st_BGColor;
}			




/*
function FUN_JSC_V00_PRC_Validate_Radio_Button_01_01 (st_ID, st_Message)
{
    var nu_Value;
	nu_Value = getInputValue(document.getElementById(st_ID));
//	alert(st_ID);
//	alert(nu_Value);
	
	
	if (nu_Value == null)
	{
	    alert(st_Message);
	    return false;
	}
	else
	{
	    return true;
	}
}			
*/




function FUN_JSC_V00_PRC_Toggle_HYLI_01_01 (st_ID_Disable, st_ID_Enable, st_Class_Restore)
{
    /*Implementation : FUN_JSC_V00_PRC_Toggle_HYLI_01_01 ('A_ID_EXPAND_ALL', 'A_ID_COLLAPSE_ALL', 'HYLI_CS91_FS09_FWNO_01_01');*/ 
    /*Works IN : IE Only*/ 
    //alert(st_ID_Disable);
    //alert(st_ID_Enable);
    
    var st_HYLI_1, st_HYLI_2;

    st_HYLI_1 = document.getElementById(st_ID_Disable);
    st_HYLI_1.className = "HYLI_Disabled";
    st_HYLI_1.disabled = true;
    
    st_HYLI_2 = document.getElementById(st_ID_Enable);
    st_HYLI_2.className = st_Class_Restore;
    st_HYLI_2.disabled = false;
}			




function alertSize() 
{
  var myWidth = 800, myHeight = 600;
  
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE 6+ in 'standards compliant mode'
    //myWidth = document.documentElement.clientWidth;
    //myHeight = document.documentElement.clientHeight;
    
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}




function FUN_JSC_V00_PRC_Text_Limit_01_01(st_Field_Label, nu_Field_Length, nu_Limit_Length) 
{
    //alert(st_Field_Label);
    //alert(nu_Field_Length);
    //alert(nu_Limit_Length);

	if (st_Field_Label.value.length > nu_Limit_Length) 
	{
		st_Field_Label.value = st_Field_Label.value.substring(0, nu_Limit_Length);
	}
	else 
	{
		nu_Field_Length.value = nu_Limit_Length - st_Field_Label.value.length;
	}
}
