function emailCheck(objEmail)
{
	if(objEmail.value=="")
	{
		alert("Please enter your email address");
		//form1.email.select();
		return false;
	}
	else
	{
		var mail=objEmail.value;
		aindex=mail.indexOf("@");
		nexta=mail.lastIndexOf("@");
		dotindex=mail.lastIndexOf(".");
		if((aindex > 0)&&(aindex==nexta)&&(dotindex>aindex)&&((dotindex-aindex)>1))
		{
			return true;
		}
		else
		{	
			alert("Enter your email in proper format.");
			//form1.email.select();
			return false;
		}		
	}
}
function emailCheck1 (emailStr) {
/* The following pattern is used to check if the entered e-mail address
   fits the user@domain format.  It also is used to separate the username
   from the domain. */
var emailPat=/^(.+)@(.+)$/
/* The following string represents the pattern for matching all special
   characters.  We don't want to allow special characters in the address. 
   These characters include ( ) < > @ , ; : \ " . [ ]    */
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
/* The following string represents the range of characters allowed in a 
   username or domainname.  It really states which chars aren't allowed. */
var validChars="\[^\\s" + specialChars + "\]"
/* The following pattern applies if the "user" is a quoted string (in
   which case, there are no rules about which characters are allowed
   and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
   is a legal e-mail address. */
var quotedUser="(\"[^\"]*\")"
/* The following pattern applies for domains that are IP addresses,
   rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
   e-mail address. NOTE: The square brackets are required. */
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
/* The following string represents an atom (basically a series of
   non-special characters.) */
var atom=validChars + '+'
/* The following string represents one word in the typical username.
   For example, in john.doe@somewhere.com, john and doe are words.
   Basically, a word is either an atom or quoted string. */
var word="(" + atom + "|" + quotedUser + ")"
// The following pattern describes the structure of the user
var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
/* The following pattern describes the structure of a normal symbolic
   domain, as opposed to ipDomainPat, shown above. */
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


/* Finally, let's start trying to figure out if the supplied address is
   valid. */

/* Begin with the coarse pattern to simply break up user@domain into
   different pieces that are easy to analyze. */
var matchArray=emailStr.match(emailPat)
if (matchArray==null) {
  /* Too many/few @'s or something; basically, this address doesn't
     even fit the general mould of a valid e-mail address. */
	alert("Email address seems incorrect (check @ and .'s)")
	return false
}
var user=matchArray[1]
var domain=matchArray[2]

// See if "user" is valid 
if (user.match(userPat)==null) {
    // user is not valid
    alert("The username doesn't seem to be valid.")
    return false
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
   host name) make sure the IP address is valid. */
var IPArray=domain.match(ipDomainPat)
if (IPArray!=null) {
    // this is an IP address
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        alert("Destination IP address is invalid!")
		return false
	    }
    }
    return true
}

// Domain is symbolic name
var domainArray=domain.match(domainPat)
if (domainArray==null) {
	alert("The domain name doesn't seem to be valid.")
    return false
}

/* domain name seems valid, but now make sure that it ends in a
   three-letter word (like com, edu, gov) or a two-letter word,
   representing country (uk, nl), and that there's a hostname preceding 
   the domain or country. */

/* Now we need to break up the domain to get a count of how many atoms
   it consists of. */
var atomPat=new RegExp(atom,"g")
var domArr=domain.match(atomPat)
var len=domArr.length
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   // the address must end in a two letter or three letter word.
   alert("The address must end in a three-letter domain, or two letter country.")
   return false
}

// Make sure there's a host name preceding the domain.
if (len<2) {
   var errStr="This address is missing a hostname!"
   alert(errStr)
   return false
}

// If we've gotten this far, everything's valid!
return true;
}


