if (window.console){	var c=console.log}else{ c = function(){}}
jQuery.fn.bindAll = function(options) { 	var $this = this;	jQuery.each(options, function(key, val){ 	$this.bind(key, val);	});	return this;}
function _(id){return document.getElementById(id)}
function  ajax_submit(f,return_funct){
	method 	= f.method.toUpperCase() ;	data	= $(f).serialize();
	uri		= method=='POST' ? f.action : f.action + '?'+data
	$.ajax({ type: method,url: uri,data: data ,success: function(msg){ return_funct(  msg ); }})		
	return false
}
$(function(){
		$('#part-inner').cycle({
				fx:      'fade'	,speed:1500	,timeout:4000 /*, cleartypeNoBg:true */
				,prev:'.btn-prev',next:'.btn-next'
		});
		$('#news').cycle({
				fx:'scrollHorz',speed:1000	,timeout:4000 /*, cleartypeNoBg:true */
				,prev:'.btn-prev-s'	,next:'.btn-next-s'
		});
}) ;

$(function(){
	if (!_('ballon-outer')){		
		html = '<div id="ballon-outer" style="position:absolute; width:541px;display:none">'
		html += '<div id="ballon-close" '
		html += 'style="background:url(images/ballon-t-flip.png) bottom no-repeat; height:18px;cursor:pointer">'
		html += '</div><div  id="ballon-cont" '
		html += 'style="background:url(images/grad-bottom.jpg) bottom repeat-x;'
		html += 'background-color:#FFF; border-left:#e5e5e5 1px solid;padding:5px; '
		html += 'border-right:#bebebe 1px solid; min-height:150px;"></div>'
		html += '<div id="ballon-bottom" style="background:url(images/ballon-b.png) no-repeat; height:24px;"></div>'
		html += '</div>'	
		$('#main').append(html)
	}	
	$('#ballon-close').click(function(){
			$('#ballon-outer').fadeOut();
			$('ballon-cont').html('') ;
	})	
	$('.list-besoin li[class!="definition"]').css({cursor:'pointer'}).click(function(){
		var cont = { need:$(this).find('.list-need').html(),solution:$(this).find('.list-solution').html(),def:$(this).next().html()	}	
		html = '<div style="margin:0 40px 20px; height:200px"><h3>'+cont.need + '</h3>'
		html += '<p class="color-blue">'+cont.solution.toUpperCase()+'</p>'
		html += '<p style="color:#3c3c3c">'+cont.def+'</p></div>'
		$('#ballon-cont').html(html).css({width:529,overflow:'hidden'})	
		os 		= $(this).offset()
		win={}	//win.outerHeight = $(document).height()win.innerHeight	= $(window).height() 
		win.scrollTop	= $(window).scrollTop() 
		elm={}
		elm.callerTop	= os.top
		elm.outerTop	= os.top - 290				
		if (win.scrollTop > elm.outerTop){
			$('#ballon-close').css({height:41})
			$('#ballon-bottom').css({background:'url(images/ballon-b-flip.png) top no-repeat'})	
			B_TOP = elm.callerTop
		}else{
			$('#ballon-close').css({height:18})
			$('#ballon-bottom').css({background:'url(images/ballon-b.png) top no-repeat'})				
			B_TOP = elm.outerTop
		}	
		$('#ballon-outer').css({top:B_TOP,left:os.left+370}).fadeIn()	
	}/*,function(){	$('#ballon-outer').css({display:'none'});		}*/)	
	$('.ballon').click(function(){	
		os = $(this).offset()		
		h = $(this).attr('href')
		html = '<iframe width="531" height="350" frameborder="0" scrolling="no"'
		html += 'marginheight="0" marginwidth="0" src="'+h+'"></iframe>'
		$('#ballon-cont').html(html).css({width:529,overflow:'hidden'})
		$('#ballon-outer').css({height:400,top:os.top-400,left:os.left-250}).fadeIn()
		return false
	})
}) ;
$(function(){	
	dialog = {multi:110,single: -100}
	$('.upload-control').swfupload({
			button_action:dialog.single, /*multi:SWFUpload.BUTTON_ACTION.SELECT_FILES */		
			upload_url: "upload/upload.php",
			file_size_limit : "25600"/*25MB*/,
			file_types : "*.doc;*.docx;*.pdf;*.odt;*.htm;*.html;*.rtf;*.txt", /*SEP ; */
			file_types_description : "Tous les Document",
			file_upload_limit : "10",
			flash_url : "swfupload/swfupload.swf",
			button_image_url : "swfupload/swfupload_110x159.jpg",
			button_width : 111,
			button_height : 39.5,
			button_placeholder : $('.upload', this)[0], /*!!! do not use jquery object */
			debug: false
	}).bindAll({
		swfuploadLoaded: function(event){ 	},
		fileQueued: function(event, file){		
			$(this).swfupload('startUpload');		
		},
		fileQueueError: function(event, file, errorCode, message){			
			$(this).find('.out').html('Max upload attamps has riched ! ')	
		},
		fileDialogStart: function(event){	},
		fileDialogComplete: function(event, numFilesSelected, numFilesQueued){ },
		uploadStart: function(event, file){			
			$(this).find('.out').html('<img src="images/loading.gif" />') 
		},
		uploadProgress: function(event, file, bytesLoaded){	},
		uploadSuccess: function(event, file, serverData){	 	
			eval("o=("+serverData+")")
			if (o.status==1){		//upload sucess
				$(this).html(o.message)
			}else{					//upload error
				$(this).find('.out').html(	o.message )
			}
		},
		uploadComplete: function(event, file){	},
		uploadError: function(event, file, errorCode, message){			
			$(this).find('.out').html( 'UPLOAD ERROR' ) 		
		}
	});
});	
$(function(){
	$('.list-contact li a').click(function(){
		contact = this.href.substring(this.href.indexOf('#')+1).toUpperCase()
		$('#hdn-contact').val(contact)
		$clone = $($(this).parent().parent().find('img')[0]).clone()
		$(	'#contact-img'	).html($clone)
		return false ;
	})
	
})