window.onload = function() 
{ 
	Cufon.replace('h1');
	Cufon.replace('.NewsItemNameCopy_1');
	Cufon.replace('.ProductItemNameValueCopy_2');
	Cufon.replace('.AdSearchCategoryTitleCopy');

	//$("ul.rmRootGroup li").each(function(){
	//	if(!$(this).hasClass("rmFirst")) $(this).children('.rmSlide').remove();
	//	
	//	})

	$(".ProductSearchSortOrderInputBox_1 option[value='DateDESC']").remove();
	$(".ProductSearchSortOrderInputBox_1 option[value='DateASC']").remove();

	/* Header Search */
	if (document.getElementById('ctl00_Basicsearch1_txtSearch')!=null){
		document.getElementById('ctl00_Basicsearch1_txtSearch').value="Site Search";
		var element1 = document.getElementById('ctl00_Basicsearch1_txtSearch'); 	 
		element1.value = "Site Search";
		
		window.focus()
		
		element1.onfocus = function() { 
			if (element1.value=='Site Search'){element1.value=""};
		}
		
		element1.onblur = function() { 
			if (element1.value==''){element1.value="Site Search"};
		}
	}

	if (document.getElementById('Searchresults1_divSearchResultsList')!=null){
		$('.SearchResultsProductRRPValueCopy_1').each(function(index) {
			//alert($(this).text());
			if ($(this).text()=="$0.00"){
				$(this).parent().css("display","none");
			}
		});
	}
	
	if (document.getElementById('AdSearchFieldsContainer')!=null){
		
		document.getElementById('ctl02_txtMinPrice').value="Min. price ($)";
		var element2 = document.getElementById('ctl02_txtMinPrice'); 	 
		element2.value = "Min. price ($)";
		
		document.getElementById('ctl02_txtMaxPrice').value="Max. price ($)";
		var element3 = document.getElementById('ctl02_txtMaxPrice'); 	 
		element3.value = "Max. price ($)";
		
		document.getElementById('ctl02_txtKeyword').value="Keyword(s)";
		var element4 = document.getElementById('ctl02_txtKeyword'); 	 
		element4.value = "Keyword(s)";
		
		window.focus()
		
		element2.onfocus = function() { 
			if (element2.value=='Min. price ($)'){element2.value=""};
		}
		
		element2.onblur = function() { 
			if (element2.value==''){element2.value="Min. price ($)"};
		}
		
		element3.onfocus = function() { 
			if (element3.value=='Max. price ($)'){element3.value=""};
		}
		
		element3.onblur = function() { 
			if (element3.value==''){element3.value="Max. price ($)"};
		}
		
		element4.onfocus = function() { 
			if (element4.value=='Keyword(s)'){element4.value=""};
		}
		
		element4.onblur = function() { 
			if (element4.value==''){element4.value="Keyword(s)"};
		}
	}
	
	
	/* Home News List */
	if (document.getElementById('ctl02_RadRotator1')!=null){
		document.getElementById('ctl02_RadRotator1').style.paddingBottom="0px"
		document.getElementById('ctl02_RadRotator1').style.height="203px"
	}
	
	/* Checkout */
	if (document.getElementById('objCheckoutRegistration_PhysicalAddress_lblCountry')!=null){
		document.getElementById('objCheckoutRegistration_PhysicalAddress_lblCountry').innerHTML="Country";
	}
	if (document.getElementById('objCheckoutRegistration_PhysicalAddress_lblState')!=null){
		document.getElementById('objCheckoutRegistration_PhysicalAddress_lblState').innerHTML="State";
	}
	if (document.getElementById('objCheckoutRegistration_PostalAddress_lblCountry')!=null){
		document.getElementById('objCheckoutRegistration_PostalAddress_lblCountry').innerHTML="Country";
	}
	if (document.getElementById('objCheckoutRegistration_PostalAddress_lblState')!=null){
		document.getElementById('objCheckoutRegistration_PostalAddress_lblState').innerHTML="State";
	}
	if (document.getElementById('objCheckoutShoppingCart_dgrdDataGrid')==null){
		if (document.getElementById('EditShoppingCart')!=null){
			document.getElementById('EditShoppingCart').style.display="none";	
		}
	}
	
}

