﻿window.onload=function(){
	Nifty("div#butonmeniu","bottom","#C7C7F2","#FFF","big border transparent smooth");	
}



function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
			oldonload();
      }
      func();
    }
  }
}

addLoadEvent(	function() {

	
	
	//	If right block container exists
	if($('#bloc_right_container')) {	
		
		//	Rounded corners for right block elements
		//$('.bloc_right_holder').corner("round 8px").parent().css('padding', '2px').corner("round 10px");		

		$("#bloc_right_container .bloc_right_wrapper").each( function(intIndex ) {
			 	var newElementId = 'block-wrapper-'+intIndex ;
			 	$(this).attr('id', newElementId);				 				 		
		});		
	}
	
	
	$('.bloc_right_holder a ').hover(
		
	function() { 	
		
		$(this).children().each( function()	{			
			if(	this.className == 'title')	{
				$(this).addClass('thover');
			}else if(this.className == 'content')	{			
				$(this).addClass('chover');
			}
		});
	
	}, function() {
		
		$(this).children().each( function()	{			
			if(	this.className.toString().indexOf('thover') != -1)	{
				$(this).removeClass('thover');
			}else if(this.className.toString().indexOf('chover') != -1)	{
				$(this).removeClass('chover');
			}
		});	
		
	});
	
	
	// MENU PLIANT 	
	$('.toggler').click (
	function() { 
			var el = $(this).parent().next();			
			el.toggle();
			
			var titi = $(this).parent().children().children('.triangle');
			var a = titi.attr('src');
			var b = titi.attr('secondsrc'); 
			titi.attr('src',b); 
			titi.attr('secondsrc',a);
	
	
		}	
	);
	
	function convertToLatin(toConvert){
		var frenchChars = new Array();
		var engChars = new Array();
		var i;
		var temp;
		temp = toConvert;
		frenchChars[0]='é';
		frenchChars[1]='è';
		frenchChars[2]='ê';
		frenchChars[3]='à';
		frenchChars[4]='ç';
		frenchChars[5]='û';
		frenchChars[6]='ô';
		frenchChars[7]=' ';
	
		engChars[0] = 'e';
		engChars[1] = 'e';
		engChars[2] = 'e';
		engChars[3] = 'a';
		engChars[4] = 'c';
		engChars[5] = 'u';
		engChars[6] = 'o';
		engChars[7] = '_';		
		
		temp = toConvert.toLowerCase();
		temp = temp.replace(/ /g,"_");
		temp = temp.replace(/é/g,"e");
		temp = temp.replace(/ê/g,"e");
		temp = temp.replace(/è/g,"e");
		temp = temp.replace(/à/g,"a");
		temp = temp.replace(/ç/g,"c");
		temp = temp.replace(/û/g,"u");
		temp = temp.replace(/ô/g,"o");		
		return temp;
		
	}
	
	$('.ninjulescu').each( 
	function(intIndex ) {
		var m = $(this).parent().parent().parent().prev().find('h1');	//header tag
		var t = $(this).parent().parent().prev().find('a.txtbleu14'); // link tag
		var img = $(this).parent().parent().prev().find('a.cat_image');			
		t.text(m.text());				
		var src= "fileadmin/templates/images/File_manager_images/" + convertToLatin(m.text()) + ".gif";				
		img.html('<img src="'+src+'" border="0" height="26" width="28">');
		
	})

	$('.collapsed_ninjulescu').each( 
	function(intIndex ) {
		var m = $(this).parent().parent().parent().prev().find('h1');	//header tag
		var t = $(this).parent().parent().prev().find('a.txtbleu14'); // link tag
		var img = $(this).parent().parent().prev().find('a.cat_image');			
		t.text(m.text());				
		var src= "fileadmin/templates/images/File_manager_images/" + convertToLatin(m.text()) + ".gif";				
		img.html('<img src="'+src+'" border="0" height="26" width="28">');
		
	})	
});


	$(document).ready(	function(){
							
							//Submenu display
							$('#butonmeniu .menuitem').hover(
								function () {
									$(this).children().next().toggle();
								},
								
								function () {
									$(this).children().next().toggle();
								}
							);
							/*
							//NOT IE
							if (!(jQuery.browser.msie))
							{
								$('#butonmeniu .menuitem .mtop a').each(function(){
									$(this).attr("min",($(this).attr("onmouseover")));
									$(this).attr("mout",($(this).attr("onmouseout")));								
									$(this).removeAttr('onmouseout');
									$(this).removeAttr('onmouseover');								
									$(this).hover(
										function() {										
											eval($(this).attr("min"));
										},
										function() {
											eval($(this).attr("mout"));
										}
									);								
								});
							}
							else  //IE
							{*/
								$('#butonmeniu .menuitem .mtop').each (function() {
									var oldATag= $(this).html();
									$(this).empty();
									oldATag = oldATag.replace(/onmouseover/,"min");
									oldATag = oldATag.replace(/onmouseout/,"mout");									
									$(this).append(oldATag);
								});
								$('#butonmeniu .menuitem .mtop a').each (function() {
									$(this).hover(
										function() {										
												eval($(this).attr("min"));
											},
										function() {
											eval($(this).attr("mout"));
										});
								});
								
						//	}
														
												
							/*
							$('#butonmeniu .menuitem').mouseover(								
								function(){																
									$(this).children().next().toggle();
								}
							);
							$('#butonmeniu .menuitem').mouseout(
								function() {							
									$(this).children().next().toggle();
								}								
							);*/
							$(".anylinkcss:last").css("width","125px");
							//Flicker fix???
							/*
							try {
							  document.execCommand('BackgroundImageCache', false, true);
							} catch(e) {}*/
	
		Nifty("div.cartouche","normal transparent");
		
		//Hiding empty a tags generated by typo3 in the communiques news right menu
		//$("#news_container ul").children("a:contains('')").hide();
		$("#news_container ul a:empty").hide();
	});
					
//Flicker fix?
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
		




