var alert_old = window.alert;

window.alert = function(msg) {
  jQuery("<div />", { html: !!msg ? msg.replace(/\n/, "<br />") : "" }).dialog({
    title: "Alert",
    modal: true,
    buttons: {
      Ok: function() {
        $(this).dialog('close');
      }
    }
  });
};

function upgradePrompt(url) {
  jQuery("<div />", { html: 
'<p>' +
'<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>' +
'This is only available to Platinum members or by purchasing the download with credits.' +
'</p>' +
'<p>&nbsp;</p>' +
'<p><input type=button value="UPGRADE NOW!" onclick="document.location=\''+url+'\';"></p>' +
'</div>'
  }).dialog({
    title: "Upgrade your Account!",
    modal: true,
    width: "500px",
    buttons: {
      Ok: function() {
        $(this).dialog('close');
      }
    }
  });

  return false;
}



function upgradeCreditsPrompt(url) {
  jQuery("<div />", { html: 
'<p>' +
'<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>' +
'You can get this by purchasing more credits for your account.' +
'</p>' +
'<p>&nbsp;</p>' +
'<p><input type=button value="BUY NOW!" onclick="document.location=\''+url+'\';"></p>' +
'</div>'
  }).dialog({
    title: "Purchase Credits!",
    modal: true,
    width: "500px",
    buttons: {
      Ok: function() {
        $(this).dialog('close');
      }
    }
  });

  return false;
}


function loginPrompt( continueUrl ) {
  var formContainer = $( '#popup-login-container' ).clone();
  if ( !continueUrl ) continueUrl = window.location;
  formContainer.find( 'input[name=continue]' ).attr( { value: continueUrl } );
  formContainer.dialog({
    title: '<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 0;"></span> Please login with your account.',
    modal: true,
    width: "360px",
    resizable: false,
    closeOnEscape: true,
    buttons: {
      Login: function() {
        $("form", $(this)).submit();
        $(this).dialog('close');
      }
    }
  });

  return false;
}


$(function(){
  $('.rollover').hover(
    function(e){
      $(this).find('.img-in').show();
      $(this).find('.img-out').hide();
    },
    function(e){
      $(this).find('.img-in').hide();
      $(this).find('.img-out').show();
    }
  );
});

