function tabOne(tab)
{
	if(tab==1)
	{
		document.getElementById('img1').src='http://busneeds.com/images/image_11.jpg';
	}
	else
	{
		document.getElementById('img1').src='http://busneeds.com/images/image-down_11.jpg';
	}
	if(tab==2)
	{
		document.getElementById('img2').src='http://busneeds.com/images/image-down_13.jpg';
	}
	else
	{
		document.getElementById('img2').src='http://busneeds.com/images/image_13.jpg';
	}
	if(tab==3)
	{
		document.getElementById('img3').src='http://busneeds.com/images/image-down_14.jpg';
	}
	else
	{
		document.getElementById('img3').src='http://busneeds.com/images/image_14.jpg';
	}
	for(var i=1;i<=3;i++)
	{
		if(tab==i)
		{
			document.getElementById('page'+i).style.display='';
		}
		else
		{
			document.getElementById('page'+i).style.display='none';
		}
	}
}
function stCk(val,id,company_id,total)
{
	var cb_out_name='c_set_cookie_cb'+id;
	if(document.getElementById(cb_out_name).checked==true)
	{
	var cb_name='c_set_cookie_quote'+id;
	listBusCokkie(cb_name,id,company_id,'1',total);
	}
	else
	{
	var cb_name='c_set_cookie_quote'+id;
	listBusCokkie(cb_name,id,company_id,'0',total);
	}
}
function stCkLimo(val,id,company_id,total)
{
	var cb_out_name='c_set_cookie_cb'+id;
	if(document.getElementById(cb_out_name).checked==true)
	{
	var cb_name='c_set_cookie_quote'+id;
	listLimoCokkie(cb_name,id,company_id,'1',total);
	}
	else
	{
	var cb_name='c_set_cookie_quote'+id;
	listLimoCokkie(cb_name,id,company_id,'0',total);
	}
}
function zipCheck()
{
	if(document.getElementById('zip_1').value=='ZIP :')
	{
		document.getElementById('zip_1').value='';
	}
}
function cityCheck()
{
	alert("Select a State");
}
function searchListing(type,pageNo,sl)
{
	if(sl=='srch')
	{
		 var nn=100;
		 clearCookie(nn);
	}
if(type=='B')
{
	var bus1=document.getElementById('my_bus_id_1').value;
	var state1=document.getElementById('my_state_id_1').value;
	var city1=document.getElementById('my_city_id_1').value;
	var zip1=document.getElementById('zip_1').value;
	if(bus1=="")
	{
		alert("Select a Bus type.");
		return false;
	}
	if(state1=="" && city1=="" && (zip1=="" || zip1=='ZIP :'))
	{
		alert("Select a State and City OR Enter a Zip Code.");
		return false;
	}
	if(state1!="" && city1=="" && (zip1=="" || zip1=='ZIP :'))
	{
		alert("Select a City.");
		return false;
	}
	if(zip1!='' && zip1!='ZIP :')
	{
		if(zip1.length!=5)
		{
			alert('Zip might be five in length.');
			return false;
		}
		document.getElementById('my_state_id_1').value='';
		document.getElementById('my_city_id_1').value='';
		//alert("With Zip");		
		listBusWithZip(bus1,zip1,pageNo,sl);
	}
	else
	{
		document.getElementById('zip_1').value='ZIP :';
		//alert("With Out Zip");
		listBusWithOutZip(bus1,state1,city1,pageNo,sl);
	}
}
if(type=='L')
{
 
	var limo1=document.getElementById('my_limo_id_3').value;
	var state1=document.getElementById('my_state_id_3').value;
	var city1=document.getElementById('my_city_id_3').value;
	var zip1=document.getElementById('zip_3').value;
	if(limo1=="")
	{
		alert("Select a Limo type.");
		return false;
	}
	if(state1=="" && city1=="" && (zip1=="" || zip1=='ZIP :'))
	{
		alert("Select a State and City OR Enter a Zip Code.");
		return false;
	}
	if(state1!="" && city1=="" && (zip1=="" || zip1=='ZIP :'))
	{
		alert("Select a City.");
		return false;
	}
	if(zip1!='' && zip1!='ZIP :')
	{
		if(zip1.length!=5)
		{
			alert('Zip might be five in length.');
			return false;
		}
		document.getElementById('my_state_id_3').value='';
		document.getElementById('my_city_id_3').value='';
		//alert("With Zip");		
		listLimoWithZip(limo1,zip1,pageNo,sl);
	}
	else
	{
		document.getElementById('zip_3').value='ZIP :';
		//alert("With Out Zip");
		listLimoWithOutZip(limo1,state1,city1,pageNo,sl);
	}

}
}
function clearCookie(nn)
{
	for(var j=0;j<=nn;j++)
	{
		var name='c_set_cookie_quote'+j;
		deletecookie(name);
	}

}
function deletecookie(name) 
{
		var expdate = new Date();
		expdate.setTime(expdate.getTime() - 100);
		document.cookie = name += "=; expires=" + expdate.toGMTString();
}
function createRequestObjectB1()
{	var request_o; 
	var browser = navigator.appName; 
	if(browser == "Microsoft Internet Explorer")
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	else		
		request_o = new XMLHttpRequest();	
	return request_o; 
	
}
var httpB1 = createRequestObjectB1(); 

