$(function() {

	$('.fclear').next('br').remove();

	//messageflash
	$('#messageflash').hide();
	$('#messageflash').slideDown('slow').delay(5000).slideUp('slow');
	
	var $homepageflash = $('#homeflash').cycle();
	
	$('#flash1').mouseover(function() { $homepageflash.cycle(0); return false;  });
	$('#flash2').mouseover(function() { $homepageflash.cycle(1); return false;   });
	$('#flash3').mouseover(function() { $homepageflash.cycle(2); return false;   });
	
	
	//open links in a new window
	$('a[href^="http://"]').attr({
	    target: "_blank", 
	    title: "Opens in a new window"
	});
	
	$(".productgallery a, .fancybox").fancybox();

	if ($("#logout").length == 0) {	
		$(".thirdul").hide();
	}
		
	$(".minus").hide();
	$("#selectedsubcat").next(".thirdul").slideToggle();
	$("#selectedsubcat").children().toggle();
	
	
	$("a.subcategorylink").click(function(){ 
		
		
		
		//$(".thirdul").hide("slow");
	 	$(this).next(".thirdul").slideToggle();
	 	$(this).children().toggle();
	//	return false;
	 });
	
	$("a#selectedsubcat").click(function(){ 		
	 	$(this).next(".thirdul").hide();
		//alert('test');
	});
	
	
	$(".sortable").sortable({
		placeholder: 'ui-state-highlight',
		revert: true,
		stop: function(i) {
			placeholder: 'ui-state-highlight'				
			$.ajax({
				type: "GET",
				url: "/reorderaddons",
				data: $(this).sortable("serialize")});
		}														
	});
	$(".sortable").disableSelection();


	
});
