// plugin to clear forms object
$.fn.clearForm = function() {
  return this.each(function() {
	var type = this.type, tag = this.tagName.toLowerCase();
	if (tag == 'form')
	  return $(':input',this).clearForm();
	if (type == 'text' || type == 'password' || tag == 'textarea')
	  this.value = '';
	else if (type == 'checkbox' || type == 'radio')
	  this.checked = false;
	else if (tag == 'select')
	  this.selectedIndex = 0;
  });
};

function  halowa(cors)
{
	 //var course ='<div id="m_course">'+links+'</div>';  							
			$('#accomm2_back').addClass("activeTab");
			$("#page_loader").html('');	// remove contents from main div 	
			$("#m_accomm").html(cors);
					
	}







// plugin to clear forms object

	$(document).ready(function() {
	/*var accom ; // this variable to set accommodation */
	//var courses_value ; // this variable to set course
	
	//default action
	//accom = 'garret';
	//courses_value ='standard';
	
	//alert(year);
	//alert(courses_value) ;
//alert($("#page_loader").stripy());

switch(accom)
	{
		case'castel_arabel':
			/*$('#accomm2_back').addClass("activeTab");
			$("#page_loader").html('');	// remove contents from main div 	
			$("#m_accomm").html('<b>Castel Arabel</b>')*/
			var yearq=document.getElementById('yearx').value ;
			$("#_loaders").load("course.htm",{acc:accom,course:courses_value,year:yearq});	
			break ;
			case'garret':
/*			$('#accomm1_back').addClass("activeTab");
			$("#page_loader").html('');	// remove contents from main div 	
			$("#m_accomm").html('<b>Garret</b>')*/
			
			var yearq=document.getElementById('yearx').value ;
			//alert (yearq);
			$("#_loaders").load("course.htm",{acc:accom,course:courses_value,year:yearq});	
			break ;
			case'host':
			/*$('#accomm3_back').addClass("activeTab");
			$("#page_loader").html('');	// remove contents from main div 	
			$("#m_accomm").html('<b>Host family</b>')*/
			var yearq=document.getElementById('yearx').value ;
			//alert(yearq);
			$("#_loaders").load("course.htm",{acc:accom,course:courses_value,year:yearq});	
			
			break ;
			case'sun_holidays':
		/*	$('#accomm4_back').addClass("activeTab");
			$("#page_loader").html('');	// remove contents from main div 	
			$("#m_accomm").html('<b>Sun Holidays</b>')*/
			var yearq=document.getElementById('yearx').value ;
			$("#_loaders").load("course.htm",{acc:accom,course:courses_value,year:yearq});	
			break ;
			
			case'robert':
			/*$('#accomm4_back').addClass("activeTab");
			$("#page_loader").html('');	// remove contents from main div 	
			$("#m_accomm").html('<b>Robert soleau</b>')*/
			var yearq=document.getElementById('yearx').value ;
			$("#_loaders").load("course.htm",{acc:accom,course:courses_value,year:yearq});	
			break ;
	}

//// for taps
$('#T2').click(function() {
var yearx=document.getElementById('yearx').value ;
//alert  (yearx) ;
$("#_loaders").load("course.htm",{acc:accom,course:courses_value,year:yearx});
});

$('#link_T1').click(function() {
var year=document.getElementById('year').value ;
//alert  (year) ;
$("#page_loader").load("course_2010.htm",{acc :accom,course:courses_value,year:year});

});
	
	
	switch (courses_value)
			 {
case 'standard':			 
					switch(accom)
					{		 		
         				case'garret':
						 course ='<div id="m_course">Garret <a href="hebergement_residence_garret.htm"  target="_blank">Details du Garret</a></div>';
						halowa('Cours standards (20 leçons/sem.)');
						break ;
						case'castel_arabel':
						 course ='<div id="m_course">Castel_arabel <a href="hebergement_residence_castel_arabel.htm"  target="_blank">Details du Garret</a></div>';
						halowa('Cours standards (20 leçons/sem.)');
						break ;
						
			
                    }
			  
			  break ;
			  
			  case 'int1c':
			  course ='<div id="m_course">cours intensifs 1 (30 le&ccedil;ons/sem.)<a href="cours_intensifs_1.htm"> Details du   cours</a></div>';
			  break ;
			  case 'int2c':
			  course ='<div id="m_course">cours intensifs 2 (36 le&ccedil;ons/sem.)<a href="cours_intensifs_2.htm"> Details du   cours</a></div>';
			  break ;
			  case 'Executive':
			  course ='<div id="m_course">cours dirigeants (30 le&ccedil;ons/sem.)<a href="cours_dirigeants.htm"> Details du   cours</a></div>';
			  break ;
			  case 'individual':
			  course ='<div id="m_course">cours particuliers (20 , 30 et 40  le&ccedil;ons/sem.)<a href="cours_particuliers.htm"> Details du   cours</a></div>';
			  break ;
			  case 'no':
			  course ='<div id="m_course"></div>';
			  break ;
			  default:
			  course = course;
			  break ;
			 }
			 
			 $("#m_course").html(''+course+'')
	// end of default		 

		
		$('#accomm1_container').click(function() {
			//
			$("#page_loader").animate( { width:"0%",opacity:"0" }, 250,function(){
			$("#page_loader").html('');	// remove contents from main div 	
								$('#accomm1_back').css('background-color', "#ffffff");
								
								$('.activeTab').animate( {width:'25%',opacity:"0" }, 50,function(){
								
								$(this).removeClass('activeTab').addClass('verticaltabs whitegreytext').next().removeClass('orange').parent().addClass('verticaltabs whitegreytext');
								$("#m_accomm").fadeTo('fast', 0, function() { // animate selectbox text 
								$(this).css({ marginLeft: 0});
								$("#m_accomm").html('Garret').animate({ marginLeft: 5, opacity: '1'}, "normal",function(){
								 
									//alert('haaaaaa');
											$('#accomm1_back').animate( {width:'100%', backgroundColor:"#ffffff",opacity:"1" },"fast",function(){
											$(this).addClass('activeTab');
											$(this).removeClass('verticaltabs whitegreytext');
											$(this).addClass('selected');
											
											$('#accomm1_front').addClass('orange');
											$('#accomm1_container').removeClass('verticaltabs whitegreytext');
											$(this).addClass('selected orange'); 
											
											$("#page_loader").load("course.htm",{acc :accom,course:courses_value}, function(){
												$(this).animate( { width:"100%",opacity:"1" },"slow" );
											});
									});
								
								
								});
								
							});
					});	accom = 'garret';	
			});
			
		});
		
		$('#accomm2_container').click(function() {
			//
			
			$("#page_loader").animate( { width:"0%",opacity:"0" }, 250,function(){    // hidding 
			$("#page_loader").html('');// remove contents from main div 		
								//$('#accomm2_back').css('background-color', "#ffffff");
								
								$('.activeTab').animate( {width:'25%',opacity:"0" }, 50,function(){
								
								$(this).removeClass('activeTab').addClass('verticaltabs whitegreytext').next().removeClass('orange').parent().addClass('verticaltabs whitegreytext');
								
								$("#m_accomm").fadeTo('fast', 0, function() { // animate selectbox text 
								$(this).css({ marginLeft: 0});
								$("#m_accomm").html('Castel arabel').animate({ marginLeft: 5, opacity: '1'}, "normal",function(){
								 
									//alert('haaaaaa');
											$('#accomm2_back').animate( {width:'100%', backgroundColor:"#ffffff",opacity:"1" },"fast",function(){
											$(this).addClass('activeTab');
											$(this).removeClass('verticaltabs whitegreytext');
											$(this).addClass('selected');
											
											$('#accomm2_front').addClass('orange');
											$('#accomm2_container').removeClass('verticaltabs whitegreytext');
											$(this).addClass('selected orange'); 
											
											$("#page_loader").load("course.htm",{acc :accom,course:courses_value}, function(){
												$(this).animate( { width:"100%",opacity:"1" },"slow" );
											});
									});
								
								
								});
								
							});
					});	accom = 'castel_arabel';	
			});
			
		});
		
		$('#accomm3_container').click(function() {
			//
			
			$("#page_loader").animate( { width:"0%",opacity:"0" }, 250,function(){
			$("#page_loader").html('');// remove contents from main div 		
								//$('#accomm3_back').css('background-color', "#ffffff");
								
								$('.activeTab').animate( {width:'25%',opacity:"0" }, 50,function(){
								
								$(this).removeClass('activeTab').addClass('verticaltabs whitegreytext').next().removeClass('orange').parent().addClass('verticaltabs whitegreytext');
								
								$("#m_accomm").fadeTo('fast', 0, function() { // animate selectbox text 
								$(this).css({ marginLeft: 0});
								$("#m_accomm").html('Famille d&rsquo;acceuil').animate({ marginLeft: 5, opacity: '1'}, "normal",function(){
								 
									//alert('haaaaaa');
											$('#accomm3_back').animate( {width:'100%', backgroundColor:"#ffffff",opacity:"1" },"fast",function(){
											$(this).addClass('activeTab');
											$(this).removeClass('verticaltabs whitegreytext');
											$(this).addClass('selected');
											
											$('#accomm3_front').addClass('orange');
											$('#accomm3_container').removeClass('verticaltabs whitegreytext');
											$(this).addClass('selected orange'); 
											
											$("#page_loader").load("course.htm",{acc :accom,course:courses_value}, function(){
												$(this).animate( { width:"100%",opacity:"1" },"slow" );
											});
									});
								
								
								});
								
							});
					});	accom = 'host';	
			});
			
		});
		
		$('#accomm4_container').click(function() {
			//
			
			$("#page_loader").animate( { width:"0%",opacity:"0" }, 250,function(){
			$("#page_loader").html('');// remove contents from main div 		
								//$('#accomm4_back').css('background-color', "#ffffff");
								
								$('.activeTab').animate( {width:'25%',opacity:"0" }, 50,function(){
								
								$(this).removeClass('activeTab').addClass('verticaltabs whitegreytext').next().removeClass('orange').parent().addClass('verticaltabs whitegreytext');
								
								$("#m_accomm").fadeTo('fast', 0, function() { // animate selectbox text 
								$(this).css({ marginLeft: 0});
								$("#m_accomm").html('Sun holidays').animate({ marginLeft: 5, opacity: '1'}, "normal",function(){
								 
									//alert('haaaaaa');
											$('#accomm4_back').animate( {width:'100%', backgroundColor:"#ffffff",opacity:"1" },"fast",function(){
											$(this).addClass('activeTab');
											$(this).removeClass('verticaltabs whitegreytext');
											$(this).addClass('selected');
											
											$('#accomm4_front').addClass('orange');
											$('#accomm4_container').removeClass('verticaltabs whitegreytext');
											$(this).addClass('selected orange'); 
											
											$("#page_loader").load("course.htm",{acc :accom,course:courses_value}, function(){
												$(this).animate( { width:"100%",opacity:"1" },"slow" );
											});
									});
								
								
								});
								
							});
					});	accom = 'sun_holidays';	
			});
			
		});
		
		$('#courses').change(function() { // on change selectbox
			 
			 var course = $("#courses").val();
			 
			 if(course == "")
			 {
			 	return false;
			 }
			 
			 courses_value = course;
			 switch (course)
			 {
			 case 'standard':
			  course ="<div id='m_course'>Cours standards (20 le&ccedil;ons/sem.)<a href='cours_standard.htm'> Details du   cours</a></div>";
			  break ;
			  
			  case 'int1c':
			  course ='<div id="m_course">cours intensifs 1 (30 le&ccedil;ons/sem.)<a href="cours_intensifs_1.htm"> Details du   cours</a></div>';
			  break ;
			  case 'int2c':
			  course ='<div id="m_course">cours intensifs 2 (36 le&ccedil;ons/sem.)<a href="cours_intensifs_2.htm"> Details du   cours</a></div>';
			  break ;
			  case 'Executive':
			  course ='<div id="m_course">cours dirigeants (30 le&ccedil;ons/sem.)<a href="cours_dirigeants.htm"> Details du   cours</a></div>';
			  break ;
			  case 'individual':
			  course ='<div id="m_course">cours particuliers (20 , 30 et 40  le&ccedil;ons/sem.)<a href="cours_particuliers.htm"> Details du   cours</a></div>';
			  break ;
			  case 'no':
			  course ='<div id="m_course"></div>';
			  break ;
			  default:
			 // course = course;
			  break ;
			 }
			// courses_value = course; // the value of selectbox ( courses) 
			$("#page_loader").html();
			$("#page_loader").animate( { height:"10%",opacity:"0" }, 200,function(){
								//$(this).css('background-color', "#33CCFF"); 
								
					$("#m_course").fadeTo('slow', 0, function() { // animate selectbox text 
						$(this).css({ marginLeft: 0});
						//alert(accom);
			 			//alert(courses_value);
						$(this).html(''+course+'').animate({ marginLeft: 5, opacity: '1'}, 1000);//fadeTo('slow', 1);
						
						// animate main panel			
						//alert(courses_value);
						$("#page_loader").load('course.htm',{ acc :accom,course:courses_value}, function(){ //alert('mahmoud');
							$(this).animate( { height:"95%",opacity:"1" }, 2000);
							
						});
					});	
					
			});
							//$(this).slideDown('slow');
						
		});
	});	