function validation_message(divid,message,top_position,left_position,left_text_position)
{
    if(top_position=='' || top_position==undefined){
        top_position='19';
    }if(left_position=='' || left_position==undefined){
        left_position='35';
    }if(left_text_position=='' || left_text_position==undefined){
        left_text_position='57';
    }
	
    document.getElementById(divid).innerHTML = '<div style="position:absolute; top:-'+top_position+'px; left:'+left_position+'px;"><img src="images/error-icon.gif"></div><div style="position:absolute; top:0px;left:'+left_text_position+'px;">'+message+'</div>'
}
function validation_message_applynow(divid,message,top_position)
{
    if(top_position=='' || top_position==undefined){
        top_position='19';
    }
    document.getElementById(divid).innerHTML = '<div style="position:absolute; top:-'+top_position+'px; left: -18px;"><img src="images/error-icon.gif"></div>'+message;
}
function validation_message_without_image(divid,message)
{
    document.getElementById(divid).innerHTML = message;
}
function validation_image(divid,top_position)
{
    if(top_position=='' || top_position==undefined){
        top_position='17';
    }
    document.getElementById(divid).innerHTML = '<div style="position:absolute; top:-'+top_position+'px; left: -18px;"><img src="images/error-icon.gif"></div>';
}
function reset_errmessages(divid_arr){
    for(j=0;j<divid_arr.length;j++){
        document.getElementById(divid_arr[j]).innerHTML = '';
		document.getElementById(divid_arr[j]).style.height = '0px';
    }
}
function inputvalidation_red(val)
{
    document.getElementById(val).className = 'input-red';
}
function validation_height(val,width)
{
	if(val == 'errmsg_loanamo')
    	document.getElementById(val).style.height = "20px";
	else
		document.getElementById(val).style.height = "15px";
	if(width=='yes'){
        document.getElementById(val).style.width = "200px";
    }
}
function selecterrorvalidation_red(val)
{
    ////document.getElementById(val).className = 'error-select';
}
function errorvalidation_red(val)
{
    document.getElementById(val).className = 'error-input';
}
function resetstyle(frm)
{    
    var n = frm.elements.length;
	for(var i=0;i<n;i++)
	{
		var id = frm.elements[i].id;
        if(id != ""){
            inputvalidation(id);
        }
	}
}

function inputvalidation(val)
{
    document.getElementById(val).className = 'input';
}

function resetstyle_application(frm)
{    
    var n = frm.elements.length;
	for(var i=0;i<n;i++)
	{
		var id = frm.elements[i].id;
        if(id != ""){
            applyinputvalidation(id);
        }
	}
}

function applyinputvalidation(val)
{
    document.getElementById(val).className = 'apply-input';
}

function remove_space(events)
{
	val = events.charCode? events.charCode :events.keyCode;
	if(val == "32")
		return false;
	else
		return true;
}

function openthinkbox(url,querystring,title,width,height)
{
	var u = url+"?"+querystring+"&keepThis=false&TB_iframe=false&height="+height+"&width="+width;	
	var t = title;
	var g = null;	
	TB_show(t, u, g);
	
	if(document.getElementById("bReset"))
		document.getElementById("bReset").focus();
	return false;
}


function checkValidDigit_modifycode(events)
{ 	
	var unicodes=events.charCode? events.charCode :events.keyCode;
	if(unicodes > 47 && unicodes < 58 )
	   return true;
	else if(unicodes == '46' || unicodes == '9')
		return true;
	else if(unicodes == '8')
		return true;
	else
		return false;
}
function popwindow(val)
{
	window.open('newsletter.php?iNewsTId='+val, 'pollwindow','status=no, toolbars=no, width=805, height=450,top=50,left=100, resizable=yes');
}
function popwindow_newsletter(val)
{
	window.open('newsletter.php?iNewsTId='+val, 'pollwindow','status=no, toolbars=no, width=805, height=550,top=50,left=100, resizable=yes');
}

function popwindow_static_Page(val)
{
	window.open('static_page_popup.php?iCPageId='+val, 'pollwindow','status=yes, scrollbars=yes,  toolbars=yes, width=805, height=450,top=50,left=100, resizable=yes');
}
function bulmailwindow(val)
{
	window.open('sendmail.php?iMemberId='+val, 'pollwindow','status=no, toolbars=no, width=560, height=540,top=50,left=100, resizable=yes');
}

