sfHover = function() {
	var sfEls = document.getElementById("treemenu1").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function setMinbe_DateTo() {
	var d1 = $('#Start_Date').datepicker('getDate');
	var d2 = Date.DateAdd("d", 1, d1);
	$('#Last_Day').attr('value', $.datepicker.formatDate('dd/mm/yy', d2));
	$('#Last_Day').data('minDate', d2);
};
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

$(document).ready(function() {
	
	function popitup(url) {
		
		/*$("#dialog_product").load(url).dialog({
			
			  modal:true,
			  width : 1000,
			  height : 1000,
			  resizable : false,
			  buttons: {
			    "Close": function() { $(this).dialog("close"); }
			  }

			}); */
		newwindow=window.open(url,'','height=700,width=1000,scrollbars=yes');
		if (window.focus) {newwindow.focus()}
		return false;
	}

	$('a[name=product]').click(function(e) {
		var rel = $(this).attr('rel');
		
		var url =  rel;
		popitup(url);
	});
	
	$("#Start_Date").datepicker({autoSize:true,
		prevText: '',
		nextText: '',
		defaultDate: 0,
		minDate: 0,
		maxDate: '+1y+1m',
		onSelect: function(dateText) {
			setMinbe_DateTo();
			return false;
		}
		});
	
	$("#Last_Day").datepicker({autoSize:true,
		prevText: '',
		nextText: '',
		defaultDate: 0,
		minDate: 0,
		maxDate: '+1y+1m',
		beforeShow: function(input) {
			return { minDate: $(this).data('minDate') };
		}
	});
	
	 $('#mycarousel').jcarousel({
	        auto: 2,
	        wrap: 'last',
	        initCallback: mycarousel_initCallback
	    });
	 
	$("a[rel^='prettyPhoto']").prettyPhoto();
	
	
	$('a.gallery').click(function() {
		
		
		 var largePath = $(this).attr("href");
			 var largeAlt = $(this).attr("title");

			$("#photo_display").attr({ src: largePath, alt: largeAlt , title: largeAlt });
		
		$('#photo').find("span").html($(this).attr("title"));
		
		
		$('#photo_display').fadeIn();
		return false;
	});

});


