function openOnlineEditor(contextPath) {
		w = 800;
		h = 480;
		x = (screen.width-w)/2;
		y = ((screen.height-h)/2);
		y = y - (y*0.2)
		ppWin = window.open(contextPath + '?wicket:bookmarkablePage=:ch.edorex.PP.pages.flash.OnlineEditorPage','online_editor','width='+w+',height='+h+',top='+y+',left='+x+',toolbar=no,dependent=yes,resizable=no,scrollbars=no');
		window.ppWin.focus();
}

function openOnlineEditorSPI(contextPath) {
	w = 800;
	h = 480;
	x = (screen.width-w)/2;
	y = ((screen.height-h)/2);
	y = y - (y*0.2)
	ppWin = window.open(contextPath + '?wicket:bookmarkablePage=:ch.edorex.PP.pages.flash.ReturnAddressTypeFormPage','online_editor','width='+w+',height='+h+',top='+y+',left='+x+',toolbar=no,dependent=yes,resizable=no,scrollbars=no');
	window.ppWin.focus();
}

//ATTENTION: This is called directly from the flash. If the context is changed
//we need to change this. Problem: Flash does not know its context
function prepareDownload(contextPath) {
	url = contextPath + "/?wicket:bookmarkablePage=:ch.edorex.PP.pages.flash.FlashSwitchPage";	
	if(parent) {
		if(parent.opener) {
			parent.opener.document.location = url;
			parent.close();
		} else {
			parent.document.location = url;
			parent.close();
		}
	} else {
		document.location = url;
	}
}
		
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImagesArray(array) {
	if (preloadFlag == true) {
		var d = document; var img;
		for (var i=0; i<array.length; i+=2) {
			img = null; var n = array[i];
			if (d.images) {img = d.images[n];}
			if (!img && d.getElementById) {img = d.getElementById(n);}
			if (img) {img.src = array[i+1];}
		}
	}
}

function changeImages() {
	changeImagesArray(changeImages.arguments);
}

function rowRoll(tID, isOver) {
	var theRow = document.getElementById(tID)
	theRow.style.backgroundColor = (isOver) ? '#ff6600' : '#ffffff';
	theRow.style.color = (isOver) ? '#ffffff' : '#000000';
}

function oc(id) {
	e=document.getElementById(id).style;
	if (e.display=='') {
		e.display='none';
	} else {
		e.display='';
	}
}

function visno(id) {
	e = document.getElementById(id).style;
	e.display='none';
}

function visyes(id) {
	e = document.getElementById(id).style;
	e.display='block';
}
	
function verifyNumChars(formfeld, feldname, numChars) {
	if(formfeld.value.length < numChars) {
		formfeld.style.backgroundColor = '#E4E7FF';
		formfeld.focus();
		formfeld.select();
		return false;
	} else {
		formfeld.style.backgroundColor = '#ffffff';
		return true;
	}
}

function verifyEmail(formfeld, feldname) {
	if(!isEmailAddr(formfeld.value)) {
		formfeld.style.backgroundColor = '#E4E7FF';
		formfeld.focus();
		formfeld.select();
		return false;
	} else {
		formfeld.style.backgroundColor = '#ffffff';
		return true;
	}
}

function isEmailAddr(email) {
	var result = false;
	var theStr = new String(email);
	var index = theStr.indexOf("@");
	if (index > 0) {
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
			result = true;
	}
	return result;
}

// ppeasy_bild

function setScaling(id) {
		var breite = 0;
		var hoehe = 0;
		if(id == 1) {
			breite = displayWidth;
			hoehe = (displayWidth/grafikWidth)*grafikHeight;
		} else if(id == 2) {
			breite = (displayHeight/grafikHeight)*grafikWidth;;
			hoehe = displayHeight;
		} else if(id == 3) {
			breite = displayWidth;
			hoehe = displayHeight;
		} else {
			dpiRatio = 72/grafikDpi;
			breite = grafikWidth*dpiRatio;
			hoehe = grafikHeight*dpiRatio;
		}
		var el = document.getElementById("previewBanner");
		el.width = breite;
		el.height = hoehe;
		
		if(breite < displayWidth) {
			$("grafik").style.marginLeft = parseInt(displayWidth-breite+1)+'px';
		} else {
			$("grafik").style.marginLeft = 0;
		}
	}
	
	function setColor(id) {
		var el = document.getElementById("previewBanner");
		if(id == 1) {
			el.src = fileColor;
		} else {
			el.src = fileGray;
		}
	}
	
//ppeasy_ausgabe

function deselectEtikette(id) {
	var maxed = false;
	if(id >= maxEtiketten) {
		id = maxEtiketten-1;
		maxed = true;
	}
	if(id == ersteEtikette-1 && !maxed) {
		ersteEtikette = ersteEtikette-1;
	} else {
		ersteEtikette = id+1;
	}
	var disabledLabels = document.getElementById("disabledLabels");
	disabledLabels.value = ersteEtikette-1;
	
	for(x=1; x <= anzahlX; x++) {
		for(y=1; y <= anzahlY; y++) {
			var i = (x+((y-1)*anzahlX));
			var el = document.getElementById("zelle"+i);
			if(i < ersteEtikette ) {
				el.style.backgroundColor = '#dddddd';
			} else {
				el.style.backgroundColor = '#ffffff';
			}
		}
	}
	var el = document.getElementById("nextPageTextSpan");
	var elInput = document.getElementById("nextPageText");
	if (el != null) {
		if(ersteEtikette > 1) {
			el.style.color = '#000000';
			elInput.disabled = false;
		} else {
			el.style.color = '#999999';
			elInput.disabled = true;
		}
	}
}

function selectFormatGroup(el) {
	if(el.name != "pdf") {
		if(el.checked == false) {
			$("jpg").checked = false;
			$("eps").checked = false;
			$("tif").checked = false;
			$("png").checked = false;
			//$("wmf").checked = false;
			$("bmp").checked = false;
		} else {
			if(!checkSelectedFormat()) {
				$("jpg").checked = true;
			}
		}
	}
}

function selectFormat(el) {
	if(el.checked) {
		$("zusatz").checked = true;
	} else {
		if(!checkSelectedFormat()) {
			$("zusatz").checked = false;
		}
	}
}

function checkSelectedFormat() {
	if($("jpg").checked) return true;
	if($("eps").checked) return true;
	if($("tif").checked) return true;
	if($("png").checked) return true;
	if($("bmp").checked) return true;
	return false;
}