function checkValidNumber()
{
	val = event.keyCode;
	if(val<48)
	  event.keyCode=0;
	if(val>57)
	  event.keyCode=0;
	return true;
}
function checkValidPhoneFormat(events,msg)
{
	var val = events.charCode? events.charCode :events.keyCode;
	if((val <48 && val!=46 && val!=43 && val!=45 && val!=13) || val>57)
	{
		if(val == 8 && msg != "")
		{
			msg.value = '';
			return false;
		}
		else
		{
			return false;
		}
	}
	return true;
}

function checkValidDigit()
{ 	
	val = event.keyCode;
	if(val<48 && val!=46)
	{
	  event.keyCode=0;
	}
	if(val>57)
	{
	  event.keyCode=0;
	}
	return true;
}

function checkValid_Price(events)
{
	val = events.charCode? events.charCode :events.keyCode;
	if(val<48 && val!=46 && val!=9 && val != 8 && val!=44)
	{
	//	alert("Please enter digits");
 	 	return false;
	}
	if(val>57)
	{
	//	alert("Please enter digits");
  		return false;
	}
	return true;
}
function checkValidDigitPlus()
{ 	
	val = event.keyCode;
	if(val<48 && val!=46 && val!=43)
	{
	  event.keyCode=0;
	}
	if(val>57)
	{
	  event.keyCode=0;
	}
	return true;
}

function removespace(e)
{
	if(!e)
        e = window.event;
    if(e.keyCode)
		val = e.keyCode;
    else
		val = e.charCode;
  
	
	if(val == "32")
	{
		/*
		if(e.keyCode)
		e.keyCode=0;
	    else
		e.charCode=0;
		*/
		return false;

		
	}
	else
	{
		return true;
	}
	}
function removespace_name(event)
{
	val = event.keyCode;
	 var val=event.charCode? event.charCode :event.keyCode;	
  	if(val == "32")
	{
		//event.keyCode=0;
		return false;
	}
	else
	{
		return true;
	}
}

function init() { 
if (!document.getElementById) return false; 
var f = document.getElementById('auto_off'); 
alert(f);
var u = f.elements[0]; 
f.setAttribute("autocomplete", "off"); 

}

function setSelectList(list_arr,selval)
{
	for(i=0;i<list_arr.length;i++)
	{
		if(list_arr[i].value == selval)
		{
			list_arr[i].selected=true;
			break;
		}
	}
}

//Modified By chetan(28/01/06)
function printreport(file_url,TOP_HEADER,eReportType,Id)
{
	
	pollwindow=window.open(file_url+'?TOP_HEADER='+TOP_HEADER+'&eReportType='+eReportType+'&Id='+Id, 'pollwindow','status=no, toolbars=no, width=805, height=450,top=50,left=100, resizable=yes');
	//pollwindow.focus();
	return false;
}
function RedirectURL(URL,ExtraParam)
{
	//alert("here");return false;
	if(!ExtraParam)ExtraParam='';
	window.location=URL+ExtraParam;
	return false;
}

function alpha(value,length)
{
	chk1="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- ";
	for(i=0;i<length;i++)
	{
		ch1=value.charAt(i);
		rtn1=chk1.indexOf(ch1);
		if(rtn1==-1)
			return false;
	}
	return true;
}
function alphanum(value,length)
{
	chk1="1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_. ";
	for(i=0;i<length;i++)
	{
		ch1=value.charAt(i);
		rtn1=chk1.indexOf(ch1);
		if(rtn1==-1)
			return false;
	}
	return true;
}

function alphanum_filename(value,length)
{
	chk1="%";
	for(i=0;i<length;i++)
	{
		ch1 = value.charAt(i);
		rtn1 = chk1.indexOf(ch1);

		if(rtn1==0)
		{
			alert("Please enter valid search content.");
			return false;
		}
	}
	return true;
}

function decimalNumber(value,length){
	chk1="1234567890.";
	for(i=0;i<length;i++)
	{
		ch1=value.charAt(i);
		rtn1=chk1.indexOf(ch1);
		if(rtn1==-1)
			return false;
	}
	return true;
}
function number(value,length){
	chk1="1234567890-";
	for(i=0;i<length;i++)
	{
		ch1=value.charAt(i);
		rtn1=chk1.indexOf(ch1);
		if(rtn1==-1)
			return false;
	}
	return true;
}
function onlynumber(value,length){
	chk1="1234567890";
	for(i=0;i<length;i++)
	{
		ch1=value.charAt(i);
		rtn1=chk1.indexOf(ch1);
		if(rtn1==-1)
			return false;
	}
	return true;
}

