/**
*DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*I did a bit of tweaking, so don't blame SmartWebby.com for the mistakes
*/

function echeck(str) {
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.lastIndexOf(dot);
		var rv = 1;			
		if(lat<1||ldot-lat<4||ldot<5||lstr-ldot!=4){
			rv = 0;
		}

                if (str.indexOf(" ")!=-1)
		{ 		     
                     rv = 0;
		}

                if (rv==0)
                {		     
		}
 		return rv;					
}
function TestDataCheck()
{
	var FirstName = document.contact.name.value;
	var email     = document.contact.email.value;
	var returnval;
	var booVar = 2;
	
	if ( (FirstName != '') && (email != '')) {  
		returnval = true;   
	}	
	else
	{
		alert("Please Enter information in all required fields");      
		document.getElementById('fstNm').style.color="red";
		document.getElementById('emailo').style.color="red";
		document.getElementsByName('name')[0].focus;
		return false;
	}
	booVar = echeck(email);
	if (booVar!=1)
	{		
		alert("We're sorry, there seems to be a problem with your email format.  Can you please re-check it?");
		document.getElementById('emailo').style.color="red";
		document.getElementsByName('email')[0].focus();
		return false;
	}
	return returnval
}

function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "d";
  else
    return results[1];
}

function checkstatus ()
{
	if (gup("status")=="pass")
	{
		document.getElementById('thanks').innerHTML="<span style='font-weight:600;color:green'>Thank you for your submission, a qualified Affinity Insurance Group customer service representative will be in touch shortly.</span>";
	}
	else if (gup("status")=="fail")
	{
		document.getElementById('thanks').innerHTML="<span style='font-weight:600;color:red'>I'm sorry, but there seems to be a problem with your e-mail address.<br />Please try again.<br /></span>";
	}
	else 
	{
		return;
	}
}

function showType(intNum, checkType)
{	
	t=setTimeout("",10);
	picture="../images/slide"+intNum+".png";	
	var imageDescription=new Array(); // regular array (add an optional integer
	imageDescription[0]="We offer Competitive rates for your home"; 
	imageDescription[5]="We offer Competitive rates for your home";       // argument to control array's size)
	imageDescription[2]="Our Auto rates are among the industry's best";
	imageDescription[3]="We Cover Your Business Needs";       // argument to control array's size)
	imageDescription[6]="Whatever you do to relax, our Life insurance products will help you provide for your family";
	imageDescription[4]="We Cover Your Business Needs"; 
	imageDescription[1]="High Water is No Trouble when you have Affinity Flood Insurance!";       // argument to control array's size)
	imageDescription[7]="We are a locally owned and operated West Virginia insurance agency";
	imageDescription[8]="Contact Us today to get your personalized rate quotes"; 
	if (checkType == 1)
	{
		document.getElementById('imgHolder').style.backgroundImage="url("+picture+")";	
		document.getElementById('imgHolder').innerHTML='<h2 style="background-color:white;color:blue">'+imageDescription[intNum]+'</h2><img id="typePic" alt="" title="various pics" src="images/empty.png"></img>';
		document.getElementById('typePic').title=imageDescription[intNum];		
	}
	else 
	{	
		document.getElementById('imgHolder').innerHTML="<img id='typePic' alt='selected tab photo' src='"+picture+"'></img>";
		document.getElementById('typePic').title=imageDescription[intNum];	
	}

}