function listBusWithZip(bus1,zip1,pageNo,sl)
{	
	passingUrl='http://busneeds.com/ajaxListBus.php?bus1='+bus1+'&zip1='+zip1+'&pageNo='+pageNo+'&sl='+sl+'&sid='+Math.random();
	httpB1.open('get', passingUrl);
	document.getElementById('listing').innerHTML='<img src="http://busneeds.com/images/loading2.gif" border="0"/>';
	httpB1.onreadystatechange = handleDeleteB1;
	httpB1.send(null);	
}
function listBusWithOutZip(bus1,state1,city1,pageNo,sl)
{	
	passingUrl='http://busneeds.com/ajaxListBus.php?bus1='+bus1+'&state1='+state1+'&city1='+city1+'&pageNo='+pageNo+'&sl='+sl+'&sid='+Math.random();
	httpB1.open('get', passingUrl);
	document.getElementById('listing').innerHTML='<img src="http://busneeds.com/images/loading2.gif" border="0"/>';
	httpB1.onreadystatechange = handleDeleteB1;
	httpB1.send(null);	
}
function listBusCokkie(cb_name,id,company_id,ts,total)
{	
	passingUrl='http://busneeds.com/ajaxListBusCokkie.php?cb_name='+cb_name+'&id='+id+'&ts='+ts+'&total='+total+'&company_id='+company_id+'&sid='+Math.random();
	httpB1.open('get', passingUrl);
	httpB1.onreadystatechange = handleDeleteB2;
	httpB1.send(null);	
}
//Limo code starts Here
function listLimoWithZip(limo1,zip1,pageNo,sl)
{	
	passingUrl='http://busneeds.com/ajaxListLimo.php?limo1='+limo1+'&zip1='+zip1+'&pageNo='+pageNo+'&sl='+sl+'&sid='+Math.random();
	httpB1.open('get', passingUrl);
	document.getElementById('listing').innerHTML='<img src="http://busneeds.com/images/loading2.gif" border="0"/>';
	httpB1.onreadystatechange = handleDeleteB1;
	httpB1.send(null);	
}
function listLimoWithOutZip(limo1,state1,city1,pageNo,sl)
{	
	passingUrl='http://busneeds.com/ajaxListLimo.php?limo1='+limo1+'&state1='+state1+'&city1='+city1+'&pageNo='+pageNo+'&sl='+sl+'&sid='+Math.random();
	httpB1.open('get', passingUrl);
	document.getElementById('listing').innerHTML='<img src="http://busneeds.com/images/loading2.gif" border="0"/>';
	httpB1.onreadystatechange = handleDeleteB1;
	httpB1.send(null);	
}
function listLimoCokkie(cb_name,id,company_id,ts,total)
{	
	passingUrl='http://busneeds.com/ajaxListLimoCokkie.php?cb_name='+cb_name+'&id='+id+'&ts='+ts+'&total='+total+'&company_id='+company_id+'&sid='+Math.random();
	httpB1.open('get', passingUrl);
	httpB1.onreadystatechange = handleDeleteB2;
	httpB1.send(null);	
}
//Limo code Ends Here

function handleDeleteB1()
{	
	if(httpB1.readyState == 4)
	{	
		var response = httpB1.responseText;	
		document.getElementById('listing').innerHTML = response;
	}
}
function handleDeleteB2()
{	
	if(httpB1.readyState == 4)
	{	
		var response = httpB1.responseText;	
		var res=parseInt(response);
		document.getElementById('quoteCount').value = res;
		document.getElementById('quoteCount_2').value = res;
		if(res=='0' || res=='1')
		{
		document.getElementById('listing_company_id').innerHTML = 'company';
		document.getElementById('listing_company_id_2').innerHTML = 'company';
		}
		else
		{
		document.getElementById('listing_company_id').innerHTML = 'companies';	
		document.getElementById('listing_company_id_2').innerHTML = 'companies';	
		}
		if(res=='0')
		{
		document.getElementById('listing_id').innerHTML = 'No';
		document.getElementById('listing_id_2').innerHTML = 'No';
		}
		else
		{
		document.getElementById('listing_id').innerHTML = res;	
		document.getElementById('listing_id_2').innerHTML = res;	
		}
	}
}

function checkQuote(val)
{
	if(val=='2')
	{
		if(document.getElementById('companyCount').value=='0')
		{
			alert("No Search Result found. Please go with another Search");
			return false;
		}
		if(document.getElementById('quoteCount_2').value=='0')
		{
			alert("No Company selected for Quoting. Please select atleast One Company.");
			return false;
		}
		return true;
	}
	if(val=='1')
	{
		if(document.getElementById('companyCount').value=='0')
		{
			alert("No Search Result found. Please go with another Search");
			return false;
		}
		if(document.getElementById('quoteCount').value=='0')
		{
			alert("No Company selected for Quoting. Please select atleast One Company from listing.");
			return false;
		}
		return true;
	}
}
