﻿// Grußkarten

function showGrusstexteingabe(id,wkid)
{
	var content = "grusskarte/grusskartentext.php?id="+id+"&wkid="+wkid;
	
	newModalWindow = new ModalWindow({
			type: 		'iframe',
			theme: 		'lebkuchen',
			title: 		'Grußkarte beschriften',
			url: 		content,
			width:		782,
			height:		390
		});
};

function closeGrusstexteingabe(url)
{
	window.location.href = url;
};


// Info-Dialog "bla wurde in den Warenkorb gelegt"
 
var timeout;
function openInfoDialog(name) {
 	Dialog.info("<br /><strong>"+name+"</strong><br />wurde in den Warenkorb gelegt ...",
				{width:250, height:100, title:"Warenkorb", showProgress: false, draggable: false, className: "lebkuchen"});
				
	timeout=4;
	setTimeout(infoTimeout, 1000)
};
function openGreetingDialog() {
 	Dialog.info("<br /><strong>Warenkorb wird aktualisiert...</strong><br />",
				{width:250, height:100, title:"Warenkorb", showProgress: true, draggable: false, className: "lebkuchen"});				
	timeout=1;
	setTimeout(infoTimeout, 500)
};
function openGrusstextVorschau(z1,z2) {
	var content = "gusstext.php?zeile1=" + z1 + "&zeile2=" + z2;
	var url2 = '<div style="overflow:hidden; height:350px; width:500px; text-align:center;"><iframe src="' + content + '" height="350" width="500" frameborder="0" scrolling="no" style="display:block;overflow:hidden; height:350px; width:500px;"></iframe></div>';
	var meldung = "Vorschau";
 	Dialog.info	(	url2, {
					width: 500,
					height: 350,
					showProgress: false,
					draggable: false,
					resizable: false,
					className: "lebkuchen",
					title: meldung,
					showEffect: Effect.Appear,
					hideEffect: Effect.Fade,
					showEffectOptions: {duration:2.5},
					hideEffectOptions: {duration:1.5}
				});
};
function infoTimeout() {
	timeout--;
	if (timeout >0) {
		//Dialog.setInfoMessage("Test of info panel, it will close <br>in " + timeout + "s ...")
		setTimeout(infoTimeout, 1000)
	} else
	Dialog.closeInfo()
};

// Liefertermin zu kurzfristig
function TerminZuKurz(datum) {
	var meldung = "Liefertermin zu kurzfristig";
	var content = "dialog_terminzukurz.php?datum="+datum;
	var breite  = 450;
	var hoehe   = 215;
 	Dialog.info	(	null, {
					width: breite,
					height: hoehe,
					showProgress: false,
					draggable: false,
					resizable: false,
					className: "lebkuchen",
					title: meldung,
					showEffect: Effect.Appear,
					hideEffect: Effect.Fade,
					url: content,
					showEffectOptions: {duration:2.5},
					hideEffectOptions: {duration:1.5}
				});
}

// Produkt löschen
function wirklichLoeschen(artikel, pid) {
	var meldung = "Hinweis";
	var content = 'dialog_loeschen.php?artikel='+artikel+'&pid='+pid;
	var breite  = 350;
	var hoehe   = 115;
	var url = '<div class="cutter" style="height:'+hoehe+'px; width:'+breite+'px;"><iframe src="' + content + '" height="'+hoehe+'" width="'+breite+'" frameborder="0" scrolling="no" style="overflow:hidden; height:'+hoehe+'px; width:'+breite+'px;"></iframe></div>';

 	Dialog.info	(	url, {
					width: breite,
					height: hoehe,
					showProgress: false,
					draggable: false,
					resizable: false,
					className: "lebkuchen",
					title: meldung,
					showEffect: Effect.Appear,
					hideEffect: Effect.Fade,
					showEffectOptions: {duration:2.5},
					hideEffectOptions: {duration:1.5}
				});
}


// KALDENER
function kalender(url) {
	var breite  = 310;
	var hoehe   = 345;
	var url2 = '<div style="overflow:hidden; height:355px; width:310px; text-align:center;"><iframe src="' + url + '" height="355px" width="310px" frameborder="0" scrolling="no" style="overflow:hidden; height:355px; width:310px;"></iframe></div>';
	var meldung = "Liefertermin wählen";
 	Dialog.info	(	url2, {
					width: breite+10,
					height: hoehe+10,
					showProgress: false,
					draggable: false,
					resizable: false,
					className: "lebkuchen",
					title: meldung,
					showEffect: Effect.Appear,
					hideEffect: Effect.Fade,
					showEffectOptions: {duration:2.5},
					hideEffectOptions: {duration:1.5}
				});
};


// Warnmeldung warenkorb

