<!--
//<![CDATA[
		   
var selectdd_text = "-- select --";

$(document).ready( function() { 

	//Flash
	$("#home_panel").html("").flash({
		src: '/swf/ward1.swf?id=xkjh',
		width: 980,
		height: 310,
		wmode: "transparent"
	});
	
	//////////////////////////////////////////////////////////////////////////////
	// *** USED PRODUCT SELECTOR
	//////////////////////////////////////////////////////////////////////////////
	
	$("#used_dd").ajaxAddOption("/__ajax/__product_usedcategory_json.asp?rand="+fetch_unix_timestamp(), {"id":"", "action":"cat"}, true, function() {
																												
										$("#used_dd").selectOptions("", null); 
										  $("#used_dd option").each(function() { 
													 $(this).html(replaceAll($(this).html(), "&amp;quot;", "\""));
													 $(this).html(replaceAll($(this).html(), "&amp;", "&"));
											});	
										  
										  if($("#used_dd option").length <=1)
											{
												$("#used_dd").attr("disabled", "disabled");		
											}
											else
											{
												$("#used_dd").attr("disabled", "");		
											}
										
									 });
	
		$("#viewusedmachines").click(function() {
									  var catid = $("#used_dd").val();
									  
									  if(catid!='') {
									  	location.replace("/catalogue/?c1=" + catid + "&p=1&old=1");
									  }
									  else {
										return false;  
									  }
									  });
	
	
	//////////////////////////////////////////////////////////////////////////////
	// *** PRODUCT SELECTOR
	//////////////////////////////////////////////////////////////////////////////
	// Prepare category dropdown
	$("#cat1_dd").ajaxAddOption("/__ajax/__product_category_json.asp?rand="+fetch_unix_timestamp(), {"id":"", "action":"cat"}, true, function() { 
																												 $("#cat1_dd").selectOptions("", null); 
																												  $("#cat1_dd option").each(function() { 
																															 $(this).html(replaceAll($(this).html(), "&amp;quot;", "\""));
																															 $(this).html(replaceAll($(this).html(), "&amp;", "&"));
																													});	
																												  
																												  if($("#cat1_dd option").length <=1)
																													{
																														$("#cat1_dd").attr("disabled", "disabled");		
																													}
																													else
																													{
																														$("#cat1_dd").attr("disabled", "");		
																													}
																													
																												 }, null);
	
	
	$("#cat1_dd").attr("disabled", "");	
	$("#cat2_dd, #cat3_dd").removeOption(/./);
	$("#cat2_dd, #cat3_dd").attr("disabled", "disabled");
	$("#cat2_dd, #cat3_dd").addOption("", selectdd_text);
	
	// Bind events to category dropdowns - DROP DOWN 1
	$("#cat1_dd").change(function() {
			
			$("#cat2_dd, #cat3_dd").removeOption(/./);
			$("#cat2_dd, #cat3_dd").attr("disabled", "disabled");	
			$("#cat2_dd, #cat3_dd").addOption("", selectdd_text);
			
			var cat1_val = $(this).val();

			if(cat1_val!='') {		
				
				$("#cat2_dd").ajaxAddOption(
											"/__ajax/__product_category_json.asp?rand="+fetch_unix_timestamp(), 
											{"id":cat1_val, "action":"cat"},
											true,
											function() {
												$("#cat2_dd").selectOptions("", null);
												$("#cat2_dd option").each(function() { 
														 $(this).html(replaceAll($(this).html(), "&amp;quot;", "\""));
														 $(this).html(replaceAll($(this).html(), "&amp;", "&"));
												});	
												
												if($("#cat2_dd option").length <=1)
												{
													$("#cat2_dd").attr("disabled", "disabled");		
												}
												else
												{
													$("#cat2_dd").attr("disabled", "");		
												}
												
											},
											null
										)
				$("#cat2_dd").attr("disabled", "");		
				
				
				
				UpdateCounter(cat1_val);
				$("#BtnResetSelector").show();
				
			}
			
	 });
	
	// Bind events to category dropdowns - DROP DOWN 2
	$("#cat2_dd").change(function() {
			
			$("#cat3_dd").removeOption(/./);	
			$("#cat3_dd").attr("disabled", "disabled");	
			
			var cat1_val= $("#cat1_dd").val();
			var cat2_val = $(this).val();
			
			
			if(cat2_val!='') {
				
				
				$("#cat3_dd").ajaxAddOption(
											"/__ajax/__product_category_json.asp?rand="+fetch_unix_timestamp(), 
											{"id":cat2_val, "action":"cat"},
											true,
											function() {
												$("#cat3_dd").selectOptions("", null);
												$("#cat3_dd option").each(function() { 
														 $(this).html(replaceAll($(this).html(), "&amp;quot;", "\""));
														 $(this).html(replaceAll($(this).html(), "&amp;", "&"));
												});	
												
												if($("#cat3_dd option").length <=1)
												{
													$("#cat3_dd").attr("disabled", "disabled");		
												}
												else
												{
													$("#cat3_dd").attr("disabled", "");		
												}
												
											},
											null
										)
				
				$("#cat3_dd").attr("disabled", "");		
				
				
				UpdateCounter(cat2_val);
				
				$("#BtnResetSelector").show();
			}
			
	 });
	
	// Bind events to category dropdowns - DROP DOWN 3
	$("#cat3_dd").change(function() {			
			
			var cat1_val= $("#cat1_dd").val();
			var cat2_val= $("#cat2_dd").val();
			var cat3_val = $(this).val();
			
			if(cat3_val!='') {	
			
				UpdateCounter(cat3_val);
				$("#BtnResetSelector").show();
			}
					 
	 });
	
	$("#viewmachines").click(function() {
		var cat1_val= $("#cat1_dd").val();
		var cat2_val= $("#cat2_dd").val();
		var cat3_val = $("#cat3_dd").val();
		location.href = '/catalogue/?c1=' + cat1_val + '&c2=' + cat2_val + '&c3=' + cat3_val
	 });
	
	$("#BtnResetSelector").click(function() {
		$("#cat1_dd").ajaxAddOption("/__ajax/__product_category_json.asp", {"id":"", "action":"cat"}, true, function() { $("#cat1_dd").selectOptions("", null); }, null);
		$("#cat1_dd").attr("disabled", "");	
		$("#cat2_dd, #cat3_dd").removeOption(/./);
		$("#cat2_dd, #cat3_dd").attr("disabled", "disabled");
		$("#cat2_dd, #cat3_dd").addOption("", "Select an option");
		
		$("#resultCount").html("0");
		
		$(this).hide();
		return false;
	 });
	//////////////////////////////////////////////////////////////////////////////
	// *** END PRODUCT SELECTOR
	//////////////////////////////////////////////////////////////////////////////
	

//News ticker
	
	//every five seconds swap headlines
		$(".headline2").hide();
		$(".headline3").hide();
		$(".headline4").hide();
		setInterval("swapHeadlines()",5000);


//Accordion stuff
	
	//Set correct width on each panel
		var panelCount, panelWidth, h1Width, accordionWidth, moveDistance;
		
		h1Width = 58;
		accordionWidth = $("#accordion").width();

		panelCount = $("#accordion > div.accordion_panel").size();
		panelWidth = accordionWidth-((panelCount-1)*h1Width);
		$("#accordion div.accordion_panel").width(panelWidth);
		
	//Loop through each div and set z index and left values
		for (i=0;i<panelCount;i++)
		{
			if (i==0)
			{
				$("#accordion div.accordion_panel:eq(" + i +")").css("border-left","none");
			}
			if (i==panelCount-1)	
			{
				$("#accordion div.accordion_panel:eq(" + i +") h1").addClass("active");
			}
			$("#accordion div.accordion_panel:eq(" + i +")").css("z-index",i+1).css("left",i*h1Width);
		}
	
	//On click add active class and run correct animation
		$("#accordion div.accordion_panel h1").click( function() {
											   
			var indexOfClicked = $("h1").index(this);								   
			$("#accordion div.accordion_panel h1").removeClass("active").removeClass("hover");
			$("#rightside_panel").removeClass("active");
			$(this).addClass("active").next().addClass("active");
			
			//on the rightside panel add class active to fix ie6 bug
			
			for (i=0;i<panelCount;i++)
			{
				moveDistance = i*h1Width	
				if (i > indexOfClicked)
				{
					moveDistance = accordionWidth - (h1Width*(panelCount-i));
				}
				
				$("#accordion div.accordion_panel:eq(" + i +")").animate({"left": "" + moveDistance +"px"});
				
			}
		});
	
	
	//Add hover classes on hover
		$("#accordion div.accordion_panel h1").hover( function() {
			if (!$(this).hasClass("active")) {
				$(this).addClass("hover");
			}
		},function() { 
			if (!$(this).hasClass("active")) {
				$(this).removeClass("hover");
			}
		});
});

var headline = 1;

function swapHeadlines() {
	
	$(".headline" + headline).fadeOut("slow");
	if (headline < 4)
		headline++;
	else
		headline = 1;
	$(".headline" + headline).fadeIn("slow");
}

function UpdateCounter(cat) {
	
	$.ajax({
	   type: "POST",
	   url: "/__ajax/__category_count.asp",
	   data: "id="+cat,
	   success: function(msg){
			//$("#result_count").html(msg); 
			$("#resultCount").html(msg);
	   }
	   });
	   
}

//]]>
-->	