function Trim(s) 
{
	return s.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function pollwin(url,w, h)
{
	pollwindow=window.open(url,'pollwindow','top=0,left=0,status=no,toolbars=no,scrollbars=no,width='+w+',height='+h+',maximize=no,resizable');
	pollwindow.focus();
}






// This code was written by Tyler Akins and has been placed in the
// public domain.  It would be nice if you left this header intact.
// Base64 code from Tyler Akins -- http://rumkin.com

var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

function encode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   do {
      chr1 = input.charCodeAt(i++);
      chr2 = input.charCodeAt(i++);
      chr3 = input.charCodeAt(i++);

      enc1 = chr1 >> 2;
      enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
      enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
      enc4 = chr3 & 63;

      if (isNaN(chr2)) {
         enc3 = enc4 = 64;
      } else if (isNaN(chr3)) {
         enc4 = 64;
      }

      output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
         keyStr.charAt(enc3) + keyStr.charAt(enc4);
   } while (i < input.length);
   
   return output;
}

function decode64(input) {
   var output = "";
   var chr1, chr2, chr3;
   var enc1, enc2, enc3, enc4;
   var i = 0;

   // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
   input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

   do {
      enc1 = keyStr.indexOf(input.charAt(i++));
      enc2 = keyStr.indexOf(input.charAt(i++));
      enc3 = keyStr.indexOf(input.charAt(i++));
      enc4 = keyStr.indexOf(input.charAt(i++));

      chr1 = (enc1 << 2) | (enc2 >> 4);
      chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
      chr3 = ((enc3 & 3) << 6) | enc4;

      output = output + String.fromCharCode(chr1);

      if (enc3 != 64) {
         output = output + String.fromCharCode(chr2);
      }
      if (enc4 != 64) {
         output = output + String.fromCharCode(chr3);
      }
   } while (i < input.length);

   return output;
}

/* Added By chetan  
Purpose : Checking for obj availabe and Its Not Blank Value*/
function checkValidNull(obj, msg)
{
	if(obj)
	{
		if(Trim(obj.value)=="")
		{
			obj.value = '';
			alert(msg);
			obj.focus();
			return false;
		}
	}
	else
		return false;	
	return true;	
}


function checkValidZero(obj, msg)
{
	if(obj)
	{
		if(Trim(obj.value)=="" || Trim(obj.value)=="0")
		{
			alert(msg);
			obj.focus();
			return false;
		}
	}
	else
		return false;	
	return true;	
}

/* It is compare the condition (equal,greater,less) 
Parameter : Objname,
comparision value
condition pass 'Equal', 'Greater','Less'
Alere Message to Dipslay
*/
function checkValidCompare(obj,comparewithvalue,condition, msg)
{
	if(obj)
	{
		val=obj.value;
		flag=false;
		if(condition=='Equal' && val==comparewithvalue)
			flag=true;
		if(condition=='Greater' && val >= comparewithvalue)
			flag=true;
		if(condition=='Less' && val< comparewithvalue)
			flag=true;
		if(condition=='LessEqual' && val<= comparewithvalue)
			flag=true;
		
		if(flag)
		{
			alert(msg);
			obj.focus();
			return false;
		}
		else
			return true;	
	}
	else
		return false;	
}

function checkValidLength(obj,len, msg)
{
	if(obj)
	{
		val=Trim(obj.value);
		if(val=="" || val.length<len )
		{
			alert(msg);
			obj.focus();
			return false;
		}
	}
	else
		return false;	
	return true;	
}

function checkValidFloatNumber(obj, msg)
{
	chk1="1234567890.";
	flag=false;
	if(obj)
	{
		value=obj.value;
		if(Trim(value)!="")
		{
			len=obj.value.length;
			//alert(len);
			for(i=0;i<len;i++)
			{
				ch1=value.charAt(i);
				rtn1=chk1.indexOf(ch1);
				if(rtn1==-1)
					flag=true;
			}
		}else flag=true;
	}else{
		flag=true;
		msg='Object is not Avaible';
	}
	if(flag)
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}

