$('#BoxPop').ready(function() {
			
	if($.cookie('popupVD') != 'first'){
		$("#BoxPop").colorbox({width:"530px", height:"513px", inline:true, href:"#BoxPop", open:true});
		//alert('si hay popup');
	}
							
							
	$('#cboxClose').click(function() {
	  $.cookie('popupVD', 'first', { expires: null, path: '/', domain: 'voyagesdestination.com', secure: false });
	  //alert('cerraste');
	});		
	
	$('#wrapper').css('display','block');
							
});

$(document).ready(function() {
						
	$(".showmailsubscribe").colorbox({width:"500px", height:"435px", iframe:true});
	
	/*if($.cookie('popupVD') == 'first'){
		//alert('ya no hubo popup');
		$('#wrapper').css('display','block');
	}else{
		$("#BoxPop").colorbox({width:"530px", height:"513px", inline:true, href:"#BoxPop", open:true});
		//alert('si hay popup');
	}
	
	$('#cboxClose').click(function() {
	  $.cookie('popupVD', 'first', { expires: null, path: '/', domain: 'voyagesdestination.com', secure: false });
	  $('#wrapper').css('display','block');
	  //alert('cerraste');
	});*/
	
	/*$('#cboxClose').click(function() {
	  $.cookie('popupVD', 'first', { expires: null, path: '/', domain: 'voyagesdestination.com', secure: false });
	  //alert('cerraste');
	});*/
	
	$('#mainBanner').css("visibility","visible");
	
	$("#mainBanner").showcase({
		css: {visibility: "visible"},
			animation: { type: "fade", interval:4000 },
			titleBar: { 
			enabled: false,
			autoHide: false
		},
		navigator: { 
			css: {marginLeft:"6px", marginBottom:"6px"},
			autoHide: true,
			showNumber:false,
			position:"bottom-left",
			item: {
				css: {
					width: "17px", height: "12px", fontSize: "15px", border:"none", paddingTop:"5px", marginRight:"5px",
				backgroundColor: "#FFF", color: "#000", border:"1px solid #FFF" },
				cssHover: {
					color: "#07366d", border:"none", backgroundColor: "#FFF", border:"1px solid #FFF" },
				cssSelected: {
					backgroundColor: "#1492e3", border:"none", color: "#FFF", border:"1px solid #FFF" }
			}
		}
	});
	

	
});


function checkSubscribeForm(lang){
	errors = 0;
	
	var subs_submit = $("#subs_submit").val();
	var name = $("#subs_name").val();
	var lastName = $("#subs_lastName").val();
	var age = $("#subs_age").val();
	var emailtocheck = $("#subs_email").val();
	var sex = $("#subs_sex").val();
	var civil = $("#subs_civil").val();
	
	var lang = $("#subs_lang").val();
	
	if($("#pref_sud").attr('checked')){
		var sud = 1;
	}else{
		var sud = 0;
	}
	
	if($("#pref_cruises").attr('checked')){
		var cruises = 1;
	}else{
		var cruises = 0;
	}
	
	if($("#pref_flights").attr('checked')){
		var flights = 1;
	}else{
		var flights = 0;
	}
	
	if($("#pref_family").attr('checked')){
		var family = 1;
	}else{
		var family = 0;
	}
	
	if($("#pref_europe").attr('checked')){
		var europe = 1;
	}else{
		var europe = 0;
	}
	
	if($("#pref_adult").attr('checked')){
		var adult = 1;
	}else{
		var adult = 0;
	}
	
	if($("#pref_couples").attr('checked')){
		var couples = 1;
	}else{
		var couples = 0;
	}
	
	if (name == null || name == "" ){
		if(lang = 'fr'){
			alert("Veuillez inscrire votre prénom");
		}else{
			alert('Please enter your first name');	
		}
		errors = errors + 1;
	}
	
	if (lastName == null || lastName == "" ){
		if(lang = 'fr'){
			alert("Veuillez inscrire votre nom de famille");
		}else{
			alert('Please enter your last name');	
		}
		errors = errors + 1;
	}
	
	if (age == null || age == "" ){
		if(lang = 'fr'){
			alert("Veuillez inscrire votre âge");
		}else{
			alert('Please enter your age');	
		}
		errors = errors + 1;
	}
	
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailtocheck)){
		//GOOD EMAIL
	}else{
		if(lang = 'fr'){
			alert("Veuillez inscrire une addresse courriel valide");
		}else{
			alert('Please enter a valid e-mail address');	
		}
		errors = errors + 1;
	}
	
	if (errors != 0){
		
		return false;
		
	}else{
	
		$.ajax({
		   url: "http://www.voyagesdestination.com/ajax/newsletter_subscribe.php",
		   type: "POST",
		   data: ({
					subs_submit : subs_submit,
					name : name,
					lastName : lastName,
					age : age,
					email : emailtocheck,
					sex : sex,
					civil : civil,
					sud : sud,
					cruises : cruises,
					flights : flights,
					family : family,
					europe : europe,
					adult : adult,
					couples : couples,
					lang: lang
				  }),
		   success: function(msg){
				if(msg == 'error'){
				 
				}else{
				 
				 if(lang == 'fr'){
					$("#subscribe_form_div").html("Merci "+name+" "+lastName+". Vous receverez un courriel de confirmation à l'addresse suivante: "+emailtocheck);	
				 }else{
					$("#subscribe_form_div").html("Thank you "+name+" "+lastName+". We have sent a confirmation e-mail to this e-mail: "+emailtocheck);	
				 }
				 
				 
				}
			}
		 });
	 
	}
	 return false ;
	
}

/*
$(document).ready(function() {
						   
	$(".showmailsubscribe").colorbox({width:"500px", height:"435px", iframe:true});
	
	$('#mainBanner').css("visibility","visible");
	
	$("#mainBanner").showcase({
		css: {visibility: "visible"},
			animation: { type: "fade", interval:6000 },
			titleBar: { 
			enabled: false,
			autoHide: false
		},
		navigator: { 
			css: {marginLeft:"6px", marginBottom:"6px"},
			autoHide: true,
			showNumber:false,
			position:"bottom-left",
			item: {
				css: {
					width: "17px", height: "12px", fontSize: "15px", border:"none", paddingTop:"5px", marginRight:"5px",
				backgroundColor: "#FFF", color: "#000", border:"1px solid #FFF" },
				cssHover: {
					color: "#07366d", border:"none", backgroundColor: "#FFF", border:"1px solid #FFF" },
				cssSelected: {
					backgroundColor: "#1492e3", border:"none", color: "#FFF", border:"1px solid #FFF" }
			}
		}
	}); 
		
});*/
