// JQUERY DELAY
$.fn.delay = function(time, callback){
    jQuery.fx.step.delay = function(){};
    return this.animate({delay:1}, time, callback);
}

// CHECK ALL
$(function () { // this line makes sure this code runs on page load
	$('.checkall').click(function () {
		$(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked);
	});

});

// JQUERY
$(document).ready(function(){	

	$(".dropdown dt a").click(function() {
		$(".dropdown dd ul").toggle();
	});

// PRETTYPHOTO
$("a[rel^='prettyPhoto']").prettyPhoto();

// FACEBOX
$('a[rel*=facebox]').facebox() 

$.smoothAnchors("normal");

$('#submitform').ajaxForm({
	target: '#error',
	success: function() {
	$('#error').fadeIn('slow');
	}
});

$('#booking_onoff').bind('click',function() { 
	if($(this).is(':checked')) { 
	  $('#configbooking').show("normal");
	 } 
	else {
	  $('#configbooking').hide("normal");
	}
}); 

$(".addarticle").click(function () {
	  var currentId = $(this).attr('id');
	  $('#form' + currentId).show("normal");
	  $('#' + currentId).hide("normal");
});

// DELETE PHOTO


$(function() {
$(".delete").click(function() {
var answer = confirm('Etes-vous sûr de vouloir supprimer ?');
if (answer)
{
	var element = $(this);
	var id = element.attr("id");
	var string = 'id='+ id ;
	
	$.ajax({
	   type: "POST",
	   url: "inc/ajax/delete.php",
	   data: string,
	   cache: false,
	   success: function(){
		//$('#d_' + id).slideUp('slow', function() {$(this).remove();});
		//$('#d_' + id).hide("normal");
	  }
	 });
	
	$(".delete").click(function () {
	element.parent().parent().fadeOut();
	
});
}
return false;
});
});


			
$(function() {

// SMS INBOX
 $('#inbox_number').bind('change', function () {
    var url = $(this).val(); // get selected option value
    if (url) { // require url to have value
      window.location = url; // open url
    }
    return false;
  });
  			   
// distrib
$(".hlr").click(function() {
	
	var id = $(this).parent().attr("class").split('|');
	var string = 'contact_num=' + id[0] + '&customers_id=' + id[1];
	$(this).parent().html("<img src='inc/facebox/loading.gif'>");
		
	$.ajax({
	   type: "POST",
	   url: "inc/ajax/hlr.php",
	   data: string,
	   cache: false,
	   success: function(){
	   }
	 });
	
	$(".hlr").click(function () {
		$(this).parent().html('Reload');
});
		
return false;
});
});


// SMS ALERT
$("#booking_sms").focus(function () {
	  var currentId = $(this).attr('value');
	  if (currentId != '') {
	  	$('#sms_alert').show("normal");
	  }
	  else {
	  	$('#sms_alert').hide("normal");
	  }
});
$(".datepicker").datepicker({
	dateFormat: 'yy-mm-dd'
});
//

  });