function checkKeyEventNumber()
{  
	val = event.keyCode;
   	if(val==13)	return true;
	if(val<48)	event.keyCode=0;
	if(val>57)	event.keyCode=0;
	return true;
}
function checkKeyEventFloatNumber()
{  
	
	
	//alert(event+" "+navigator.appName);
	var val;
	if (navigator.appName == "Microsoft Internet Explorer")
      val = window.event.keyCode;
   	else if (navigator.appName == "Navigator")
		val = event.which;
   	else if (navigator.appName == "Mozilla")
       val = event.keyCode;
   	else if (navigator.appName == "Netscape")
       val = event.which;

	//alert(val);
	//val = event.keyCode;
   
	if(val==13)		return true;
	if(val<48 && val!=46 && val!=43 && val!=45)
  		event.keyCode=0;
	if(val>57)
		event.keyCode=0;
	return true;
}

function phoneformate(value,length)
{
	chk1="1234567890()- ";
	for(i=0;i<length;i++)
	{
		ch1=value.charAt(i);
		rtn1=chk1.indexOf(ch1);
		if(rtn1==-1)
			return false;
	}
	return true;
}

function checkValidPhoneFormate(obj, msg)
{
	chk1="+.1234567890()- ";
	flag=false;
	if(obj)
	{
		value=obj.value;
		if(Trim(value)!="")
		{
			len=obj.value.length;
			for(i=0;i<len;i++)
			{
				ch1=value.charAt(i);
				rtn1=chk1.indexOf(ch1);
				if(rtn1==-1)
					flag=true;
			}
		}
	}else{
		flag=true;
		msg='Object is not Avaible';
	}
	if(flag)
	{
		alert(msg);
		obj.focus();
		return false;
	}
	return true;
}
function openLoadingWindow(loadMsg)
{
	if(loadMsg)
		loadMsg += " Loading..." ;
	else
		loadMsg = "Loading...";
	winObj=window.open("",0,"menubar=no,resiable=no,width=320,height=10,top=50,left=50");
	//	winObj.document.write("<style>BODY {FONT-FAMILY: Arial, Helvetica, sans-serif; }</style><body bgcolor='#FDFCD9'><table width=100%><tr><Td align=center><h1>Loading....</h1></TD></tr></table></body>");
	winObj.document.write("<style>BODY {FONT-FAMILY: Arial, Helvetica, sans-serif; }</style><body bgcolor='#FDFCD9'><h1><span id='load_div'></span></h1><script>word=new String('"+loadMsg+"');i=0;function showMessage(){if(i>word.length)i=0;document.getElementById('load_div').innerHTML=word.substring(0,i);i++;window.setTimeout('showMessage()', 40);}showMessage();</script>");
	return winObj;
}
function closeLoadingWindow(winObj)
{
	winObj.close();
}
function getHTTPObject()
{
	// code for Mozilla, etc.
	if (window.XMLHttpRequest)
  	{
  		xmlhttp=new XMLHttpRequest()
  	}
// code for IE
	else if (window.ActiveXObject)
  	{
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  	}
	return xmlhttp;
}
function Highlight(e)
{
	//	alert(e.className);
	if(e.className!="raw_selectedbg")
		e.className="mouseover";
}
function UnHighlight(e,classname)
{
	//	alert(e.className)
	if(e.className!="raw_selectedbg")
		e.className=classname;
}
function openPopupImageWindow(ImageName,ImagePath)
{
	s=window.open('popup.php?page=enlarge&pid=1&h=1000&w=700&popup=1&vImage='+ImageName+'&vImagepath='+ImagePath,'enlarged_view','toolbar=no,resizable=no,scrollbars=no,width=700, height=700'); 
	s.focus();
	return false;
}
function Delete_Image(tablename,fieldname,fieldid,value,Image)
{
	document.frmadd.mode.value='DeleteImage';
	//alert(tablename+" "+fieldname+" "+fieldid+" "+value);
	document.frmadd.TABLENAME.value=tablename;
	document.frmadd.FIELDNAME.value=fieldname;
	document.frmadd.FIELDID.value=fieldid;
	document.frmadd.FIELDVALUE.value=value;
	document.frmadd.IMAGEVALUE.value=Image;
	document.frmadd.submit();
}
function setSelectList(list_arr,selval)
{
	for(i=0;i<list_arr.length;i++)
	{
		if(list_arr[i].value == selval)
		{
			list_arr[i].selected=true;
			break;
		}
	}
}

