<!--
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];}
}
//-->

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;
	
	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	} //End While
	return strTemp;

} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function checkForBlank(ctr, msg)
{
	if(Trim(ctr.value)=='')
	{
		alert("Please insert the "+msg);
		ctr.focus();
		return true;
	}
	else return false;
}
function checkPassword(ctr)
{
	if(Trim(ctr.value)=='')
	{
		alert("Please insert the Password.");
		ctr.focus();
		return true;
	}
	var numaric = ctr.value;
	if(numaric.length<8){
		alert("Invalid Password. Must have at least 8 characters and contain letters AND numbers.");
		ctr.focus();
		return true;
	}
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 	alert("Invalid Password. Must have at least 8 characters and contain letters AND numbers.");
				ctr.focus();
				return true;
		  }
		}
 return false;
}
/*
function checkPassword(ctr) //Constrain password: must be alphanumeric and contain at least 8 chars
{
	
	if(Trim(ctr.value)=='')
	{
		alert("Please insert the Password.");
		ctr.focus();
		return true;
	}
	
	//var re = /^(?=.*\d)(?=.*[A-Za-z])\w{7,}$/;
	var re = /^(.*\d)(.*[A-Za-z])\w{7,}$/;
	if (!re.test(ctr.value)) 
	{ 
		alert("Invalid Password. Must have at least 8 characters and contain letters AND numbers.");
		ctr.focus();
		return true;	
	}	
	
	else return false;
}
*/
function isEmailAddr(ctr)
{
  var result = true;
  var theStr = new String(ctr.value)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = false;
  }
  if(result==true){
	  alert("Please enter a complete email address in the form: yourname@yourdomain.com");
	  ctr.focus();
  }
  return result;
}

function checkNAN(ctr, msg){  // Number field validation
 	var result = true;
	var txt_num = new String(ctr.value)

	var x=txt_num
	if(ctr.value!=''){
		var anum=/(^\d+$)|(^\d+\.\d+$)/
		if (anum.test(x))
			result=false
		else{
			alert('Please input a valid number for '+ msg +'!');
			ctr.focus();		
			result=true
		}
	}
	else{
		result=false
	}
	return (result)
}

function checkForSelection(ctr, msg,default_index){  // List field validation
	if(!default_index) default_index=0;
	result=false;
	if(ctr.selectedIndex==default_index){
		alert('Please select a '+ msg +'!');
		ctr.focus();
		result=true;
	}
	return result;
}	

function checkForCheck(ctr, msg){  // List field validation
	result=false;
	if(!ctr.checked){
		alert(msg +'!');
		ctr.focus();
		result=true;
	}
	return result;
}	
function checkForRCheck(ctr, msg){  // List field validation
	var radio_choice = false;

	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < ctr.length; counter++)
	{
	// If a radio button has been selected it will return true
	// (If not it will return false)
		if (ctr[counter].checked)
			radio_choice = true; 
	}
	
	if (!radio_choice)
	{
		// If there were no selections made display an alert box 
		alert(msg +'!');
		return (true);
	}
	return (false);
}

function pw_retype(ctr1, ctr2){  //password retype checking
	result=false;
	if(ctr1.value!=ctr2.value){
		alert('Password And Confirm Password should be same');
		ctr2.focus();
		result=true;
	}
	return result;
}

function fld_confirm(ctr1, ctr2, str){  //password retype checking
	result=false;
	if(ctr1.value!=ctr2.value){
		alert(str+' And Confirm '+str+' should be same');
		ctr2.focus();
		result=true;
	}
	return result;
}


function len_check(ctr, msg, ln){  //check for min. length
	if(ln==null) ln = 6;
	var theStr = new String(Trim(ctr.value));
	if(theStr.length<ln)
	{
		alert("Please enter atleast " + ln + " characters for "+msg);
		ctr.focus();
		return true;
	}
	return false;
}
function len_check1(ctr, msg, ln){  //check for min. length
	var theStr = new String(Trim(ctr.value));
	if(theStr.length<ln)
	{
		alert("Please enter " + ln + " characters for "+msg);
		ctr.focus();
		return true;
	}
	return false;
}

//----------------
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(ctr, date_fmt, msg){
	var dtCh= "-";
	var minYear=1900;
	var maxYear=2100;	
	var dtStr = new String(ctr.value)
	var daysInMonth = new DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strYear=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strDay=dtStr.substring(pos2+1)
	if(!date_fmt){
		var date_fmt="dd-mm-yyyy";
	}
	if(date_fmt=="mm-dd-yyyy"){
		var strMonth=dtStr.substring(0,pos1)
		var strDay=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
	}
	else if(date_fmt=="dd-mm-yyyy"){
		var strDay=dtStr.substring(0,pos1)
		var strMonth=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
	}

	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert('The '+ msg +' format should be : yyyy-mm-dd')
		return true
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert('Please enter a valid 4 digit year between '+minYear+' and '+maxYear + ' for '+ msg)
		return true
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert('Please enter a valid month for '+ msg)
		return true
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert('Please enter a valid day for '+ msg)
		return true
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert('Please enter a valid date for '+ msg)
		return true
	}
return false
}

function image_preview(scr_ctr,disp_ctr,img_dir) //image display
  {  
  	if(!img_dir){
		img_dir='';
	}
	var filename = scr_ctr.value;
	var Img = new Image();
	/*if (navigator.appName == "Netscape")
	{
	  alert("Previews do not work in Netscape.");
	}
	else
	{*/
	  Img.src = img_dir+filename;
	  disp_ctr.src = Img.src;
	//}
  }
  
function newwindow(win_name,win_title,width,height,scrollbar) 
{ 
window.open(win_name,win_title,'width='+width+',height='+height+',scrollbars='+scrollbar); 
} 

