// JavaScript Document
function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
setInterval( "slideSwitch()", 5000 );
});

function ValidateClick() {
form_product=document.quoteform.type.value; //selected product
aff_id=document.quoteform.affil.value; //lead affiliate id
zipcode=document.quoteform.zipcode.value; //zipcode

siteURL ="";
var siteURL ="http://www.insuranceratesguide.com/forms";
//siteURL = siteURL + "/" + form_product + "?a=" + aff_id +"&t=" +;
getfield = [];//array with values in form fields
getfield[0] = aff_id;
getfield[1] = form_product;
getfield[2] = zipcode; //zip code
webjuice=0;
form_behavior=0; //0: Normal - 1: BW Ads.
prod_id=0;

switch (form_product) {
case 'auto': form_behavior=1; prod_id=300; break;
case 'home': form_behavior=1; break;
case 'health':form_behavior=1; prod_id=200; break;
case 'life': form_behavior=1; prod_id=260; break;
case 'condo':form_behavior=1; break;
case 'renters':form_behavior=1; break;
case 'annuity':form_behavior=1; break;
}
	if (form_behavior==1){//BW
	siteURL = siteURL + "/" + form_product + "/?a=" +aff_id+ "&t=646&c="+document.getElementById('campaign_name').value+"&zip="+zipcode;
	document.quoteform.method="get";
	window.open(siteURL,null,"fullscreen=yes, toolbars=yes, scrollbars=yes, menubar=yes, location=yes");
	}
}

function quote(affil_name,theme_id)
{
	var url;
	var qt = document.getElementById('type').value;
	if (qt != '')
	{
		var affil = 1;
		var af = document.getElementById('affil');
		if (af)
		{
			affil = af.value;
		}
		var z = document.getElementById('zipcode').value;

		url = 'http://www.insuranceratesguide.com/forms/'+ qt+ '?a='+ affil+ '&t='+ theme_id +'&c='+ affil_name;
		if (/^\d{5}$/.test(z))
		{
			url += '&zip='+ z;
		}
		//document.location.href = url;
		window.location.assign(url);
		return false;
	}
	return false;
}

function toggleAutoInsurance()
{
	var qt = document.getElementById('type').value;
	if (qt != 'auto')
	{
		document.getElementById('auto_insurance').style.display="none";
	}
	else
	{
		document.getElementById('auto_insurance').style.display="";
	}
}

(function() {
    var wa = document.createElement('script'); wa.type = 'text/javascript'; wa.async = true;
    wa.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://ca15146') + '.luckyorange.com/w.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(wa, s);
  })();

