
    
function isEmail(emailStr) {
    var checkTLD = 1;
    var knownDomsPat = /^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|­pro|museum|fr)$/;
    var emailPat = /^(.+)@(.+)$/;
    var specialChars = "\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
    var validChars = "\[^\\s" + specialChars + "\]";
    var quotedUser = "(\"[^\"]*\")";
    var ipDomainPat = /^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
    var atom = validChars + '+';
    var word = "(" + atom + "|" + quotedUser + ")";
    var userPat = new RegExp("^" + word + "(\\." + word + ")*$");
    var domainPat = new RegExp("^" + atom + "(\\." + atom +")*$");
    var matchArray = emailStr.match(emailPat);
    if (matchArray == null) { alert("Cette adresse email n'est pas conforme!"); return false; }
    var user = matchArray[1];
    var domain = matchArray[2];
    for (i=0; i<user.length; i++) {
        if (user.charCodeAt(i) > 127) { alert("Cette adresse email n'est pas conforme!"); return false; }
    }
    for (i=0; i<domain.length; i++) {
        if (domain.charCodeAt(i) > 127) { alert("Cette adresse email n'est pas conforme!"); return false; }
    }
    if (user.match(userPat) == null) { alert("Cette adresse email n'est pas conforme!"); return false; }
    var IPArray=domain.match(ipDomainPat);
    if (IPArray != null) {
        for (var i=1; i<=4; i++) {
            if (IPArray[i] > 255) { alert("Cette adresse email n'est pas conforme!"); return false; }
        }
        return true;
    }
    var atomPat = new RegExp("^" + atom + "$");
    var domArr = domain.split(".");
    var len = domArr.length;
    for (i=0; i<len; i++) {
        if (domArr[i].search(atomPat) == -1) { alert("Cette adresse email n'est pas conforme!"); return false; }
    }
    if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) { alert("Cette adresse email n'est pas conforme!"); return false; }
    if (len < 2) { alert("Cette adresse email n'est pas conforme!"); return false; }
    return true;
}

function ajax_image_load(nid, delta) {
    
//    alert(Drupal.settings);
    var basePath = Drupal.settings.basePath;
    $.ajax({
        type: "POST",
        url: basePath+"my_ajax_callbacks/image/"+nid+"/"+delta,
        dataType: "html",
        success: function(msg){ 
            $("#ajax_image_content").html(msg);
        }
    });
}

$(document).ready(function() {
    $("body.front .views-field, .node-type-thematique .views-field, body.front .bon-plan-header").click( function(){
        $('a:first', this).click();
        window.location = $('a:first', this).attr('href');
        return false;
    });
    
    
    
    $("a.deal-not-available").click( function(){
      alert("Nous sommes désolés, cette offre n'est plus disponible, retrouvez tous nos autres bons plans sur notre site en cliquant sur la rubrique qui vous intéresse !");
      return false;
    });
});

var openclose = function(options) {
   jQuery(options.conteneur + " " + options.interrupteur).click(function() {
       jQuery(this).toggleClass("actif");
       jQuery(this).parents(options.conteneur).children(options.blocouvrable).animate({height: "toggle"}, 100);
       return false;
   });
   jQuery(options.conteneur + " " + options.blocouvrable).click(function() {
       jQuery(this).toggleClass("actif");
       jQuery(this).parents(options.conteneur).children(options.blocouvrable).animate({height: "toggle"}, 100);
   });
};

$(document).ready(function() {
	openclose({ conteneur: "#city-select", interrupteur: ".city-select-oc", blocouvrable: "#city-select-i" });			// open close pseudo select
    $('#edit-mail').toggleVal();
    $('#edit-codepostal').toggleVal();
    
    
    $("#tv-spot").click(function() {
        $.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'		: 830,
			'height'		: 480,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			   	 'wmode'		: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
        return false;
    });
});

$.fn.toggleVal = function() {
  return this.each(function() {
    $(this).focus(function() {
      if($(this).val() == this.defaultValue) { $(this).val(""); }
    }).blur(function() {
      if($(this).val() == "") { $(this).val(this.defaultValue); }
    });
  });
}; 
