$(document).ready(function(){

	// fixing child selectors
	$('#top div ul li:last-child').addClass('last');
	$('#footer ul li:last-child').addClass('last');
	$('ul.news li:last-child').addClass('last');
	$('.searchFilters li:last-child').addClass('last');
	$('.customerRev li:last-child').addClass('last');
	$('.hillarysDescription ul li:last-child').addClass('last');
	$('ul.horizontalDisplay li:last-child').addClass('last');
	$('.newsList li:last-child').addClass('last');
	$('.newsSingle p:last-child').addClass('last');
	
	// blue tabs hover
	$('.blueTabs li').hover(
		function() {
		 	$(this).toggleClass('hoveredTab');
			}
	);
	$('.blueTabs+div.searchFilters').css('border-top','none');
	
	// JQUERY TAB NAV <----
	// Homepage carousel
	$('#carousel').jcarousel({
       scroll: 1,
	   visible: 3
    });
	
	// Product carousel
	$('#slideshow').jcarousel({
       scroll: 1,
	   visible: 1
    });
	
	// Movie carousel
	$('#gwvcarousel').jcarousel({
       scroll: 1,
	   visible: 4
    });
	
	// Movie callbacks
	function callback(videoName)
	{
		alert(videoName);
	}	
	/*	jQuery('#flash').externalInterface({
			method:'loadVideo',
			args:videoName
		});
*/
	
	// EASY TABS.
	$('#tab-container').easytabs({
		animationSpeed: 160,
		defaultTab: "li#defaulttab",
		cycle: 3000
	});
	// hook to the main script
	$('#tab-container').bind('easytabs:midTransition',function(){
		$('#tab-container a').css("color","#FFFFFF");
		var curr_tab = $('#tab-container .active a').attr("href");
		if( curr_tab == "#shutters" )
		{
			$('#tab-container .active a').css("color","#AB3F0A");
		}
		else if ( curr_tab == "#conservatory" )
		{
			$('#tab-container .active a').css("color","#1D98A6");
		}
		else if ( curr_tab == "#awnings" )
		{
			$('#tab-container .active a').css("color","#F75A2E");
		}
		else
		{
			//
		}
		$('#tab-container a.smallInfo').css("color","#333333");
		$('#tab-container a.smallRed').css("color","#FFFFFF");
	});
	
	
	
	// nav sublist
	$('ul#mainNav li').hover(
		function() {
		 	$(this).addClass('active');
			},
		function() {	
		 	$(this).removeClass('active');
			}
	);
	
	
	// choose finish list hover
	$('.chooseFinish li').hover(
		function() {
		 	$(this).toggleClass('hovered');
			}
	);
	
	
	// compact list hover
	$('.compactList li').hover(
		function() {
		 	$(this).children('span').toggle();
			}
	);
	
	
	// blue tabs hover
	$('.blueTabs li').mouseover(function()
	{
		$(this).addClass('hoveredTab');
	}).mouseleave(function(){
		$(this).removeClass('hoveredTab');
	});
	
	$('.blueTabs+div.searchFilters').css('border-top','none');
	
	
	$(".cboxElement").click(function(event){
	 event.preventDefault();
	
	var rel = $(this).attr("rel");
	$("#clickImage").attr("src","http://www.blinds-on-line.co.uk/media/img/5.gif");
	$("#clickImage").css("border","0px none");
	
	
	
	$.ajax({
				url: "#",
				type:"post",
				data:"rel="+rel,
				complete:function(http,status)
				{
					
					
					
					$("#clickImage").attr("src",rel);
					
					$("#clickImage").css("border","0px none");
					
					
					
					
				}
			});
	});
	
	// hover tooltip
	$(".popupTriger").tooltip({ relative: true,position: "top center",offset: [2,68],effect:'fade'});
	
	// adding html elements
	$("div.innerRounded").before('<div class="roundedTop"></div>');
	$("div.innerRounded").after('<div class="roundedBottom"></div>');
	$("div#homeImprovement").before('<div class="bigroundedTop"></div>');
	$("div#homeImprovement").after('<div class="bigroundedBottom"></div>');
	
	// combobox custom selects
	$(".customComboHolder select").change(function () {
          var str = "";
          $(this).find("option:selected").each(function () {
                str += $(this).text();
              });
          $(this).parent().find("div").text(str);
        })
        .change();

	// list fropdown
	$('li.singleDropdown').click(
		function()
			{
			 	$(this).children('ul').toggle();
			 	if( $('ul.spezdrop').is(':visible') )
			 	{
			 		$('ul.spezdrop').mouseover(function(){
			 			//
			 		}).mouseleave(function(){
			 			$(this).hide();
			 		});
			 	}
			}
		);
	
	$('li.singleDropdown').hover(function(){
		$(this).css('text-decoration','underline');
	},function(){
		$(this).css('text-decoration','none');
	});
	
	$('a.colorInput').click(function(){
		$(this).next('div').toggle();
	});
	
	
	$("select.pricefromsel").change(function(){
		var selected_option = $("select.pricefromsel option:selected").val();
		var cOptions = { domain: '.hevvytraffik.com', path: '/', hoursToLive: 336, secure: false }
		$.cookie('bsmpricefrom',selected_option,cOptions);
		location.reload(true);
	});
	$("select.pricetosel").change(function(){
		var selected_option = $("select.pricetosel option:selected").val();
		var cOptions = { domain: '.hevvytraffik.com', path: '/', hoursToLive: 336, secure: false }
		$.cookie('bsmpriceto',selected_option,cOptions);
		location.reload(true);
	});

	/* LAZY LOAD BY DENOQ.COM */

	$('.imgHolder').each(function(index){
		var link = $(this).children().attr('rel');
		if( link != undefined )
		{
			var ttitle = $(this).children().html();
			var imgheight = $(this).children().height();
			var imgwidth = $(this).children().width();
			$(this).delay(450*(index+2)).queue(function(n){
				$(this).html( '<img src="' + link + '" border="0" width="' + imgwidth + '" height="' + imgheight + '" title="' + ttitle + '" alt="' + ttitle + '" />' );
			});
		}
	});
	
});



























/* GOO */
/*
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
	var pageTracker = _gat._getTracker("UA-9165746-1");
	pageTracker._trackPageview();
	} catch(err) {}

var sc_project=4860291; 
var sc_invisible=1; 
var sc_partition=57; 
var sc_click_stat=1; 
var sc_security="7311975f";

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
	var pageTracker = _gat._getTracker("UA-9509122-1");
	pageTracker._trackPageview();
	} catch(err) {}
*/