function achtung(nachricht) {
	var content = "dialog_warnung.php?nachricht="+nachricht;
	var url2 = '<div style="overflow:hidden; height:150px; width:310px; text-align:center;"><iframe src="' + content + '" height="150" width="310" frameborder="0" scrolling="no" style="display:block;overflow:hidden; height:150px; width:310px;"></iframe></div>';
	var meldung = "Achtung";
 	Dialog.info	(	url2, {
					width: 320,
					height: 150,
					showProgress: false,
					draggable: false,
					resizable: false,
					className: "lebkuchen",
					title: meldung,
					showEffect: Effect.Appear,
					hideEffect: Effect.Fade,
					showEffectOptions: {duration:2.5},
					hideEffectOptions: {duration:1.5}					
				});
};

// Es wurde kein Empfänger gewählt (1. WK-Seite)


function showEmpfError(liste) {
 	Dialog.info("<div style='text-align:left; padding: 0 15px; 0 20px;' id='errMessage'><br /><strong>Bitte legen Sie für folgende Artikel Ihre Empfänger fest, bevor Sie fortfahren:</strong><br /><br />"+liste+"<br /><br /><a href='javascript:Dialog.closeInfo();' class='button' title='Ok' style='background-image:url(bilder/button_ok.gif); width:71px; height:21px; top:4px; left:0;'><span>Ok</span></a></div>",
				{	width:350,
					//height:100,
					title:"Fehlende Empfänger",
					showProgress: false,
					draggable: false,
					className: "lebkuchen"
				});
};

// Abfrage, welcher Empfänger gelöscht werden soll (1. WK-Seite)


function showEmpfDel(liste) {
 	Dialog.info("<div style='text-align:left; padding: 0 15px; 0 20px;' id='errMessage'><br /><strong>Welcher Empfänger darf aus der Liste dieses Artikels weggenommen werden?</strong><br /><br />"+liste+"<br /><br /><a href='javascript:Dialog.closeInfo();' class='button' title='Ok' style='background-image:url(bilder/btn_dialog_abbrechen_zurueck.gif); width:151px; height:21px; top:4px; left:0;'><span>Ok</span></a></div>",
				{	width:350,
					//height:100,
					title:"Anzahl verringern",
					showProgress: false,
					draggable: false,
					className: "lebkuchen"
				});
};

function refreshWk(url) {
		//alert(url);
		window.iframeShop.window.iframeWk.document.location.replace(url);
		Dialog.closeInfo();
		return false;
};

// Grusskarte belegen?

function saveSettings(element, zid) {

	var divKarte = element.parentNode;
	element.style.display = "none";
	
	var loading = window.iframeShop.window.iframeWk.document.createElement('div');
	loading.className = "loading";
		
	$(divKarte).appendChild(loading);
	
	if(element.className == "btnKarteOff") {
		var type = "x"; // Karte wird beigelegt
	} else {
		var type = ""; // Karte wird nicht beigelegt
	};

	var url = "../sys/greeting_fnc.php?zid="+zid+"&type="+type;
	
	new Ajax.Request(url, {
							method: 'get',
							onSuccess: function(transport) {
								
								//alert(transport.responseText);
								
								if(transport.responseText != "on"){
									element.className = "btnKarteOff";
								} else {
									element.className = "btnKarteOn";
								};
								setTimeout(function() {
									loading.parentNode.removeChild(loading);
									element.style.display = "block";
								}, 500);
													
							} 
	});
};


// Grusstext Eingabe
function editGreetingMessage(element, zid) {

var content = "dialog_grusstext_edit.php?zid="+zid;
	
	newModalWindow = new ModalWindow({
			type: 		'iframe',
			theme: 		'lebkuchen',
			title: 		'Grusstext ändern',
			url: 		content,
			width:		511,
			height:		375
		});

};// Grusstext Eingabe

function setGreetingMessage(element, zid) {

	var content = "dialog_grusstext.php?zid="+zid;
	
	newModalWindow = new ModalWindow({
			type: 		'iframe',
			theme: 		'lebkuchen',
			title: 		'Grusstext ändern',
			url: 		content,
			width:		511,
			height:		375
		});
};

function setWKMessage() {
	
	newModalWindow = new ModalWindow({
			type: 		'alert',
			theme: 		'lebkuchen',
			title: 		'Achtung',
			message: 	'<p align=\'center\'>Warenkorb wird aktualisiert... <br><br> <img src="bilder/progress.gif"></p><br><br>',
			width: 		310
		});
	timeout=1;
	setTimeout(modalTimeout, 1000)
};

function modalTimeout() {
	timeout--;
	if (timeout >0) {
		//Dialog.setInfoMessage("Test of info panel, it will close <br>in " + timeout + "s ...")
		setTimeout(modalTimeout, 1000)
	} else
	newModalWindow.closeWindow();
};
