jQuery.fn.center = function() {
  this.css("position","absolute");
  this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
  this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
  return this;
}

function getAjaxElements() {
  $.get('/home/order_info', function(data) {
    $('#checkout_links').css({opacity: 0});
    $('#checkout_links').html(data);   
    Cufon.replace($('.oratorStd'), {fontFamily: 'Orator Std', hover: {color: '#FFF'}, hoverables: {li:'true', a:'true'}});
     Cufon.replace($('.turquoiseLink'), { fontFamily: 'Orator Std', hover: {color: '#04f3f3'}, hoverables: {li:'true', a:'true'} });
    Cufon.now();
    $("#checkout_links").fadeTo(1100, 1, "easeOutCubic");    
  });             
}

var fT = 0;                                        
function fadeInImages() { 
 for(var i=0;i<$(".pImg").length;i++) {
    $("#pImg-"+i).delay(i*100).fadeTo(900, 1, "easeOutCubic");
 }
}

function setImages() { 
 $(".pImg, .aImg").each(function() {
   $(this).css({opacity: 0, display: "block"});
 });                    
} 


$(window).load(function() {
  if($(".pImg").length > 0) {
    setImages();
    fadeInImages();  
    setTimeout(function() {$("#footer").show()}, 2000);
  }
  var ll = document.location.toString();
  if(ll.indexOf("ty=1") > 0)
    $("#subscriber_input").val('THANK YOU');  
  else if(ll.indexOf("ty=er") > 0)
    $("#subscriber_input").val('ERROR - INVALID EMAIL');  
  else
    $("#subscriber_input").val('JOIN MAILING LIST');
  $('#subscriber_input').focus(function(){
    if(($(this).val()=='JOIN MAILING LIST') || ($(this).val()=='THANK YOU') || ($(this).val()=='ERROR - INVALID EMAIL'))
      $(this).val('');
  });
});

$.fn.delay = function( time, name ) {
  return this.queue( ( name || "fx" ), function() {
    var self = this;
    setTimeout(function() { $.dequeue(self); } , time );
  } );
};