function pageLoad(sender, args) {
	$('.ShoppingCartProductPropertyItemContainer_1').each(function(index) {
		//alert(index + ': ' + $(this).text());
		$(this).children(".ShoppingCartProductPropertyItemNameCopy_1:first").css("display","none");
		$(this).children(".ShoppingCartProductPropertyItemValueCopy_1:first").css("width","118px");
	});

	if (document.getElementById('ProductItem1_lblStockLevelStatusValue')!=null){
		var Status;
		Status = document.getElementById('ProductItem1_lblStockLevelStatusValue').innerHTML;
		if (Status=="Out of Stock"){
			document.getElementById('ProductItemSoldContainer').style.display="block";
			$("#imgBookTestRide").attr("src","/Images/Book_a_Test_Ride_Button_Off.gif");
			$("#imgEnquireNow").attr("src","/Images/Enquire_Now_Button_Off.gif");
			$("#hrfBookTestRide").removeAttr("href");
			$("#hrfEnquiryNow").removeAttr("href");
			$(".ProductItemRRPTitleCopy_3").css("color","#979797");
			$(".ProductItemRRPValueCopy_3").css("color","#979797");
		}
		else {
			document.getElementById('ProductItemSoldContainer').style.display="none";
			$("#imgBookTestRide").attr("src","/Images/Book_a_Test_Ride_Button.gif");
			$("#imgEnquireNow").attr("src","/Images/Enquire_Now_Button.gif");
		}
	}

}