function Trim(myval)
{
	var chklen=myval.length; 
	var pos=0;
	mychar = myval.charAt(0);

	while(pos>=0 || lstpos >=0)
	{
		pos=myval.indexOf(" ");
		if (pos==0)
		{
			myval=myval.substring(1,chklen);
			chklen = myval.length;
			mychar = myval.charAt(0);
		}
		lstpos=myval.lastIndexOf(" ");

		if (lstpos==chklen-1)
		{	
			myval=myval.substring(0,chklen-1);
			chklen=myval.length;
			mychar = myval.charAt(chklen-1);
		}
		
		if(mychar!=" ")
			break;

	}
	return myval;			
}

function IsNumber(Expression)
{
	Expression = Expression.toLowerCase();
	RefString = ".0123456789";

	if (Expression.length < 1) 
		return (false);
	var count =0;
	for (var i = 0; i < Expression.length; i++) 
	{
		var ch = Expression.substr(i, 1)
		var a = RefString.indexOf(ch, 0)
		if (a == -1)
			return (false);
		if(ch=='.')	
			count++;
		if(count>1)	
			return false;
	}
	return(true);
}

// JavaScript Document

	//**************  This is important function validate your Form ********************
	//*************   Read this tips to use this function, depend on id of input type.
	//***	if you not want to validate text box, DONT WRITE ID
	//***	if you not want to validate text box, WRITE 'not' as prefix of id
	//***	Validate textbox as number and character, Write ID, That also title of alert msg.
	//***	
	//***	
	//***	
	
	function chkvalid(frm)
	{
		//var n = "document." + document.forms[0].name;
		var n = frm;
		var nam,r;
		r=0;
		//alert(frm);
		//	alert(eval(n).elements.length);
		//	alert(s.elements.length);
			for(i=0;i < eval(n).elements.length;i++)
				{	
				var s = eval(n).elements[i] ; 
					if((s.type == "text" || s.type == "password") && s.disabled==false )
						{
							
							var strblank = s.id.substr(0,3);
							//alert(s.id);
							var strid = s.id.substr(3,s.id.length-1);
							//alert(strblank + "---" + strid);
							
							if((s.value == "" || s.value.split(" ").join("").length==0) && (strblank != "not") && (strblank != ""))
								{
										//alert(strid);
										if(strblank == "no." || strblank == "em." || strblank == "al.")
											alert("You are requested to fill " + strid);
										else
											alert("You are requested to fill " + s.id);
										s.focus();		
										//s.select();	
										return false;
								}
							if(strid == "no." || strblank == "no.")
							{
								if(chknumdot(s.value) == false)
									{
										alert(strid+ " must be number from [0,9]");
										s.select();
										return false;
									}	
							}
							
							if(strid == "al." || strblank == "al.")
							{
								if(chkalpha(s.value) == false)
									{
										alert(strid+ " must be alphabet from [A-Z],[a-z]");
										s.select();
										return false;
									}	
							}

							if(strid == "nd." || strblank == "nd.")
							{
								if(chknumdot(s.value) == false)
									{
										alert(strid+ " must be number from [0-9 and .]");
										s.select();
										return false;
									}	
							}
							if(strid == "an." || strblank == "an.")
							{
								if(chkalphanum(s.value) == false)
								{
									alert(strid+ " must be alpha numeric character");
									s.select();
									return false;
								}	
							}		
							if(strid == "em." || strblank == "em.")
							{
								if(validate_email(s)==false)
								{	return false; }
							}		
						}  

						if(s.type == "textarea"  && s.disabled==false)
						{
							tarea = s.id.split(",")
							//alert(tarea[1]);							
								//if((s.value == "" || s.value.split(" ").join("").length==0) && (parseInt(tarea[1]) > 0 ) && (s.id != ""))
								if((s.value == "" || s.value.split(" ").join("").length==0) && (parseInt(tarea[1]) > 0 ) && (s.id != ""))
									{
										alert("You are requested to fill " + tarea[0]);
										s.select();	
										return false;
									}
								if(parseInt(tarea[1]) < parseInt(s.value.length))
									{
										alert("Length of " + tarea[0] +" is not more then " + tarea[1] + " character ");
										s.select();
										return false;
									}
						}
					if(s.type == "select-one"  && s.disabled==false)
					{
						if(s.selectedIndex == 0 && s.id.length > 0)
						{
							alert("You are requested to select " + s.id);
							s.focus();
							return false;
						}
					}
					if(s.type == "checkbox"  && s.disabled==false)
					{
						//YET TO CODE
					}
					if(s.type == "radio"  && s.disabled==false)
					{
						//YET TO CODE
					}
				}
		return true;
		}

	function chknumdot(strvalue)
		{
			
			var j, strnum;
			var blnstr = "false";
		//	alert("chknumber"+strvalue);
			for(j=0; j<=strvalue.length-1; j++)
				{ 
				strnum = strvalue.charCodeAt(j);
					if ((strnum >= 48 && strnum <=57) || (strnum==46))
						{ }
					else
						{ return false;}
				}
				return true;
		}
		
	function chknum(strValue)
		{
			var i, strnum;
			for(i=0; i<=strValue.length-1; i++)
			{
				strnum = strValue.charCodeAt(i);
				
				if (strnum >= 48 && strnum <= 57)
				{}
				else
				{
					
					return false;
				}
			}
			return true;
		}
		
		
		function chkalpha(strValue)
		{
			var i, strnum;
			
			for(i=0; i<=strValue.length-1; i++)
			{
				strnum = strValue.charCodeAt(i);
				
				if (strnum >= 48 && strnum <= 57)
				{
				return false;	
				}
				else
				{
					
				}
			}
			return true;
		}
		
		function chkalphanum(strValue)
		{
			var i, strnum;
			
			for(i=0; i<=strValue.length-1; i++)
			{
				strnum = strValue.charCodeAt(i);
				
				if ((strnum >= 48 && strnum <= 59)  || (strnum==46) || (strnum >= 65 && strnum <= 90) || (strnum >= 97 && strnum <= 122) || (strnum >= 35 && strnum <= 37) || (strnum==63) || (strnum==64)|| (strnum >= 42 && strnum <= 45) || (strnum==95) || (strnum==32) || (strnum==40)|| (strnum==41))
				{}
				else
				{
					
					return false;
				}
			}
			return true;
		}
	function ValidateCreditCard(s)
		{
			var now = new Date()
			var month = now.getMonth();
			var year = now.getYear();
			
			if(s.card.value=="" || s.card.value=="Select")
				{
				alert("Select card type");
				s.card.focus();
				return false;
				}
			else if(s.txtno.value=="" || s.txtno.value.split(" ").join("").length==0)
				{
				alert("Enter card number.");
				s.txtno.select();
				return false;
				}
						else if(chknum(s.txtno.value,"Only number [0,9] is allowed.")==false)
				{
				s.txtno.select();
				return false;
				}
			else if(s.card.value=="visa card" && s.txtno.value.length != 16 || s.card.value=="visa card" && chkvalidcard(s.txtno.value) != 4)
				{
					alert("Card number is not valid");
					s.txtno.select();
					return false;
				}
			else if(s.card.value=="MasterCard" && s.txtno.value.length != 16 || s.card.value=="MasterCard" && chkvalidcard(s.txtno.value) != 5)
				{
					alert("Card number is not valid");
					s.txtno.select();
					return false;
				}
			else if(s.card.value=="American Express" && s.txtno.value.length != 14 || s.card.value=="American Express" && chkvalidcard(s.txtno.value) != 3)
				{
					alert("Card number is not valid");
					s.txtno.select();
					return false;
				}
			else if(s.month.value == 0 || s.year.value == "Year")
				{
					alert("Please, Select Month and Year of card expire date");
					s.month.focus();
					return false;
				}
			else if(s.month.value <= month && s.year.value == year)
				{
					alert("Sorry, Your card was Expire.");
					s.month.focus();
					return false;
				}
				
		}
	function chkvalidcard(no)
		{
			first = no.substring(0,1);
			//alert(first);
			return first;
		}
	function Onecheckbox(s)
		{
			var str;
			var blnVehicle = "false";
			var blnSubCate = "false";
			for(var i=0;i<s.elements.length;i++)
			{
				if(s.elements[i].type == "checkbox")
					{
						//alert(s.elements[i].name);
						if(s.elements[i].name == "cbxVehicle[]")
							{
								if(s.elements[i].checked == true)
									{ blnVehicle = "true" ;}
							}
						if(s.elements[i].name == "cbxSubCate[]")
							{
								if(s.elements[i].checked == true)
									{ blnSubCate = "true" ;}
							}
					}
			} 
	if(blnVehicle == "false")
		{
			alert("Please, Select atlease one vehicle.");
			return false;	
		}
	if(blnSubCate == "false")
		{
			alert("Please, Select atlease one subcategory.");
			return false;	
		}
	return true;	
	}
