function ImgError(source){
    source.src = "/images/none.gif";
    source.onerror = "";
    return true;
}

/* CYCLE */

$(function() {
    $('#promo').cycle({
        fx:     'fade',
        speed:  'fast',
        timeout: 5000,
        pager:  '#promo-nav',
		slideExpr: 'a'
    });
});

$(document).ready(function(){

	$(".partnoboxd:contains('Potted')").prepend('<a class="info" style="cursor:pointer; float: right; margin: 0px 0px 0px 5px;"><img src="images/info_icon.jpg" alt="info"></a><div class="tooltip"><h2>Potted Roses</h2><p>From late Oct/Nov - March, the plants are dug from the field as bare root and freshly potted. From March onwards most plants have been potted for a minimum of a month or two.</p><p>Orders for potted roses must be received by 11 am if next day delivery is required.</p></div>');
	
	$(".partnoboxd:contains('Bare Root')").prepend('<a class="info" style="cursor:pointer; float: right; margin: 0px 0px 0px 5px;"><img src="images/info_icon.jpg" alt="info"></a><div class="tooltip"><h2>Bare Root</h2><p>The bare root despatch season runs from NOVEMBER to FEBRUARY. Orders are taken all year round with the earliiest dated orders being despatched first (early NOVEMBER). The backlog of orders will follow and catches up by mid DECEMBER. Thereafter further orders are despatched within 7-10 days. </p></div>');
	
	if ($("#cartmaininner1 tr td:contains('Bare Root')").length > 0) 
	{
	$("#cartmaininner1 tr td:contains('110ml Hand and Foot Balm')").append('<br /><em><strong>Please note:</strong> This product will be sent at the same time as your plants, otherwise please make separate order.</em>');
	$("#cartmaininner1 tr td:contains('60ml Moisturiser')").append('<br /><em><strong>Please note:</strong> This product will be sent at the same time as your plants, otherwise please make separate order.</em>');
	$("#cartmaininner1 tr td:contains('Turkish Delight')").append('<br /><em><strong>Please note:</strong> This product will be sent at the same time as your plants, otherwise please make separate order.</em>');
	}
	
	$("#various1").fancybox({
				'titlePosition'		: 'inside',
				'transitionIn'		: 'none',
				'transitionOut'		: 'none'
			});

	/* HIDE IRELAND FROM DROP DOWN */
	$(".note").each(function(){
		$('select#zoneid option[value="29"]').remove();
	});

	/* CART BUTTON */
	$(".cartbutton").click(function(){
		QuantityValue = $(this).parent().parent().find(".cartquantity").val();
			if (QuantityValue == 0) {$(this).parent().parent().find(".cartquantity").val('1');}
		$('#ato-m').submit();
	});
	
	/* CART ZONES */
	var zonename = $("#zonename").text();
	$("#zoneid option[name='"+zonename+"']").attr('selected', 'selected');


	$(" #nav ul:empty").css("display", "none");
	$(" #nav li a.current").parent().find("ul").css("display", "block");
	
	/* FORM JS */
	$(".addqty").click(function(){
		$(this).next().val( Number($(this).next().val()) + 1 );
		x = $(this).parent().attr('name');
        $(".changetheqty").change();
	});
	
	$(".subtractqty").click(function(){
		$(this).prev().val( Number($(this).prev().val()) - 1 );
		x = $(this).parent().attr('name');
        $(".changetheqty").change();
	});
	
	$(".changetheqty").change(function() {
		alert
	  t = eval("document." + x + ".quantity")
        failed = false
        if (isNaN(t.value))
        {
           alert("Please enter a valid number in quantity ");
           t.value = 1;
           t.focus();
           failed = true
     
        }
        else 
        {
          if (t.value <= 0 )
          {
                        alert("Quantity cannot be zero or less");
                        t.value = 1;
                        t.focus();
      
                        failed = true
          }
        }
  		eval("document." +x+ ".submit()")
        if (failed)
           document ['navigation'].quanttest.value = 'nogo'
	});



	$(".partnobox tr:even").addClass("beige");
	$(".partnobox tr:odd").addClass("pink");
	$(".partnobox tr:first").addClass('bold');	
	
	$("#prodimglink").fancybox();
});
