﻿jQuery.noConflict();
jQuery(document).ready(function($) {
	
	// add tounload to all links
	
		$('a').click(function() {tounload=false;});
		
		$('.button').click(function() {tounload=false;});
		$('button').click(function() {tounload=false;});
	
								
	/*homepage.html*/
	/*
	$('.top_buttons > a').each(function(){
			$(this).bind('mouseover',function(){
				$(this).css({
					'background-image':'url(../images/header/frame-hover.png)'
				});
				$(this).find('span').css({
					'background-image':'url(../images/header/frame-hover.png)'
				});
			});
			$(this).bind('mouseout',function(){
				$(this).css({
					'background-image':'url(../images/header/frame.gif)'
				});
				$(this).find('span').css({
					'background-image':'url(../images/header/frame.gif)'
				});
			});
			
	});
	*/
	
	
	
	$('.tabs .tab1').click(function(){
		$('.tab-con-current').removeClass('tab-con-current');
		$('.vous-aimez-aussi').addClass('tab-con-current');
	});
	$('.tabs .tab2').click(function(){
		$('.tab-con-current').removeClass('tab-con-current');
		$('.composition').addClass('tab-con-current');
	});
	$('.tabs .tab3').click(function(){
		$('.tab-con-current').removeClass('tab-con-current');
		$('.utilisation').addClass('tab-con-current');
	});
	$('.tabs .tab4').click(function(){
		$('.tab-con-current').removeClass('tab-con-current');
		$('.avantages').addClass('tab-con-current');
	});
	$('.tabs .tab5').click(function(){
		$('.tab-con-current').removeClass('tab-con-current');
		$('.commentaires').addClass('tab-con-current');
	});

	
	$('#nav a').each(function(){
		if($(this).attr('href')==document.location){
			$(this).parent().addClass('active');
		}
	});
		
	
	
		$('.hbr-button a').bind({
				mouseover:function(){
					$(this).find('img').css('display','none');
				},
				mouseout:function(){
					$(this).find('img').css('display','block');
				}
		 });
			$('.home-product-button a').bind({
				mouseover:function(){
					$(this).find('img').css('display','none');
				},
				mouseout:function(){
					$(this).find('img').css('display','block');
				}
		 });
			
		/*epilation.html	*/
			var epilation = new Array('.epilation-avant','.epilation-pendant','.epilation-apres');
			for(var i=0;i<epilation.length;i++)
			{
				$(epilation[i]).bind({
					'mouseover':function(){
						$(this). addClass('toto');		
					},
					'mouseout':function(){
						$(this).removeClass('toto');
					}
									 });									  
			}
			
			$('#minus').click(function(){
				if($('#qty').val()>1){
					$('#qty').val($('#qty').val()-1);
				}
				return false;
			});
			
			$('#plus').click(function(){
				$('#qty').val(parseInt($('#qty').val())+1);
				return false;
			});
			
			
			/*product*/
			$('.tab').each(function(){
				$(this).bind({
						'mouseover':function(){
							$(this).addClass('tata');
						},
						'mouseout':function(){
							$(this).removeClass('tata');
						},
						'click':function(){
							$(this).addClass('tab-current').siblings().removeClass('tab-current')
						}
				});
			});
			
	$(document).keypress(function(evt){
			var charCode = (evt.keyCode!=0) ? evt.keyCode : evt.charCode
			if(charCode == 116 || charCode == 114){
				tounload=false;
			}
	})

});
var tounload = true;
window.onbeforeunload = function() {
	if(tounload) {
		text = jQuery('#popup-text').text();
		alert(text);
	}
}
