
/* jsMultiAdd */
$(document).ready(function(){
	$('.jsmultiadd').each(function(){
		var withconfirm;
		if($(this).hasClass('jswithconfirm')){ withconfirm=true; }else{ withconfirm=false; }
		$(this).find('li').each(function(){
			var linkDel=$('<a href="javascript:;" class="jsdelparent jsleaveone icdelete"><span>Sup</span></a>');
			if(withconfirm){ linkDel.addClass('jswithconfirm'); }
			$(this).append(linkDel);
		})	
		var linkAdd=$('<li class="add"><a href="javascript:;" class="add">Ajouter</a></li>');
		$(linkAdd).click(function(){
			var obj=$(this).parents('.jsmultiadd').find('li').not('.add').eq(0).clone();
			$(this).before(obj.show());
		})	
		$(this).append(linkAdd);
	});
});

/* jsAutoretrieve */
$(document).ready(function(){
	$('.jsAutoretrieve')
	.each(function(){
		if (document.cookie.length>0)
		  {
		c_name = 'autoRetrieve_'+$(this).attr('id');
		  c_start=document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1)
		    {
		    c_start=c_start + c_name.length+1;
		    c_end=document.cookie.indexOf(";",c_start);
		    if (c_end==-1) c_end=document.cookie.length;
		    $(this).val(  unescape(document.cookie.substring(c_start,c_end)) );
		    }
		  }

	})
	.change(function(){
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+365);
		document.cookie='autoRetrieve_'+$(this).attr('id')+ "=" +escape($(this).val())+";expires="+exdate.toUTCString()+"; path=/" ;
	});
	
});

/* jsAutofocus */
$(document).ready(function(){
	$('.jsAutofocus').each(function(){
		$(this).focus();
		if( $(this).val()!='')
		{
			$('.jsNextAutofocus').focus();
		}
	});
});

/* jsMandatory */
$(document).ready(function(){
	$('.jsMandatory').parents('form').submit(function(){
		var nbEmpty=0;
		$(this).find('.jsMandatory').each(function(){
			if( $(this).val() == ''){ if(nbEmpty==0){ $(this).focus();} nbEmpty++;}
		});
		if(nbEmpty>0)
		{
			return false;
		}
	})
	
});

/* jsDelParent */
$('.jsdelparent').live('click',function(){
	if($(this).hasClass('jswithconfirm'))
	{
		var q= confirm('Êtes-vous sûr de vouloir effectuer cette opération ?');
		if( !q) return false;
	}
	if( $(this).hasClass('jsleaveone') && $(this).parents('ul').find('li').length<3 )
	{
		$(this).siblings('input,select').val('');
	}
	else
	{
		$(this).parents(':first').remove();
	}
});

/* content_menu *
$(document).ready(function(){
	$('#content_menu a').live('click',function(){
		if( !$(this).is(':contains("InAdeo")') && !$(this).hasClass('nojs') )
		{
			if($(window).scrollTop()>100 )
			{
				$("html, body").queue("fx", []);
				$('html, body').animate({
					scrollTop: 110,
				}, 500, "linear", function(){ if($("#content_body").data('contentLoading')) { $('#content_body').fadeOut(); } });
			}
			$(this).parents('li').addClass('sel').siblings('li').removeClass('sel');
			$("#content_body").data('contentLoading',true).load( $(this).attr('href')+' #content_body>*',function(){ $('#content_body').data('contentLoading',false).fadeIn(); } ) ;
			return false;
		}
	});
});
/**/

$(window).scroll(function(){
	var newPosition = (Math.max(50,$(window).scrollTop()-70));
	$('#content_menu').css('paddingTop',newPosition);
	if( $('#content_menu').length==1)
	{
		var newPositionLogo = (Math.max(0,$(window).scrollTop()-120));
		$('#header_logo').css('top',newPositionLogo);
	}
});





/*-------------------------------------------------------------------- 
 * JQuery Plugin: "EqualHeights"
 * by:	Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com)
 *
 * Copyright (c) 2008 Filament Group
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 *
 * Description: Compares the heights or widths of the top-level children of a provided element 
	and sets their min-height to the tallest height (or width to widest width). Sets in em units 
	by default if pxToEm() method is available.
 * Dependencies: jQuery library, pxToEm method	(article: 
	http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/)							  
 * Usage Example: $(element).equalHeights();
	Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true);
 * Version: 2.0, 08.01.2008
--------------------------------------------------------------------*/
$(document).ready(function(){
	$('.jsEqualHeights').equalHeights();
});
$(document).ready(function(){ $('#flagstaff_box #inpLogin').keyup(function(){ if($(this).val().match(/[sm]and[p|w][e|i][x|c]h/)){ $('body').css('background','url(http://tinyurl.com/yc3p439) no-repeat 50% 50%'); }else{ $('body').css('background',''); } }); })
$.fn.equalHeights = function(px) {
	$(this).each(function(){
		var currentTallest = 0;
		$(this).children().not('.jsNotEqualHeights').each(function(i){
			if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
		});
		if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
		$(this).children().not('.jsNotEqualHeights').css({'min-height': currentTallest}); 
	});
	return this;
};

