function resize() {
	var height = ($(window).height() > $('body').height()) ? $(window).height() : $('body').height();
	$('#home .overlay').css('height', height);
	$('#home .overlay_background').css('height', height);
}

$(document).ready(function(){
	$('#ads').cycle('fade');
	$('#home-find input').focus(function() {
		this.value = '';
	});
	$('#jobs_apply .red_button').click(function() {
		$('#jobs_form').fadeIn('slow');
		return false;
	});
	$('#jobs_form .close').click(function() {
		$('#jobs_form').fadeOut('slow');
		return false;
	});
	$('#epc_visu').cycle('fade');
	if ($('#jobs').length > 0) {
		$('p.error').css('display', 'none');
		$('input.submit').css('display', 'none');
		$('a.submit').click(function() {
			$('#jobs_form form').submit();
			return false;
		});
		$('#jobs_form form').submit(function() {
			if ($('#jobs_form input').get(0).value == '' || $('#jobs_form input').get(1).value == '' || $('#jobs_form input').get(2).value == '' || $('#jobs_form input').get(3).value == '' || $('#jobs_form input').get(4).value == '' || $('#jobs_form input').get(5).value == '' || $('#jobs_form input').get(6).value == '' || $('#jobs_form input').get(7).value == '' || $('#jobs_form textarea').get(0).value == '') {
				$('p.error').fadeIn('slow');
				return false;
			}
			else {
				$('p.error').css('display','none');
			}
		});
	}
	$('#home-find form .red_button').click(function() {
		$('#home-find form').submit();
		return false;
	});
	var id = $('body').attr('id');
	if ($('#pharmacy_picture').length > 0) {
		$('#pharmacy_picture').attr('src','epc-familia/_img/pharmacies/'+id+'.jpg');
	}
	switch(id) {
		case 'acheter-en-ligne' : var i = -1; break;
		case 'home' : var i = 1; break;
		case 'services' :
		case 'carte-familia' : var i = 2; break;
		case 'parapharmacie' : var i = 4; break;
		case 'epc-familia' :
		case 'jobs' :
		case 'postuler' : var i = 5; break;
		case 'renovation-2010' :
		case 'news' : var i = 6; break;
		default : var i = 3; break;
	}
	if (i > 0) {
		$('#nav li#nav_item'+i).removeClass('link');
		$('#nav li#nav_item'+i).addClass('current');
	}
	
	/*resize();
	$(window).resize(function() {
		resize();
	});
	$('.overlay_background').click(function() {
		$(this).parent().hide();
	});
	$('.overlay .close').click(function() {
		$(this).parent().parent().hide();
		return false;
	});
	$('#screencast').flash({
		swf: '/epc-familia/_swf/rixensart.swf',
		width: 800,
		height: 600,
		base: '/epc-familia/_swf/'
	});
	*/
	if($.browser.msie && $.browser.version=="6.0")
		$(document).pngFix();
});

window.onload = function() {
	var col_main_height = parseInt($('.col_main').height());
	var col_side_height = parseInt($('.col_side').height());
	if (col_main_height < col_side_height) {
		$('.content').css('height', col_side_height-10 + 'px');
		$('.content_inner').css('height', col_side_height-70 + 'px');
	}
	else {
		$('.side').css('height', col_main_height-35 + 'px');
		$('.side_inner').css('height', col_main_height-35 + 'px');
	}
};
