// JavaScript Document
$(document).ready( function() { 	
							
							
	//producttabs						
	$("#producttabs > ul").tabs({ fxSlide: true, fxFade: true, fxSpeed: 'fast' });
	
	//homepage banner
	//$(".flashbox > ul").tabs({ fxSlide: true, fxFade: true, fxSpeed: 'fast', fxAutoHeight: true });
	 
	$(".flashbox").show("slow",function(){
	});
	
	//$(".flashbox").tabsRotate(5000);
	$focus_tab = 1;
	$("#showroom > ul").tabs($focus_tab,{ fxSlide: true, fxFade: true, fxSpeed: 'slow' });
	//Form focus first field
	//$("#form1 :input:visible:enabled:first").focus();
	
	//search Brand-model
	makeSublist('parent','child', false, '1');
	
	//go to model page
	$("#searchmodel").click( function() { 	
		$searchid=$("#child").val();
		document.location.href="model.php?model_id=" + $searchid;
	});
	
});

function makeSublist(parent,child,isSubselectOptional,childVal)
{
	$("body").append("<select style='display:none' id='"+parent+child+"'></select>");
	$('#'+parent+child).html($("#"+child+" option"));
	
		var parentValue = $('#'+parent).attr('value');
		$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
	
	childVal = (typeof childVal == "undefined")? "" : childVal ;
	$("#"+child+' option[@value="'+ childVal +'"]').attr('selected','selected');
	
	$('#'+parent).change( 
		function()
		{
			var parentValue = $('#'+parent).attr('value');
			$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
			if(isSubselectOptional) $('#'+child).prepend("<option value='none'> -- Select -- </option>");
			$('#'+child).trigger("change");
                        $('#'+child).focus();
		}
	);
}