/*	added by bhavin	23-jan-2006		*/

function checkObjectNull(obj, msg)
{
	if("undefined" != typeof(obj.type))// If multiple value then return error
	{
		typeVal = obj.type
	}
	else
	{
		typeVal = obj[0].type
	}
	switch(typeVal)
	{
		case "text":
			if(Trim(obj.value)=="")
			{
				alert(msg);
				obj.focus();
				return false;
			}
			break;
		case "radio":
			var tot = obj.length;
//				alert(tot);
			flag = 0;
			if(tot>0)// Return undefined if array of object 
			{
				for(i=0; i<tot ; i++)
				{
					if(obj[i].checked)
					{
						flag=1;
						break;
					}
				}
			}
			else
			{
				if(obj.checked)
					flag=1;
			}
			if(flag==0)
			{
				alert(msg);
				if(tot>=0) obj[0].focus();
				else obj.focus();
				return false;
			}
			break;
		case "checkbox":
			var tot = obj.length;
//				alert(tot);
			flag = 0;
			if(tot>0)// Return undefined if array of object 
			{
				for(i=0; i<tot ; i++)
				{
					if(obj[i].checked)
					{
						flag=1;
						break;
					}
				}
			}
			else
			{
				if(obj.checked)
					flag=1;
			}
			if(flag==0)
			{
				alert(msg);
				if(tot>=0) obj[0].focus();
				else obj.focus();
				return false;
			}
			break;

		case "select-one":			
			if(obj.selectedIndex==0)
			{
				alert(msg);					
				obj.focus();
				return false;
			}
			break;
		case "textarea":
			if(obj.value=="")
			{
				alert(msg);
				obj.focus();
				return false;
			}
			break;
		case "file":
			if(obj.value=="")
			{
				alert(msg);
				obj.focus();
				return false;
			}			
			break;
	}
	return true;
}

function btnCancel_click(URL)
{
	//alert(URL);
	window.location=URL;
	return false;
}
function checkDate()
{
	//alert(enddate);
	/*
	if(document.frmlist.iCompanyId)
		document.frmlist.iCompanyId.value="";
	if(document.frmlist.keyword)
		document.frmlist.keyword.value="";
	*/
	var startdate=document.getElementById('dStartDate').value;
	var curdate=document.getElementById('dEndDate').value;
	if(curdate=="")
		return true;
	/*var enddate=document.getElementById('lastpackdEnddate').value;	*/
	var sdate=startdate.split('-');
    var syr=sdate[0];
    var smon=sdate[1];
   	var sday=sdate[2];
	
	var cdate=curdate.split('-');
    var cur_yr=cdate[0];
    var cur_mon=cdate[1];
   	var cur_date=cdate[2];
		//var today=new Date();
      	//cur_yr=today.getYear();      	
      	//cur_mon=today.getMonth()+1;
      	//cur_date=today.getDate();
		if(syr>cur_yr)
      	{
        	alert("End Date year should be greater than or equal to current year");
        	return false;
      	}
      	if(syr==cur_yr && smon>parseInt(cur_mon))
      	{
        	alert("End Date month should be greater than or equal to current month");
        	return false;
      	}
     	 if(syr==cur_yr && smon==cur_mon && sday>cur_date)
      	{
        	alert("End Date day should be greater than or equal to current day");
        	return false;
      	}
		
	//}
	return true;	
}

//Remove Html Tags and make &nbsp to ''
function removeHTMLTags(str){
	strInputCode = str.replace(/&(lt|gt);/g,function (strMatch, p1){
	 	return (p1 == "lt")? "<" : ">";
	});
	var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
	var repStr = strTagStrippedText.replace(/^[\s(&nbsp;)]+/g,'').replace(/[\s(&nbsp;)]+$/g,'');
	return repStr;
}
/*	End Fucntion */	

function resetstyle(frm)
{    
    var n = frm.elements.length;
	for(var i=0;i<n;i++)
	{
		var id = frm.elements[i].id;
        if(id != ""){
            inputvalidation(id);
        }
	}
}	