//email validate code.		
function validate_email(ele)
{
	var emailStr=ele.value;
	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(theForm.email.value==""){
		return true;
	}*/
	if (matchArray==null) {
		err=true
		errEleNm= ele.name
		alert("Email address seems incorrect (check @ and .'s)");
		ele.focus();
		return false;
	}
	var user=matchArray[1];
	var domain=matchArray[2];
	if (user.match(userPat)==null) {
		err=true
		errEleNm= ele.name
		alert("The username in Email ID doesn't seem to be valid.");
		ele.focus();
		return false;
	}
	
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
				err=true
				errEleNm= ele.name
				alert("Destination IP address in Email ID is invalid!");
				ele.focus();
				return false;
			}
		}
	}  

	var domainArray=domain.match(domainPat);
	if (domainArray==null) {
		err=true
		errEleNm= ele.name
		alert("The domain name in Email ID doesn't seem to be valid.");
		ele.focus();
		return false;
	}

	var atomPat=new RegExp(atom,"g");
	var domArr=domain.match(atomPat);
	var len=domArr.length;
	if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>3) {
		err=true
		errEleNm= ele.name
		alert("The Email address must end in a three-letter domain, or two letter country.");
		ele.focus();
		return false;
	}
	if (len<2) {
		var errStr="This Email address is missing a hostname!";
		err=true
		errEleNm= ele.name
		alert(errStr);
		ele.focus();
		return false;
	  }
	 err=false
	 errEleNm= ""
	return true;
}
		
