$(document).ready(function(){
    $.getScript('/player/js/swfobject.js',function(){
        $.getScript('/player/js/uppod_player.js');
    });
});


$(document).ready(centerPos);
$(window).resize(centerPos);

function centerPos () {

	var topPixels;
/*	var topPixels1 = (document.documentElement.scrollHeight - 800)/2;
	var topPixels2 = (document.documentElement.clientHeight - 800)/2;
    if (topPixels1 < topPixels2) {
    	topPixels = topPixels2;
    } else {
    	topPixels = topPixels1;
    }
*/
var isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
     if (isOpera) {
          var height = document.body.clientHeight;
     } else {
          var height = $(window).height();
     }


    topPixels = (parseInt(height)-800)/2;

    if (topPixels < 0) {
    	topPixels = 0;
    }

    $(".container").css( { top:topPixels, "margin-top":'0px' } );
    //$("#popup").css( { top:topPixels, "margin-top":'0px' } );

    var leftPixels;
/*	var leftPixels1 = (document.documentElement.scrollWidth - 1000)/2;
	var leftPixels2 = (document.documentElement.clientWidth - 1000)/2;
    if (leftPixels1 < leftPixels2) {
    	leftPixels = leftPixels2;
    } else {
    	leftPixels = leftPixels1;
    }
*/
    leftPixels = (parseInt($(window).width())-1000)/2;

    if (leftPixels < 0) {
    	leftPixels = 0;
    }
    $(".container").css("left", leftPixels);
    $(".container").css("margin-left", "0px");

   // $("#popup").css("left", leftPixels);
   // $("#popup").css("margin-left", "0px");
}
window.onload = init;
function init () {

	$(".menu_bg>a").hover(
      function () {
		var className = $(this).attr("id");
		$(this).parent().children(".fire").css("display", "block");
        $(this).parent().children(".fire").addClass(className);
      }, 
      function () {
        var className = $(this).attr("id");
		$(this).parent().children(".fire").css("display", "none");
        $(this).parent().children(".fire").removeClass(className);
      }
    );
	$(".reset").hover(
	  function () {
        $(this).css("background", "url(/images/content_button_bg.jpg)");
      }, 
      function () {
        $(this).css("background", "none");
      }
    );
}

$(document).ready(function (){

    $("a.promo_link").click(function(){
        showPopUp('popup');
        return false;
    });

    $(".logo a").click(function(){
        showPopUp('popup');
        return false;
    });

    $('body').append('<div id="popup"><div id="text"></div></div>');
    $('#popup').append('<div id="close" /><div id="loader" />')
               .css({'z-index': 4001, 'display': 'none'});
    $('#close').click(function() {return closePopUp('popup')} );

    $('.container').append('<a href="http://www.facebook.com/pages/eClipse-foto/45644893284" target="_blank" class="facebook">&nbsp;</a>');
    $('.facebook').click(function(){$(this).blur()});

});


// popup window
     function closePopUp(id) {
          $("body").attr("onkeypress", "");
          $('#'+id).hide("normal");//.fadeOut("normal");
          $('.overlay').fadeOut("normal", function() { $('.overlay').remove(); });

          return false;
     }

     function showPopUp(id) {

          $('#text').html(' ');
          $('#loader').show();
          $('#text').load('/promotions2.html', function () {
                  $('#loader').hide();
           });

          $("body").attr("onkeypress", "if(event.keyCode == 27) {closePopUp('" + id + "');}");
          $("<div/>")
          .addClass('overlay')
          .css({'opacity':0.5, 'height':$(document).height(), 'z-index': 4000, 'display': 'none'})
          .bind("click", function() { return closePopUp(id); })
          .appendTo('body')
          .fadeIn("normal");

          $('#' + id)
          .css({'z-index':5000})
          .show("normal");//.fadeIn("normal");

          return false;
     }

