var scriptAjax = null;

function init(){

	setInit()
	setEvent()
	
	setTimeout(setBoxIcone,750)
	//setBoxIcone()
}

function setInit(){
	
	scriptAjax = domain+'/ajax.php'				
	
	//$('.boxContent').height(612);
	$.ajaxSetup({
					async:false,
					cache:true,
					type:'POST'
				})

				
	$('img.setLangue').click(hEvent)
	
	
	
	$('.selector').hover(
		function(){
			var n=$(this).attr('src')
			$(this).attr('src',n.replace(/_off/,'_on'))
		},
		function(){
			var n=$(this).attr('src')
			$(this).attr('src',n.replace(/_on/,'_off'))
		}
	)
	
	$('#pane2').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16});
	
	/*
	$('#panel')
					.jScrollPane({
															showArrows:true, 
															arrowSize: 15,
															scrollbarWidth: 14, 
															scrollbarMargin :5,
															wheelSpeed :18,
															animateTo:false, 															
															dragMinHeight:0,
															dragMaxHeight:99999,
															animateInterval:100,
															animateStep:3,
															maintainPosition:true,
															scrollbarOnLeft:false,
															reinitialiseOnImageLoad:true
														});	
	*/
	/*
	$('.zoomImg').zoomimage({
								border: 2,
								centered: true,
								hideSource: true,
								Opacity:0.5,
								duration:300,
								easing:'linear',
								controls:true,
								controlsTrigger:'mouseover',
								prevent:14,
								caption:true
								
							});
	*/


}



function setBoxIcone(){
	bI = $('.boxIcone')
	wbI = 0
	bW = $(bI).innerWidth()
	nI = $('img',$(bI)).size()
	$('img',$(bI)).each(
		function(){
			//alert($(this).outerWidth())
			wbI +=$(this).outerWidth()
		}
	)
	tM = 2*(Math.floor((bW - wbI)/2))
	mI = Math.floor(tM/nI/2)
	//alert(bW+' '+wbI+' '+tM+' '+nI+' '+mI)
	$('img',$(bI)).css('padding','0px '+mI+'px 0px '+mI+'px')
	$(bI).width(wbI+(2*nI*mI)).css('display','none').css('visibility','visible').fadeIn(500)
}



function setEvent(){
	//$(window).bind('resize',hEvent)
	
	$('.selector').click(hEvent)
	
	/*	
	$('.buttonToEnlight').hover(
		function(){
			var n = $('img',$(this)).attr('src')
			tn = n.split('_')
			$('img',$(this)).attr('src',tn[0]+'_on_'+tn[1])
		},
		function(){
			var n = $('img',$(this)).attr('src')
			$('img',$(this)).attr('src',n.replace(/_on/,''))
		}
	)
	*/
}


function hEvent(e){
	var t = e.type,o = e.target;
	switch(t){
		case 'resize':
			window.location.href = window.location.href
			break;
		case 'click':
			if($(o).hasClass('selector')){
				
			}
			if($(o).hasClass('setLangue')){
				param = {
							action:'setLangue',
							subAction:'setLangue',
							langueID:$(o).attr('jqParam')
						}
				
				$('#debug').load(scriptAjax,param)	
				//alert(window.location.href)
				window.location.href = window.location.href
				return false;
			}
			
			break;
		case 'mouseenter':
		
		
			break;
		case 'mouseleave':
		
			break;
	}
}



