/*
	TGLYNES JAVASCRIPT
	CREATED:31.03.10
	MODIFIED:07.06.10
	AUTHOR:ANDY FIELD
	USES THE JQUERY LIBRARY
*/

$(document).ready(function() {

	$("#print a").click(function(event){
		print();
		return false;
	});

	$("#top").click(function(){
		$("html, body").animate({scrollTop: "0px"}, 300);
		return false;
	});
	
	$("#txtKeyword").focus(function(){
		$(this).attr("value","");
	});
	
	$("#ddlHear").bind("change", function (e) { 
	    if( $("#ddlHear").val() == "Other") {
    	  $("li#other").show();
		}
    	else{
	      $("li#other").hide();
		}
	});
	
	$("#ddlQuotation").bind("change", function (e) { 
	    if( $("#ddlQuotation").val() == "Email") {
    	  $("span#emailme").show();
		}
    	else{
	      $("span#emailme").hide();
		}
		if( $("#ddlQuotation").val() == "Telephone") {
    	  $("span#telephoneme").show();
		}
    	else{
	      $("span#telephoneme").hide();
		}
		if( $("#ddlQuotation").val() == "Fax") {
    	  $("span#faxme").show();
		}
    	else{
	      $("span#faxme").hide();
		}
	});
	
  
	$("#btnAdd").click(function() {
	var num		= $(".cloned").length;
	var newNum	= new Number(num + 1);

	var newElem = $("#input" + num).clone().attr("id", "input" + newNum);
	
	newElem.find(".clone01").attr("id", "txtPurchase" + newNum).attr("name", "purchase_qty" + newNum);
	newElem.find(".clone02").attr("id", "txtHire" + newNum).attr("name", "hire_qty" + newNum);
	newElem.find(".clone03").attr("id", "txtSize" + newNum).attr("name", "size" + newNum);
	newElem.find(".clone04").attr("id", "txtDescription" + newNum).attr("name", "description" + newNum);
	newElem.find(".clone05").attr("id", "txtReference" + newNum).attr("name", "product_reference" + newNum);
	
	$("#input" + num).after(newElem);
	$("#btnRemove").attr("disabled","");

	if (newNum == 5)
		$("#btnAdd").attr("disabled","disabled");
	});

	$("#btnRemove").click(function() {
	var num	= $(".cloned").length;

	$("#input" + num).remove();
	$("#btnAdd").attr("disabled","");

	if (num-1 == 1)
	$("#btnRemove").attr("disabled","disabled");
	});

	$("#btnRemove").attr("disabled","disabled");

	$("#slideshow").cycle({ 
    	delay:  2000, 
	    speed:  500, 
	    height: 405
	}); 

	$("div.carousel").carousel( { 
		pagination: true
	});

	//$("#accordion dl").accordion();
	//$("#accordion dd:not(:first)").hide();
	$("#accordion dd").hide();
	$("#accordion dt a").click(function(){
	$("#accordion dd:visible").slideUp();
		$(this).parent().next().slideDown();
			return false;
	});

	//$("#action a").fadeOut("2000", function() {
		//$("#action a").fadeOut("slow");
	//});
	
	$("#four-col li").click(function(){
		window.location=$(this).find("a").attr("href"); return false;
	});
	
	$("#four-col li").hover(function(){
		$(this).addClass("hoverbox");
		}, function() {
		  $(this).removeClass("hoverbox");
	});
	
	$("#home ul#ilist").load("/home/logos/");
	var refreshId = setInterval(function() {
	$("#home ul#ilist").load('/home/logos/?v='+ Math.random());
	}, 9000);
	
});