function initPage(){
	var nav = new Array();
	nav[0] = document.getElementById("hover1");
	nav[1] = document.getElementById("hover2");
	nav[2] = document.getElementById("hover3");
	for (var j = 0; j < nav.length; j++){
		if (nav[j]){
			var nodes = nav[j].getElementsByTagName("li");
			for (var i = 0; i < nodes.length; i++){
				nodes[i].onmouseover = function (){
					if (this.className.indexOf("hover") == -1){
						this.className += "hover";
					}
				}
				nodes[i].onmouseout = function (){
					this.className = this.className.replace("hover","");
				}
			}
			nodes = [];
		}
	}
}
if (window.attachEvent && !window.opera) window.attachEvent("onload", initPage);// JavaScript Document


function compare()
{
	var product = $('[name=compare]:checked').val();
	var productSelected = '';
	var count = 0;	
	var selected = document.fmscompare.compare;
	if ( selected.length )
	{
		for ( i = 0; i < selected.length; i++ )
		{
			if ( selected[i].checked == true )
			{
				productSelected += selected[i].value + ',';
				count++;
			}
		}
	}
	else
	{
		if ( selected.checked == true )
		productSelected = selected.value;
	}
	if ( count < 2 )
	{
		alert('กรุณาเลือกรายการมากกว่า 1 รายการ');
		return false;
	}
	if ( count > 3 )
	{
		alert('จำกัดไว้สูงสุด 3 รายการเท่านั้น');
		return false;
	}
	window.location = 'car-compare.php?id_car=' + productSelected;
}

function compare_tent(id)
{
	var product = $('[name=compare]:checked').val();
	var productSelected = '';
	var count = 0;	
	var selected = document.fmscompare.compare;
	if ( selected.length )
	{
		for ( i = 0; i < selected.length; i++ )
		{
			if ( selected[i].checked == true )
			{
				productSelected += selected[i].value + ',';
				count++;
			}
		}
	}
	else
	{
		if ( selected.checked == true )
		productSelected = selected.value;
	}
	if ( count < 2 )
	{
		alert('กรุณาเลือกรายการมากกว่า 1 รายการ');
		return false;
	}
	if ( count > 3 )
	{
		alert('จำกัดไว้สูงสุด 3 รายการเท่านั้น');
		return false;
	}
	window.location = 'car-compare.php?tent='+id+'&id_car=' + productSelected;
}

function SearchCar(url){
s_type = document.getElementById('s_type').value;
Brand_car = document.getElementById('brand_car').value;
Model = document.getElementById('model').value;
Face = document.getElementById('face').value;
CYear = document.getElementById('s_year').value;
CPrice = document.getElementById('s_price').value;

Path = url;
if (s_type!="0"){
Path += "Type=" + s_type + "&";
}
if (Brand_car !='0') {
Path += "Brand_car=" + Brand_car + "&";
  if (Model != '0'){
      Path += "Model=" + Model + "&";
          if (Face != '0'){
               Path += "Face=" + Face + "&";
          }
  }

}
switch (CYear){
    case "":break;default:
    YearCar = CYear.split("-");
    Path += "Year1=" + YearCar[0] + "&";
    Path += "Year2=" + YearCar[1] + "&";
}
switch (CPrice){
    case "":break;default:
    PriceCar = CPrice.split("-");
    Path += "Price1=" + PriceCar[0] + "&";
    Path += "Price2=" + PriceCar[1] + "&";
}
	window.open(Path);
	return false;
}
/* Search 2 */
function SearchCar2(url2){
s_type = document.getElementById('s_type').value;
Brand_car = document.getElementById('BrandCar').value;
Model = document.getElementById('Model').value;
Face = document.getElementById('Face').value;
CYear = document.getElementById('s_year').value;
CPrice = document.getElementById('s_price').value;

Path = url2;
if (s_type!="0"){
Path += "Type=" + s_type + "&";
}
if (Brand_car !='0') {
Path += "Brand_car=" + Brand_car + "&";
  if (Model != '0'){
      Path += "Model=" + Model + "&";
          if (Face != '0'){
               Path += "Face=" + Face + "&";
          }
  }

}
switch (CYear){
    case "":break;default:
    YearCar = CYear.split("-");
    Path += "Year1=" + YearCar[0] + "&";
    Path += "Year2=" + YearCar[1] + "&";
}
switch (CPrice){
    case "":break;default:
    PriceCar = CPrice.split("-");
    Path += "Price1=" + PriceCar[0] + "&";
    Path += "Price2=" + PriceCar[1] + "&";
}
	window.open(Path);
	return false;
}




function SearchCar_tent(url){
s_type = document.getElementById('s_typeTent').value;
Brand_car = document.getElementById('brand_carTent').value;
Model = document.getElementById('modelTent').value;
Face = document.getElementById('faceTent').value;
CYear = document.getElementById('s_yearTent').value;
CPrice = document.getElementById('s_priceTent').value;

Path = url;
if (s_type!="0"){
Path += "Type=" + s_type + "&";
}
if (Brand_car !='0') {
Path += "brand_carTent=" + Brand_car + "&";
  if (Model != '0'){
      Path += "modelTent=" + Model + "&";
          if (Face != '0'){
               Path += "faceTent=" + Face + "&";
          }
  }

}
switch (CYear){
    case "":break;default:
    YearCar = CYear.split("-");
    Path += "Year1=" + YearCar[0] + "&";
    Path += "Year2=" + YearCar[1] + "&";
}
switch (CPrice){
    case "":break;default:
    PriceCar = CPrice.split("-");
    Path += "Price1=" + PriceCar[0] + "&";
    Path += "Price2=" + PriceCar[1] + "&";
}
	window.open(Path);
	return false;
}



function Show_Popup(action, userid) {
$('#popup').fadeIn('fast');
$('#window').fadeIn('fast');
}
function Close_Popup() {
$('#popup').fadeOut('fast');
$('#window').fadeOut('fast');
}