function chkfiletype(strVal)
{
		var dot;
		var strext = new String;
		var arrext = new Array(".jpg",".jpeg",".gif", ".bmp", ".tiff", ".JPG", ".JPEG", ".GIF", ".BMP", ".TIFF");
		dot = strVal.lastIndexOf(".");
		strext = strVal.substring(dot);
		for (i=0;i<=arrext.length-1;i++)
		{
			 
			if (arrext[i] == strext)
			{		
					return true;
			}
		}
		//alert(strext);
		return false;
}							
	
function checkspace(strValue)
{
	//alert(strValue.split(" ").length);
	if(strValue.split(" ").length>1)
	{
			return false;
			
	}
	
	return true;
}

//for checking both entered password are same
function chkpassword(ele1,ele2)
{
	var pass1,pass2;
	pass1 = ele1.value;
	pass2 = ele2.value;
	
	if(pass1 != pass2)
	{
		alert("Password and confirm password are not same.\nTry again.");
		ele1.select();
		return false;
	}
	return true;
}

//for checking both entered Email address are same
function chkemailequal(ele1,ele2)
{
	var email1,email2;
	email1 = ele1.value;
	email2 = ele2.value;
	
	if(email1 != email2)
	{
		alert("E-Mail Address and Re-type E-Mail Address are not same!");
		ele1.select();
		return false;
	}
	return true;
}


// to change table row color when user clicks on the checkbox in listing.

