  // Fineway Studis JS


  // INICIALIZATION ////////////////////////////////////////////////
  
  
  var activeSection = 0;
  var activeSite = 0;
  var oldActiveSection = 0;
  var oldActiveSite = 0;
  var $ = jQuery.noConflict();
	var specialParameter;
	
  // HASH //////////////////////////////////////////////////////////
  hash = "qa97621ca56as5dasd546aszx213a";


$(document).ready(function(){


    $.history.init(pageload);  //init
    
    

    // MENU-CLICK /////////////////////////////////////////////////////////
    $("li div[id*='']").click(function() {
      var idecko = $(this).attr('id'); idecko = idecko[1];      
      switch(idecko){
        case "1": newName = "/news/"; break; 
        case "2": newName = "/about-us/"; break;
        case "3": newName = "/inspiration/"; break;
        case "4": newName = "/projects-and-creativity/"; break;
        case "5": newName = "/career/"; break;
        case "6": newName = "/dev-support/"; break;
        case "7": newName = "/contact/"; break;
        default:  newName = "/news/";      
      }
      window.location.hash = "#"+newName;
      $.history.load(newName);
    }); 
    

 /*
  $('a').each(function (){
    var colorbefore;
    $(this).mouseover(function (){ 
      colorbefore = $(this).css("color");

      if (colorbefore != "rgb(206, 201, 201)"){
        $(this).animate({ color: "#cf0000",  }, 400 );     
      }    
    });
      
    $(this).mouseout(function (){  
      if (colorbefore != "rgb(206, 201, 201)"){
        $(this).animate({ color: "#a0825b",  }, 400 );   
      }
    })        	
  });
    */
    
  

	$('.lgames').animate({ opacity: 0.0 }, 1 ); 
	$('.laboutus').animate({ opacity: 0.0 }, 1 );
	$('.lwhatwecan').animate({ opacity: 0.0 }, 1 );
	$('.lcreativestudio').animate({ opacity: 0.0 }, 1 );
	$('.lprojects').animate({ opacity: 0.0 }, 1 );
	$('.lpartners').animate({ opacity: 0.0 }, 1 );
	$('.lsupport').animate({ opacity: 0.0 }, 1 );

  $('li div').mouseover(function (){ 
    $('.up').animate({ opacity: 1.0 }, 250 ); 
  });
	$('li div').mouseout(function (){ 
    $('.up').animate({ opacity: 0.0 }, 100 );
  });
  
	
  $('#link-aboutus').mouseover(function (){ 
    $('.laboutus').animate({ opacity: 1.0 }, 250 ); 
  });
	$('#link-aboutus').mouseout(function (){ 
    $('.laboutus').animate({ opacity: 0.0 }, 100 );
  });
  
  $('#link-whatwecan').mouseover(function (){ 
    $('.lwhatwecan').animate({ opacity: 1.0 }, 250 ); 
  });
	$('#link-whatwecan').mouseout(function (){ 
    $('.lwhatwecan').animate({ opacity: 0.0 }, 100 );
  });	
	
  $('#link-games').mouseover(function (){ 
    $('.lgames').animate({ opacity: 1.0 }, 250 ); 
  });
	$('#link-games').mouseout(function (){ 
    $('.lgames').animate({ opacity: 0.0 }, 100 );
  });	
  
  $('#link-creativestudio').mouseover(function (){ 
    $('.lcreativestudio').animate({ opacity: 1.0 }, 250 ); 
  });
	$('#link-creativestudio').mouseout(function (){ 
    $('.lcreativestudio').animate({ opacity: 0.0 }, 100 );
  });	
  
  $('#link-projects').mouseover(function (){ 
    $('.lprojects').animate({ opacity: 1.0 }, 250 ); 
  });
	$('#link-projects').mouseout(function (){ 
    $('.lprojects').animate({ opacity: 0.0 }, 100 );
  });	
  
  $('#link-partners').mouseover(function (){ 
    $('.lpartners').animate({ opacity: 1.0 }, 250 ); 
  });
	$('#link-partners').mouseout(function (){ 
    $('.lpartners').animate({ opacity: 0.0 }, 100 );
  });	
  
  $('#link-support').mouseover(function (){ 
    $('.lsupport').animate({ opacity: 1.0 }, 250 ); 
  });
	$('#link-support').mouseout(function (){ 
    $('.lsupport').animate({ opacity: 0.0 }, 100 );
  });	
  

  $.scrollTo.defaults.axis = 'xy';
  	$('.smallmenu a').click(function(){
  	  //$j.scrollTo( "#body", {duration:600});
  	  
      var hasah = this.href;			
			hasah = hasah.replace(/^.*#/, '');
	
      $.history.load(hasah);
      
			return false;               
  	});	
	
	
	
	
	
	
	
	
	
	
	
	$('#ca2').animate({opacity: 0.0});  
  $('#ca3').animate({opacity: 0.0});    
	
	$('.gototop').click(function(){
		$.scrollTo( "#body", {duration:1000} );
	});
	
 });
 
 
 
 
 
 
 
 
 // PAGELOAD ///////////////////////////////
 function pageload(hasah) { 
			
			var address = hasah.split("/");
			var newSection;
			var newSite;
		
    
			switch(address[1]){
        case "news":     newSection = 1; 
                         newSite = 1;      
            break;  
        case "about-us": newSection = 2;
          switch(address[2]){
            case "who-we-are":    newSite = 1; break;
            case "style-of-creation":           newSite = 2; break;            
            default:                    newSite = 1;      
          } break;
        case "inspiration":      newSection = 3; 
          switch(address[2]){
            case "informace-pro-novinare": newSite = 1; break;
            case "akreditace":             newSite = 2; break;
            case "presskit":               newSite = 3; break;

            default:                       newSite = 1;      
          } break;
        case "projects-and-creativity": newSection = 4;
          switch(address[2]){
            case "games-production":       newSite = 1; break;
            case "events-organization":    newSite = 2; break;
            case "websolutions":           newSite = 3; break;
            case "movies-and-tvshows":    newSite = 4; break;
            case "game-communities":    newSite = 5; break;
            default:                       newSite = 1;      
          } break;
        case "career":   newSection = 5; newSite = 1; break;
        case "dev-support":   newSection = 6; newSite = 1; break;
        case "contact":    newSection = 7; newSite = 1; break;
        default:           newSection = 1; newSite = 1;  break;   
      }
      if(address[3]) specialParameter=address[3];
      
      
      //alert(newSection);
			//alert(newSite);
			
			
			setSite(newSection,newSite,0);
      			
	}

   // SET SITE ///////////////////////////////
  function setSite(theme,site,mode) {    
    
    var banner = 0;
    if(theme != activeSection) { activeSite = 0; }
    
    if(mode == 1 || activeSite != site){
    
     
                             
    if(theme != activeSection) {  
      
      $('#banner .icon').fadeOut(150);
      $('#banner .text').fadeOut(150);
      banner = 1;
      $('html, body').animate({ scrollTop: 0 }, 'slow');
    }else{
      $('html, body').animate({ scrollTop: 355 }, 'slow');
    }   
   	
      $('#content').animate({
          opacity: 0.0
        }, 500,function() {

         additional =  "";
      oldActiveSite = activeSite;
      activeSite = site;   
       
      var adresa = "ajax/getBanner.php?hash="+hash+"&menu="+theme+"&site="+site;        
      $.post(adresa,{}, function(data) {
    
      if(banner == 1) { 
        $('#banner').html(data); 
        $('#banner .icon').fadeIn(1000);
         $('#banner .text').fadeIn(1000);
      }   
         
           });
        activeSection = theme; 
        adresa = "pages/getPage"+theme+"-"+site+".php"+additional;       
      $.post(adresa,{}, function(data) {
        $('#content').html(data);
           $('#content').animate({
          opacity: 1.0
        }, 500,function() {}); 
      }); 

        });
           
    }       
       
  };
	
	
	next_car = 2;
	  // CAROUSEL ///////////////////////////////	
	function show_car() {
	  
		if (next_car == 1) {
		 
			hide_next();
			$('#ca1').fadeIn('slow',function(){  });
	     $("#car1a").fadeIn('fast');
		}
		else if (next_car == 2) {
			hide_next();
			$('#ca2').fadeIn('slow',function(){  });
		  $("#car2a").fadeIn('fast');
		}
		else if (next_car == 3) {
			hide_next();
			$('#ca3').fadeIn('slow',function(){	 });
		  $("#car3a").fadeIn('fast'); 
			next_car = 0;
		};
		next_car++;		
	}
	
	function start_car() {running_car = setInterval(show_car,4000)};
	function stop_car() {clearInterval(running_car)};
	
  function hide_next(){
   
    $('#ca1').fadeOut('slow', function() {  });
    $('#ca2').fadeOut('slow', function() {  });
    $('#ca3').fadeOut('slow', function() {  });
    $("#car1a").fadeOut('fast'); 
    $("#car2a").fadeOut('fast'); 
    $("#car3a").fadeOut('fast'); 
  }	
                            
	start_car();
	
