jQuery.fn.extend({
  slideRightShow: function(callbackFnk) {
	  if( $(this).is(':hidden') ){ if(typeof callbackFnk == 'function'){  return callbackFnk.call(this);}		  
	  }else{
	  
    return this.each(function() {
        $(this).show('slide', {direction: 'right'}, "slow",function(){
		  if(typeof callbackFnk == 'function'){
        callbackFnk.call(this);
      }
	  });
    });
	  }
  },
  slideLeftHide: function(callbackFnk) {
	  
	  if( $(this).is(':hidden') ){ if(typeof callbackFnk == 'function'){  return callbackFnk.call(this);}		  
	  }else{
	  
    return this.each(function() {		
      $(this).hide('slide', {direction: 'left'}, "slow",function(){
		  if(typeof callbackFnk == 'function'){
        callbackFnk.call(this);
      }
	  });
    });
	
	  }
	
  },
  slideRightHide: function(callbackFnk) {
	  
	  if( $(this).is(':hidden') ){ if(typeof callbackFnk == 'function'){ return callbackFnk.call(this); }		  
	  }else{
    return this.each(function() {
      $(this).hide('slide', {direction: 'right'}, "slow",function(){
		  if(typeof callbackFnk == 'function'){
        callbackFnk.call(this);
      }});
    });
	  }
	
  },
  slideLeftShow: function(callbackFnk) {
	  
	  if( $(this).is(':hidden') ){  if(typeof callbackFnk == 'function'){ return callbackFnk.call(this); }		  
	  }else{
	  
    return this.each(function() {
      $(this).show('slide', {direction: 'left'}, "slow",function(){
		  if(typeof callbackFnk == 'function'){
        callbackFnk.call(this);
      		}
		  });
	  // now we are calling our own callback function	  
    });
	  }
  }
});


