var Concours = {
	options_infolettre: {
		iframe:true,
		href:'/politique-de-confidentialite',
		opacity:0,
		initialWidth:'0px',
		width:'800px',
		initialHeight:'0px',
		height:'550px',
		top:'20px',
		onOpen:function(){$('#colorbox_close').click(function(){$(this).colorbox.close()})}
	},
	options_partenaires: {
		inline:true,
		href:'#partenaires',
		opacity:0,
		initialWidth:'0px',
		width:'300px',
		initialHeight:'0px',
		height:'260px',
		onOpen:function(){
			$('#colorbox_close').click(function(){$(this).colorbox.close()});
			$('#partenaires').show();
		}
	},
	init:function() {
		
		$('#freeform').submit(function(){
			// concatenate dates selects
			$('#date_naissance').val($('#jour_naissance').val()+'/'+$('#mois_naissance').val()+'/'+$('#annee_naissance').val());
			
			// assign the right flash message
			if ($('#opt_in_infolettre').is(':checked')) {
				$('#flash_message').val($('#message_infolettre').html())
			}
			else {
				$('#flash_message').val($('#message_default').html())
			}
			
			$('.focus').each(function(){
				if (this.value == this.defaultValue) {
					$(this).val('');
				}
			});
		})
		
		//fix size issue in IE 6 and 7
		if (jQuery.browser.msie && parseInt(jQuery.browser.version) <= 7) {
		  	Concours.options_partenaires.height = '290px';
			Concours.options_infolettre.height = '580px';
		}
	
		$('#politique_confidentialite').click().colorbox(Concours.options_infolettre)
		$('#liens_partenaires').click().colorbox(Concours.options_partenaires)
		
		$(document).bind('cbox_cleanup', function(){
		        $('#partenaires').hide()
		});
		
		
		$('.focus').focus(function() {
			if (this.value == this.defaultValue) {
				$(this).val('');
				$(this).addClass('hasfocus');
			}
		}).blur(function() {
			if (this.value == '') {
				$(this).val(this.defaultValue)
				$(this).removeClass('hasfocus');
			}		
		});
	}
};

$(document).ready(function(){
	Concours.init();
});
