
jQuery(document).ready(function() {
		
		jQuery('.parent a').click( function() {
			if ($(this).next('.child').is(":hidden")) {
				$(this).next('.child').html("<img src='images/query.gif' style='padding-left: 170px'>");
				$(this).next('.child').slideDown("slow");
				var child = $(this).next('.child');
				var id = $(this).attr('id');
				$.ajax({
				url: "faq.php",
				type: "POST",
				child: child,
				data: ({faq : id }),
				success: function(content){
					child.html("");
					child.html(content);
				}
			});
				$(this).next('.child').slideDown("slow");
			} else {
				$(this).next('.child').slideUp();
				$(this).next('.child').html("");
			}
		});
		
		jQuery('.deploy a').click( function() {
			if ($(this).next('.child').is(":hidden")) {
				$(this).next('.child').html("<img src='../images/query.gif' style='padding-left: 170px; padding-top: 10px'>");
				$(this).next('.child').slideDown("slow");
				var child = $(this).next('.child');
				var id = $(this).attr('id');
				$.ajax({
				url: "index.php",
				type: "POST",
				child: child,
				data: ({info : id }),
				success: function(content){
					child.html("");
					child.html(content);
				}
			});
				$(this).next('.child').slideDown("slow");
			} else {
				$(this).next('.child').slideUp();
				$(this).next('.child').html("");
			}
		});
		
		$('#downloads :checkbox').click(function() {
				dataString = $("#downloads").serialize();
				$.ajax({
				url: "download.php",
				type: "POST",
				data: dataString
			});
		});
		
		$('#newsletters :checkbox').click(function() {
				dataString = $("#newsletters").serialize();
				$.ajax({
				url: "my_account.php",
				type: "POST",
				data: dataString
			});
		});
		
		$(function() {
		$('#c form').submit(function() {
			$('#html').html("<img src='images/query.gif'>");
				$.ajax({
				url: "phone.php",
				type: "POST",
				data: ({code : $('#c input[name=code]').val(), article : $('#c input[name=article]').val(), send: "ok"}),
				success: function(content){
					if(content == "winner") $('#html').html("<b>Vous avez gagné! L'article vous sera envoyé rapidement!<br />[ <a href='http://www.trouble-clic.com/my_account.php?selected=orders' class='linkwhite'>Afficher mes commandes</a> ]</b>");
					else if(content == "no_exist")	$('#html').html("<b>Le code que vous avez entré est invalide</b>");
					else if(content == "already")	$('#html').html("<b>Le code que vous avez entré a déjà été utilisé</b>");
					else if(content == "empty")	$('#html').html("<b>Merci de renseigner un code</b>");
					else if(content == "lose") $('#html').html("<b>Ce n'est pas pour cette fois, retentez votre chance</b>");
					else $('#html').html("<b>Une erreure est survenue, veuillez réessayer</b>");
					
					$('#c input[name=code]').val('');
					$("#html").fadeOut(500); $("#html").fadeIn(500); $("#html").fadeOut(500); $("#html").fadeIn(500);
				}
			});
			return false;
		});
	});
		
		jQuery('#cote').accordion({
			header: 'div.title',
			active: false, 
			alwaysOpen: false,
			autoheight: false,
			active: '.selected',
			animated: 'easeslide'
		});
		
		jQuery('#retour').accordion({
			header: 'div.title',
			active: false, 
			alwaysOpen: false,
			autoheight: false,
			active: '.selected',
			animated: 'easeslide'
		});
	
		jQuery('#menu').accordion({ 
			header: 'dt', 
			active: false, 
			alwaysOpen: false,
			autoheight: false,
			active: '.selected',
			animated: 'easeslide'
		});
		
		jQuery('#presta').accordion({ 
			header: 'dt', 
			active: false, 
			alwaysOpen: false,
			autoheight: false,
			active: '.selected',
			animated: 'bounceslide'
		});
		
		jQuery('#comment').accordion({ 
			header: 'dt', 
			active: false, 
			alwaysOpen: false,
			autoheight: false,
			active: '.selected',
			animated: 'bounceslide'
		});
		
		jQuery('#speed').accordion({ 
			header: 'dt', 
			active: false, 
			alwaysOpen: false,
			autoheight: false,
			active: '.selected',
			animated: false
		});
		
		$("a[rel=picture]").fancybox({
			'overlayColor'		: '#000',
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'hideOnContentClick'	: true,
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack',
			'titlePosition' 		: 'inside'
		});
		
		$("a#facebook_image").fancybox({
			'overlayColor'		: '#fff',
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'hideOnContentClick'	: true,
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack',
			'titlePosition' 		: 'inside'
		});
		
		$("a#inline").fancybox({
			'width'				: 600,
			'autoScale'			: false,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'overlayColor'		: '#c0c0c0',
			'easingIn'      	: 'easeOutBack',
			'easingOut'     	: 'easeInBack',
			'scrolling'			: 'no'
		});
		
		$("a#nfo").fancybox({
			'autoScale'			: false,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'overlayColor'		: '#000',
			'easingIn'      	: 'easeOutBack',
			'easingOut'     	: 'easeInBack',
			'scrolling'			: 'no'
		});
		
		$("a#website").fancybox({
			'width'				: '90%',
			'height'				: '90%',
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$("a#msn").fancybox({
			'width'				: '90%',
			'height'				: '90%',
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'scrolling'			: 'no',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack',
			'hideOnOverlayClick'	: false
		});
				
		$("a#popup_center").fancybox({
			'padding'				: 0,
			'width'				: 460,
			'height'				: '90%',
			'autoScale'			: false,
			'autoDimensions'	: true,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$("#audiotel_fr").fancybox({
			'padding'				: 0,
			'width'				: 300,
			'height'				: 300,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$("#audiotel_be").fancybox({
			'padding'				: 0,
			'width'				: 300,
			'height'				: 215,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$("#audiotel_ch").fancybox({
			'padding'				: 0,
			'width'				: 300,
			'height'				: 215,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$("#audiotel_cb").fancybox({
			'padding'				: 0,
			'width'				: 600,
			'height'				: 570,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$("#audiotel_neosurf").fancybox({
			'padding'				: 0,
			'width'				: 600,
			'height'				: 500,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$("#audiotel_hipay").fancybox({
			'padding'				: 0,
			'width'				: 600,
			'height'				: 500,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$("#youtube").click(function() {
			$.fancybox({
				'padding'			: 0,
				'autoScale'		: false,
				'transitionIn'	: 'fade',
				'transitionOut'	: 'fade',
				'title'			: this.title,
				'overlayColor'	: '#000',
				'width'			: 640,
				'height'			: 390,
				'href'			: this.href.replace(new RegExp("watch\?v=", "i"), 'v/'),
				'type'			: 'swf',
				'swf'				: {
				'wmode'			: 'transparent',
				'allowfullscreen'	: 'true' }
			});
			return false;
		});
		
		$("a#prevent").fancybox({
			'padding'				: 0,
			'width'				: 425,
			'height'				: 400,
			'scrolling'			: 'no',
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'overlayColor'		: '#000',
			'easingIn'      		: 'easeOutBack',
			'easingOut'     		: 'easeInBack'
		});
		
		$('#photos').galleryView({});
		
	});
	
	if (document.images)
    {
      preload_image_object = new Image();
      image_url = new Array();
      image_url[0] = "images/menu_1_on.png";
      image_url[1] = "images/menu_2_on.png";
      image_url[2] = "images/menu_3_on.png";
      image_url[3] = "images/menu_4_on.png";
	  image_url[4] = "images/menu_5_on.png";

		var i = 0;
		for(i=0; i<=4; i++) 
		preload_image_object.src = image_url[i];
    }
	
	function enter(evt)
	{
		var charCode = (evt.which) ? evt.which : window.event.keyCode; 
		if (charCode == 13) 
		{
			jQuery('#send_enter').click();
			return false;
		}
	}
	
	function SelectAll(id)
	{
		document.getElementById(id).focus();
		document.getElementById(id).select();
	}
