// JavaScript Document

jQuery.noConflict();

jQuery(document).ready(function(){
	jQuery('#sizerwrap').dialog({
						autoOpen: false,
						width: 300,
						modal:true,
						buttons: {
							Done: function() {
								jQuery(this).dialog('close');
							}
						}
	 });
	  
	jQuery('#sizerwrap_link').click(function(){
						jQuery('#sizerwrap').dialog('open');
						return false;
	 });
	 
	jQuery('#sizerwrap2').dialog({
						autoOpen: false,
						width: 728,
						modal:true,
						buttons: {
							Done: function() {
								jQuery(this).dialog('close');
							}
						}
	 });
	 
	 jQuery('#sizerwrap_link2').click(function(){
						jQuery('#sizerwrap2').dialog('open');
						return false;
	 });
	 
	 jQuery('#newsletterpromo').dialog({
				autoOpen: false,
				modal: true,
				width: 555,            
				resizable: false,
                             buttons: {
						Done: function() {
							jQuery(this).dialog('close');
						}
					}
			});
    jQuery('#newsletter_link').click(function(){
    jQuery('#newsletterpromo').dialog('open');
		return false; 
		
		});
		
	jQuery('#specialpromo').dialog({
				autoOpen: false,
				modal: true,
				width: 555,            
				resizable: false
			});
    jQuery('#specialpromo_link').click(function(){
    jQuery('#specialpromo').dialog('open');
		return false; 
		
		});
	
	jQuery('#sharpmenRegister').dialog({
				autoOpen: false,
				modal: true,
				width: 555,            
				resizable: false
			});
    jQuery('#sharpmenRegister_link').click(function(){
    jQuery('#sharpmenRegister').dialog('open');
		return false; 
		
		});
}); 

document.observe("dom:loaded", function() { 								
				function sendRequest(e){
					 if($F('newsletter-f').length == 0) {
					  	$('update_div').innerHTML = "<label>You have to fill the fields</label>";
					 } else {
						 new Ajax.Request('http://akselparis.com/newsletter/subscriber/new',
						{
							method:'post',
							parameters: $('newsletter-validate-detail-footer').serialize(true),
							onLoading: function(){
								$('update_div').show();
								$('update_div').innerHTML = "<label><img src='http://akselparis.com/skin/frontend/default/aksel/images/opc-ajax-loader.gif' alt='ajaxspinner' /></label>";
							},
							onSuccess: function(transport){
								var response = transport.responseText || "No response text";
								$('update_div').innerHTML = "<label>Success. Thank You !</label>";
							},
							onFailure: function(){ 
								$('update_div').innerHTML = "<label>Something went wrong...</label>";
							}
						}); 
					 }
					Event.stop(e);
				}
			Event.observe('newsletter-validate-detail-footer', 'submit', sendRequest);
		}); 


