// <!CDATA[
function IMG1_onclick() {}

function showDialog()
{ //Force reload in order to guarantee that the onload event handler of the dialog which configures it executes on every show.
  var oWnd = window.radopen(null, "sss");
  oWnd.setUrl("/radlogin.aspx");
}
function CloseAndRebind(args)
{ GetRadWindow().Close();
  //document.location.reload();
}    
function GetRadWindow()
{ var oWindow = null;
  if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
  else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;//IE (and Moz as well)
  return oWindow;
}

function ShowTab(tab)
{
document.getElementById('Zip').style.display ='none';
document.getElementById('dvCounty').style.display ='none';
document.getElementById('User').style.display ='none';
document.getElementById('Zip').style.visibility ='hidden';
document.getElementById('dvCounty').style.visibility ='hidden';
document.getElementById('User').style.visibility ='hidden';
document.getElementById('zipS').style.background ='url(/images/bt-zipsearch.jpg';
document.getElementById('zipC').style.background ='url(/images/bt-countysearch.jpg)';
document.getElementById('zipN').style.background ='url(/images/bt-namesearch.jpg)';

switch(tab)
{
case 1:
document.getElementById('Zip').style.display ='block';
document.getElementById('Zip').style.visibility ='visible';
document.getElementById('zipS').style.background ='url(/images/bt-zipsearch-h.jpg';
document.forms[0].ctl00$stype.value='1';
break;
case 2:
document.getElementById('dvCounty').style.display ='block';
document.getElementById('dvCounty').style.visibility ='visible';
document.getElementById('zipC').style.background ='url(/images/bt-countysearch-h.jpg)';
document.forms[0].ctl00$stype.value='2';
break;
case 3:
document.getElementById('User').style.display ='block';
document.getElementById('User').style.visibility ='visible';
document.getElementById('zipN').style.background ='url(/images/bt-namesearch-h.jpg)';
document.forms[0].ctl00$stype.value='3';
break; 
}
}

function searchprofessional()
{
bln = false;

if(document.forms[0].ctl00$stype.value=="1")
{
if(SearchZipCodeValidation())
bln = true;
}
if(document.forms[0].ctl00$stype.value=="2")
{
if(document.forms[0].ctl00$State.value=="Select State" || document.forms[0].ctl00$County.value=="Select")
{
alert("Please select state and county");
bln=false;
}
else
{
bln = true;
}
}
if(document.forms[0].ctl00$stype.value=="3")
{
if(SearchNameValidation())
bln = true;
}
if(bln)
{document.forms[0].action = 'searchresult.aspx';
document.forms[0].stype.value = document.forms[0].ctl00$stype.value;
document.forms[0].s_cty.value = document.forms[0].ctl00$County.value;
document.forms[0].s_state.value = document.forms[0].ctl00$State.value;
document.forms[0].submit();
}


}
function SearchNameValidation() 
{ 
if ((document.getElementById("txtFirstName").value=="")&& (document.getElementById("txtLastName").value==""))
{
alert("Please enter first/last Name");
document.getElementById("txtFirstName").focus();
return (false);
}
return (true)

}
	
function SearchZipCodeValidation() 
{ 
if (document.getElementById("txtZip").value=="")
{
alert("Please enter zip code");
document.getElementById("txtZip").focus();
return (false);
}
if (isNaN(document.getElementById("txtZip").value))
{
	alert("Please enter only digits for the zip code field");
	document.getElementById("txtZip").focus();
	return (false);
}
if (document.getElementById("txtZip").value.length < 5)
{
	alert("Please enter at least 5 digits in the zip code field");
	document.getElementById("txtZip").focus();
	return (false);
}
return (true)
}
	
function SearchCountyStateValidation() 
{ 
if (document.getElementById("State").selectedIndex==0)
{
	alert("Please select state");
	document.getElementById("State").focus();
	return (false); 
}

if (document.getElementById("txtCounty").value=="")
{
alert("Please enter county") 
document.getElementById("txtCounty").focus()
return (false);
}

return (true);
	}


function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_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 frmsubmit()
{
if(verifyRequired())
{
var fname=document.forms[0].fields_fname.value;
var lname=document.forms[0].fields_lname.value;
var email=document.forms[0].fields_email.value
//document.forms[0].action = 'http://app.icontact.com/icp/signup.php';
//alert("newsletterthanks.aspx?fn="+fname+"&ln="+lname+"&el="+email);
//document.forms[0].action = "newsletterthanks.aspx?fn="+fname+"&ln="+lname+"&el="+email;
//document.forms[0].submit();
location.href="newsletterthanks.aspx?fn="+fname+"&ln="+lname+"&el="+email;
}

}

//THIS FUNTION CHECK FOR A VALID  EMAIL ADDRESS.
function isValidEmail(emailid) {
if (emailid == ""){
return false; // because  it is not optional 
}
else{
var eid=emailid;

if (eid.indexOf(' ')!= -1){
return false ; // no spaces
} 
if (eid.length < 6 ){
return false ; // at least j.a@in
}
at=eid.indexOf('@', 0); //check from first position ---- 
if ( at == -1 || at == 0){ //should not be at first place
return false ;
}else{
var at1=eid.indexOf('@', (at + 1)); //looking for another at one place ahead
if ( at1 == -1 ) // ie only one at is there
{
var dot=eid.indexOf('.',(at + 1));//looking for just next value
if(dot == (at + 1)|| dot== -1){ //if dot is not there or in the next place
return false ;
}
else{
if ( (dot + 2 ) < eid.length )
return true ;
else{
return false ;
}
}
}
else // two @ are there
{
return false;
}
}
return false ;
}
}
/////////////////////End Function /////////////////////////////////////////////

function verifyRequired() {
if (document.forms[0].fields_fname.value == "")
{
document.forms[0].fields_fname.focus();
alert("Please enter first name");
return false;
}
if (document.forms[0].fields_lname.value == "")
{
document.forms[0].fields_lname.focus();
alert("Please enter last name");
return false;
}
if (document.forms[0].fields_email.value == "")
{
document.forms[0].fields_email.focus();
alert("Please enter email address");
return false;
}
if(!isValidEmail(document.forms[0].fields_email.value))
{
alert("Please enter valid email address");
return false;
}

return true;
}

/*function preload(images) 
{	if (document.images) {
	var i = 0;
	var imageArray = new Array();
	imageArray = images.split(',');
	var imageObj = new Image();
	document.write('<div style="display:none"><img name="imageObj" /></div>');
		for(i=0; i<=imageArray.length-1; i++) {
		//document.write('<img src="/images/' + imageArray[i] + '" />');// Write to page (uncomment to check images)
		imageObj.src='/images/' + images[i];
		}
	}
}

preload('logo.jpg,facebook-icons.jpg,linkedin-icons.jpg,twitter-icons.jpg,top-linkleft.jpg,top-linkright.jpg,tab-left.jpg,tab-bg.jpg,tab-right.jpg,body-bg.jpg,background-bg.jpg,bt-zipsearch-h.jpg,bt-countysearch-h.jpg,bt-namesearch.jpg,search-bg-left.jpg,btnsearch.jpg,join_now.jpg,image-1.jpg,image-2.jpg,image-3.jpg,image-4.jpg,image-5.jpg,btn-join.jpg,banner.jpg,login.jpg,join-now.jpg,blue-button.jpg,top-linkbg.jpg,search-icon.png,partition.jpg,partition1.jpg');*/

//]]>   

function OpenSN(strURL)
{
var newWindow = window.open(strURL, '_blank');
newWindow.focus();
return false;
}
