/**
 *
 * CDP JavaScript Function
 * 
 * Global function for javascript interaction
 * 
 */
 
 /**
 * We wait for the document ready before doing anything 
 */
 $(document).ready(function() {
 
	// handle mouseover and mouseout on buttons with text
	$("li.menu_item img, img.button").mouseover(function(event){
		var temp = $(this).attr('src');
		temp = temp.replace('_fre','_highlight_fre');
		temp = temp.replace('_eng','_highlight_eng');
		$(this).attr({src:temp});
	});
	
	$("li.menu_item img, img.button").mouseout(function(event){
		var temp = $(this).attr('src');
		temp = temp.replace('_highlight','');
		$(this).attr({src:temp});
	});
	
	
	// handle mouseover and mouseout on buttons without text
	$("img.linked_in, img.letter, img.rss, img.goto_btn, img.dropdown").mouseover(function(event){
		var temp = $(this).attr('src');
		temp = temp.replace('.','_highlight.');
		$(this).attr({src:temp});
	});
	
	// handle mouseover and mouseout on buttons without text
	$(".arrowOver").mouseover(function(event){
		var curr = $(this).attr('id');
		var currElements = curr.split('_');
		var temp = $('#inscription_btn_' + currElements[1]).attr('src');
		temp = temp.replace('.','_highlight.');
		$('#inscription_btn_' + currElements[1]).attr({src:temp});
	});
	
	$("img.linked_in, img.letter, img.rss, img.goto_btn, img.dropdown").mouseout(function(event){
		var temp = $(this).attr('src');
		temp = temp.replace('_highlight','');
		$(this).attr({src:temp});
	});
	
	$(".arrowOver").mouseout(function(event){
		var curr = $(this).attr('id');
		var currElements = curr.split('_');
		var temp = $('#inscription_btn_' + currElements[1]).attr('src');
		temp = temp.replace('_highlight','');
		$('#inscription_btn_' + currElements[1]).attr({src:temp});
	});
	
	// Rollover for submit elements
	$(function() {
	    $('.save').hover(function() {
	        var temp = $(this).attr('src');
			temp = temp.replace('_fre','_highlight_fre');
			temp = temp.replace('_eng','_highlight_eng');
			$(this).attr({src:temp});
	    }, function() {
	        var temp = $(this).attr('src');
			temp = temp.replace('_highlight','');
			$(this).attr({src:temp});
	    });
	});
	
	// handle dropdown
	$("img.dropdown").each(function(i)
	{
		var open = false;
		
		$(this).parents("div.description_frame").children("ul.conference_schedule").hide();
			
		$(this).click(function(event){	
			
			if(!open)
			{
				var temp = $(this).attr('src');
				temp = temp.replace('.png','');
				temp += '_invert.png'
				$(this).attr({src:temp});
			
				$(this).parents("div.description_frame").css('backgroundColor',"#d1d0c8");
				$(this).parents("div.description_frame").children("ul.conference_schedule").show();
								
				$(this).trigger("mouseout");
				
				$(this).unbind('mouseover');
			}
			else
			{
				var temp = $(this).attr('src');
				temp = temp.replace('_invert','');
				$(this).attr({src:temp});
			
				$(this).parents("div.description_frame").css('backgroundColor',"#c7c6bb");
				$(this).parents("div.description_frame").children("ul.conference_schedule").hide();
				
				$(this).bind('mouseover',function(event){
					var temp = $(this).attr('src');
					temp = temp.replace('.png','');
					temp += '_highlight.png'
					$(this).attr({src:temp});
				});
				
			}
			
			open = !open;

		});
		
	});
	
});
 
 