function chngtrcolor(cid,cstatus)
{
	
	//alert(cstatus);
	if(cstatus)
		document.getElementById("tr"+cid).bgColor = "#FF6666";
	else
		document.getElementById("tr"+cid).bgColor = "";
}

function chngtrcolor_announcement(cid,cstatus)
{
	
	//alert(cstatus);
	if(cstatus)
		document.getElementById("totr"+cid).bgColor = "#F0F0f0";
	else
		document.getElementById("totr"+cid).bgColor = "white";
}
// to enable checkbox click function properly in uniform manner

function CheckUncheckAll(frm,chk)
{
	
	
	if(chk.name.substr(0,5) == "intId")
		{chngtrcolor(chk.id,chk.checked)}
	if(chk.name.substr(0,8)!="CheckAll")
	{
		
		CheckName = chk.name.substr(0,5);
		MyChecked	= true;

		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].name.substr(0,5)==CheckName && frm.elements[i].checked==false)
				
				MyChecked=false;
		}

		CheckAll = eval("frm.CheckAll_"+CheckName.substr(0,5));
		CheckAll.checked=MyChecked;
	}		
	else
	{
		
		CheckName = chk.name.substr(9,chk.name.length);
		if(chk.checked==true)
			AllChecked = true;
		else
			AllChecked = false;
		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].type == "checkbox" && frm.elements[i].name.substr(0,5)==CheckName)
			{
				
				frm.elements[i].checked=AllChecked;	
				
				if(frm.elements[i].name.substr(0,5) == "intId"){chngtrcolor(frm.elements[i].id,frm.elements[i].checked);}
			}
		}
	}
}



function CheckUncheckAll_html(frm,chk)
{
	
	//alert(chk.name.substr(8,5));
	if(chk.name.substr(8,5) == "intId")
		{chngtrcolor(chk.id,chk.checked)}
	//alert(chk.name.substr(8,5));
	if(chk.name.substr(8,16)!="CheckAll_intId")
	{
		
		CheckName = chk.name.substr(8,5);
		//alert(CheckName);
		MyChecked	= true;

		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].name.substr(8,5)==CheckName && frm.elements[i].checked==false)
				
				MyChecked=false;
		}
		//alert("before");
		CheckAll = eval("frm.html_chbCheckAll_"+CheckName);
		//alert("frm.html_chbCheckAll_"+CheckName);
		CheckAll.checked=MyChecked;
		//alert("after");
	}		
	else
	{
		
		CheckName = chk.name.substr(17,chk.name.length);
		//alert(CheckName);
		if(chk.checked==true)
			AllChecked = true;
		else
			AllChecked = false;
		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].type == "checkbox" && frm.elements[i].name.substr(8,5)==CheckName)
			{
				
				frm.elements[i].checked=AllChecked;	
				
				if(frm.elements[i].name.substr(8,5) == "intId"){chngtrcolor(frm.elements[i].id,frm.elements[i].checked);}
			}
		}
	}
}

function chngtrcolor_grp(cid,cstatus)
{
	
	//alert(cstatus);
	if(cstatus)
		document.getElementById("togtr"+cid).bgColor = "#F0F0f0";
	else
		document.getElementById("togtr"+cid).bgColor = "white";
}
function CheckUncheckAll_html_grp(frm,chk)
{
	
	//alert(chk.name.substr(8,5));
	if(chk.name.substr(8,5) == "grpId")
		{chngtrcolor_grp(chk.id,chk.checked)}
	//alert(chk.name.substr(8,14));
	if(chk.name.substr(8,14)!="CheckAll_grpId")
	{
		
		//alert(chk.name.substr(8,14));
		CheckName = chk.name.substr(8,5);
		//alert(CheckName);
		MyChecked	= true;

		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].name.substr(8,5)==CheckName && frm.elements[i].checked==false)
				
				MyChecked=false;
		}
		//alert("before");
		CheckAll = eval("frm.html_chbCheckAll_"+CheckName);
		//alert("frm.html_chbCheckAll_"+CheckName);
		CheckAll.checked=MyChecked;
		//alert("after");
	}		
	else
	{
		//alert("all-all");	
		CheckName = chk.name.substr(17,chk.name.length);
		//alert(CheckName);
		if(chk.checked==true)
			AllChecked = true;
		else
			AllChecked = false;
		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].type == "checkbox" && frm.elements[i].name.substr(8,5)==CheckName)
			{
				
				frm.elements[i].checked=AllChecked;	
				if(frm.elements[i].name.substr(8,5) == "grpId"){chngtrcolor_grp(frm.elements[i].id,frm.elements[i].checked);}
			}
		}
	}
}


