/******************************************************************************* ----oOo---*****************************************************************************/


$ (function(){
	 var ajaxRequest;  // The variable that makes Ajax possible!
 try{
   // Opera 8.0+, Firefox, Safari
   ajaxRequest = new XMLHttpRequest();
 }catch (e){
   // Internet Explorer Browsers
   try{
      ajaxRequest = new ActiveXObject('Msxml2.XMLHTTP');
   }catch (e) {
      try{
         ajaxRequest = new ActiveXObject('Microsoft.XMLHTTP');
      }catch (e){
         // Something went wrong
         alert('Your browser broke!');
         return false;
      }
   }
 }
 
 
  function closeallex(){ 
  
  $('.ladda').parent().removeClass('expand');
	  $ ('div.yttrechanger').animate( {
			width: '220',
			 height: '290'
			  }, 300, function() {
			// Animation complete.
			});
			
			 $ ('div.inrechanger').animate( {
			width: '220',
			 height: '284'
			  }, 300, function() {
			// Animation complete.
			});
			
			$ ('div.ladda').fadeOut(30);
			$ ('div.start').fadeIn(300);
		 };
		 
 function openX(idD,widthW,heightH){
	   		
			var idY= ('#yttrechanger' + idD);
			var idI= ('#innrechanger' + idD);
			var idL= ('#ladda' + idD);	
			var idS= ('#start' + idD);
			
     $ ('.closeall').css({ left: widthW - 66 + 'px'});

			
			$(idY).animate( {
				width: widthW,
				 height: heightH 
				  }, 300, function() {
				// Animation complete.
				});
				
				 $(idI).animate( {
				width: widthW,
				 height: (heightH - 6)
				  }, 300, function() {
				// Animation complete.
				});
	 
  		$(idL).fadeIn(300);
  		$(idS).fadeOut(30);
	 
	 };
	 
	 function loadX(idD,widthW,heightH,fileX){
	
			var idY= ('#yttrechanger' + idD);
			var idI= ('#innrechanger' + idD);	
			var idL= ('#ladda' + idD);	
			var idS= ('#start' + idD);
			var idAdd= ('#Add' + idD);
			var idClose= ('.close' + idD);
			$(idL).parent().addClass('expand');
		
			$(idL).load(fileX).fadeOut(1);
			
			$ ('.closeall').css({ left: widthW - 66 + 'px'});
					
			$ (idAdd).css({ left: widthW - 101 + 'px', //get AddThison right left and top position
                    top: heightH - 22 + 'px'});
 
  			$(idY).animate( {
				width: widthW,
				 height: heightH
				  }, 300, function() {
				// Animation complete.
				});
				
				 $(idI).animate( {
				width: widthW,
				 height: (heightH - 6)
				  }, 300, function() {
				// Animation complete.
				});
  		$(idL).delay(2000).fadeIn(1500);
  		$(idS).fadeOut(50); 

	
};
	
// Open Howdy start
$('.openHowdy').live('click', function() {
   idD = 'Howdy';
   fileX='HowdyFolder/Howdy.php';
   widthW = 680;
   heightH = 590;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);		
		}
  return false; 
  });
  // Open Howdy Ends
  
  		// close Howdy starts
       $('.closeHowdy').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Howdy Ends	
	
	
	
// Open Stick_And_Sit start
$('.openStick_And_Sit').live('click', function() {
   idD = 'Stick_And_Sit';
   fileX='Stick_And_SitFolder/Stick_And_Sit.php';
   widthW = 680;
   heightH = 590;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);		
		}
  return false; 
  });
  // Open Stick_And_Sit Ends
  
  		// close Stick_And_Sit starts
       $('.closeStick_And_Sit').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Stick_And_Sit Ends	
	
	
	// Open Jak start
$('.openJak').live('click', function() {
   idD = 'Jak';
   fileX='JakobFolder/Jak.php';
   widthW = 680;
   heightH = 290;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);

   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

  
openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);		
		}
  return false; 
  });
  // Open Jak Ends
  
  		// close Jak starts
       $('.closeJak').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Jak Ends
	
	
