$(function(){
	var currentUrl=document.location.href;

	$('.openpopup').colorbox({
		initialWidth	: '50',
		initialHeight	: '50',
		onOpen			: function(){
			link = $(this).attr('href');

			try{
				_gaq.push(['_setAccount', gaIdCode]);
				_gaq.push(['_trackPageview', '/'+link ]);
			}
			catch(err){}
		},
		onComplete : function(){
			$('#prov_url').val(currentUrl);

			$('input.autocomp').each(function(){
				var table = $(this).attr('name');
				$(this).autocomplete({
					source : "contact/autocomp.html?input="+table
				});
			});
		}
	});

//	{href:function(){return $(this).attr('href')//+'?ajax=true'}}

//	$('.openpopup').click(function(){
//		var $link = $(this).attr('href');
//		
//		$('.popup_content').load($link, {ajax : true}, function(){
//			if($("#prov_url").length>0) $("#prov_url").val(currentUrl);
//			$('.popup').fadeIn();
//			_gaq.push(['_setAccount', gaIdCode]);
//			_gaq.push(['_trackPageview', '/'+$link ]);
//		});
//		
//		return false;
//	});
	
//	$('.closepopup').click(function(){
//		$('.popup').fadeOut(function(){
//			$('.popup_content').html('');
//		});
//
//		return false;
//	});

	//fermeture de la popup avec la touche 'escape'
//	var keypressaction = function(event){
//		if(event.keyCode == 27 && $('.closepopup:visible').length>0)
//			$('.popup:visible').fadeOut(function(){
//				$('.popup_content').html('');
//			});
//	}
//
//	$(document).bind('keypress', keypressaction);
});
