$(function() {
   $('#newsletter-signup').click(function(){
      $.ajax({
        type: "POST",
        url: "index.php",
        data: { 
          page : "/modules/newsletter/ajax_newsletter_signup", 
          email : $('#newsletter-email').val()
        },
        success: function(subscriber) {
         $("#newsletter-dialog").dialog({
	    width: 650,
	    resizable: false,
	    modal:true,
	    close: function() { $(this).dialog( 'destroy' );}
	    });
	     if(subscriber.id != null)
         {
            $("#newsletter-error").hide();
            $("#newsletter-success").show();
         }
         else
         {
            $("#newsletter-error").show().text(subscriber.errors.email);
            $("#newsletter-success").hide();
         }

	    },
        dataType:"json"
      });
      return false;
   });
   jQuery("#loading").ajaxStart(function(){jQuery(this).show()});
   jQuery("#loading").ajaxStop(function(){jQuery(this).hide()});


$('#newsletter-email').focus(function(){
$(this).val("");
});
});

$(function() {

    $('#productImage a').lightBox();
    $('#enlargeImage a').lightBox();

    $('#thumbnails a').click(function(){
        $("#mainImage").attr('src', $(this).attr('href'));
        $('#productImage a').attr('href', $(this).attr('rel'));
        $('#enlargeImage a').attr('href', $(this).attr('rel'));
        return false;
    });
});