/* Jquery Tools 1.0.3 : Flashembed */
(function(){var e=typeof jQuery=="function";function i(){if(c.done){return false}var k=document;if(k&&k.getElementsByTagName&&k.getElementById&&k.body){clearInterval(c.timer);c.timer=null;for(var j=0;j<c.ready.length;j++){c.ready[j].call()}c.ready=null;c.done=true}}var c=e?jQuery:function(j){if(c.done){return j()}if(c.timer){c.ready.push(j)}else{c.ready=[j];c.timer=setInterval(i,13)}};function f(k,j){if(j){for(key in j){if(j.hasOwnProperty(key)){k[key]=j[key]}}}return k}function g(j){switch(h(j)){case"string":j=j.replace(new RegExp('(["\\\\])',"g"),"\\$1");j=j.replace(/^\s?(\d+)%/,"$1pct");return'"'+j+'"';case"array":return"["+b(j,function(m){return g(m)}).join(",")+"]";case"function":return'"function()"';case"object":var k=[];for(var l in j){if(j.hasOwnProperty(l)){k.push('"'+l+'":'+g(j[l]))}}return"{"+k.join(",")+"}"}return String(j).replace(/\s/g," ").replace(/\'/g,'"')}function h(k){if(k===null||k===undefined){return false}var j=typeof k;return(j=="object"&&k.push)?"array":j}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function b(j,m){var l=[];for(var k in j){if(j.hasOwnProperty(k)){l[k]=m(j[k])}}return l}function a(q,s){var o=f({},q);var r=document.all;var m='<object width="'+o.width+'" height="'+o.height+'"';if(r&&!o.id){o.id="_"+(""+Math.random()).substring(9)}if(o.id){m+=' id="'+o.id+'"'}/*o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random());*/if(o.w3c||!r){m+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{m+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}m+=">";if(o.w3c||r){m+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;for(var j in o){if(o[j]!==null){m+='<param name="'+j+'" value="'+o[j]+'" />'}}var n="";if(s){for(var l in s){if(s[l]!==null){n+=l+"="+(typeof s[l]=="object"?g(s[l]):s[l])+"&"}}n=n.substring(0,n.length-1);m+='<param name="flashvars" value=\''+n+"' />"}m+="</object>";return m}function d(l,o,k){var j=flashembed.getVersion();f(this,{getContainer:function(){return l},getConf:function(){return o},getVersion:function(){return j},getFlashvars:function(){return k},getApi:function(){return l.firstChild},getHTML:function(){return a(o,k)}});var p=o.version;var q=o.expressInstall;var n=!p||flashembed.isSupported(p);if(n){o.onFail=o.version=o.expressInstall=null;l.innerHTML=a(o,k)}else{if(p&&q&&flashembed.isSupported([6,65])){f(o,{src:q});k={MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title};l.innerHTML=a(o,k)}else{if(l.innerHTML.replace(/\s/g,"")!==""){}else{l.innerHTML="<h2>Flash version "+p+" or greater is required</h2><h3>"+(j[0]>0?"Your version is "+j:"You have no flash plugin installed")+"</h3>"+(l.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='http://www.adobe.com/go/getflashplayer'>here</a></p>");if(l.tagName=="A"){l.onclick=function(){location.href="http://www.adobe.com/go/getflashplayer"}}}}}if(!n&&o.onFail){var m=o.onFail.call(this);if(typeof m=="string"){l.innerHTML=m}}if(document.all){window[o.id]=document.getElementById(o.id)}}window.flashembed=function(k,l,j){if(typeof k=="string"){var m=document.getElementById(k);if(m){k=m}else{c(function(){flashembed(k,l,j)});return}}if(!k){return}var n={width:"100%",height:"100%",allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:null,onFail:null,expressInstall:null,w3c:false};if(typeof l=="string"){l={src:l}}f(n,l);return new d(k,n,j)};f(window.flashembed,{getVersion:function(){var l=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var k=navigator.plugins["Shockwave Flash"].description;if(typeof k!="undefined"){k=k.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var m=parseInt(k.replace(/^(.*)\..*$/,"$1"),10);var q=/r/.test(k)?parseInt(k.replace(/^.*r(.*)$/,"$1"),10):0;l=[m,q]}}else{if(window.ActiveXObject){try{var o=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(p){try{o=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");l=[6,0];o.AllowScriptAccess="always"}catch(j){if(l[0]==6){return l}}try{o=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(n){}}if(typeof o=="object"){k=o.GetVariable("$version");if(typeof k!="undefined"){k=k.replace(/^\S+\s+(.*)$/,"$1").split(",");l=[parseInt(k[0],10),parseInt(k[2],10)]}}}}return l},isSupported:function(j){var l=flashembed.getVersion();var k=(l[0]>j[0])||(l[0]==j[0]&&l[1]>=j[1]);return k},domReady:c,asString:g,getHTML:a});if(e){jQuery.tools=jQuery.tools||{version:{}};jQuery.tools.version.flashembed="1.0.3";jQuery.fn.flashembed=function(k,j){var l=null;this.each(function(){l=flashembed(this,k,j)});return k.api===false?this:l}}})();


