// remap jQuery to $
(function($){})(window.jQuery);


/* Page is ready */
$(document).ready(function (){
  
  if ($("#show-video").length > 0){
    
    $("#popup-video").css("opacity", "0");
    
    $('#show-video').click(function() {
      
      $('.vjs-poster').css("width",640);
      $('.vjs-poster').css("height",360);
      $('.video-js').css("height",360);
      
      //$('#popup-video').fadeIn("slow");
      $("#popup-video").css("visibility", "visible");
      $("#popup-video").animate({"opacity": "1"},{queue:false, duration:600, easing:"expoEaseInOut"});
      
      
    });
  }
  
  if ($("#close-video").length > 0){
    
    $('#close-video').click(function() {
      //$('#popup-video').fadeOut();
      
      $("#popup-video").animate({
        "opacity": "0"
      }, {
        queue:false,
        duration:400,
        easing:"expoEaseInOut",
        complete: function() {
          $(this).css("visibility", "hidden");
          $(".video-js")[0].player.pause();
        }
      });
      
    });
    
  }
  
});


/* optional triggers

$(window).load(function() {
	
});

$(window).resize(function() {
	
});

*/

function buyforms_validate() {
  var server  = $("input#fserver").val()+"/";
  var lang    = $("input#flang").val();
  var cat     = $("input#fcat").val();
  var slug    = $('select#buy-form-country option:selected').val();
  
  if( slug != "nothing" ) {
  
    if( lang != "" ) { lang = lang+"/";  }
    if( cat != "" ) {  cat = cat+"/";  }
  
    var url   = server+lang+cat+slug;
    window.location = url;
  }
}
