function validateIns(f){
	var srcid = 'landingpage1';

	if(f.srcid.value != ''){
		srcid = f.srcid.value;
	}

	if(srcid == 'get-quotes-results800'){
		if(f.statecode.value == ''){
			alert('Please select a state.');
			return false;
		}
	}

	if(srcid != 'landingpage1' && srcid != 'get-quotes-results800'){
		if(f.zipcode.value == ''){
			if(srcid == 'landingpage2' || srcid == 'landingpage8002' || srcid == 'landingpage8003'){
				alert('Please select a state.');
			} else {
				alert('Please enter your zipcode.');
			}
			f.zipcode.focus();
			return false;
		} else if(!validZIP(f.zipcode.value)){
			alert('Please enter valid 5-digits zipcode.');
			f.zipcode.focus();
			return false;
		} else if (!existingZIP(f.zipcode.value)) {
			alert('This zipcode does not exist.');
			f.zipcode.focus();
			return false;
		}
	}

	if(srcid == 'auto' || srcid == 'landingpage8002' || srcid == 'landingpage2' || srcid == 'landingpage')
	{
		xmlUrl = '/toggle.php?toggle=auto';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					if(xmlHttp.responseText == 'InsuranceLeadzAuto'){
						InsuranceLeadzAuto(f.zipcode.value, f.ni_var1.value);
					} else if(xmlHttp.responseText == 'AutoFrame'){
						AutoFrame(f.zipcode.value, f.ni_var1.value + '_x');
					} else if(xmlHttp.responseText == 'AutoFrameMOSS'){
						AutoFrameMOSS(f.zipcode.value, f.ni_var1.value + '_x');
					} else if(xmlHttp.responseText == 'BW'){
						if(window.location.host == 'quotecarinsurance'){
							document.location = 'http://quotecarinsurance/autoinsurancequotes.php?zipcode=' + f.zipcode.value + '&ni_var1=' + f.ni_var1.value;
						} else {
							document.location = 'http://www.quotecarinsurance.com/autoinsurancequotes.php?zipcode=' + f.zipcode.value + '&ni_var1=' + f.ni_var1.value;
						}
						return false;
					}
					return false;
				}
			}
		}

		xmlHttp.send(null);
	}
	else if(srcid == 'home')
	{
		//tgUrl = 'https://www.insuranceleadz.com/form/home';
		tgUrl = 'https://forms.insuranceagents.com/home/';
		_url = tgUrl + '?zip=' + f.zipcode.value + '&a=38402&c=' + f.ni_var1.value + '&t=396';

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&Zip=' + f.zipcode.value + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = _url;
				}
			}
		}
		xmlHttp.send(null);
	}
	else if(srcid == 'health')
	{
		//tgUrl = 'https://www.insuranceleadz.com/form/health';
		//_url = tgUrl + '?zip=' + f.zipcode.value + '&a=38402&c=' + f.ni_var1.value + '&t=396';

		tgUrl = 'http://www.ehealthinsurance.com/ehi/Alliance?allid=AOV28265&type=IFP';
		_url = tgUrl + '&zip=' + f.zipcode.value;

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&Zip=' + f.zipcode.value + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = _url;
				}
			}
		}
		xmlHttp.send(null);
	}
	else if(srcid == 'life')
	{
		//tgUrl = 'https://www.insuranceleadz.com/form/life';
		tgUrl = 'https://forms.insuranceagents.com/life/';
		_url = tgUrl + '?zip=' + f.zipcode.value + '&a=38402&c=' + f.ni_var1.value + '&t=396';

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&Zip=' + f.zipcode.value + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = _url;
				}
			}
		}
		xmlHttp.send(null);
	}
	/*else if(srcid == 'landingpage')
	{
		//tgUrl = 'http://www.quotecarinsurance.com/get-quotes.php';
		tgUrl = 'http://quotecarinsurance/get-quotes.php';
		_url = tgUrl + '?zip=' + f.zipcode.value + '&a=38402&c=' + f.ni_var1.value + '&t=396';

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&Zip=' + f.zipcode.value + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = _url;
				}
			}
		}

		xmlHttp.send(null);
	}*/
	else if(srcid == 'landingpage1')
	{
		var str = f.zipcode.value;
		state = str.split("#");
		//tgUrl = 'http://www.quotecarinsurance.com/';
		tgUrl = 'http://quotecarinsurance/Cheap-' + state[1] + "-Car-Insurance.php";
		//document.location = tgUrl;

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&Zip=' + state[0] + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = tgUrl;
				}
			}
		}

		xmlHttp.send(null);
	}
	/*else if(srcid == 'landingpage2')
	{
		//tgUrl = 'http://www.quotecarinsurance.com/get-quotes.php';
		tgUrl = 'http://quotecarinsurance/get-quotes800.php';
		_url = tgUrl + '?zip=' + f.zipcode.value + '&a=38402&c=' + f.ni_var1.value + '&t=396';

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&Zip=' + f.zipcode.value + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = _url;
				}
			}
		}

		xmlHttp.send(null);
	}*/
	/*else if(srcid == 'landingpage8002')
	{
		//tgUrl = 'http://www.quotecarinsurance.com/get-quotes.php';
		tgUrl = 'http://quotecarinsurance/get-quotes8002.php';
		_url = tgUrl + '?zip=' + f.zipcode.value + '&a=38402&c=' + f.ni_var1.value + '&t=396';

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&Zip=' + f.zipcode.value + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = _url;
				}
			}
		}

		xmlHttp.send(null);
	}*/
	else if(srcid == 'landingpage8003')
	{
		//tgUrl = 'http://www.quotecarinsurance.com/get-quotes.php';

		var client = '';

		if(f.quoteType.value == 'home'){
			client = '173909';
		} else if(f.quoteType.value == 'life'){
			client = '161283';
		} else if(f.quoteType.value == 'health'){
			client = '2436';
		} else {
			client = '176295';	// by default -> auto
		}

		tgUrl = 'http://quotecarinsurance/get-quotes8003.php';
		_url = tgUrl + '?zip=' + f.zipcode.value + '&a=38402&c=' + f.ni_var1.value + '&t=396&client=' + client;

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&Zip=' + f.zipcode.value + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = _url;
				}
			}
		}

		xmlHttp.send(null);
	}
	else if(srcid == 'get-quotes-results800')
	{
		//tgUrl = 'http://www.quotecarinsurance.com/get-quotes.php';
		tgUrl = 'http://quotecarinsurance/get-quotes-results800.php';
		_url = tgUrl + '?statecode=' + f.statecode.value + '&a=38402&c=' + f.ni_var1.value + '&t=396';

		xmlUrl = '/savestat.php?tgUrl=' + escape(tgUrl) + '&statecode=' + f.statecode.value + '&AffID=38402&Nivar=' + f.ni_var1.value + '&Theme=396';
		xmlHttp.open('GET', xmlUrl, true);

		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4){
				if(xmlHttp.status == 200){
					document.location = _url;
				}
			}
		}

		xmlHttp.send(null);
	}

	return false;
}