$(document).ready(function(){
	
	var curent_lang = getCookie('lang');
        
    $('#lang').change(function() {   
        changeLang($(this).val());
		location.reload(true);	       	
	});	
       
   // $('#lang_flag').css({'background':'transparent url(./img/header/'+curent_lang+'.gif) no-repeat'});    
    $("#lang option[value='"+curent_lang+"']").attr('selected', 'selected');
    change_id();
	 
 }); 
  
  function getCookie(c_name)
  {
  if (document.cookie.length>0)
    {
    c_start=document.cookie.indexOf(c_name + "=");
    if (c_start!=-1)
      {
      c_start=c_start + c_name.length+1;
      c_end=document.cookie.indexOf(";",c_start);
      if (c_end==-1) c_end=document.cookie.length;
      return unescape(document.cookie.substring(c_start,c_end));
      }
    }
  return "";
  }
  
 
  
  function changeLang(lang){
	  setCookie("lang", lang, 30, '/' ); 
  }
  
  function request_live(selectedIndex){
	  if(selectedIndex == 2){		 
		  $("#contact_tel").css("display", "block");
		  $("#contact_tel_lbl").css("display", "block");
		  $("#contact_address").css("display", "block");
		  $("#contact_address_lbl").css("display", "block");
	  }
	  else
	  {
		  $("#contact_tel").css("display", "none");
		  $("#contact_tel_lbl").css("display", "none");
		  $("#contact_address").css("display", "none");
		  $("#contact_address_lbl").css("display", "none");
	  }
  }
  
  function change_id(val_id){
	
	val_id = (val_id != "" && val_id != null) ? val_id : "overview";
	switch(val_id)
	{
		case "overview" : 
		{
			$("#overview").attr("class", "flex_btn_over");
			$("#features").attr("class", "flex_btn");
			$("#spec_feat").attr("class", "flex_btn");
			$("#whats_new").attr("class", "flex_btn");
			$("#tech_car").attr("class", "flex_btn");
			
			$("#overview").mouseover(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#overview").mouseout(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#tech_car").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#tech_car").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#features").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#features").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#spec_feat").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#spec_feat").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#whats_new").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#whats_new").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			break;
		} 
		case "tech_car" : 
		{
			$("#tech_car").attr("class", "flex_btn_over");
			$("#overview").attr("class", "flex_btn");
			$("#features").attr("class", "flex_btn");
			$("#spec_feat").attr("class", "flex_btn");
			$("#whats_new").attr("class", "flex_btn");
			
			$("#tech_car").mouseover(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#tech_car").mouseout(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#overview").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#overview").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#features").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#features").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#spec_feat").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#spec_feat").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#whats_new").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#whats_new").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			break;
		} 
		case "features" : 
		{
			$("#overview").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#overview").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#tech_car").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#tech_car").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
									
			$("#spec_feat").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#spec_feat").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#whats_new").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#whats_new").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			$("#features").mouseover(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#features").mouseout(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#features").attr("class", "flex_btn_over");
			$("#overview").attr("class", "flex_btn");
			$("#spec_feat").attr("class", "flex_btn");
			$("#whats_new").attr("class", "flex_btn");
			$("#tech_car").attr("class", "flex_btn");
			break;
		} 
		case "spec_feat" : 
		{
			$("#overview").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#overview").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#tech_car").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#tech_car").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#features").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#features").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
								
			$("#whats_new").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#whats_new").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			$("#spec_feat").mouseover(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#spec_feat").mouseout(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#spec_feat").attr("class", "flex_btn_over");
			$("#overview").attr("class", "flex_btn");
			$("#features").attr("class", "flex_btn");
			$("#whats_new").attr("class", "flex_btn");
			$("#tech_car").attr("class", "flex_btn");
			break;
		} 
		case "whats_new" : 
		{
			$("#overview").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#overview").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#tech_car").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#tech_car").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			
			$("#features").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#features").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
								
			$("#spec_feat").mouseover(function(){
				$(this).removeClass("flex_btn").addClass("flex_btn_over");
			});
			$("#spec_feat").mouseout(function(){
				$(this).removeClass("flex_btn_over").addClass("flex_btn");
			});
			$("#whats_new").mouseover(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#whats_new").mouseout(function(){
				$(this).attr("class", "flex_btn_over");
			});
			$("#whats_new").attr("class", "flex_btn_over");
			$("#overview").attr("class", "flex_btn");
			$("#features").attr("class", "flex_btn");
			$("#spec_feat").attr("class", "flex_btn");
			$("#tech_car").attr("class", "flex_btn");
			break;
		} 
	}	
}

function changeCover ( ids ) {
	$("#photos_ids").html("<img src='/img/brochures/"+ids+".jpg'>");
}
