var LECORMORAN = {
	version:'1.1'
};
$(document).ready(function(){
	
	/* add configuration to the content flow slideshow add-on */
	ContentFlowGlobal.setAddOnConf('slideshow', {
		startOnLoad: true,
		duration : 2000,
		showControlls: false
	});
	
	/* apply dropmenu on header menu */
	$("#h-navigation").dropmenu();
	
	/* apply fancybox on pictures */
	$(".pictures a").fancybox();
	
	/* apply the google search */
	$('#h-nav-search-input').keypress(function(event) {
	  if (event.keyCode == '13') {
	     window.location = 'http://www.google.fr/#hl=fr&q=site%3Alecormoran.net+' + $(this).val();
	   }
	});
	
	/* init the input placeholder for non webkit browsers */
	if(!$.browser.webkit)
	{
		$('input[type=search]').each(function(){
			$(this).val($(this).attr('placeholder')).attr('empty', true);
			$(this).focus(function(){
				if($(this).attr('empty') == 'true')
				{
					$(this).val('');
				}
			});
			$(this).blur(function(){
				if($(this).val() == '')
				{
					$(this).val($(this).attr('placeholder')).attr('empty', true);
				}
			});
			$(this).change(function(){
				$(this).attr('empty', $(this).val() != '');
			});
		});
	}
	
	
	/* for non webkit and firfox browsers */
	if(!$.browser.webkit && !$.browser.mozilla)
	{
		// add the advice message
		setMessage({
			title: 'Navigateur',
			iconClass: 'icon-alert',
			message: '<li>Le site actuel est optimis&eacute; pour <a href="http://www.google.com/chrome/" target="_blank">Chrome</a>, <a href="http://www.apple.com/safari/" target="_blank">Safari</a> et <a href="http://www.mozilla.com/firefox/" target="_blank">Firefox</a>.</li><li>Si vous avez des problèmes d\'affichage et afin de b&eacute;n&eacute;ficier de l\'ensemble des fonctionalit&eacute;s du site vous pouvez utliser l\'un de ces navigateurs ou installer le plugin <a href="http://www.google.com/chromeframe">Google Chrome Frame pour Internet Explorer</a>.</li>'
		});
				
		var head = document.getElementsByTagName("head")[0];
		
		// add the stylesheet
		var cssNode = document.createElement('link');
		cssNode.type = 'text/css';
		cssNode.rel = 'stylesheet';
		cssNode.href = 'resources/' + LECORMORAN.version + '/css/themes/lecormoran_ie.css';
		cssNode.media = 'screen';
		cssNode.charset = 'utf-8';
		head.appendChild(cssNode);
		
	}
	
	if($.browser.msie)
	{
		IE7_PNG_SUFFIX=".png";
	}	
});

function setMessage(params)
{
	// add the advice message
	$('#message h1').html(params.title || '');
	if(params.iconClass)
	{
		$('#message .icon').addClass(params.iconClass);
	}
	else
	{
		$('#message .icon').removeClass().addClass('icon');
	}
	$('#message ul').html(params.message || '');
	$('#message').css('display','block');
	$('#message .icon-close').click(function(){
		$('#message').css('display', 'none');
	});
}
