/** 
 * @projectDescription Dilicom CLIL main script file
 *
 * @author 	Sébastien Dussaut sebastien.dussaut@mediagong.tv
 * @version 	0.1 
 */



/**
 * @classDescription UD-Net main Javascript Class
 */

var Clil = {
	/**
	 * Inits main functions
	 * @method
	 */
	init: function() {
		Clil.initTabs();
		
	},
	/**
	 * Inits tabs
	 * @method
	 */
	initTabs: function() {
		jQuery("#right").find("div:eq(1)").hide();
		jQuery("#right ul > li:first").addClass("active");
		
		jQuery("#right ul a").bind("click", function(event) {
			event.preventDefault();
			jQuery(this).parent().addClass("active")
								 .siblings().removeClass("active");
			jQuery(this.hash).show()
							 .siblings("div").hide();
							 
			jQuery(this).blur();
		});
		
		jQuery("#header #navigation li").hover(function(){
			$(this).addClass("hover");			
		},function(){
			$(this).removeClass("hover");	
		});
	}
}



function positioneFooter() {
    var h = $(document).height();
    var w = $("#inner").width();
    $(".footer").css("position","absolute").css("width",w+"px").css("top",(h-50)+"px").css("height","50px");
}
jQuery(document).ready(function(){
	Clil.init();

	//effet pyjama sur le tableau des résultats*/
	//$('#tab_result table').each(function() {
    //    $('tr:even', this).addClass('pair');
	//});
	
	//bubble
	$("a.btn_bubble").each(function() {
		$(this).hover(
		  function () {
			//$("a.btn_bubble .bubble").show("");
			$(this).children(".bubble").show();
			
		  }, 
		  function () {
		   //$("a.btn_bubble .bubble").hide("");
		   $(this).children(".bubble").hide();
		  }
		 );
		});
		
	
		$("a.btn_bubble_new").each(function() {
		$(this).hover(
		  function () {
			//$("a.btn_bubble .bubble").show("");
			$(this).children(".bubble_new").show();
			
		  }, 
		  function () {
		   //$("a.btn_bubble .bubble").hide("");
		   $(this).children(".bubble_new").hide();
		  }
		 );
		});
		
		$("a.btn_bubble_gln").each(function() {
		$(this).hover(
		  function () {
			//$("a.btn_bubble .bubble").show("");
			$(this).children(".bubble_gln").show();
			
		  }, 
		  function () {
		   //$("a.btn_bubble .bubble").hide("");
		   $(this).children(".bubble_gln").hide();
		  }
		 );
		});
		
	
	$("#orderingSelectionForm select").change(function() {
		$("#orderingSelectionForm #p").val(1);
		this.form.submit();
	});
	
	$(function(){
 		$(".admin").click(function(){
	 	$("#fm_gerer").submit();
 		});
	});	
	$(".nice_input").wrap("<div class='nice_input_wrapper'/>"); 
	$(".nice_inputXL").wrap("<div class='nice_input_wrapperXL'/>");
	$(".nice_input_120").wrap("<div class='nice_input_wrapper120'/>"); 
	$(".nice_input_120bis").wrap("<div class='nice_input_wrapper120bis'/>");
	
	/*	var chpasswdUrl="<html:url value='/j_spring_security_check_asknew'/>";
		$(function(){
			$("#chpasswd_btn").click(function(){
				$("#connectionForm").attr("action",chpasswdUrl).submit();
			});
		});
		
		$(function() {
			$("#connectionForm").validate({
				ignoreTitle: true,
				rules: {
					j_password : {
						required:true
					
					},
					j_username : {
						required:true
					
					}
				}
			});
		});
		*/

	$(window).bind('resize',positioneFooter);
	$(positioneFooter);
	$('.roundedDiv').corner();
	
	// mise a jour des select skinnés
	var ie6 = false;
	if($.browser.msie && parseFloat(jQuery.browser.version) <=6){
		ie6 = true;
	}
	if(!ie6){
		$('.skinedSelect').select_skin();
	}
});