// Open Svalbard start
$('.openSvalbard').live('click', function() {
   idD = 'Svalbard';
   fileX='SvalbardFolder/Svalbard.php';
   widthW = 756;
   heightH = 590;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

  y=3;  /* distance between cells */
tot=753;  /* Cellwith + distance */
  h=530;  /* cellHeight*/
	
    touchslider.createSlidePanel(idSlide, tot-y, h, y); 

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);
			
		}
  return false; 
  });
  // Open Svalbard Ends
  
  		// close Svalbard starts
       $('.closeSvalbard').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Svalbard Ends	


// Open Buildo start
$('.openBuildo').live('click', function() {
   idD = 'Buildo';
   fileX='BuildoFolder/Buildo.php';
   widthW = 756;
   heightH = 590;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

  y=3;  /* distance between cells */
tot=753;  /* Cellwith + distance */
  h=530;  /* cellHeight*/
	
    touchslider.createSlidePanel(idSlide, tot-y, h, y); 

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);
			
		}
  return false; 
  });
  // Open Buildo Ends
  
  		// close Buildo starts
       $('.closeBuildo').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Buildo Ends	


  // Open Transport start
$('.openTransport').live('click', function() {
   idD = 'Transport';
   fileX='TransportFolder/Transport.php';
   widthW = 756;
   heightH = 590;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

  y=3;  /* distance between cells */
tot=753;  /* Cellwith + distance */
  h=530;  /* cellHeight*/
	
    touchslider.createSlidePanel(idSlide, tot-y, h, y); 

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);
			
		}
  return false; 
  });
  // Open Transport Ends
  
  		// close Transport starts
       $('.closeTransport').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Transport Ends	

   // Open Knight start
$('.openKnight').live('click', function() {
   idD = 'Knight';
   fileX='KnightFolder/Knight.php';
   widthW = 756;
   heightH = 590;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

  y=3;  /* distance between cells */
tot=753;  /* Cellwith + distance */
  h=530;  /* cellHeight*/
	
    touchslider.createSlidePanel(idSlide, tot-y, h, y); 

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);
			
		}
  return false; 
  });
  // Open Knight Ends
  
  		// close Knight starts
       $('.closeKnight').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Knight Ends	
  
  
  
  
     // Open FaktumShop start
$('.openFaktumShop').live('click', function() {
   idD = 'FaktumShop';
   fileX='FaktumShopFolder/FaktumShop.php';
   widthW = 756;
   heightH = 590;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

  y=3;  /* distance between cells */
tot=753;  /* Cellwith + distance */
  h=530;  /* cellHeight*/
	
    touchslider.createSlidePanel(idSlide, tot-y, h, y); 

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);
			
		}
  return false; 
  });
  // Open FaktumShop Ends
  
  		// close FaktumShop starts
       $('.closeFaktumShop').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close FaktumShop Ends	
  
  
  
  
  
  
  
// Open Book start
$('.openBook').live('click', function() {
   idD = 'Book';
   fileX='BookFolder/Book.php';
   widthW = 836;
   heightH = 670;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

	y=3;  /* distance between cells */
tot=833;  /* Cellwith + distance */
  h=606;  /* cellHeight*/
	
    touchslider.createSlidePanel(idSlide, tot-y, h, y); 

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);
			
		}
  return false; 
  });
  // Open Book Ends
  
  		// close Book starts
       $('.closeBook').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Book Ends	
	
	
// Open BookMovie start
$('.openBookMovie').live('click', function() {
   idD = 'BookMovie';
   fileX='BookMovieFolder/BookMovie.php';
   widthW = 680;
   heightH = 290;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);

   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

  
openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);		
		}
  return false; 
  });
  // Open BookMovie Ends
  
  		// close BookMovie starts
       $('.closeBookMovie').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close BookMovie Ends
	
		 
// Open Template start
$('.openTemplate').live('click', function() {
   idD = 'Template';
   fileX= 'TemplateFolder/Template.php';
   widthW = 480;
   heightH = 290;
  
   closeallex();	
   idCont = ('#' + idD + 'Cont');
   idSlide = ('#slidebar' + idD);
   // Öppnas igen
    if ($(idCont).length) { // implies *not* zero 	

openX(idD,widthW,heightH);
  	} 
  // Första laddningen av innehåll
 	else {
		loadX(idD,widthW,heightH,fileX);		
		}
  return false; 
  });
  // Open Template Ends
  
  		// close Template starts
       $('.closeTemplate').live('click',function() {
			 
		   closeallex();	

			return false; 
		});
		// close Template Ends	
		
		
		
 return false; 
});


