function reloadParent() {
	window.top.location.reload();
}
function popSellsTerms(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'sells-terms','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=200,width=360');
	} else {
		var win = new Window('sells-terms', {className: "alphacube", title: "Conditions de vente", 
														top:70, left:100, width:360, height:200, resizable: true, 
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	}
}
function popShippingTerms(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'shipping-terms','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=150,width=360');
	} else {
		var win = new Window('shipping-terms', {className: "alphacube", title: "Conditions de livraison", 
														top:90, left:200, width:360, height:150, resizable: true, 
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	}
}
function popShippingAddress(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'shipping-form','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=300,width=480');
	} else {
		var win = new Window('shipping-form', {className: "alphacube", title: "Adresse de livraison", 
														top:90, left:200, width:480, height:300, resizable: true, 
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	}
}
function popPointsRelais(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'points-relais','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=300,width=480');
	} else {
		var win = new Window('points-relais', {className: "alphacube", title: "Points Relais", 
														top:90, left:200, width:480, height:300, resizable: true, 
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	}
}
function popRelaisColisTNT(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'relais-colis','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=480,width=640');
	} else {
		var win = new Window('relais-colis', {className: "alphacube", title: "Relais Colis&reg; TNT 24h", 
														top:90, left:200, width:640, height:480, resizable: true, 
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	}
}

function popApplicationForm(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'application-form','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=240,width=520');
	} else {
		var win = new Window('application-form', {className: "alphacube", title: "Recrutement", 
														top:90, left:200, width:520, height:240, resizable: true, 
														url: sUrl,
														showEffectOptions: {duration:3}})
		win.setDestroyOnClose();
		win.showCenter();
	
		var myObserver = {
			onClose: function(eventName, win) {
				reloadParent();
			}
		}
		Windows.addObserver(myObserver);
	}
}

function popNewAccount(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'new-account','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=420,width=720');
	} else {
		var win = new Window('new-account', {className: "alphacube", title: "Nouveau compte", 
														top:90, left:200, width:720, height:420, resizable: true,
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	
		var myObserver = {
			onClose: function(eventName, win) {
				reloadParent();
			}
		}
		Windows.addObserver(myObserver);
	}
}
function popValidOrder(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'valid-order','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=160,width=520');
	} else {
		var win = new Window('valid-order', {className: "alphacube", title: "Validation de la commande", 
														top:90, left:200, width:520, height:160, resizable: true,
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	
		var myObserver = {
			onClose: function(eventName, win) {
				reloadParent();
			}
		}
		Windows.addObserver(myObserver);
	}
}
function popSendOrder(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'send-order','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=160,width=520');
	} else {
		var win = new Window('send-order', {className: "alphacube", title: "Expedition de la commande", 
														top:90, left:200, width:520, height:160, resizable: true,
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	
		var myObserver = {
			onClose: function(eventName, win) {
				reloadParent();
			}
		}
		Windows.addObserver(myObserver);
	}
}

function popPreviewHome(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'preview-home','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=320,width=520');
	} else {
		var win = new Window('preview-home', {className: "alphacube", title: "Pr&eacute;-visualiser", 
														top:90, left:200, width:520, height:320, resizable: true,
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
		var myObserver = {
			onClose: function(eventName, win) {
				reloadParent();
			}
		}
		Windows.addObserver(myObserver);
	}
}
function popSendMail(sUrl) {
	if(typeof Window == 'undefined'){
		window.open(sUrl,'send-mail','toolbar=no,menubar=yes,location=no,directories=no,status=no,scrollbars=yes,resizable=yes,copyhistory=no,height=550,width=640');
	} else {
		var win = new Window('send-mail', {className: "alphacube", title: "Nouveau message", 
														top:90, left:200, width:640, height:480, resizable: true,
														url: sUrl, 
														showEffectOptions: {duration:3}}) 
		win.setDestroyOnClose();
		win.showCenter();
	
		var myObserver = {
			onClose: function(eventName, win) {
				reloadParent();
			}
		}
		Windows.addObserver(myObserver);
	}
}
function dialReassort(callBack) {
	Dialog.confirm($('setReAssort').innerHTML, {windowParameters: {className:"alphacube", width:400}, 
					okLabel: "Valider", cancelLabel: "Annuler", 
					ok:function(win){ 
						//--- Adaptation de la hauteur de la fenetre
						Windows.focusedWindow.updateHeight();
						//--- Execute la fonction callback
						eval(callBack);
						//--- Animation
						new Effect.Shake(Windows.focusedWindow.getId());
						Windows.closeAll();
						return false;}});
}
function dialTransfert(callBack) {
	Dialog.confirm("Transf&eacute;rer le r&eacute;-assort au stock&nbsp;?", {windowParameters: {className:"alphacube", width:400}, 
					okLabel: "Valider", cancelLabel: "Annuler", 
					ok:function(win){ 
						//--- Adaptation de la hauteur de la fenetre
						Windows.focusedWindow.updateHeight();
						//--- Execute la fonction callback
						eval(callBack);
						//--- Animation
						new Effect.Shake(Windows.focusedWindow.getId());
						Windows.closeAll();
						return false;}});
}
function dialPromotion(callBack) {
	Dialog.confirm($('promote').innerHTML, {windowParameters: {className:"alphacube", width:400}, 
					okLabel: "Valider", cancelLabel: "Annuler", 
					ok:function(win){ 
						//--- Adaptation de la hauteur de la fenetre
						Windows.focusedWindow.updateHeight();
						//--- Execute la fonction callback
						eval(callBack);
						//--- Animation
						new Effect.Shake(Windows.focusedWindow.getId());
						Windows.closeAll();
						return false;}});
}
function popPassRecovery() {
	Dialog.confirm($('revovery-fields').innerHTML, {windowParameters: {className:"alphacube", width:400}, 
															okLabel: "Envoyer", cancelLabel: "Annuler", 
															ok:function(win){ 
																Windows.focusedWindow.updateHeight();
																
																//--- Envoi du mot de passe
																passwordRecovery();
																
																new Effect.Shake(Windows.focusedWindow.getId());
																Windows.closeAll();
																return false;}});
}
function dialSendOrder() {
	Dialog.confirm($('expedition-fields').innerHTML, {windowParameters: {className:"alphacube", width:400}, 
															okLabel: "Exp&eacute;dier", cancelLabel: "Annuler", 
															ok:function(win){ 
																Windows.focusedWindow.updateHeight();
																
																//--- Enregistrement de l'état puis envoi du mail
																alert("ok")
																
																
																new Effect.Shake(Windows.focusedWindow.getId());
																Windows.closeAll();
																return false;}});
}
function dialExpedition(callback) {
	Dialog.confirm($('expedition-fields').innerHTML, {windowParameters: {className:"alphacube", width:400}, 
					okLabel: "Exp&eacute;dier", cancelLabel: "Annuler", 
					ok:function(win){ 
						Windows.focusedWindow.updateHeight();
						var motif = /lnk_/;
						sQuery = sQuery.replace(motif,"");
						//--- Enregistrement de l'état puis envoi du mail
						var pars = "do=manageOrder&q="+sQuery+"&OrderId="+sID+"&NumExpedition="+$F("NumExpedition")+"&InformCust="+$F("inform-cust");
						//alert(pars);
						var myAjax = new Ajax.Request( sUrl, {method: 'get', parameters: pars, onComplete: feedback} );
						
						
						new Effect.Shake(Windows.focusedWindow.getId());
						Windows.closeAll();
						return false;}});
}