function chngtrcolor_dir(cid,cstatus)
{
	
	//alert(cstatus);
	if(cstatus)
		document.getElementById("toetr"+cid).bgColor = "#F0F0f0";
	else
		document.getElementById("toetr"+cid).bgColor = "white";
}
function CheckUncheckAll_html_dir(frm,chk)
{
	
	//alert(chk.name.substr(8,5));
	if(chk.name.substr(8,5) == "dirId")
		{chngtrcolor_dir(chk.id,chk.checked)}
	//alert(chk.name.substr(8,14));
	if(chk.name.substr(8,14)!="CheckAll_dirId")
	{
		
		//alert(chk.name.substr(8,14));
		CheckName = chk.name.substr(8,5);
		//alert(CheckName);
		MyChecked	= true;

		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].name.substr(8,5)==CheckName && frm.elements[i].checked==false)
				
				MyChecked=false;
		}
		//alert("before");
		CheckAll = eval("frm.html_chbCheckAll_"+CheckName);
		//alert("frm.html_chbCheckAll_"+CheckName);
		CheckAll.checked=MyChecked;
		//alert("after");
	}		
	else
	{
		//alert("all-all");	
		CheckName = chk.name.substr(17,chk.name.length);
		//alert(CheckName);
		if(chk.checked==true)
			AllChecked = true;
		else
			AllChecked = false;
		for(i=0;i<frm.elements.length;i++)
		{
			if(frm.elements[i].type == "checkbox" && frm.elements[i].name.substr(8,5)==CheckName)
			{
				
				frm.elements[i].checked=AllChecked;	
				if(frm.elements[i].name.substr(8,5) == "dirId"){chngtrcolor_dir(frm.elements[i].id,frm.elements[i].checked);}
			}
		}
	}
}

//lnk = link ID to be clicked
//tab = table ID on which to perform operation
//disp = display name
//hide = hide name
function showhide(lnk,tab,disp,hide)
{
		
	//alert("here");
	if(document.getElementById(lnk) != undefined && document.getElementById(tab) != undefined)
	{
			//alert(document.getElementById(lnk).innerHTML);
			if(document.getElementById(lnk).innerHTML == disp)
			{
					
				document.getElementById(tab).style.display = "";
				document.getElementById(lnk).innerHTML = hide;
			}	
			else if(document.getElementById(lnk).innerHTML == hide)
			{
				//alert(document.getElementById(lnk).innerHTML);
				document.getElementById(lnk).innerHTML = disp;
				document.getElementById(tab).style.display = "none";
			}
	}
}


