/*
  $(document).ready(function(){
$("#com_form").validate();
  });
*/
//
function check_valid_fields()
{
//validation init
//$("form#com_form  input, form#com_form textarea").each(function(i){
$("form#com_form .validated").each(function(i){
  $(this).validate.init(this);
 }); 

    if ($("form#com_form .error").length>1)
    {
        alert("Error! Please fill all the required fields.");
        return false;
    }
    else if ($('#com_form input:checked').length==0)
    {
        alert("Error! Make checked at least one checkbox.");
        return false;
    }
    return true;
}

  $(document).ready(function(){
	  var path = location.pathname.substring(1);
  	  pathSplitted = path.split("/");
	  var st = pathSplitted.pop();
	  if (st != "") {
	  	$('#leftnavigation a[href$="' + st + '"]').addClass('active');
	  } else {
		 $('#leftnavigation a[href$="index.php"]').addClass('active');		  
	  }

	  //Accordeaon jQuery
	  $(".readMore").click(function () {
		  $(this).next(".readMoreContent").slideToggle("slow");
	  });    
	  
	  
      $("#com_form").submit ( function() {
        if (!check_valid_fields())
            return false;
        else
        return true;    
      }); 
      
      $("#additionnalAttendeesSelect").change(function(){ 
          var numberOfAttendees;    
          numberOfAttendees = $("#additionnalAttendeesSelect").val();
          for(i=1;i<=5;i++)
          {
        	  if (i <= numberOfAttendees){
        		  $("#additionnalAttendees"+i).removeClass("hide");
        		  $("#additionnalAttendees"+i).find('input').addClass("validated");
        	  } else {
        		  $("#additionnalAttendees"+i).addClass("hide");
        		  $("#additionnalAttendees"+i).find('input').removeClass("validated");
        	  }
          }
      });
      
      $('.infoOfferCode').qtip({
    	   content: "eg CC*MM1 found on the address label on the back of the brochure<br/><img src=\"images/code_example.jpg\" alt=\"\"></img>",
    	   show: 'mouseover',
    	   hide: 'mouseout'
    	})      
  });