$(document).ready(function () {

	$('.ShoppingCartProductPropertyItemContainer_1').each(function(index) {
		//alert(index + ': ' + $(this).text());
		$(this).children(".ShoppingCartProductPropertyItemNameCopy_1:first").css("display","none");
		$(this).children(".ShoppingCartProductPropertyItemValueCopy_1:first").css("width","118px");
	});
	
	//$(".ShoppingCartProductPropertyItemContainer_1 .ShoppingCartProductPropertyItemNameCopy_1:first").css("display","none");
	//$(".ShoppingCartProductPropertyItemContainer_1 .ShoppingCartProductPropertyItemValueCopy_1:first").css("width","118px");
	
	$('.ShoppingCartProductPropertyItemContainer_2').each(function(index) {
		//alert(index + ': ' + $(this).text());
		$(this).children(".ShoppingCartProductPropertyItemNameCopy_2:first").css("display","none");
		$(this).children(".ShoppingCartProductPropertyItemValueCopy_2:first").css("width","118px");
	});
	
	//$(".ShoppingCartProductPropertyItemContainer_2 .ShoppingCartProductPropertyItemNameCopy_2:first").css("display","none");
	//$(".ShoppingCartProductPropertyItemContainer_2 .ShoppingCartProductPropertyItemValueCopy_2:first").css("width","118px");
	
  	/* Home News and Gallery swap function */
	$("#btnNewsAndEvent").click(function() {
		$("#FlickrGalleryContainer").hide("fast", function() {
			$("#btnNewsAndEvent").attr("src", "/Images/NewsAndEvents_r.gif");
			$("#btnFlickrGallery").attr("src", "/Images/Gallery.gif");
			$("#NewsAndEventsContainer").show("slow", function() {});
		});
	});
	
	$("#btnFlickrGallery").click(function() {
		$("#NewsAndEventsContainer").hide("fast", function() {
			$("#btnNewsAndEvent").attr("src", "/Images/NewsAndEvents.gif");
			$("#btnFlickrGallery").attr("src", "/Images/Gallery_r.gif");
			$("#FlickrGalleryContainer").show("slow", function() {});
		});
	});
	
	/* New product Tab swap functions */
	$("#tdTabPro01").click(function() {
		$("#tdTabPro02").removeClass("TabPro02_r");
		$("#tdTabPro02").addClass("TabPro02");
		$("#TabPro02Span").removeClass("TabPro02SpanCopy_r");
		$("#TabPro02Span").addClass("TabPro02SpanCopy");
		Cufon.replace('.TabPro02SpanCopy', {
			color: '#828282'
		});
		
		$("#tdTabPro03").removeClass("TabPro03_r");
		$("#tdTabPro03").addClass("TabPro03");
		$("#TabPro03Span").removeClass("TabPro03SpanCopy_r");
		$("#TabPro03Span").addClass("TabPro03SpanCopy");
		Cufon.replace('.TabPro03SpanCopy', {
			color: '#828282'
		});
			
		$("#tdTabPro01").removeClass("TabPro01");
		$("#tdTabPro01").addClass("TabPro01_r");
		$("#TabPro01Span").removeClass("TabPro01SpanCopy");
		$("#TabPro01Span").addClass("TabPro01SpanCopy_r");
		Cufon.replace('.TabPro01SpanCopy_r', {
			color: '#ffffff'
		});
		
		$("#ProductNewContent02").hide("fast", function() {});
		$("#ProductNewContent03").hide("fast", function() {});
		$("#ProductNewContent01").show("fast", function() {});
		
	});
	
	$("#tdTabPro02").click(function() {
		$("#tdTabPro01").removeClass("TabPro01_r");
		$("#tdTabPro01").addClass("TabPro01");
		$("#TabPro01Span").removeClass("TabPro01SpanCopy_r");
		$("#TabPro01Span").addClass("TabPro01SpanCopy");
		Cufon.replace('.TabPro01SpanCopy', {
			color: '#828282'
		});
		
		$("#tdTabPro03").removeClass("TabPro03_r");
		$("#tdTabPro03").addClass("TabPro03");
		$("#TabPro03Span").removeClass("TabPro03SpanCopy_r");
		$("#TabPro03Span").addClass("TabPro03SpanCopy");
		Cufon.replace('.TabPro03SpanCopy', {
			color: '#828282'
		});
			
		$("#tdTabPro02").removeClass("TabPro02");
		$("#tdTabPro02").addClass("TabPro02_r");
		$("#TabPro02Span").removeClass("TabPro02SpanCopy");
		$("#TabPro02Span").addClass("TabPro02SpanCopy_r");
		Cufon.replace('.TabPro02SpanCopy_r', {
			color: '#ffffff'
		});
		
		$("#ProductNewContent01").hide("fast", function() {});
		$("#ProductNewContent03").hide("fast", function() {});
		$("#ProductNewContent02").show("fast", function() {});
		
	});
	
	$("#tdTabPro03").click(function() {
		$("#tdTabPro01").removeClass("TabPro01_r");
		$("#tdTabPro01").addClass("TabPro01");
		$("#TabPro01Span").removeClass("TabPro01SpanCopy_r");
		$("#TabPro01Span").addClass("TabPro01SpanCopy");
		Cufon.replace('.TabPro01SpanCopy', {
			color: '#828282'
		});
		
		$("#tdTabPro02").removeClass("TabPro02_r");
		$("#tdTabPro02").addClass("TabPro02");
		$("#TabPro02Span").removeClass("TabPro02SpanCopy_r");
		$("#TabPro02Span").addClass("TabPro02SpanCopy");
		Cufon.replace('.TabPro02SpanCopy', {
			color: '#828282'
		});
			
		$("#tdTabPro03").removeClass("TabPro03");
		$("#tdTabPro03").addClass("TabPro03_r");
		$("#TabPro03Span").removeClass("TabPro03SpanCopy");
		$("#TabPro03Span").addClass("TabPro03SpanCopy_r");
		Cufon.replace('.TabPro03SpanCopy_r', {
			color: '#ffffff'
		});
		
		$("#ProductNewContent01").hide("fast", function() {});
		$("#ProductNewContent02").hide("fast", function() {});
		$("#ProductNewContent03").show("fast", function() {});
		
	});
	
	/* Brands Landing Tab swap functions */
	$("#tdTab01").click(function() {
		$("#tdTab02").removeClass("Tab02_r");
		$("#tdTab02").addClass("Tab02");
		$("#Tab02Span").removeClass("Tab02SpanCopy_r");
		$("#Tab02Span").addClass("Tab02SpanCopy");
		Cufon.replace('.Tab02SpanCopy', {
			color: '#828282'
		});
			
		$("#tdTab01").removeClass("Tab01");
		$("#tdTab01").addClass("Tab01_r");
		$("#Tab01Span").removeClass("Tab01SpanCopy");
		$("#Tab01Span").addClass("Tab01SpanCopy_r");
		Cufon.replace('.Tab01SpanCopy_r', {
			color: '#ffffff'
		});
		
		$("#BrandsLandingContent02").hide("fast", function() {
			$("#BrandsLandingContent01").show("slow", function() {});
		});
		
	});
	
	$("#tdTab02").click(function() {
		$("#tdTab01").removeClass("Tab01_r");
		$("#tdTab01").addClass("Tab01");
		$("#Tab01Span").removeClass("Tab01SpanCopy_r");
		$("#Tab01Span").addClass("Tab01SpanCopy");
		Cufon.replace('.Tab01SpanCopy', {
			color: '#828282'
		});
			
		$("#tdTab02").removeClass("Tab02");
		$("#tdTab02").addClass("Tab02_r");
		$("#Tab02Span").removeClass("Tab02SpanCopy");
		$("#Tab02Span").addClass("Tab02SpanCopy_r");
		Cufon.replace('.Tab02SpanCopy_r', {
			color: '#ffffff'
		});
		
		$("#BrandsLandingContent01").hide("fast", function() {
			$("#BrandsLandingContent02").show("slow", function() {});
		});
		
	});

	if ($(".SearchResultsPagingContainer_1").length!=0) {
		
		var next = '';
		var Previous = '';
		var Paging = '';
		var newdiv
		
		Previous =$(".SearchResultsPagingPreviousPageContainer_1").html();
		next = $(".SearchResultsPagingNextPageContainer_1").html();
		Paging = $(".SearchResultsPagingListContainer_1").html(); 
										
		newdiv = '<table border=0 cellspacing=0 cellpadding=0 align=left><tr><td><div id="Searchresults1_Paging_plhPagingBottom_divPagingPreviousPage" class="SearchResultsPagingPreviousPageContainer_1">' + Previous + '</div><div id="Searchresults1_Paging_plhPagingBottom_divPagingList" class="SearchResultsPagingListContainer_1">' +Paging+'</div><div id="Searchresults1_Paging_plhPagingBottom_divPagingNextPage" class="SearchResultsPagingNextPageContainer_1">' +next+'</div></td></tr></table>';
		
		$(".SearchResultsPagingContainer_1").html(newdiv);
													
	}
	
});

