/* author   : jean-luc menetrey
 * desc     : Imedia - cridec.ch - application web object
 * Copyright: Imedia.ch - ©2011
 */


//gvo main desktop wrapper instance
if (typeof gvo != 'object')
	cri = {};

//Init gvo application
jQuery(document).ready(function() {
	cri.app.init();
	return;
});

cri.app = {
	init: function(){
		this.designTitle();
		
		if(jQuery('fieldset#form-contact').length > 0){
			this.cssCheckBox();
		}
		
		jQuery('div#sidebar ul#nav li.item54').css('display','none');  //Deactivate menu formation

		
	},
	designTitle: function(){
		var a = jQuery.merge(jQuery("div#content h1"),jQuery("div#content h2"));
		a.each(function(){
			var o= jQuery(this);
			if (o.parent().context.nodeName != 'DIV' && ! (o.parent().hasClass('title'))){
				o.wrap('<div class="jquery-title"></div>');
			}
		});
	},
	cssCheckBox: function(){
		//Fight IE
		jQuery('input[type="checkbox"]').addClass( 'checkbox');  //hide all input 		

		jQuery("span.checkbox").addClass('unchecked');
		jQuery("span.checkbox").bind("click",function(e){
			var o = jQuery(this);
			if(o.hasClass('checked')){
				o.removeClass('checked');
				o.addClass('unchecked');
				
				//Ensure attribute checked is on children input 
				o.find('input.checkbox').attr('checked','');
				
			} else {
				o.removeClass('unchecked');
				o.addClass('checked');
				//Ensure attribute checked is on children input 
				o.find('input.checkbox').attr('checked','checked');
			}
			return false;
		});
	}
};



