// javascript validation library 
// written by neelmani chitransi
// for origin softech pvt ltd.
// all right reserved.
// do not modify this script
// this script use is intended to only use on the softwar developed by originsoftech.
// library path url=http://www.originsoftech.biz/library/javascript/jlib.js
	//	formname: name of the form 
	// selectionbox: id of the check box click on which all the check box of the form will get selected 
	//
	function CheckAll(formname,selectionbox)
	{
		var elements = document.forms[formname].elements.length;
		for(j=0;j<elements;j++)
			{
					
				var x= document.forms[formname].elements[j];
				//alert(x.type);
				if (x.type=="checkbox")
				{
					if(x.name != selectionbox)
					{
						if (x.checked==true)
						{
							x.checked=false;
						}
						else
						{
							x.checked=true;
						}
					}
				}
			}
	}
	
function ValidateForm(formname,checkarray)
	{
			var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
			var usPhone =/^\d{3}-\d{3}-\d{4}$/
			errmsgshow='';
			errorcolor="#FF6666";
			var elements = document.forms[formname].elements.length;
			for(j=0;j<elements;j++)
			{
				var x= document.forms[formname].elements[j];
				if (x.type!="submit" && x.type!="reset" && x.type!="button")
				{
						x.style.backgroundColor="#ffffff";
				}
			}
			a=checkarray.length;
			for(i=0;i<a;i++)
			{	
				var msg1='';
				msg1=checkarray[i];
				brk=msg1.split('|');
				try
				{
						curid=document.getElementById(brk[0]); // brk[0] the name of the field to be checked 
						errtype=brk[2];
						errmsg=brk[1];
						if(brk.length>3)
						{
							limitlow=brk[3];
							limithigh=brk[4];
						}
						if(brk.length>3)
						{
							textlow=brk[3];
							texthigh=brk[4];
						}
						switch(errtype)
						{
							case "blank":
									{
										if (curid.value.length<=0)
										{
											errmsgshow+=errmsg +"\n";
											//curid.style.backgroundColor=errorcolor;
											//curid.style.borderColor=errorcolor;
										}
									}
									break;
							
							case "equalpwd":
									{
										var nextval = document.getElementById(textlow);	
										if (curid.value != nextval.value){
										errmsgshow+=errmsg +"\n";
										//curid.style.backgroundColor=errorcolor;
										//nextval.style.backgroundColor=errorcolor;
										}
									}
									break;
							
							case "uploadcheck":
									{
										var oldimage = document.getElementById(textlow);
										if(oldimage.value=="")
										{
											errmsgshow+=errmsg +"\n";
											//curid.style.backgroundColor=errorcolor;
											//nextval.style.backgroundColor=errorcolor;	
										}
									}
									break;
							
							case "checked":
									{
										if (!curid.checked)
										{
											errmsgshow+=errmsg +"\n";
											curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "email":
									{
										var returnval=emailfilter.test(curid.value)
										if (returnval==false){
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "usphone":
									{
										var returnval=usPhone.test(curid.value)
										if (returnval==false){
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "number":
									{
										if (isNaN(curid.value)){
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "float":
									{
										if (isNaN(curid.value)){
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "text":
									{
										if (!isNaN(curid.value)){
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
		
							case "negative":
									{
										if (curid.value<0){
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "numberlimit":
									{
										if ( ! (curid.value>=limitlow && curid.value<=limithigh))
										{
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "match":
									{
										if ( !(curid.value==document.getElementById(brk[3]).value))
										{
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "textlengthlimit":
									{
										if ( !(curid.value.length >= textlow && curid.value.length<=texthigh))
										{
										errmsgshow+=errmsg +"\n";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "dateUS":
									{
										//mm/dd/yyyy
										var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errmsgshow+=errmsg +"\n";
											curid.style.backgroundColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[0]
											var dayfield=curid.value.split("/")[1]
											var yearfield=curid.value.split("/")[2]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errmsgshow+=errmsg +"\n";
												curid.style.backgroundColor=errorcolor;
												break;
											}
										}
									}
									break;
							case "dateUK":
									{
										//dd/mm/yyyy
										var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errmsgshow+=errmsg +"\n";
											curid.style.backgroundColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[1]
											var dayfield=curid.value.split("/")[0]
											var yearfield=curid.value.split("/")[2]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errmsgshow+=errmsg +"\n";
												curid.style.backgroundColor=errorcolor;
												break;
											}
										}
									}
									break;
							case "dateEU":
									{	// yyyy/mm/dd
										var validformat=/^\d{4}\/\d{2}\/\d{2}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errmsgshow+=errmsg +"\n";
											curid.style.backgroundColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[1]
											var dayfield=curid.value.split("/")[2]
											var yearfield=curid.value.split("/")[0]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errmsgshow+=errmsg +"\n";
												curid.style.backgroundColor=errorcolor;
												break;
											}
										}
									}
									break;					
						}
				}
				catch(err)
				{
						 txt="There is an error on this page.\n\n";
						  txt+="Error description: " + err.description +"\n\n"+msg1+ "\n\n";
						  txt+="Click OK to continue.\n\n";
						  alert(txt);

				}
			}
			if (errmsgshow.length >0)
			{
				errors="Following errors encountred Please correct Them \n";
				errors+=errmsgshow;
				alert (errors);
				return false;
			}
			else
			{
				return true;
			}
			//	alert (errmsgshow);
	}
	
// this function will return the resul in an htmlformat to a target control where you 
// want to display the error message
//
//
function ValidateFormDiv(formname,checkarray,errdiv)
	{
			var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
			var usPhone =/^\d{3}-\d{3}-\d{4}$/
			errmsgshow='';
			errorcolor="#FF6699";
			var elements = document.forms[formname].elements.length;
			for(j=0;j<elements;j++)
			{
				var x= document.forms[formname].elements[j];
				if (x.type!="submit" && x.type!="reset" && x.type!="button")
				{
						x.style.backgroundColor="#ffffff";
				}
			}
			a=checkarray.length;
			for(i=0;i<a;i++)
			{	
				var msg1='';
				msg1=checkarray[i];
				brk=msg1.split('|');
				try
				{
						curid=document.getElementById(brk[0]); // brk[0] the name of the field to be checked 
						errtype=brk[2];
						errmsg=brk[1];
						if(brk.length>3)
						{
							limitlow=brk[3];
							limithigh=brk[4];
						}
						if(brk.length>3)
						{
							textlow=brk[3];
							texthigh=brk[4];
						}
						
						switch(errtype)
						{
							case "blank":
									{
										if (curid.value.length<=0)
										{
											errmsgshow+=errmsg +"<br/>";
											curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "checked":
									{
										if (!curid.checked)
										{
											errmsgshow+=errmsg +"<br/>";
											curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "email":
									{
										var returnval=emailfilter.test(curid.value)
										if (returnval==false){
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
									
							case "mintextlimit":
									{
										if (curid.value.length < textlow){
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;		
									
							case "usphone":
									{
										var returnval=usPhone.test(curid.value)
										if (returnval==false){
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "number":
									{
										if (isNaN(curid.value)){
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "float":
									{
										if (isNaN(curid.value)){
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "text":
									{
										if (!isNaN(curid.value)){
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
		
							case "negative":
									{
										if (curid.value<0){
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							
							case "equalpwd":
									{
										var nextval = document.getElementById(textlow);	
										if (curid.value != nextval.value){
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										nextval.style.backgroundColor=errorcolor;
										}
									}
									break;
							
							case "dependent":
									{
										var nextid = document.getElementById(textlow);
										if (curid.checked==false && nextid.value==''){
										errmsgshow+=errmsg +"<br/>";
										nextid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "dependent_obj":
									{
										var nextid = document.getElementById(textlow);
										if (curid.value=='other' && nextid.value==''){
										errmsgshow+=errmsg +"<br/>";
										nextid.style.backgroundColor=errorcolor;
										}
									}
									break;
									
							case "numberlimit":
									{
										if (curid.value.length>limitlow || curid.value.length<limithigh)
										{
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "match":
									{
										if ( !(curid.value==document.getElementById(brk[3]).value))
										{
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "textlengthlimit":
									{
										if ( !(curid.value.length >= textlow && curid.value.length<=texthigh))
										{
										errmsgshow+=errmsg +"<br/>";
										curid.style.backgroundColor=errorcolor;
										}
									}
									break;
							case "dateUS":
									{
										//mm/dd/yyyy
										var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errmsgshow+=errmsg +"<br/>";
											curid.style.backgroundColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[0]
											var dayfield=curid.value.split("/")[1]
											var yearfield=curid.value.split("/")[2]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errmsgshow+=errmsg +"<br/>";
												curid.style.backgroundColor=errorcolor;
												break;
											}
										}
									}
									break;
							case "dateUK":
									{
										//dd/mm/yyyy
										var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errmsgshow+=errmsg +"<br/>";
											curid.style.backgroundColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[1]
											var dayfield=curid.value.split("/")[0]
											var yearfield=curid.value.split("/")[2]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errmsgshow+=errmsg +"<br/>";
												curid.style.backgroundColor=errorcolor;
												break;
											}
										}
									}
									break;
							case "dateEU":
									{	// yyyy/mm/dd
										var validformat=/^\d{4}\/\d{2}\/\d{2}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errmsgshow+=errmsg +"<br/>";
											curid.style.borderColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[1]
											var dayfield=curid.value.split("/")[2]
											var yearfield=curid.value.split("/")[0]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errmsgshow+=errmsg +"<br/>";
												curid.style.borderColor=errorcolor;
												break;
											}
										}
									}
									break;					
						}
				}
				catch(err)
				{
						 txt="There is an error on this page.\n\n";
						  txt+="Error description: " + err.description +"\n\n"+msg1+ "\n\n";
						  txt+="Click OK to continue.\n\n";
						  alert(txt);

				}
			}
			if (errmsgshow.length >0)
			{
				errors="<div class='message error'><p><strong>Error!</strong> Following errors encountred Please correct Them</b></p> ";
				errors+=errmsgshow;
				document.getElementById(errdiv).innerHTML=errors;
				//alert (errors);
				return false;
			}
			else
			{
				return true;
			}
			//	alert (errmsgshow);
	}

// this function will return the result in an html format to a target control where you 
// want to display the error message
// fieldid|messsage|errortype|errdiv|para1|para2
//
function ValidateFormDivIndividual(formname,checkarray)
	{
			var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
			var usPhone =/^\d{3}-\d{3}-\d{4}$/
			errmsgshow='';
			errorcolor="#ff0000";
			bordercolor="";
			var elements = document.forms[formname].elements.length;
			for(j=0;j<elements;j++)
			{
				var x= document.forms[formname].elements[j];
				if (x.type!="submit" && x.type!="reset" && x.type!="button")
				{
						x.style.borderColor="#ffffff";
				}
			}
			a=checkarray.length;
			for(i=0;i<a;i++)
			{	
				var msg1='';
				msg1=checkarray[i];
				brk=msg1.split('|');
				try
				{
						curid=document.getElementById(brk[0]); // brk[0] the name of the field to be checked 
						errtype=brk[2];
						errmsg=brk[1];
						if(brk.length>4)
						{
							limitlow=brk[4];
							limithigh=brk[5];
							textlow=brk[4];
							texthigh=brk[5];
						}
						
						switch(errtype)
						{
							case "blank":
									{
										if (curid.value.length<=0)
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "checked":
									{
										if (!curid.checked)
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "email":
									{
										var returnval=emailfilter.test(curid.value)
										if (returnval==false){
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "usphone":
									{
										var returnval=usPhone.test(curid.value)
										if (returnval==false){
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "number":
									{
										if (isNaN(curid.value)){
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "float":
									{
										if (isNaN(curid.value)){
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "text":
									{
										if (!isNaN(curid.value)){
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
		
							case "negative":
									{
										if (curid.value<0){
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "numberlimit":
									{
										if ( ! (curid.value>=limitlow && curid.value<=limithigh))
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "match":
									{
										if ( !(curid.value==document.getElementById(brk[4]).value))
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "textlengthlimit":
									{
										if ( !(curid.value.length >= textlow && curid.value.length<=texthigh))
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML='' ;
											curid.style.borderColor=bordercolor;
										}
									}
									break;
							case "dateUS":
									{
										//mm/dd/yyyy
										var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[0]
											var dayfield=curid.value.split("/")[1]
											var yearfield=curid.value.split("/")[2]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errdiv=document.getElementById(brk[3]);
												errdiv.innerHTML=errmsg ;
												errdiv.style.color=errorcolor;
												errmsgshow+=errmsg +"\n";
												curid.style.borderColor=errorcolor;
												break;
											}
											else
											{
												errdiv=document.getElementById(brk[3]);
												errdiv.innerHTML='' ;
												curid.style.borderColor=bordercolor;
											}
										}
									}
									break;
							case "dateUK":
									{
										//dd/mm/yyyy
										var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[1]
											var dayfield=curid.value.split("/")[0]
											var yearfield=curid.value.split("/")[2]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errdiv=document.getElementById(brk[3]);
												errdiv.innerHTML=errmsg ;
												errdiv.style.color=errorcolor;
												errmsgshow+=errmsg +"\n";
												curid.style.borderColor=errorcolor;
												break;
											}
											else
											{
												errdiv=document.getElementById(brk[3]);
												errdiv.innerHTML='' ;
												curid.style.borderColor=bordercolor;
											}
										}
									}
									break;
							case "dateEU":
									{	// yyyy/mm/dd
										var validformat=/^\d{4}\/\d{2}\/\d{2}$/ //Basic check for format validity
										if (!validformat.test(curid.value))
										{
											errdiv=document.getElementById(brk[3]);
											errdiv.innerHTML=errmsg ;
											errdiv.style.color=errorcolor;
											errmsgshow+=errmsg +"\n";
											curid.style.borderColor=errorcolor;
										}
										else
										{ //Detailed check for valid date ranges
											var monthfield=curid.value.split("/")[1]
											var dayfield=curid.value.split("/")[2]
											var yearfield=curid.value.split("/")[0]
											var dayobj = new Date(yearfield, monthfield-1, dayfield)
											if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
											{
												errdiv=document.getElementById(brk[3]);
												errdiv.innerHTML=errmsg ;
												errdiv.style.color=errorcolor;
												errmsgshow+=errmsg +"\n";
												curid.style.borderColor=errorcolor;
												break;
											}
											else
											{
												errdiv=document.getElementById(brk[3]);
												errdiv.innerHTML='' ;
												curid.style.borderColor=bordercolor;
											}
										}
									}
									break;					
						}
				}
				catch(err)
				{
							 txt="There is an error on this page.\n\n";
						 	 txt+="Error description: " + err.description +"\n\n"+msg1+ "\n\n";
						  	 txt+="Click OK to continue.\n\n";
						  	 alert(txt);

				}
			}
			if (errmsgshow.length >0)
			{
				//errors="Following errors encountred Please correct Them \n";
				//errors+=errmsgshow;
				//alert (errors);
				return false;
			}
			else
			{
				return true;
			}
			//	alert (errmsgshow);
	}
function redirectPage(tgt,id)
{
 var val = document.getElementById(id).value;	
 window.location=tgt+'&cpgno='+val;
}
function checkAdminInfo()
{
	var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
 if(document.getElementById('username').value=='')
 {
 	document.getElementById('userErr').innerHTML="&nbsp;<img src='../images/message_warning.png' height='20' width='20' border='0'>&nbsp;User Name Can not be blank";
	return false;
 }
 else
 {
 	document.getElementById('userErr').innerHTML="&nbsp;<img src='../images/message_confirmation.gif' border='0' height='20' width='20'>";
 }
 if(document.getElementById('email').value=='')
 {
 	document.getElementById('emailErr').innerHTML="&nbsp;<img src='../images/message_warning.png' height='20' width='20' border='0'>&nbsp;Email Can not be blank";
	return false;
 }
 else
 {
 	document.getElementById('emailErr').innerHTML="&nbsp;<img src='../images/message_confirmation.gif' border='0' height='20' width='20'>";
 }
 if(document.getElementById('email').value !='' && emailfilter.test(document.getElementById('email').value)==false)
 {
 	document.getElementById('emailErr').innerHTML="&nbsp;<img src='../images/message_warning.png' height='20' width='20' border='0'>&nbsp;Invalid Email Id";
	return false;
 }
 else
 {
 	document.getElementById('emailErr').innerHTML="&nbsp;<img src='../images/message_confirmation.gif' border='0' height='20' width='20'>";
 }
 if(document.getElementById('newpwd').value!='' && document.getElementById('oldpwd').value !=document.getElementById('oldhpwd').value)
 {
 	document.getElementById('opwdErr').innerHTML="&nbsp;<img src='../images/message_warning.png' height='20' width='20' border='0'>&nbsp;Please enter the correct old pwd.";
	return false;
 }
 else
 {
 	document.getElementById('opwdErr').innerHTML="&nbsp;<img src='../images/message_confirmation.gif' border='0' height='20' width='20'>";
 }
 if(document.getElementById('newpwd').value !='' && document.getElementById('newpwd').value.length<8)
 {
 	document.getElementById('npwdErr').innerHTML="&nbsp;<img src='../images/message_warning.png' height='20' width='20' border='0'>&nbsp;Should be Min. 8 Char";
	return false;
 }
 else
 {
 	document.getElementById('npwdErr').innerHTML="&nbsp;<img src='../images/message_confirmation.gif' border='0' height='20' width='20'>";
 }
 if(document.getElementById('newpwd').value !=document.getElementById('confirmpwd').value)
 {
 	document.getElementById('cpwdErr').innerHTML="&nbsp;<img src='../images/message_warning.png' height='20' width='20' border='0'>&nbsp;New Pwd & Confirm Pwd should be equal";
	return false;
 }
 else
 {
 	document.getElementById('cpwdErr').innerHTML="&nbsp;<img src='../images/message_confirmation.gif' border='0' height='20' width='20'>";
 }
 return true;
}

//Show Hide window
function showHideWin(loginDiv, pwdDiv)
{
	document.getElementById(loginDiv).style.display='none';
	document.getElementById(pwdDiv).style.display='block';
}

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar, pcontainer) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=blanket_height/2-150;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar, pcontainer) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-150;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(zlink)

  {

   if (!window.optionWindow) 

    {

	optionWindow = window.open(zlink,"Example","width=500,height=400,toolbar=0,status=0,location=0,menubar=0,scrollbars=yes,resizable=0");

	}

   else

	{

	if (!optionWindow.closed)

	  {

	  optionWindow.focus();

	  optionWindow.location = zlink

	  }

	 else

	  {

	   optionWindow = window.open(zlink, "Example","width=500,height=400,toolbar=0,status=0,location=0,menubar=0,scrollbars=yes,resizable=0");

	  }

	}

   }
function showHideDOD(chkObj, trgObj)
{
	var radobj = document.getElementById(chkObj);
	var desObj = document.getElementById(trgObj);
	if(radobj.checked && radobj.value==1)
	{
		desObj.style.visibility='hidden';
		desObj.style.position='absolute';
	}
	else
	{
		desObj.style.visibility='visible';
		desObj.style.position='relative';
	}
}

function occupation_select(selVal, trgObj)
{
	var targetDiv = document.getElementById(trgObj);
	if(selVal=='service' || selVal=='business')
	{
		targetDiv.style.visibility='visible';
		targetDiv.style.position='relative';
	}
	else
	{
		targetDiv.style.visibility='hidden';
		targetDiv.style.position='absolute';
	}
}

function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
        var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "counttxt";
        var countBody = opt_countBody ? opt_countBody : "countBody";
        var maxSize = opt_maxSize ? opt_maxSize : 1024;

        var field = document.getElementById(countedTextBox);

        if (field && field.value.length >= maxSize) {
                field.value = field.value.substring(0, maxSize);
        }
        var txtField = document.getElementById(countBody);
                if (txtField) { 
                txtField.innerHTML = maxSize-field.value.length;
        }
}

function showAlternate_No(obj,tgt1,tgt2)
{
	var chkObj = document.getElementById(obj);
	var tgt1Obj = document.getElementById(tgt1);
	var tgt2Obj = document.getElementById(tgt2);
	
	if(chkObj.checked && chkObj.value=='phone')
	{
			
		tgt1Obj.style.display='block';
		tgt2Obj.style.display='none';
	}
	else if(chkObj.checked && chkObj.value=='mobile')
	{
		
		tgt2Obj.style.display='block';
		tgt1Obj.style.display='none';
	}
	else if(chkObj.checked && chkObj.value=='none')
	{
			
		tgt2Obj.style.display='none';
		tgt1Obj.style.display='none';
	}
	
}

function show_other_text(stateVal,txtObj)
{
	var txtId = document.getElementById(txtObj);
	if(stateVal=='other')
	{
		txtId.disabled=false;
	}
	else
	{
		txtId.disabled=true;
	}
	
}

function showPwdArea(obj1,obj2)
{
	document.getElementById(obj1).style.position='relative';
	document.getElementById(obj1).style.visibility='visible';
	document.getElementById(obj2).style.position='relative';
	document.getElementById(obj2).style.visibility='visible';
	document.getElementById('member_pwd').value='';
	document.getElementById('member_cpwd').value='';
	
}
function showHideSpouseDetails(chkObj,targObjArray)
{
	var radobj = document.getElementById(chkObj);
	var cntTgtObj = targObjArray.length;
	
	//var desObj = document.getElementById(targObj);
	if(radobj.checked && radobj.value==1)
	{
		for(var i=0;i<cntTgtObj;i++)
		{
			desObj = document.getElementById(targObjArray[i]);
			desObj.style.visibility='visible';
			desObj.style.position='relative';
		}
	}
	else
	{
		for(var i=0;i<cntTgtObj;i++)
		{
			desObj = document.getElementById(targObjArray[i]);
			desObj.style.visibility='hidden';
			desObj.style.position='absolute';
		}
	}
}