function showhide_image(lnk,tab,disp,hide)
{
	if(document.getElementById(lnk) != undefined && document.getElementById(tab) != undefined)
	{
			//alert(document.getElementById(lnk).src.search(disp) + " = " + disp);
			if(document.getElementById(lnk).src.search(disp) > 0)
			{
					
				document.getElementById(tab).style.display = "";
				document.getElementById(lnk).src = hide;
				document.getElementById(lnk).alt = "Click here to hide content";
				//alert(document.getElementById(lnk).src);
			}	
			else if(document.getElementById(lnk).src.search(hide) > 0)
			{
				//alert(document.getElementById(lnk).innerHTML);
				document.getElementById(lnk).src = disp;
				document.getElementById(tab).style.display = "none";
				document.getElementById(lnk).alt = "Click here to see hidden content";
			}
	}
}
//this function will check number as well as with -
function chknumdash(strValue, strMsg)
{
			var i, strnum;
			for(i=0; i<=strValue.length-1; i++)
			{
				strnum = strValue.charCodeAt(i);
				if ((strnum >= 48 && strnum <= 57) || strnum==45)
				{}
				else
				{
					alert(strMsg);
					return false;
				}
			}
			return true;
}											
//function runs a loop for each control and gets no of check boxes selected
function noofcheckbox(frm)
{
	intno = 0;
	var strfrm = frm;
	for(i=0;i < eval(strfrm).elements.length;i++)
	{
		if(eval(strfrm).elements[i].type == "checkbox" && eval(strfrm).elements[i].checked)
		{	
			intno++;
		}
	}
	return intno;
}
function IsDate(dateStr)
{
	// Checks for the following valid date formats:
	// MM/DD/YYYY   MM-DD-YYYY
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	var matchArray = dateStr.match(datePat)
	if (matchArray == null)
		return false
	month = matchArray[1]
	day = matchArray[3]
	year = matchArray[4]
	if (month < 1 || month > 12)
		return false
	if (day < 1 || day > 31)
		return false
	if ((month==4 || month==6 || month==9 || month==11) && day==31)
		return false
	if (month == 2)
	{
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0))
		if (day>29 || (day==29 && !isleap))
			return false;
	}
	return true;
}

function federaltaxtid(ssnl) 
{
  var ssn = ssnl.value
 
  //var matchArr = ssn.match(/^(\d{3})-?\d{2}-?\d{4}$/);
  var matchArr = ssn.match(/^(\d{2})-?\d{7}-?\d{0}$/);
  var numDashes = ssn.split('-').length - 1;
  
   		
 		if (matchArr == null || numDashes == 1)
		 {
		       if(ssn.match(/^(\d{2})-?\d{7}-?\d{0}$/))
			   {
			   return true;
			   }
		       
			   alert('Invalid Federal Tax ID No. Must be 9 digits or in the form XX-XXXXXXX.');
			   document.html_frmbapplication.html_txtfedaral.value=="";
			   ssnl.focus();
			   return false;
		 }
		 else
		 {
		   
			  var len=ssn.length;
			  var first=ssn.substr(0,2);
			  var last= ssn.substr(2,len);
			  var  formatstring=first+"-"+last;
			  document.html_frmbapplication.html_txtfedaral.value=formatstring;
			  return true;
			
		 }
      
 return true;

}
function PhoneValidation(ssn1) 
{
  var ssn = ssn1.value
	  if(ssn=="")
	  {
	  return true;
	  }
	  var matchArr = ssn.match(/^(\d{3})-?\d{3}-?\d{4}$/);
	  var numDashes = ssn.split('-').length - 1;
  if (matchArr == null || numDashes == 1)
	 {
	  alert('Invalid Phone No. Must be 10 digits or in the form XXX-XXX-XXXX.');
	  msg = "does not appear to be valid";
	  ssn1.focus();
	  return false;
	 }
else 
	   if (parseInt(matchArr[1],10)==0) 
	   {
			 alert("Invalid Phone No:");
			 msg = "does not appear to be valid";
			// document.frmloan.phone.value=="";
			 ssn1.focus();
			 return false;
	   }
	    if(ssn.match(/^(\d{3})\d{3}\d{4}$/))
			   {
					 var len=ssn.length;
					 var first=ssn.substr(0,3);
					 var middle= ssn.substr(3,3);
					 var last= ssn.substr(6,len);
					 var  formatstring=first+"-"+middle+"-"+last;
					 ssn1.value=formatstring;
					 return true; 
			   }
      return true;
}