function inputvalidation(val)
{
    document.getElementById(val).className = 'input2';
}

function validation_red(val,type)
{
    if(type == 'textarea')
        document.getElementById(val).className = 'textarea-red';
    else if(type == 'select')
    {
        ////document.getElementById(val).className = 'select-red';
    }
    else
        document.getElementById(val).className = 'input-red';
}   

//******************************************************************************************//
//********************* functions  for email-id validation ****************************//
//******************************************************************************************//
function ValidEmail(emailStr) {
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) {
		alert("Email address seems incorrect (check @ and .'s)");
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	// Start by checking that only basic ASCII characters are in the strings (0-127).
	for (i=0; i<user.length; i++) {
		if (user.charCodeAt(i)>127) {
			alert("Ths username contains invalid characters.");
			return false;
		}
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i)>127) {
			alert("Ths domain name contains invalid characters.");
			return false;
		}
	}
	if (user.match(userPat)==null) {
		alert("The username doesn't seem to be valid.");
		return false;
	}
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				alert("Destination IP address is invalid!");
				return false;
	   		}
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) {
		if (domArr[i].search(atomPat)==-1) {
			alert("The domain name does not seem to be valid.");
			return false;
	   }	
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && 
		domArr[domArr.length-1].search(knownDomsPat)==-1) {
		alert("The address must end in a well-known domain or two letter " + "country.");
		return false;
	}

// Make sure there's a host name preceding the domain.

	if (len<2) {
		alert("This address is missing a hostname!");
		return false;
	}	
	return true;
}

//Date validation using regular expression
function isValidDate(dateStr, format) {
   if (format == null) { format = "MDY"; }
   format = format.toUpperCase();
   if (format.length != 3) { format = "MDY"; }
   if ( (format.indexOf("M") == -1) || (format.indexOf("D") == -1) || (format.indexOf("Y") == -1) ) { format = "MDY"; }
   if (format.substring(0, 1) == "Y") { // If the year is first
      var reg1 = /^\d{2}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
      var reg2 = /^\d{4}(\-|\/|\.)\d{1,2}\1\d{1,2}$/
   } else if (format.substring(1, 2) == "Y") { // If the year is second
      var reg1 = /^\d{1,2}(\-|\/|\.)\d{2}\1\d{1,2}$/
      var reg2 = /^\d{1,2}(\-|\/|\.)\d{4}\1\d{1,2}$/
   } else { // The year must be third
      var reg1 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2}$/
      var reg2 = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/
   }
   // If it doesn't conform to the right format (with either a 2 digit year or 4 digit year), fail
   if ( (reg1.test(dateStr) == false) && (reg2.test(dateStr) == false) ) { return false; }
   var parts = dateStr.split(RegExp.$1); // Split into 3 parts based on what the divider was
   // Check to see if the 3 parts end up making a valid date
   if (format.substring(0, 1) == "M") { var mm = parts[0]; } 
   else if (format.substring(1, 2) == "M") { var mm = parts[1]; } else { var mm = parts[2]; }
   if (format.substring(0, 1) == "D") { var dd = parts[0]; } else if (format.substring(1, 2) == "D") { var dd = parts[1]; } else { var dd = parts[2]; }
   if (format.substring(0, 1) == "Y") { var yy = parts[0]; } else if (format.substring(1, 2) == "Y") { var yy = parts[1]; } else { var yy = parts[2]; }
   if (parseFloat(yy) <= 50) { yy = (parseFloat(yy) + 2000).toString(); }
   if (parseFloat(yy) <= 99) { yy = (parseFloat(yy) + 1900).toString(); }
   var dt = new Date(parseFloat(yy), parseFloat(mm)-1, parseFloat(dd), 0, 0, 0, 0);
   if (parseFloat(dd) != dt.getDate()) { return false; }
   if (parseFloat(mm)-1 != dt.getMonth()) { return false; }
   return true;
}

//Valid Email Using Regular Expression
function isValidEmail(emailAddress) {
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(2([0-4]\d|5[0-5])|1?\d{1,2})(\.(2([0-4]\d|5[0-5])|1?\d{1,2})){3} \])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
    return re.test(emailAddress);
}

//Valid Amont Using Regular Expression
function isValidAmount(value) {
   var re = /^[+\-0-9\.]{1,16}?$/;
   return (re.test(value));
}
