$(document).ready(function(){
	var cookieName = 'NetQuoteHomeTab';
	var index = getCookie(cookieName);    
	var type = $("#type_of option:selected").val();
	if (type == "Auto")
	{
	$("#currently").show();
	$("#currentlyText").show();
	}
	else
	{
		if ($('#MainConv').length != 0)
		{
			$("#currently").hide();
			$("#currentlyText").hide();
			document.getElementById("currently_1").checked = false;
			document.getElementById("currently_0").checked = false;
		}
	}
	
	$("#type_of").change(function () {
	var type = $("#type_of option:selected").val();
	  if (type == "Auto")
	  {
		$("#currently").show();
		$("#currentlyText").show();
	  }
	  else
	  {
		$("#currently").hide();
		$("#currentlyText").hide();
		document.getElementById("currently_1").checked = false;
		document.getElementById("currently_0").checked = false;			
	  }
	})
	$("#AutoHeaderLink img").hover(
			function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-auto-s.jpg');
			  },
			  function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-auto.jpg');
			  }
		);
		$("#HomeHeaderLink img").hover(
			function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-home-s.jpg');
			  },
			  function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-home.jpg');
			  }
		);
		$("#RentersHeaderLink img").hover(
			function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-renters-s.jpg');
			  },
			  function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-renters.jpg');
			  }
		);
		$("#BusinessHeaderLink img").hover(
			function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-business-s.jpg');
			  },
			  function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-business.jpg');
			  }
		);
		$("#LifeHeaderLink img").hover(
			function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-life-s.jpg');
			  },
			  function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-life.jpg');
			  }
		);
		$("#HealthHeaderLink img").hover(
			function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-health-s.jpg');
			  },
			  function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-health.jpg');
			  }
		);
		$("#GroupHealthHeaderLink img").hover(
			function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-group-s.jpg');
			  },
			  function () {
				$(this).attr('src', '/StaticSupport/images/nq-home-header-tab-group.jpg');
			  }
		);
	$(".tab_content").hide(); 
	$("ul.tabs li:first").addClass("active").show();
	$(".tab_content:first").show();
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); 
		$(this).addClass("active");
		$(".tab_content").hide(); 
		var activeTab = $(this).find("a").attr("href"); 
		$(activeTab).show();
		return false;
	});
	
});

  function getCookie(c_name)
  {
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{
		c_start=c_start + c_name.length+1;
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		}
	  }
	  return 0;
	}
	
	function setCookie(c_name,value,expiredays)
	{
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value)+
		((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}

function validate_formAuto()
{
    valid = true;
	var zip = $("#zip_code").val();
	var yes = document.getElementById("currently_0");
	var no = document.getElementById("currently_1");
	var type = "Auto";
	var insured = "No";
if ( zip.length == 0 || zip == "Enter ZIP Code" )
    {
        alert ( "Please enter a valid ZIP code." );
        valid = false;
    }
	else if (zip.length < 5)
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (Zip_Validate(zip) == "False")
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (type == "Auto") 
	{
		if (yes.checked == false && no.checked == false)
		{
			alert("Please indicate if you currently have auto insurance.");
			valid = false;		
		}
		if (yes.checked)	
		{
			insured = "Yes";
		}
		else
		{
			insured = "No";
		}	
	}
	
	if (valid == true)
	{		
		window.location = "/StaticSupport/asp/Redirect.aspx?placement=RD&zip_code=" + zip + "&type_of=" + type + "&currentlyinsured=" + 
insured;
		valid = false;
	}	
    return valid;
}

function validate_form()
{
    valid = true;
	var zip = $("#zip_code").val();
	var yes = document.getElementById("currently_0");
	var no = document.getElementById("currently_1");
	var type = $("#type_of option:selected").val();
	var insured = "";
	var nqid = $('#nqid').val();
    if ( zip.length == 0 )
    {
        alert ( "Please enter a valid ZIP Code." );
        valid = false;
    }
	else if (zip.length < 5)
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (Zip_Validate(zip) == "False")
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (type == "Auto") 
	{
		if (yes.checked == false && no.checked == false)
		{
			alert("Please indicate if you currently have auto insurance.");
			valid = false;		
		}
		if (yes.checked)	
		{
			insured = "Yes";
		}
		else
		{
			insured = "No";
		}	
	}
	else if (type == "Motorcycle")
	{
		var url = "/staticsupport/redirect.aspx?nqid=" + nqid + "&type_of=Motorcycle&zip_code=" + zip;
		window.open(url, "", "width=480, height=420, resizable=no, scrollbars=yes, location=no");
		return false;
	}
	if (valid == true)
	{		
		window.location = "/StaticSupport/asp/Redirect.aspx?placement=RD&seo=yes&zip_code=" + zip + "&type_of=" + type + "&currentlyinsured=" + 
insured;
		valid = false;
	}	
    return valid;
}

function validate_formBusiness()
{
    valid = true;
	var zip = $("#zip_code").val();
	var yes = document.getElementById("currently_0");
	var no = document.getElementById("currently_1");
	var type = "Business";
	var insured = "No";
if ( zip.length == 0 || zip == "Enter ZIP Code" )
    {
        alert ( "Please enter a valid ZIP code." );
        valid = false;
    }
	else if (zip.length < 5)
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (Zip_Validate(zip) == "False")
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	
	if (valid == true)
	{		
		window.location = "/StaticSupport/asp/Redirect.aspx?placement=RD&zip_code=" + zip + "&type_of=" + type + "&currentlyinsured=" + 
insured;
		valid = false;
	}	
    return valid;
}

function validate_formGroup()
{
    valid = true;
	var zip = $("#zip_code").val();
	var yes = document.getElementById("currently_0");
	var no = document.getElementById("currently_1");
	var type = "Group";
	var insured = "No";
if ( zip.length == 0 || zip == "Enter ZIP Code" )
    {
        alert ( "Please enter a valid ZIP code." );
        valid = false;
    }
	else if (zip.length < 5)
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (Zip_Validate(zip) == "False")
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	
	if (valid == true)
	{		
		window.location = "/StaticSupport/asp/Redirect.aspx?placement=RD&zip_code=" + zip + "&type_of=" + type + "&currentlyinsured=" + 
insured;
		valid = false;
	}
	
    return valid;
}

function validate_formHealth()
{
    valid = true;
	var zip = $("#zip_code").val();
	var yes = document.getElementById("currently_0");
	var no = document.getElementById("currently_1");
	var type = "Health";
	var insured = "No";
if ( zip.length == 0 || zip == "Enter ZIP Code" )
    {
        alert ( "Please enter a valid ZIP code." );
        valid = false;
    }
	else if (zip.length < 5)
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (Zip_Validate(zip) == "False")
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	
	if (valid == true)
	{		
		window.location = "/StaticSupport/asp/Redirect.aspx?placement=RD&zip_code=" + zip + "&type_of=" + type + "&currentlyinsured=" + 
insured;
		valid = false;
	}
	
    return valid;
}

function validate_formHome()
{
    valid = true;
	var zip = $("#zip_code").val();
	var yes = document.getElementById("currently_0");
	var no = document.getElementById("currently_1");
	var type = "Home";
	var insured = "No";
if ( zip.length == 0 || zip == "Enter ZIP Code" )
    {
        alert ( "Please enter a valid ZIP code." );
        valid = false;
    }
	else if (zip.length < 5)
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (Zip_Validate(zip) == "False")
	{
		alert ( "Invalid zip code" );
        valid = false;
	}

	
	if (valid == true)
	{		
		window.location = "/StaticSupport/asp/Redirect.aspx?placement=RD&zip_code=" + zip + "&type_of=" + type + "&currentlyinsured=" + 
insured;
		valid = false;
	}
	
    return valid;
}

function validate_formLife()
{
    valid = true;
	var zip = $("#zip_code").val();
	var yes = document.getElementById("currently_0");
	var no = document.getElementById("currently_1");
	var type = "Life";
	var insured = "No";
if ( zip.length == 0 || zip == "Enter ZIP Code" )
    {
        alert ( "Please enter a valid ZIP code." );
        valid = false;
    }
	else if (zip.length < 5)
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	else if (Zip_Validate(zip) == "False")
	{
		alert ( "Invalid zip code" );
        valid = false;
	}
	
	if (valid == true)
	{		
		window.location = "/StaticSupport/asp/Redirect.aspx?placement=RD&zip_code=" + zip + "&type_of=" + type + "&currentlyinsured=" + 
insured;
		valid = false;
	}
	
    return valid;
}

function Zip_Validate(zip)
{
	var boo = false;
	var url = "/handlers/ZipCodeValidation.ashx?zipcode=" + zip
	var xmlhttp=null;
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	boo = xmlhttp.responseText;
	
	return boo
}

function VaildateGoogle()
{
	var txtValue = document.getElementById("gValue").value;
	if (txtValue == "" || txtValue == null || txtValue == "Search")
	{
		alert("Please enter a keyword/phrase.");
		return false;
	}
	return true;
}

function returnYear()
{
	var today = new Date()
	var year = today.getYear()
	if (year < 1900)
	{
	year = year + 1900;
	}
	document.write(year)	
}
