// JavaScript Document

// remove slideshow images, google map and yahoo weather from iphone devices

function hideDiv(){

    if ($(window).width() > 500) {
	 $('#slideshow').append('<img src="img/headerImg2.jpg" alt="Le San Juan">');
	 $('#slideshow').append('<img src="img/headerImg3.jpg" alt="Le San Juan">');
 
    }else{
	 $("img[src='img/headerImg2.jpg']").remove();
	 $("img[src='img/headerImg3.jpg']").remove();
	 $('.map').empty();
	 $('.weather').empty();

    }
}
		//run on document load and on window resize
		$(document).ready(function () {
			//on load
			hideDiv();
			//on resize
			$(window).resize(function(){
				hideDiv();
			});
		});



/* header image slide show */

function slideSwitch() {
    var $active = $('#slideshow img.active');

	if ( $active.length == 0 ) $active = $('#slideshow img:last');
	    var $next =  $active.next().length ? $active.next()
        : $('#slideshow img:first');

		$active.addClass('last-active');
	
		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
   });
}

	$(function() {
		setInterval( "slideSwitch()", 3000 );
	});
	
	
/* tabs panel */

		$(function () {
			var tabContainers = $('.tabHolder');
			tabContainers.hide().filter(':first').show();
			
			$('.tabs a').click(function () {
				tabContainers.hide();
				tabContainers.filter(this.hash).show();
				$('.tabs li').removeClass('selected');
				$(this).parents(".tabs li").addClass('selected');
				return false;
			}).filter(':first').click();
		});


/* */



var openMyModal = function(source)
{
	modalWindow.windowId = "myModal";
	modalWindow.width = 680;
	modalWindow.height = 605;
	modalWindow.content = "<iframe width='680' height='605' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'>&lt/iframe>";
	modalWindow.open();
};	


// Form validation /////////////////////////////////////////////////
	  
$(function() {
    $('.error').hide();
    $(".button").click(function() {
      // validate and process form here

      $('.error').hide();
  	  var name = $("input#name").val();
  		if (name == "") {
        $("span#name_error").show();
        $("input#name").focus();
        return false;
      }
  	  var prenom = $("input#prenom").val();
  		if (prenom == "") {
        $("span#prenom_error").show();
        $("input#prenom").focus();
        return false;
      }
  		var phone = $("input#phone").val();
  		if (phone == "") {
        $("span#phone_error").show();
        $("input#phone").focus();
        return false;
      }
  		var email = $("input#email").val();
  		if (email == "") {
        $("span#email_error").show();
        $("input#email").focus();
        return false;
      }
  		var message = $("textarea#message").val();
  		if (message == "") {
        $("span#message_error").show();
        $("textarea#message").focus();
        return false;
      }
	  
    });
  });
	  

// thumbnail pop up  http://colorpowered.com/colorbox/ ////////////////////////
 
$(document).ready(function(){

	if ($(window).width() > 500) {
		$("a[rel='example1']").colorbox({transition:"fade"});
	
	}else{
		$('img').parent.css('background-color, black');
		return false
	}
});


  

