/**
 * BlakeEtMortimer - BlakeEtMortimer.com
 * 2010 - Apsulis (http://demo.apsulis.com)
 * 
 */

/* ToggleVal 3.0 */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(5($){$.l.e=5(2){4(!2||t 2==\'G\'){2=$.r({},$.l.e.B,2)}E 4(t 2==\'J\'&&2.I()==\'g\'){s g=m}b 0.H(5(){4(g){$(0).u(\'v.8\').u(\'F.8\').M(\'1\');b a}s 1=\'\';P(2.z){i\'f\':4($(0).9(\'f\')){1=$(0).9(\'f\');$(0).3(1)}j;i\'k\':4($(0).9(\'c\')){1=$(\'k[q="\'+$(0).9(\'c\')+\'"]\').o();$(0).3(1)}j;i\'N\':1=2.o;$(0).3(1);j;C:1=$(0).3()}$(0).d(\'8\').6(\'1\',1);4(2.x==m&&$(0).9(\'c\')){$(\'k[q="\'+$(0).9(\'c\')+\'"]\').L()}$(0).y(\'v.8\',5(){4($(0).3()==$(0).6(\'1\')){$(0).3(\'\')}$(0).d(2.h)}).y(\'F.8\',5(){4($(0).3()==\'\'&&!2.p){$(0).3($(0).6(\'1\'))}$(0).D(2.h);4($(0).3()!=\'\'&&$(0).3()!=$(0).6(\'1\')){$(0).d(2.n)}E{$(0).D(2.n)}})})};$.l.e.B={h:\'A-Q\',n:\'A-w\',z:\'C\',o:K,x:a,p:a};$.r($.O[\':\'],{8:5(7){b $(7).6(\'1\')||a},w:5(7){4($(7).6(\'1\')&&$(7).3()!=$(7).6(\'1\')){b m}b a}})})(R);',54,54,'this|defText|theOptions|val|if|function|data|elem|toggleval|attr|false|return|id|addClass|toggleVal|title|destroy|focusClass|case|break|label|fn|true|changedClass|text|sticky|for|extend|var|typeof|unbind|focus|changed|removeLabels|bind|populateFrom|tv|defaults|default|removeClass|else|blur|object|each|toLowerCase|string|null|remove|removeData|custom|expr|switch|focused|jQuery'.split('|'),0,{}))

/* Fonctions Générales */
function myInitPages() {
    jQuery('body').addClass('hasJS');
	toggleVal('input[type="text"],input[type="password"],input[type="email"]');
	// blockClick('#naviScroller li, .infoItemBoutique, #publication , .listing:not(#jeVeux) ul li, #evenement .contenuBloc, .slideVosRealisations');
    jQuery('a[rel="external"]').click( function() { window.open( jQuery(this).attr('href') ); return false; });
}

/* Configuration des plugins jQuery pré-installé */
function toggleVal(elt) {
	jQuery(elt).toggleVal();
}

function formulaires(){
	jQuery('#inscriptionVisiteur').css({display:'none'});
	jQuery('.gachette').css({cursor:'pointer'}).click(function(){ jQuery('#inscriptionVisiteur').slideToggle('medium'); });
}


function blockClick(elt){
  
  // Cible elt (en général .blocClicable)
	// Si le blocClicable contient un a.cible, c'est lui qui servira de référence
	// Sinon, par défaut, il prendra le premier lien qu'il trouve comme cible
	jQuery(elt).each(function() {
		var lien = '';
		if(jQuery(this).find('a').length){
			lien = jQuery(this).find('a');
			if(jQuery(this).find('a.cible').length){ lien = jQuery(this).find('a.cible'); }
			var where2go = '';
			where2go = jQuery(lien).attr('href');
		
			jQuery(this).css('cursor','pointer').hover(function(){ jQuery(this).addClass('survole'); },function(){ jQuery(this).removeClass('survole'); });
			jQuery(this).click(function() {
				if(jQuery(lien).attr('rel') == 'external'){
					window.open( where2go );
				}else{
					window.location = where2go;
				}return false;
			});
		}
	});
  
}

function pasDeClicDroit(){
	jQuery(document).bind("contextmenu",function(e){  
	    return false;  
	});
}

/* Fonction pour se logger dans la console de Firebug */
function consoleLog(msg) {
	console.log('%s: %o', msg, this);
	return this;
};

jQuery(document).ready(function() {
	
	initMyInitPages = myInitPages();
	if(jQuery('.gachette').length){ formulaires(); }
	if(jQuery('.noClic').length){ pasDeClicDroit(); }
	if(jQuery('.pane-list li, .item .fl').length){ blockClick('.pane-list li, .item .fl'); }
	// if(jQuery('.pane-list li').length){ jQuery(".pane-list li").click( function() { window.open( jQuery(this).find('a').attr('href') ); return false; }); }
});