$(document).ready(function(){
	var interval;
	$("#splashpage").delay(5000).fadeOut("normal");
	//$('#scrollbar2').tinyscrollbar();
	$('#scrollbar1[rel=grp]').tinyscrollbar();
	
	$('#scrollbar2[rel=grp2]').tinyscrollbar();
	
	$("#scrollbar3[rel=grpgreen]").tinyscrollbar();
	
	var faqscroll = $("#scrollbar9"); //the faq scrollbar
	faqscroll.tinyscrollbar();
	
	$('.greenfaqbacktotop').click(function(){
		faqscroll.tinyscrollbar_update(0);
		return false;
	});
	
	//$('#scrollbar2').tinyscrollbar_update();
	//hiding unecessary elements from the beg
	
	
	$("#menu01Content ul li").each(function(index){
		$(this).hide();
	});
	$("#menu02Content ul li").each(function(index){
		$(this).hide();
	});
	

	for(var i=1;i<=4;i++){
		$("#subMenu0"+i).hide();
		$("#greenSubMenu0"+i).hide();
		
	}
	
	$("#subMenu").hide();
	
	$("#subMenuContentOrange").hide();
	$("#subMenuContentGreen").hide();
	
	$("#menu01Content ul li").eq(0).show();
	$("#menu02Content ul li").eq(0).show();
	
	
	//$("#menu04Content").hide();
	
	//sitemap
	$("#sitemapUp").mouseenter(function() {$(this).stop().animate({width:'475px'},500);}).mouseleave(function(){ $(this).stop().animate({width : '37px'}),500});
	$("#sitemapDown").mouseenter(function() { $(this).stop().animate({width:'475px'},500); }).mouseleave(function(){ $(this).stop().animate({width : '37px'}),500});
	
	//bg stretcher
	
	
	$('BODY').bgStretcher({
			images: ['upload/bg/pic1.jpg','upload/bg/pic2.jpg','upload/bg/pic3.jpg','upload/bg/pic4.jpg','upload/bg/pic5.jpg','upload/bg/pic6.jpg','upload/bg/pic7.jpg','upload/bg/pic8.jpg','upload/bg/pic9.jpg','upload/bg/pic10.jpg','upload/bg/pic11.jpg','upload/bg/pic12.jpg','upload/bg/pic13.jpg','upload/bg/pic14.jpg'],
			imageWidth: 1024, 
			imageHeight: 768, 
			slideDirection: 'N',
			slideShowSpeed: 700,
			nextSlideDelay: 7000,
			transitionEffect: 'fade',
			sequenceMode: 'random',
			anchoring: 'left center',
			anchoringImg: 'left center'
		});
	
	//menubar script
	//logo
	$("#menuLogoContainer").click(function(){
		if( $("#subMenu").is(':visible') ){
			
			 if( $("#greenSubMenu").is(':visible') || $("#orangeSubMenu").is(':visible')){
				 
				 $("#subMenuContentOrange").slideLeftHide(function(){
					 
					$("#orangeSubMenu").slideLeftHide();
					 
					 });
				 $("#subMenuContentGreen").slideLeftHide(function(){
					 $("#greenSubMenu").slideLeftHide();
					 
					 });
				 
			 }
		$('a.menu01btn').removeClass('menu01selected');
		$('a.menu02btn').removeClass('menu02selected');
		}
		
		});
	//the orange buttons
	$('.menu01btn').click(function(){
		/*
		when we click on the orange submenu we have 3 cases
			1- when no menu are clicked
			2- when the green menu is clicked
			3- when the orange menu is clicked
		*/		
		
		if( !( $(this).hasClass('menu01selected') ) ){
		//get the li index
		//alert(2);
		var index = $(this).parent().index() +1;
		//this is for the sitemap
		switch(index){
			case 5: index =1; break;
			case 6: index =2; break;
			case 7: index =3; break;
			case 8: index =4; break;
			default: break;
		}
		
		// remove the focus from the gren and the orange menu
		$('a.menu01btn').removeClass('menu01selected');
		$('a.menu02btn').removeClass('menu02selected');
		$('a.orangeSubMenu01btn').removeClass('orangesubmenu01selected');
		
		$('a.orangeSubMenu02btn').removeClass('orangesubmenu02selected');
		
		$('a.greenSubMenu01btn').removeClass('greensubmenu01selected');
		
		$(this).addClass('menu01selected');
		
		
		//check if the submenu is open
		if( $("#subMenu").is(':visible') ){
			
			//if its visible that means it is already animated
			//if the submenu is opened
			 if( $("#orangeSubMenu").is(':visible') ){			
				
				/*  -3-
				this case is when the orange menu is already visible and then 
				we pressed it again so it will fade out the old submenu and 
				get the new one  */	
				
				/*
				here we have two cases
					1-the submenu content is opened.
					2-the submenu content is not opened.
				*/
				if ( $("#subMenuContentOrange").is(':visible') ){
					
					/*
						2-the submenu content is  opened.
					*/
					
						/* Here we have two cases
						 1- if we pressed the accesseries wich is the index 4
						 2- if we pressed an other orange submenu */
					
	
					if(index == 4){
						// 1 - this is the case
						
						$("#subMenuContentOrange").slideLeftHide(function(){
							
							 hideAndShowSubMenu("#subMenu0",index,4);
							 
							$("#orangeSubMenu").animate({
									width: '120px'
							}, "slow",function(){
								
							//we need also to change the width of the subMenu element other than the orngSubMenu
									$("#subMenu").width(120);
							// and to make the content larger
									$("#subMenuContentOrange").width(518);
									$("#leftMenu").width(518);
									
									
									
									hideAllOrangeSubMenuContent();
									$("#rightmenuorange04").show();
									
									$("#subMenuContentOrange").show();
									$("#subMenuContentOrange").slideLeftShow(function(){ $("#menu04Content").fadeIn("slow");});
							});
							
							
						});
						
					}else{
						// 2 - this case is when an other than index 4 is pressed
						$("#subMenuContentOrange").slideLeftHide(function(){
							
							$("#orangeSubMenu").animate({
									width: '240px'
							}, "slow",function(){
								
								
								$("#subMenu").width(240);
						
								//restore the width of the ornage submenu
								$("#subMenuContentOrange").width(398);
								$("#leftMenu").width(398);
								
								hideAllOrangeSubMenuContent();
								 hideAndShowSubMenu("#subMenu0",index,4);
								//$("#subMenu0"+index).fadeIn("slow");
								
								
							});
						});
					}

				
				}else{
					
					/*
					1- is not opened
					*/
					
					
					if( $("#orangeSubMenu").width() == 120){
						
						$("#orangeSubMenu").animate({
									width: '240px'
									}, "slow",function(){ 
									// hideAndShow("#subMenu0"+index,4);
									 hideAndShowSubMenu("#subMenu0",index,4);
									 
									 $("#subMenuContentOrange").width(398);
									 $("#leftMenu").width(398);
									 
									});
									
					}else{
				
					hideAndShowSubMenu("#subMenu0",index,4);
					
						if(index == 4){
							
					
							$("#orangeSubMenu").animate({ width: '120px'}, "slow", function(){ 
							$("#subMenu").width(120);
							
							$("#subMenuContentOrange").width(518);
							$("#leftMenu").width(518);
							//alert('bougaaa');
							
							$("#rightmenuorange04").show();
							$("#subMenuContentOrange").show();
							$("#subMenuContentOrange").slideLeftShow(function(){ $("#menu04Content").fadeIn("slow"); });
							
							});
						}
						
					}
					
					
				}
				
				
			}else{
					
				/*  -2-
				this case is when an  green submenu is opened and we 
				pressed an orange seub menu, so we will fade out the 
				green content and slide down the orange submenu items  */
				//check if a submenu content is visible
					
			
				//hide all the old Orange submenu first
				
				// ----- end -----
				
				$("#subMenuContentGreen").slideLeftHide(
				function(){ 
					$("#greenSubMenu").slideLeftHide(
					function(){
						
						switch(index){

							case 4:
								$("#menu01Content").hide();
								$("#menu02Content").hide();
								$("#menu03Content").hide();
								$("#menu04Content").hide();
								
								for(var i=1;i<=4;i++){
									$("#subMenu0"+i).hide();
								}			
							
								$("#orangeSubMenu").width(120);
								$("#subMenu").width(120);
								
								$("#subMenuContentOrange").width(518);
								$("#leftMenu").width(518);
								
								$("#orangeSubMenu").slideDown("slow",
									function(){ $("#subMenu04").fadeIn("slow",function(){
										$("#rightmenuorange04").show();
										$("#subMenuContentOrange").show();
										$("#subMenuContentOrange").slideLeftShow(function(){$("#menu04Content").fadeIn("slow"); });
								});
							});
							break;
							
							default:
							
								for(var i=1;i<=4;i++){
									$("#subMenu0"+i).hide();
								}
								$("#orangeSubMenu").width(240);
								$("#subMenu").width(240);
								
								$("#subMenuContentOrange").width(398);
								$("#leftMenu").width(398);
								
								$("#orangeSubMenu").slideDown("slow",function(){
									$("#subMenu0"+index).fadeIn("slow");									
								});
							break;
							
							
						}
						
						
					}); 
				});
					
			}
			
			//also check if we have an open submenu content
			/*if( $("#subMenuContentOrange").is(':visible') ){
				$("#subMenuContentOrange").slideLeftHide();
			}*/

		}else{
			
			/*
			-1-
			this case is when neither of the submenus are clicked
			so we slide down the orange submenu items only
			*/
			hideAllOrangeSubMenuContent();
			$("#greenSubMenu").hide();
			$("#orangeSubMenu").show();
			
			
			
			switch(index){
				case 4:
					
					$("#menu01Content").hide();
					$("#menu02Content").hide();
					$("#menu03Content").hide();
					$("#menu04Content").hide();
					
					//$("#menu0"+index+"Content").show();
					
					$("#orangeSubMenu").width(120);
					$("#subMenu").width(120);
					
					$("#subMenuContentOrange").width(518);
					$("#leftMenu").width(518);
					
					$("#rightmenuorange04").show();
					
					$("#subMenu").slideDown("slow",function(){ $("#subMenu0"+index).fadeIn("slow",function(){
						$("#subMenuContentOrange").show();
						$("#subMenuContentOrange").slideLeftShow(function(){$("#menu04Content").fadeIn("slow"); });
						});
					});
				
				break;
				
				default:
					$("#menu01Content").hide();
					$("#menu02Content").hide();
					$("#menu03Content").hide();
					$("#menu04Content").hide();
					//$("#menu0"+index+"Content").show();
				
					$("#orangeSubMenu").width(240);
					$("#subMenu").width(240);
					
					$("#subMenuContentOrange").width(398);
					$("#leftMenu").width(398);
					
					$("#subMenu").slideDown("slow",function(){
								$("#subMenu0"+index).fadeIn("slow");
							});
				break;
				
				
			}
			

		}
		$("#orangesubmenu02-01").removeClass('orangesubmenu02active');
		$("#orangesubmenu02-02").removeClass('orangesubmenu02active');
		$("#orangesubmenu02-03").removeClass('orangesubmenu02active');

		
	}
		
	});
	
	//expanding the orange right menu
	$("#rightmenuorange02-01").mouseenter(function(){
		//check first if its animating to prevent the stop()
			if( !( $("#").is(':animated') ) ){
				$("#leftMenu").stop().animate({width:'530px'},500);
				$("#subMenuContentOrange").stop().animate({width:'530px'},500);
				$(this).stop().animate({width: '170px'},500);
				$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
			}
		
		}).mouseleave(function(){
			
			if( !( $("#test1").is(':animated') ) ){
				
				$("#leftMenu").stop().animate({width:'398px'},500);
				$("#subMenuContentOrange").stop().animate({width:'398px'},500);
				$(this).stop().animate({width: '38px'},500);
				$(this).children(0).stop().animate({left:'0px'},500);
			}
	});
	$("#rightmenuorange02-02").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			
		}});
	$("#rightmenuorange02-03").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			}
			});
	$("#rightmenuorange02-04").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			}
			});
	$("#rightmenuorange02-05").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			}
			});
	$("#rightmenuorange02-06").mouseenter(function(){
		if( !( $("#menu02Content ul li").eq(6).is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#menu02Content ul li").eq(6).is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			}
			});

	$("#rightmenuorange03-01").mouseenter(function(){
		//check first if its animating to prevent the stop()
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
		
			$("#leftMenu").stop().animate({width:'530px'},500);
			$("#subMenuContentOrange").stop().animate({width:'530px'},500);
			$(this).stop().animate({width: '170px'},500);
			$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
			
			}
		
		}).mouseleave(function(){
			
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
				$("#leftMenu").stop().animate({width:'398px'},500);
				$("#subMenuContentOrange").stop().animate({width:'398px'},500);
				$(this).stop().animate({width: '38px'},500);
				$(this).children(0).stop().animate({left:'0px'},500);
			}
			});
	$("#rightmenuorange03-02").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){if( !( $("#subMenuContentOrange").is(':animated') ) ){
			
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			
		}});
	$("#rightmenuorange03-03").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			}
			});
	$("#rightmenuorange03-04").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			}
			});
	$("#rightmenuorange03-05").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			}
			});
	$("#rightmenuorange03-06").mouseenter(function(){
		if( !( $("#subMenuContentOrange").is(':animated') ) ){
		$("#leftMenu").stop().animate({width:'530px'},500);
		$("#subMenuContentOrange").stop().animate({width:'530px'},500);
		$(this).stop().animate({width: '170px'},500);
		$(this).children(0).css('position','relative').stop().animate({left:'-38px'},500);
		}
		}).mouseleave(function(){
			if( !( $("#subMenuContentOrange").is(':animated') ) ){
			$("#leftMenu").stop().animate({width:'398px'},500);
			$("#subMenuContentOrange").stop().animate({width:'398px'},500);
			$(this).stop().animate({width: '38px'},500);
			$(this).children(0).stop().animate({left:'0px'},500);
			}
			});
			
	//the green buttons
	$('a.menu02btn').click(function(){
		
		/*
		when we click on the orange submenu we have 3 cases
			1- when no menu are clicked
			2- when the green menu is clicked
			3- when the orange menu is clicked
		*/		
		
		if( !( $(this).hasClass('menu02selected') ) ){
		
		//get the li index 
		var index = $(this).parent().index() +1;
		
		
		//alert(index);
		// remove the focus from the gren and the orange menu
		$('a.menu01btn').removeClass('menu01selected');
		$('a.menu02btn').removeClass('menu02selected');
		$('a.greenclick').removeClass('greensubmenuselected');
		$(this).addClass('menu02selected');
		
		//check if the submenu is open
		if( $("#subMenu").is(':visible') ){
			
			 if( $("#greenSubMenu").is(':visible') ){	
			 
			 	/*  -3-
				this case is when the green menu is already visible and then 
				we pressed it again so it will fade out the old submenu and 
				get the new one  */	
			
					switch(index){
						case 1:
						$("#subMenuContentGreen").slideLeftHide(function(){
							
								$("#greenmenu01Content").show();
								$("#greenmenu02Content").hide();
								$("#greenmenu03Content").hide();
								$("#greenmenu04Content").hide();
							
							$("#greenSubMenu").animate({
									width: '240px'
							}, "slow",function(){

								$("#subMenu").width(240);
						
								//restore the width of the ornage submenu
								$("#subMenuContentGreen").width(398);
								$("#greenLeftMenu").width(360);
								
								
								 hideAndShowSubMenu("#greenSubMenu0",index,4);
							}); });
					break;
						case 2:// 1 - this is the case
						
							$("#subMenuContentGreen").slideLeftHide(function(){
							
								
								$("#greenmenu01Content").hide();
								$("#greenmenu02Content").show();
								$("#greenmenu03Content").hide();
								$("#greenmenu04Content").hide();
							
							 hideAndShowSubMenu("#greenSubMenu0",index,4);
							$("#greenSubMenu").animate({
									width: '120px'
							}, "slow",function(){
								
							//we need also to change the width of the subMenu element other than the orngSubMenu
									$("#subMenu").width(120);
							// and to make the content larger
									$("#subMenuContentGreen").width(518);
									$("#greenLeftMenu").width(480);
									//hideAllGreenSubMenuContent();
									$("#subMenuContentGreen").show();
									$("#subMenuContentGreen").slideLeftShow(function(){ $("#greenmenu02Content").fadeIn("slow");});
							});
							
							
						});					
					break;
						case 3:
					
					// 2 - this case is when an other than index 4 is pressed
						$("#subMenuContentGreen").slideLeftHide(function(){
							
								$("#greenmenu03Content").show();
								$("#greenmenu02Content").hide();
								$("#greenmenu01Content").hide();
								$("#greenmenu04Content").hide();
							
							$("#greenSubMenu").animate({
									width: '240px'
							}, "slow",function(){

								$("#subMenu").width(240);
						
								//restore the width of the ornage submenu
								$("#subMenuContentGreen").width(398);
								$("#greenLeftMenu").width(360);
								
								
								 hideAndShowSubMenu("#greenSubMenu0",index,4);
								$("#subMenuContentGreen").show();
								$("#subMenuContentGreen").slideLeftShow(function(){
									$("#greenmenu03Content").fadeIn("normal");
									
								});

							});
						});
					break;
						case 4:
					
					// 2 - this case is when an other than index 4 is pressed
						$("#subMenuContentGreen").slideLeftHide(function(){
							
								$("#greenmenu04Content").show();
								$("#greenmenu02Content").hide();
								$("#greenmenu03Content").hide();
								$("#greenmenu01Content").hide();
								
							$("#greenSubMenu").animate({
									width: '240px'
							}, "slow",function(){

								$("#subMenu").width(240);
						
								//restore the width of the ornage submenu
								$("#subMenuContentGreen").width(398);
								$("#greenLeftMenu").width(360);
								
								hideAllGreenSubMenuContent();
								hideAndShowSubMenu("#greenSubMenu0",index,4);
								$("#subMenuContentGreen").show();
								$("#subMenuContentGreen").slideLeftShow(function(){
									$("#greenmenu04Content").fadeIn("normal");
									
								});

							});
						});
					break;
						default:
						break;
					
					}

			 }else{
				/*  -2-
				this case is when an  orange submenu is opened and we 
				pressed an green sub menu, so we will fade out the 
				orange content and slide down the green submenu items  */
				
				//hide all the old Orange submenu first
				for(var i=1;i<=4;i++){
					$("#greenSubMenu0"+i).hide();
				}
				// ----- end -----
				
				$("#subMenuContentOrange").slideLeftHide(
				function(){ 
					$("#orangeSubMenu").slideLeftHide(
					function(){
						switch(index){
							
							case 1:
							
								$("#greenmenu01Content").show();
								$("#greenmenu02Content").hide();
								$("#greenmenu03Content").hide();
								$("#greenmenu04Content").hide();
								
							$("#greenSubMenu").width(240);
							$("#subMenu").width(240);
						
							$("#subMenuContentGreen").width(398);
							$("#greenLeftMenu").width(360);
							
							$("#greenSubMenu").slideDown("slow",function(){
								
								//hideAndShowSubMenu("#subMenu0",index,4);
								$("#greenSubMenu0"+index).fadeIn("slow");
								
								
							});
							break;
							case 2:
							
								$("#greenmenu01Content").hide();
								$("#greenmenu02Content").show();
								$("#greenmenu03Content").hide();
								$("#greenmenu04Content").hide();
							
							$("#greenSubMenu").width(120);
							$("#subMenu").width(120);
							
							$("#subMenuContentGreen").width(518);
							$("#greenLeftMenu").width(480);
							
							$("#greenSubMenu").slideDown("slow",
								function(){ $("#greenSubMenu02").fadeIn("slow",function(){
									$("#subMenuContentGreen").show();
									$("#subMenuContentGreen").slideLeftShow(function(){ $("#greenmenu02Content").fadeIn("normal"); });
							}); });
							
						
							break;
							
							default:
								$("#greenmenu01Content").hide();
								$("#greenmenu02Content").hide();
								$("#greenmenu03Content").hide();
								$("#greenmenu04Content").hide();
								$("#greenmenu0"+index+"Content").show();
							
							//restore the value of the submenu wether its 120 or not
								$("#greenSubMenu").width(240);
								$("#subMenu").width(240);
								
								$("#subMenuContentGreen").width(398);
								$("#greenLeftMenu").width(360);
								
								$("#greenSubMenu").slideDown("slow",function(){
									//hideAndShowSubMenu("#subMenu0",index,4);
									$("#greenSubMenu0"+index).fadeIn("slow");
									$("#subMenuContentGreen").show();
											$("#subMenuContentGreen").slideLeftShow(function(){ $("#greenmenu0"+index+"Content").fadeIn("normal"); });
										
									});
							
						
							break;
							
						}
					}); 
				});	
			}
				
			 
			 }else{
			/*
			-1-
			this case is when neither of the submenus are clicked
			so we slide down the green submenu items only
			*/
			hideAllGreenSubMenuContent();
			$("#greenSubMenu").show();
			$("#orangeSubMenu").hide();
			
			
			switch(index){
				case 1:
					$("#greenSubMenu").width(240);
					$("#subMenu").width(240);
				
					$("#subMenuContentGreen").width(398);
					$("#greenLeftMenu").width(360);
				
					$("#subMenu").slideDown("slow",function(){
							$("#greenSubMenu0"+index).fadeIn("normal");
						});
				break;
				
				case 2:
				
					$("#greenmenu01Content").hide();
					$("#greenmenu02Content").show();
					$("#greenmenu03Content").hide();
					$("#greenmenu04Content").hide();
				
					$("#greenSubMenu").width(120);
					$("#subMenu").width(120);
				
					$("#subMenuContentGreen").width(518);
					$("#greenLeftMenu").width(480);
				
					$("#rightmenugreen02").show();
					$("#subMenu").slideDown("normal",function(){ 
					$("#greenSubMenu02").fadeIn("normal",function(){
					
					$("#subMenuContentGreen").show();
					$("#subMenuContentGreen").slideLeftShow(function(){
						 $("#greenmenu02Content").fadeIn("normal"); });
					});
				});
				
				break;
				
				case 3:
				
					$("#greenmenu01Content").hide();
					$("#greenmenu03Content").show();
					$("#greenmenu02Content").hide();
					$("#greenmenu04Content").hide();
				
					$("#greenSubMenu").width(240);
					$("#subMenu").width(240);
				
					$("#subMenuContentGreen").width(398);
					$("#greenLeftMenu").width(360);
					
					$("#subMenu").slideDown("slow",function(){
							$("#greenSubMenu0"+index).fadeIn("normal",function(){
								
							$("#subMenuContentGreen").show();
							$("#subMenuContentGreen").slideLeftShow(function(){
							 $("#greenmenu03Content").fadeIn("normal"); });
								
								
							});
						});
				break;
				
				case 4:
				
				
					$("#greenSubMenu").width(240);
					$("#subMenu").width(240);
				
					$("#subMenuContentGreen").width(398);
					$("#greenLeftMenu").width(360);
					
					$("#subMenu").slideDown("normal",function(){ 
					$("#greenSubMenu04").fadeIn("normal",function(){
					
						$("#subMenuContentGreen").show();
							$("#subMenuContentGreen").slideLeftShow(function(){
								$("#greenmenu04Content").fadeIn("normal"); });
						});
					});
				break;
				
				default:
				break;
				
				
				
			}
			
			 
		}
		
		
		
		
		}
		
		
	});
	
	
	//functions
	function hideAndShowSubMenu(name,p,t){
			
			for(var i=0;i<=t;i++){
					
				if( $(name+i).is(':visible') ){
					$(name+i).fadeOut("normal",
					function (){
						$(name+p).fadeIn("normal");
					});
				}
			}
		}
		
	function showInsidePageFadeIn(p,t,x){
			for(var i=0;i<=t;i++){
				if( $(p).eq(i).is(':visible') ){
					$(p).eq(i).fadeOut("normal",
					function (){
						$(p).eq(x).fadeIn("normal");
						//alert(x);
					});
					break;
				}
			}
		}
		
		//orange hide all page content
	function hideAllOrangeSubMenuContent(){
		
		
		$("#menu01Content ul li").each(function(index){ $(this).hide(); });
		$("#menu01Content ul li").eq(0).show();	
		
		$("#menu02Content ul li").each(function(index){ $(this).hide(); });
		$("#menu02Content ul li").eq(0).show();
		
		$("#menu03Content ul li").each(function(index){ $(this).hide(); });
		$("#menu03Content ul li").eq(0).show();
		
		
		
		$("#rightmenuorange01").hide();
		$("#rightmenuorange02").hide();
		$("#rightmenuorange03").hide();
		$("#rightmenuorange04").hide();
		
	}
	function hideAllGreenSubMenuContent(){
		
		
		$("#greenmenu01Content ul li").each(function(index){ $(this).hide(); });
		$("#greenmenu01Content ul li").eq(0).show();	
		//$("#greenmenu01Content").hide();
		
		$("#greenmenu02Content").each(function(index){ $(this).hide(); });
		//$("#greenmenu02Content").eq(0).show();
		
		$("#greenmenu03Content").each(function(index){ $(this).hide(); });
		//$("#greenmenu03Content").eq(0).show();
		
		$("#greenmenu04Content").each(function(index){ $(this).hide(); });
		//$("#greenmenu04Content").eq(0).show();
		
		$("#rightmenugreen01").hide();
		$("#rightmenugreen02").hide();
		$("#rightmenugreen03").hide();
		$("#rightmenugreen04").hide();
		
	}
	
	function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);}
		
		
	$('a.greenclick').click(function(index){
		
		var index = $(this).parent().index()+1;
		hideAllGreenSubMenuContent();
			
			$('a.greenclick').removeClass('greensubmenuselected');
			$(this).addClass('greensubmenuselected');
			
			if( $("#subMenuContentGreen").is(':visible') ){
				showInsidePageFadeIn("#greenmenu01Content ul li",4, index);
			
			}else{
				
				$("#subMenuContentGreen").show();
				$("#subMenuContentGreen").slideLeftShow(function(){ showInsidePageFadeIn("#greenmenu01Content ul li",4, index); });
				
			}
			
			
		} );
		
	//inside the first orange page submenus buttons orange
	$('a.orangeSubMenu01btn').click(function(){
		
		if( !($(this).hasClass('orangesubmenu01selected')) ){
			
			
			$("#menu01Content").show();
			
			var index = $(this).parent().index() +1;
			
				
			$('a.orangeSubMenu01btn').removeClass('orangesubmenu01selected');
			$(this).addClass('orangesubmenu01selected');
			
				
			if( $("#subMenuContentOrange").is(':visible') ){
				showInsidePageFadeIn("#menu01Content ul li",5, index);
				
			}else{
				
				
				$("#subMenuContentOrange").show();
				$("#subMenuContentOrange").slideLeftShow(function(){
					$("#menu01Content ul li").eq(0).show();
					showInsidePageFadeIn("#menu01Content ul li",5,index); });
					
			}
			$("#rightmenuorange01").show();
				
				//alert(index);
		}
			
		});
	$('a.orangeSubMenu02btn').click(function(){
		
		//check if the button is already pressed
		if( !($(this).hasClass('arialWhitesubmenuselected')) ){
			
			//hiding the class in the submenu
			for(var t=1;t<7;t++){
			$('a.rightmenuorange02-0'+t+'btn').removeClass('arialWhiteselected');
			}
			
					//getting the indes of the actual li a
		var index = $('a.orangeSubMenu02btn').index( $(this) )+1;
		
		$("#menu01Content").hide();
		$("#menu02Content").show();
		
		var indexmultiply = 0;/* this is because the li for all the sub pages and menus are toghther example in the traditional we have the traditional and the 5 submenus 1.2.3.4.5 so the memory comes th 6th */
		
		$('a.orangeSubMenu02btn').removeClass('arialWhitesubmenuselected');
		$(this).addClass('arialWhitesubmenuselected');
		
		
		//add the class to the title of the submeu02
		$("#orangesubmenu02-01").removeClass('orangesubmenu02active');
		$("#orangesubmenu02-02").removeClass('orangesubmenu02active');
		$("#orangesubmenu02-03").removeClass('orangesubmenu02active');

		//hide other submenu contents not related to this one
		hideAllOrangeSubMenuContent();
		$("#rightmenuorange02").show();
		
		switch(index){
			case 1:	indexmultiply = 1;	$("#orangesubmenu02-01").addClass('orangesubmenu02active'); break;
			case 2:	indexmultiply = 6; 	$("#orangesubmenu02-01").addClass('orangesubmenu02active');	break;		
			case 3:	indexmultiply = 11; $("#orangesubmenu02-01").addClass('orangesubmenu02active');	break;			
			case 4:	indexmultiply = 16; $("#orangesubmenu02-02").addClass('orangesubmenu02active');	break;		
			case 5:	indexmultiply = 22; $("#orangesubmenu02-03").addClass('orangesubmenu02active');	break;			
			case 6:	indexmultiply = 27; $("#orangesubmenu02-03").addClass('orangesubmenu02active');	break;
		}
		//alert("index: "+index+", indemultiply: "+indexmultiply);
		if(index==4){
			//making the animation of posturpedic
		for(var o=1;o<=9;o++){
			$("#posturepedicanimation"+o).hide();
			
		}
		
		var numRand = Math.floor(Math.random()*8)+1;
		$("#posturepedicanimation"+numRand).fadeIn();
		window.clearInterval(interval);
		delete window.interval; 

		
		interval = setInterval(function() {
			$("#posturepedicanimation"+numRand).fadeOut();
			numRand = Math.floor(Math.random()*8)+1;
			for(var o=1;o<=9;o++){
				if($("#posturepedicanimation"+o).is(':visible') ){
					$("#posturepedicanimation"+o).fadeOut("normal",function(){
						$("#posturepedicanimation"+numRand).fadeIn();
						});
					break;
				}
			}
			
			$("#posturepedicanimation"+numRand).fadeIn("normal");
			}, 9000);
		};
		
		
		//hide all the right content and then show them
		$("#rightmenuorange02 > div").each(function(){$(this).hide();});
		$("#rightmenuorange03 > div").each(function(){$(this).hide();});
		$("#rightmenuorange04 > div").each(function(){$(this).hide();});
		
		$("#rightmenuorange02 > div").eq(index).show();
		
		
		if( $("#subMenuContentOrange").is(':visible') ){
				//alert( $(this).parent().index() );
				
				showInsidePageFadeIn("#menu02Content ul li",32, indexmultiply );
			
			}else{
				$("#subMenuContentOrange").show();
				$("#subMenuContentOrange").slideLeftShow(function(){showInsidePageFadeIn("#menu02Content ul li",32,indexmultiply ); });
				
			}
		
		}
		} );
	$('a.orangeSubMenu03btn').click(function(){
		//check if the button is already pressed
		if( !($(this).hasClass('arialWhitesubmenuselected')) ){
			
			//hiding the class in the submenu
			for(var t=1;t<7;t++){
			$('a.rightmenuorange03-0'+t+'btn').removeClass('arialWhiteselected');
			}
			
					//getting the indes of the actual li a
		var index = $('a.orangeSubMenu03btn').index($(this))+1;
		//alert(index);
		$("#menu01Content").hide();
		$("#menu02Content").hide();
		$("#menu03Content").show();
		
		var indexmultiply = 0;/* this is because the li for all the sub pages and menus are toghther example in the traditional we have the traditional and the 5 submenus 1.2.3.4.5 so the memory comes th 6th */
		
		$('a.orangeSubMenu03btn').removeClass('arialWhitesubmenuselected');
		$(this).addClass('arialWhitesubmenuselected');
		
		
		//add the class to the title of the submeu02
		$("#orangesubmenu03-01").removeClass('orangesubmenu03active');
		$("#orangesubmenu03-02").removeClass('orangesubmenu03active');
		$("#orangesubmenu03-03").removeClass('orangesubmenu03active');

		//hide other submenu contents not related to this one
		hideAllOrangeSubMenuContent();
		$("#rightmenuorange03").show();
		
		switch(index){
			case 1:	indexmultiply = 1;	$("#orangesubmenu03-01").addClass('orangesubmenu03active'); break;
			case 2:	indexmultiply = 6; 	$("#orangesubmenu03-01").addClass('orangesubmenu03active');	break;		
			case 3:	indexmultiply = 12; $("#orangesubmenu03-02").addClass('orangesubmenu03active');	break;			
			case 4:	indexmultiply = 17; $("#orangesubmenu03-02").addClass('orangesubmenu03active');	break;		
			case 5:	indexmultiply = 22; $("#orangesubmenu03-03").addClass('orangesubmenu03active');	break;			
			case 6:	indexmultiply = 27; $("#orangesubmenu03-03").addClass('orangesubmenu03active');	break;
		}
		//alert("index: "+index+", indemultiply: "+indexmultiply);
		if(index==2){
			//making the animation of posturpedic
		for(var o=1;o<=9;o++){
			$("#posturepedicanimation-"+o).hide();
			
		}
		
		var numRand = Math.floor(Math.random()*8)+1;
		$("#posturepedicanimation-"+numRand).fadeIn();
		window.clearInterval(interval);
		delete window.interval; 

		
		interval = setInterval(function() {
			$("#posturepedicanimation-"+numRand).fadeOut();
			numRand = Math.floor(Math.random()*8)+1;
			for(var o=1;o<=9;o++){
				if($("#posturepedicanimation-"+o).is(':visible') ){
					$("#posturepedicanimation-"+o).fadeOut("normal",function(){
						$("#posturepedicanimation-"+numRand).fadeIn();
						});
					break;
				}
			}
			
			$("#posturepedicanimation-"+numRand).fadeIn("normal");
			}, 9000);
		};
		
		
		//hide all the right content and then show them
		$("#rightmenuorange02 > div").each(function(){$(this).hide();});
		$("#rightmenuorange03 > div").each(function(){$(this).hide();});
		$("#rightmenuorange04 > div").each(function(){$(this).hide();});
		
		$("#rightmenuorange03 > div").eq(index).show();
		
		
		if( $("#subMenuContentOrange").is(':visible') ){
				//alert( $(this).parent().index() );
				
				showInsidePageFadeIn("#menu03Content ul li",32, indexmultiply );
			
			}else{
				$("#subMenuContentOrange").show();
				$("#subMenuContentOrange").slideLeftShow(function(){showInsidePageFadeIn("#menu03Content ul li",32,indexmultiply ); });
				
			}
		
		}
		} );
		
	
	$('a.rightmenuorange02-01btn').click(function(){
		$('a.rightmenuorange02-01btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange02-01btn').index($(this))+1;
		var indexmultiply = index +1;
		
		//alert(index);
		
		
		
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu02Content ul li",32, indexmultiply );
		
	});
	$('a.rightmenuorange02-02btn').click(function(){
		$('a.rightmenuorange02-02btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange02-02btn').index($(this))+1;
		var indexmultiply = index +6;
		//alert(index);
		
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu02Content ul li",32, indexmultiply );
		
	});
	$('a.rightmenuorange02-03btn').click(function(){
		$('a.rightmenuorange02-03btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange02-03btn').index($(this))+1;
		var indexmultiply = index +11;
		//alert(index);
		
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu02Content ul li",32, indexmultiply );
		
	});
	$('a.rightmenuorange02-04btn').click(function(){
		
		$('a.rightmenuorange02-04btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange02-04btn').index($(this))+1;
		var indexmultiply = index +16;
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu02Content ul li",32, indexmultiply );
	});
	$('a.rightmenuorange02-05btn').click(function(){
		$('a.rightmenuorange02-05btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange02-05btn').index($(this))+1;
		var indexmultiply = index +22;
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu02Content ul li",32, indexmultiply );
		
	});
	$('a.rightmenuorange02-06btn').click(function(){
		$('a.rightmenuorange02-06btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange02-06btn').index($(this))+1;
		var indexmultiply = index +27;
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu02Content ul li",32, indexmultiply );
		
	});
	
	$('a.rightmenuorange03-01btn').click(function(){
		$('a.rightmenuorange03-01btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange03-01btn').index($(this))+1;
		var indexmultiply = index +1;
		
		//alert(index);
		
		
		
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu03Content ul li",32, indexmultiply );
		
	});
	$('a.rightmenuorange03-02btn').click(function(){
		$('a.rightmenuorange03-02btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange03-02btn').index($(this))+1;
		var indexmultiply = index +12;
		//alert(index);
		
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu03Content ul li",32, indexmultiply );
		
	});
	$('a.rightmenuorange03-03btn').click(function(){
		$('a.rightmenuorange03-03btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange03-03btn').index($(this))+1;
		var indexmultiply = index +22;
		//alert(index);
		
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu03Content ul li",32, indexmultiply );
		
	});
	$('a.rightmenuorange03-04btn').click(function(){
		
		$('a.rightmenuorange03-04btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange03-04btn').index($(this))+1;
		var indexmultiply = index +6;
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu03Content ul li",32, indexmultiply );
	});
	$('a.rightmenuorange03-05btn').click(function(){
		$('a.rightmenuorange03-05btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange03-05btn').index($(this))+1;
		var indexmultiply = index +17;
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu03Content ul li",32, indexmultiply );
		
	});
	$('a.rightmenuorange03-06btn').click(function(){
		$('a.rightmenuorange03-06btn').removeClass('arialWhiteselected');
		$(this).addClass('arialWhiteselected');
		var index = $('a.rightmenuorange03-06btn').index($(this))+1;
		var indexmultiply = index +27;
		//we only this case is here, there is no way that the subMenuContentOrange will not be visible
		showInsidePageFadeIn("#menu03Content ul li",32, indexmultiply );
		
	});
	
	
		
	//this is the click of the submenu 02 inside the orange menu
	$("#orangesubmenu02-01").click(function(){
		$('a.orangeSubMenu02btntitle').removeClass('orangesubmenu02selected');
		$(this).addClass('orangesubmenu02selected');
	});
	
	$("#firstname_error").hide();
	$("#lastname_error").hide();
	$("#street_error").hide();
	$("#apt_error").hide();
	$("#city_error").hide();
	$("#email_error").hide();
	$("#confemail_error").hide();
	$("#province_error").hide();
	$("#zipcode_error").hide();
	$("#phone_error").hide();
	$("#purchase_error").hide();
	$("#manif_error").hide();
	$("#product_error").hide();
	$("#size_error").hide();
	$("#message_error").hide();
	$("#response_message").hide(); //this message is for
	
	
	$("input#submit").click(function(){
		
				$("#firstname_error").hide();
				$("#lastname_error").hide();
				$("#street_error").hide();
				$("#apt_error").hide();
				$("#city_error").hide();
				$("#email_error").hide();
				$("#confemail_error").hide();
				$("#province_error").hide();
				$("#zipcode_error").hide();
				$("#phone_error").hide();
				$("#purchase_error").hide();
				$("#manif_error").hide();
				$("#product_error").hide();
				$("#size_error").hide();
				$("#message_error").hide();
				$("#response_message").hide(); //this message is for
				
				var firstname = $("input#firstname").val();
				var lastname = $("input#lastname").val();
				var email = $("input#email").val();
				var confemail = $("input#confemail").val();
				var street = $("input#street").val();
				var apt = $("input#apt").val();
				var city = $("input#city").val();
				var province = $("input#province").val();
				var zipcode = $("input#zipcode").val();
				var manif = $("input#mdate").val();
				var product = $("input#product").val();
				var size = $("input#size").val();
				var purchase = $("input#pdate").val();
				var message = $("textarea#message").val();
				var phone = $("input#phone").val();
			
				var check = true;

				if(firstname == ""){
					$("#firstname_error").fadeIn("normal");
					check = false;
				}
				if(lastname == ""){
					$("#lastname_error").fadeIn("normal");
					check = false;
				}
				if(street == ""){
					$("#street_error").fadeIn("normal");
					check = false;
					}
				if(apt == ""){
					$("#apt_error").fadeIn("normal");
					check = false;
				}
				if(city == ""){
					$("#city_error").fadeIn("normal");
					check = false;
				}
				if(province == ""){
					$("#province_error").fadeIn("normal");
					check = false;
					}
				if(zipcode == ""){
					$("#zipcode_error").fadeIn("normal");
					check = false;
				}
				if(purchase == ""){
					$("#purchase_error").fadeIn("normal");
					check = false;
				}
				if(manif == ""){
					$("#manif_error").fadeIn("normal");
					check = false;
				}
				if(product == ""){
					$("#product_error").fadeIn("normal");
					check = false;
				}
				if(size == ""){
					$("#size_error").fadeIn("normal");
					check = false;
				}
				if(phone == ""){
					$("#phone_error").fadeIn("normal");
					check = false;
				}
				
				if(!isValidEmailAddress(email)){
					$("#email_error").fadeIn("normal");
					check = false;
				}
				if(confemail == "" || confemail != email){
					$("#confemail_error").fadeIn("normal");
					$("#email_error").fadeIn("normal");
					
					check = false;
				}
				
				if(message == ""){
					$("#message_error").fadeIn("normal");
					check = false;
				}
				if(check){
					
					$("#response_message").html("sending...");
					
					$("#response_message").fadeIn("normal");
										$.ajax({
											type: "POST",
											url: "email.php",
											data: "firstname="+name+"&lastname="+lastname+"&street="+street+"&apt="+apt+"&city"+city+"&zipcode="+zipcode+"&province="+province+"&phone="+phone+"&size="+size+"&email="+email+"&message="+message+"&product="+product+"&purchase="+purchase+"&manif="+manif,
											cache: false,
											success: function(data){
														$("#response_message").fadeOut("normal",function(){ $("#response_message").html(data);});
														$("#response_message").fadeIn("normal");
														}
											});
				}
	});
	
	
	for(var o=1;o<=9;o++){
		$("#posturepedicanimation"+o).hide();
	}
	
	$(".video").click(function() {
		$.fancybox({
			'padding'		: 0,
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'title'			: this.title,
			'width'			: 560,
			'height'		: 349,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
			'type'			: 'swf',
			'swf'			: {
			'wmode'				: 'transparent',
			'allowfullscreen'	: 'true'
			}
		});

		return false;
	});
	
	$("#pic1").click(function(){$("#pic2").removeClass("rondOpen");$("#pic02").fadeOut("noraml",function(){ $("#pic1").addClass("rondOpen");$("#pic01").fadeIn("normal"); });});
	$("#pic2").click(function(){$("#pic1").removeClass("rondOpen");$("#pic01").fadeOut("noraml",function(){ $("#pic2").addClass("rondOpen");$("#pic02").fadeIn("normal"); });});
	$("#pic3").click(function(){$("#pic4").removeClass("rondOpen");$("#pic04").fadeOut("noraml",function(){ $("#pic3").addClass("rondOpen");$("#pic03").fadeIn("normal"); });});
	$("#pic4").click(function(){$("#pic3").removeClass("rondOpen");$("#pic03").fadeOut("noraml",function(){ $("#pic4").addClass("rondOpen");$("#pic04").fadeIn("normal"); });});
	$("#pic5").click(function(){$("#pic6").removeClass("rondOpen");$("#pic06").fadeOut("noraml",function(){ $("#pic5").addClass("rondOpen");$("#pic05").fadeIn("normal"); });});
	$("#pic6").click(function(){$("#pic5").removeClass("rondOpen");$("#pic05").fadeOut("noraml",function(){ $("#pic6").addClass("rondOpen");$("#pic06").fadeIn("normal"); });});	
	$("#pic7").click(function(){$("#pic8").removeClass("rondOpen");$("#pic08").fadeOut("noraml",function(){ $("#pic7").addClass("rondOpen");$("#pic07").fadeIn("normal"); });});
	$("#pic8").click(function(){$("#pic7").removeClass("rondOpen");$("#pic07").fadeOut("noraml",function(){ $("#pic8").addClass("rondOpen");$("#pic08").fadeIn("normal"); });});
	$("#pic9").click(function(){$("#pic10").removeClass("rondOpen");$("#pic010").fadeOut("noraml",function(){ $("#pic9").addClass("rondOpen");$("#pic09").fadeIn("normal"); });});
	$("#pic10").click(function(){$("#pic9").removeClass("rondOpen");$("#pic09").fadeOut("noraml",function(){ $("#pic10").addClass("rondOpen");$("#pic010").fadeIn("normal"); });});
	$("#pic11").click(function(){$("#pic12").removeClass("rondOpen");$("#pic012").fadeOut("noraml",function(){ $("#pic11").addClass("rondOpen");$("#pic011").fadeIn("normal"); });});
	$("#pic12").click(function(){$("#pic11").removeClass("rondOpen");$("#pic011").fadeOut("noraml",function(){ $("#pic12").addClass("rondOpen");$("#pic012").fadeIn("normal"); });});
	$("#pic13").click(function(){$("#pic14").removeClass("rondOpen");$("#pic014").fadeOut("noraml",function(){ $("#pic13").addClass("rondOpen");$("#pic013").fadeIn("normal"); });});
	$("#pic14").click(function(){$("#pic13").removeClass("rondOpen");$("#pic013").fadeOut("noraml",function(){ $("#pic14").addClass("rondOpen");$("#pic014").fadeIn("normal"); });});
	$("#pic15").click(function(){$("#pic16").removeClass("rondOpen");$("#pic016").fadeOut("noraml",function(){ $("#pic15").addClass("rondOpen");$("#pic015").fadeIn("normal"); });});
	$("#pic16").click(function(){$("#pic15").removeClass("rondOpen");$("#pic015").fadeOut("noraml",function(){ $("#pic16").addClass("rondOpen");$("#pic016").fadeIn("normal"); });});
	$("#pic17").click(function(){$("#pic18").removeClass("rondOpen");$("#pic018").fadeOut("noraml",function(){ $("#pic17").addClass("rondOpen");$("#pic017").fadeIn("normal"); });});
	$("#pic18").click(function(){$("#pic17").removeClass("rondOpen");$("#pic017").fadeOut("noraml",function(){ $("#pic18").addClass("rondOpen");$("#pic018").fadeIn("normal"); });});
	$("#pic19").click(function(){$("#pic20").removeClass("rondOpen");$("#pic020").fadeOut("noraml",function(){ $("#pic19").addClass("rondOpen");$("#pic019").fadeIn("normal"); });});
	$("#pic20").click(function(){$("#pic19").removeClass("rondOpen");$("#pic019").fadeOut("noraml",function(){ $("#pic20").addClass("rondOpen");$("#pic020").fadeIn("normal"); });});		
	
});


