$(document).ready(function(){
	 //Begin: Validate login form element when the creer actualite form is submitted	

	//Reset all form fields
	/*$("#effacer").click(function(){	
		//$("#conseillerFrm").resetForm();
		 $("#conseiller_name").val('');
		 $("#conseiller_societe").val('');
		 $("#conseiller_phone").val('');
		 $("#conseiller_addresse").val('');
		 $("#conseiller_postal").val('');
		 $("#conseiller_fax").val('');
		 $("#conseiller_ville").val('');
		 $("#conseiller_pays").val('');
		 $("#conseiller_email").val('');
		 $("#demande").val('');
		 $("#information").val('');
		 $("#uniquecode").val('');
	});*/

	//Form validation
	$("#conseillerFrm").submit(function(){	 
		/*$("#validateTips").text('');
		$("#titre_msg").text('');
		$("#creation_date_msg").text('');
		$("#desc_msg").text('');
		$("#image_actualite_msg").text('');*/
		$("#errorMessage").html("");
		var name      				= $("#conseiller_name"),
			societe      			= $("#conseiller_societe"),
			phone		      		= $("#conseiller_phone"),			
			address		    		= $("#conseiller_addresse"),	
			postalcode	    		= $("#conseiller_postal"),
			fax			    		= $("#conseiller_fax"),			
			ville		    		= $("#conseiller_ville"),	
			pays		    		= $("#conseiller_pays"),
			email		    		= $("#conseiller_email"),			
			demande		    		= $("#demande"),
			info		    		= $("#information"),
			uniquecode	    		= $("#uniquecode");
			
		
		    allContainerArray   = new Array('nomError','societeError','phoneError','addressError', 'postalError', 'faxError', 'villeError', 'paysError', 'emailError', 'demandeError', 'informationError', 'uniquecode');
			allFields 		    = $([]).add(name).add(societe).add(phone).add(address).add(postalcode).add(fax).add(ville).add(pays).add(email).add(uniquecode);
			allFields.removeClass('ui-state-error'); //Remove error class if any attr("checked")),
			hideDomElement(allContainerArray); //Hide all error message container
			
			$("#errorFlag").val(0);	
			e 	=	/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9]{2,4}$/;
			if($.trim($("#conseiller_name").val())=='')
			{
				checkBlank(name, "Nom", "nomError");
				$("#conseiller_name").focus();
				if ($("#errorFlag").val() == 1)
					return false; 
			}
				
			/*if($.trim($("#conseiller_societe").val())=='')
			{
				checkBlank(societe, "Société", "societeError");
				$("#conseiller_societe").focus();
				if ($("#errorFlag").val() == 1)
					return false; 		
			}*/
			
			if($.trim($("#conseiller_phone").val())=='')
			{
				checkBlank(phone, "Téléphone", "phoneError");
				$("#conseiller_phone").focus();
				if ($("#errorFlag").val() == 1)
					return false; 		
			}
			if($.trim($("#conseiller_email").val())=='')
			{
				checkBlank(email, "E-mail", "emailError");
				$("#conseiller_email").focus();
				if ($("#errorFlag").val() == 1)
					return false; 		
			}
			if($.trim($("#conseiller_email").val())!='')
			{
				checkRegexp(email,e, "E-mail invalide", "emailError");
				$("#conseiller_email").focus();
				if ($("#errorFlag").val() == 1)
					return false; 		
			}
			if($.trim($("#demande").val())=='')
			{
				checkBlank(demande, "Objet de la demande", "demandeError");
				$("#demande").focus();
				if ($("#errorFlag").val() == 1)
					return false; 		
			}
			/*if($.trim($("#information").val())=='')
			{
				checkBlank(info, "Information supplémentaire", "informationError");
				$("#information").focus();
				if ($("#errorFlag").val() == 1)
					return false; 		
			}*/
			if($("#uniquecode").val() == ''){
			checkBlank(uniquecode, "Code de sécurité", "uniquecodeError");
			$("#uniquecode").focus();
			if ($("#errorFlag").val() == 1) return false;
		}
				
			
			
			return true;
	});
	//End:  Validate login form element when the creer actualite form is submitted 
	
	
	//Begin Contact
	
	$("#contactFrm").submit(function(){	 
		/*$("#validateTips").text('');
		$("#titre_msg").text('');
		$("#creation_date_msg").text('');
		$("#desc_msg").text('');
		$("#image_actualite_msg").text('');*/
		$("#errorMessage").html("");
		$("#errormesg1").css("display","none");
		$("#errormesg2").css("display","none");
		$("#errormesg3").css("display","none");
		$("#errormesg11").css("display","none");
		$("#errormesg12").css("display","none");
		$("#errormesg13").css("display","none");
		var name      				= $("#contact_name"),
			contact_email		    = $("#contact_email"),	
			uniquecode	    		= $("#uniquecode");
			
		
		    allContainerArray   = new Array('nomError','emailError', 'uniquecode');
			allFields 		    = $([]).add(name).add(contact_email).add(uniquecode);
			allFields.removeClass('ui-state-error'); //Remove error class if any attr("checked")),
			hideDomElement(allContainerArray); //Hide all error message container
			
			$("#errorFlag").val(0);	
			e 	=	/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9]{2,4}$/;
			if($.trim($("#contact_name").val())=='')
			{
				checkBlank(name, "Nom ou Entité", "nomError");
				$("#contact_name").focus();
				if ($("#errorFlag").val() == 1)
					return false; 
			}
				
			if($.trim($("#contact_email").val())=='')
			{
				checkBlank(contact_email, "E-mail", "emailError");
				$("#contact_email").focus();
				if ($("#errorFlag").val() == 1)
					return false; 		
			}
			if($.trim($("#contact_email").val())!='')
			{
				checkRegexp(contact_email,e, "E-mail invalide", "emailError");
				$("#emailError_container").css("margin-right","30px");
				$("#contact_email").focus();
				if ($("#errorFlag").val() == 1)
					return false; 		
			}
			if($("#uniquecode").val() == ''){
			checkBlank(uniquecode, "Code de sécurité", "uniquecodeError");
			$("#uniquecode").focus();
			if ($("#errorFlag").val() == 1) return false;
		}
			return true;
	});
	
	//End Contact
	
 });

	
