// JavaScript Document

	$(document).ready(function() {
//		$(".fixHeight").equalHeights();
//		if ($.browser.msie) $('#left input.submit').css({ top: -20});
//		if ($.browser.safari) $('#left input.submit').css({ top: -7});
			   
	   $("a.askquestion, div#bestprice").click(function(){
					
		    var theID = encodeURI($(this).attr('rel'))	
			
			if ($('#dialog').length == 0 )  {	
					
			   $.post("ajax/clients_request.asp", { formaction: 'newaccountform', idproduit: theID}, function(builtForm){							
											  
				 $('' + builtForm + '').dialog({
					  bgiframe: true,
					  autoOpen: false,
					  width: 450,
					  height: 470,
					  modal: true,
					  buttons: {
						  'Envoyer ma demande': function() {
						  
											$.ajax({
											  type: "POST",
											  url: 'ajax/clients_request.asp',
											  cache: false,
											  data: $("form#newuser").serialize(),
											  success: function(msg){
												  if (msg == 'GO') {
													 // document.location = './Compte_P2605.html#clientaddcredit';
													 $('#dialog').dialog('close');
													  alertMes("Votre message a été envoyé avec succes!<br/><br/>Un vendeur communiqueras avec vous sous peu.");
												  } else {  
													  alertMes(msg);
												  }
											  }
											});				   
							  
						  },
						  Annuler: function() {
							  $(this).dialog('close');
						  }
					  },
					  close: function() {
						  //allFields.val('').removeClass('ui-state-error');
					  }
				  });
					$('#dialog').dialog('open')
					//alertMes(builtForm);
			       return false;
		        });
					
			  }	else {
				  
				  $('#dialog').dialog('open')  
				 }	 
					
		 })
	   
	  
});


function initMenu() {
  $('#wrapper ul.l3').hide();
 //$('#menu ul:first').show();
 // $('.menu3').show();
  $('#wrapper ul li a.actionmenu').click(
    function() {
      var checkElement = $(this).next();
      if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
        return false;
        } 
      if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
        $('#wrapper ul.l3:visible').slideUp({duration: 1000, easing:'easeOutBounce'});
        checkElement.slideDown({duration: 1000, easing:'easeOutBounce'}); 
        return false;
        } 
      }
    );
  }

   function change2Promo(){
	  $("#wrapper_product").css("visibility","visible");
	   $('#wrapper_flash').hide(); 
      //$('#wrapper_flash').animate({left: -900}, 1500)
	  
	  $('#thumbNav a').eq(0).trigger('click');
	  $('a#start-stop').trigger('click');
	   setTimeout("change2Flash();", 25000);
	  }
   function change2Flash(){
	  $('#wrapper_flash').show(); 
	 // $('#wrapper_flash').animate({left: 17}, 1500)
	   setTimeout("change2Promo();", 20000);
	  }

function alertMes(msg){
	// because we create a lot of dom on the fly, we must use this random ID to prevent no auto-closing
	var theBoxId = "msgBox" + Math.floor(Math.random()*100)
	$('<div id=' + theBoxId + '>' + msg + '</div>').dialog({
		title: 'IMPORT EXPORT RV M.A.C',
		modal:true,
		resizable:false, 
		overlay: {
			opacity: .5,
			background: "black"
		},
		buttons: { 
			"OK": function() { 
				$("#" + theBoxId).dialog("destroy"); 
			}   
		} 
	});
    setTimeout('$("#' + theBoxId + '").dialog("destroy"); ', 3000);
}