function BookATestRideProdPopup(pcId,pId) 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/book_a_test_ride.aspx?pcid=' + pcId + '&pid=' + pId + '&placeValuesBeforeTB_=savedValues&TB_iframe=false&height=556&width=399&modal=true');
	});

}

function BookATestRideProdPopup_used(pcId,pId) 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/book_a_test_ride_used.aspx?pcid=' + pcId + '&pid=' + pId + '&placeValuesBeforeTB_=savedValues&TB_iframe=false&height=556&width=399&modal=true');
	});

}

function BookATestRidePopup() 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/book_a_test_ride.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=false&height=556&width=399&modal=true');
	});

}

function EnquiryNowPopup(pcId,pId) 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/product_enquiry.aspx?pcid=' + pcId + '&pid=' + pId + '&placeValuesBeforeTB_=savedValues&TB_iframe=false&height=463&width=349&modal=true');
	});

}

function BookAServicePopup() 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/book_a_service.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=false&height=407&width=749&modal=true');
	});

}

function BookADynoTest() 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/book_a_dynotest.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=false&height=320&width=749&modal=true');
	});

}

function BookACustomisation() 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/book_a_customisation.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=false&height=407&width=749&modal=true');
	});

}

function CareersPopup() 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/contact_position.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=false&height=327&width=399&modal=true');
	});

}

function SignUpPopup() 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/sign_up.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=false&height=247&width=349&modal=true');
	});

}

function LoanCalPopup() 
{  
	$(document).ready(function() {
		 tb_show('','/Content_Common/close_loanCal.aspx?placeValuesBeforeTB_=savedValues&TB_iframe=false&height=410&width=300&modal=true');
	});

}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
  return false;
}

/* Home Rad rotatoe News List function */
function startRotator(clickedButton, rotator, direction)
{
	if (!rotator.autoIntervalID)
	{
		refreshButtonsState(clickedButton, rotator);
		rotator.autoIntervalID = window.setInterval(function()
		{
			rotator.showNext(direction);
		}, rotator.get_frameDuration());
	}
}

function stopRotator(clickedButton, rotator)
{
	if (rotator.autoIntervalID)
	{
		refreshButtonsState(clickedButton, rotator)
		window.clearInterval(rotator.autoIntervalID);
		rotator.autoIntervalID = null;
	}
}

function showNextItem(clickedButton, rotator, direction)
{
	rotator.showNext(direction);
	refreshButtonsState(clickedButton, rotator);
}

// Refreshes the Stop and Start buttons
function refreshButtonsState(clickedButton, rotator)
{
	var jQueryObject = $telerik.$;
	var className = jQueryObject(clickedButton).attr("class");

	switch (className)
	{
		case "start":
			{// Start button is clicked

				jQueryObject(clickedButton).removeClass();
				jQueryObject(clickedButton).addClass("startSelected");

				// Find the stop button. stopButton is a jQuery object
				var stopButton = findSiblingButtonByClassName(clickedButton, "stopSelected");

				if (stopButton)
				{// Changes the image of the stop button
					stopButton.removeClass();
					stopButton.addClass("stop");
				}

			} break;
		case "stop":
			{// Stop button is clicked

				jQueryObject(clickedButton).removeClass();
				jQueryObject(clickedButton).addClass("stopSelected");

				// Find the start button. startButton is a jQuery object
				var startButton = findSiblingButtonByClassName(clickedButton, "startSelected");
				if (startButton)
				{// Changes the image of the start button
					startButton.removeClass();
					startButton.addClass("start");
				}

			} break;
	}
}

// Finds a button by its className. Returns a jQuery object
function findSiblingButtonByClassName(buttonInstance, className)
{
	var jQuery = $telerik.$;
	var ulElement = jQuery(buttonInstance).parent().parent(); // get the UL element
	var allLiElements = jQuery("li", ulElement); // jQuery selector to find all LI elements

	for (var i = 0; i < allLiElements.length; i++)
	{
		var currentLi = allLiElements[i];
		var currentAnchor = jQuery("A:first", currentLi); // Find the Anchor tag

		if (currentAnchor.hasClass(className))
		{
			return currentAnchor;
		}
	}
}
/* Home Rad rotatoe News List function- End  */

/* Calander control  */




