//<![CDATA[
$(document).ready(function () {

	$('#right-but, #left-but').click(function(e) {  
		e.preventDefault() 
	}); 	
		
		
		if ($('#slideshow').length>0) {
			   

			function onAfter() { 
				var index = $(this).parent().children().index(this);
				
				$("#nav li").removeClass("active");
				$("#slide"+(index+1)).addClass("active");
			}
			   
			$('#slideshow').cycle({
					speed:       200,
					timeout:     6000,
					after:   onAfter
					//pager:      '#nav',
					//pagerEvent: 'mouseover',
					//pauseOnPagerHover: true
					
					// callback fn that creates a thumbnail to use as pager anchor 
    				//pagerAnchorBuilder: function(idx, slide) { 
        			//return '<li id="slide1"><a href="prod_allpurpose.php"><img src="../images/icon_allpurpose.png" alt="All Purposes" /><span>All Purpose</span></a></li>';
			});
		
			
			$('#slide1 a').mouseover(function() {  
				$('#slideshow').cycle(0);  
				return false;  
			}); 
			
			$('#slide2 a').mouseover(function() {  
				$('#slideshow').cycle(1);  
				return false;  
			}); 
			
			$('#slide3 a').mouseover(function() {  
				$('#slideshow').cycle(2);  
				return false;  
			}); 
			 
			$('#slide4 a').mouseover(function() {  
				$('#slideshow').cycle(3);  
				return false;  
			}); 
			
			$('#slide5 a').mouseover(function() {  
				$('#slideshow').cycle(4);  
				return false;  
			}); 
		
		}
	
	
	//POPUP
	if ($('.popup_profil').length>0) {
		
		$('.popup_profil').openDOMWindow({ 
			width:860, 
			height:640, 
			positionType:'centered',
			eventType:'click',
			windowSource:'iframe',
			windowPadding:0,
			modal:1,
			overlayOpacity:55
		});
		
	}
	
	$("#titlebar span a img").click(function(e){
		e.preventDefault();
		$("#DOMWindowOverlay", window.parent.document).fadeOut(200);
		$("#DOMWindow", window.parent.document).fadeOut(200);
		$("#DOMWindowOverlay", window.parent.document).remove();
		$("#DOMWindow", window.parent.document).remove();
	});
	
	if ($("body#liste #carousel").length>0) {
	
		$("body#liste #carousel").CloudCarousel(		
		{			
			xPos: 312,
			yPos: 40,
			buttonLeft: $("#left-but"),
			buttonRight: $("#right-but"),
			altBox: $("#alt-text"),
			titleBox: $("#title-text")
		});
		
		function showCarousel1() {
			$("#carousel").addClass("visible");
			clearTimeout(timeout);
		};
		
		var timeout = setTimeout(showCarousel1,100);
	
	}
	
	if ($("body#products #carousel").length>0) {
	
		$("body#products #carousel").CloudCarousel(		
		{			
			xPos: 140,
			yPos: 50,
			buttonLeft: $("#left-but"),
			buttonRight: $("#right-but"),
			altBox: $("#alt-text"),
			titleBox: $("#title-text")
		});
		
		function showCarousel2() {
			$("#carousel").addClass("visible");
			clearTimeout(timeout);
		}
		
		var timeout = setTimeout(showCarousel2,100);
	
	}
  
	$(".swapImage").click(function(e){

    	var id = $(this).attr("rel");
		var url = $("#swappedImage").attr("rel");
		var ul_id = $("#container").find("ul").attr("id");
		
		var hover = $("#"+ul_id).attr("hover");
		var normal = $("#"+ul_id).attr("normal");
		
		$("#swappedImage").attr("src",url+id+".png");
		$("#"+ul_id+" li").css("background-image","url('"+normal+"')");
		$("#"+ul_id+" li:eq("+(id-1)+")").css("background-image","url('"+hover+"')");
		
	});
	
	$("#frame ul li").click(function(e){
		$("#frame ul li").removeClass("active");	
		$(this).addClass("active");	
	});
 
	
	$('#mainMenu .wrapper ul').superfish({ 
        delay:       500,                            // one second delay on mouseout 
        animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  false                           // disable generation of arrow mark-up 
    }); 
	
	$('#removepic').click(function(e){
	
		e.preventDefault();
		$(this).hide();
		$(".pic").hide();
		$("input[type=file]").show();
		
	});
	
	$("#frame ul li").each(function(e){

		if ($(this).find('a').attr("style")!=null) {
			$(this).addClass("active");
		}
	});
	
	/****** burn swaps ******/
	
	$("#picnic.man").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/man/burn_'+$(this).attr('burn')+'.png'); });
	$("#golf.man").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/man/burn_'+$(this).attr('burn')+'.png'); });
	$("#tennis.man").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/man/burn_'+$(this).attr('burn')+'.png'); });
	$("#canoe.man").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/man/burn_'+$(this).attr('burn')+'.png'); });
	
	$("#picnic.woman").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/woman/burn_'+$(this).attr('burn')+'.png'); });
	$("#golf.woman").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/woman/burn_'+$(this).attr('burn')+'.png'); });
	$("#tennis.woman").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/woman/burn_'+$(this).attr('burn')+'.png'); });
	$("#canoe.woman").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/woman/burn_'+$(this).attr('burn')+'.png'); });

	
	$("#picnic.child").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/child/burn_'+$(this).attr('burn')+'.png'); });
	$("#swimming").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/child/burn_'+$(this).attr('burn')+'.png'); });
	$("#soccer").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/child/burn_'+$(this).attr('burn')+'.png'); });
	$("#outside").click(function(e){ $("#swappedImage-burn").attr('src','../images/suncare_profile/child/burn_'+$(this).attr('burn')+'.png'); });
	
	$("#skin1").click(function(e){ $(".burn").attr('src','../images/suncare_profile/'+$(this).attr('path')+'/burn_1-'+$(this).attr('burn')+'.png'); });
	$("#skin2").click(function(e){ $(".burn").attr('src','../images/suncare_profile/'+$(this).attr('path')+'/burn_2-'+$(this).attr('burn')+'.png'); });
	$("#skin3").click(function(e){ $(".burn").attr('src','../images/suncare_profile/'+$(this).attr('path')+'/burn_3-'+$(this).attr('burn')+'.png'); });
	$("#skin4").click(function(e){ $(".burn").attr('src','../images/suncare_profile/'+$(this).attr('path')+'/burn_4-'+$(this).attr('burn')+'.png'); });

	
	/************************/
	
});
//]]>
