function fakeClick(fn) {
	var $a = $('<a href="#" id="fakeClick"></a>');
		$a.bind("click", function(e) {
			e.preventDefault();
			fn();
		});
	$("body").append($a);
	var evt, 
		el = $("#fakeClick").get(0);
	if (document.createEvent) {
		evt = document.createEvent("MouseEvents");
		if (evt.initMouseEvent) {
			evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
			el.dispatchEvent(evt);
		}
	}
	$(el).remove();
}

$(document).ready( function() {
  var video = $("#bgvideo").get(0);

  if (navigator.userAgent.match(/WebKit/)) {
    $('.noflash').hide();
    $('.iswk').show();
    if (navigator.userAgent.match(/iPhone/) || navigator.userAgent.match(/iPod/)) {
      $('body').css('background-color', '#fff !important');
      $("#pg-toppage #bgvideo").css('background-color', '#fff !important');
      $("#pg-toppage #bgtop").css('background-color', '#fff !important');
      $('#globalHeader').css('background-color', '#fff !important');
      $('#wrapperBottom').css('background-color', '#fff !important');
      
      $(window).bind("load orientationchange",function(){
        if(Math.abs(window.orientation) === 90){
          $("#pg-toppage #bgvideo").css('margin-top', '124px !important');
          $('#bgvideo').css('height', '660px !important');
          $('#bgvideo').css('width', '980px !important');
          $("#wrapperBottom").css('top', '820px');
        }else{
          $("#pg-toppage #bgvideo").css('margin-top', '224px !important');
          $('#bgvideo').css('height', '660px !important');
          $('#bgvideo').css('width', '980px !important');
          $("#wrapperBottom").css('top', '970px');
        }
      });
      
      
      $(video).bind('ended', function(){
        window.location.href = '/enter.html';
      });
    }
    if (navigator.userAgent.match(/iPad/)) {
      $(video).bind('ended', function(){
        window.location.href = '/enter.html';
      });
    }
  } else {
    $('.noflash').show();
    $('.iswk').hide();
  }
     
  fakeClick(function() {
    video.play();
  });


});