/***** START:jqueryslidemenu *****/

/*********************
//* jQuery Multi Level CSS Menu #2- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last update: Nov 7th, 08': Limit # of queued animations to minmize animation stuttering
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/

//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):
//var arrowimages={down:['downarrowclass', 'WebResources/Images/down_menu.gif', 23], right:['rightarrowclass', 'WebResources/Images/right_menu.gif']}
var arrowimages	=	'';
var jqueryslidemenu={

animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
			$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: ''} : {}).append('')
			$curobj.hover(
				function(e){

					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(jqueryslidemenu.animateduration.out)
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="myslidemenu" on page:
jqueryslidemenu.buildmenu("myslidemenu", arrowimages)

//jqueryslidemenu.buildmenu("myslidemenu")

/***** END:jqueryslidemenu *****/

/***** START:jqueryslidemenu_bottom *****/
/*********************
//* jQuery Multi Level CSS Menu #2- By Dynamic Drive: http://www.dynamicdrive.com/
//* Last update: Nov 7th, 08': Limit # of queued animations to minmize animation stuttering
//* Menu avaiable at DD CSS Library: http://www.dynamicdrive.com/style/
*********************/

//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):
//var arrowimages={down:['downarrowclass', 'WebResources/Images/down_menu.gif', 23], right:['rightarrowclass', 'WebResources/Images/right_menu.gif']}
var arrowimages	=	'';
var jqueryslidemenu_bottom={

animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){

	jQuery(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		
		
		var $liname = $mainmenu.find("li").parent()
		//alert($liname);
		
		var zIndexNumber = 1000;
                $liname.each(function() {
			//	alert('here');
                $liname.css('zIndex', zIndexNumber);
                zIndexNumber -= 10;
                });
		
		
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({bottom:this.istopheader? this._dimensions.h+"px" : 0})
			$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: ''} : {}).append('')
			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, bottom:$(this).offset().bottom}
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu_bottom.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(jqueryslidemenu_bottom.animateduration.out)
				}
			) //end hover
		}) //end $headers.each()
		
		 
		
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
		 

	}) //end document.ready
}
}

//build menu with ID="myslidemenu" on page:
jqueryslidemenu_bottom.buildmenu("myslidemenu1", arrowimages)

//jqueryslidemenu.buildmenu("myslidemenu")

/***** END:jqueryslidemenu_bottom *****/

