/*
###################################################
Allgemeine JS-Functionsbibliothek für den
Fahnenstyling24-Shop
###################################################
*/
var BIold = "";
var rndNr = 0;
var vCheckGlobal = '!!!';

var dragParam_RefreshTools = 0;
var dragParam_RefreshPreview = 0;
var dragParam_RefreshLibrary = 0;
var dragParam_RefreshStatus = 0;
var dragParam_vMain = 0;
var dragParam_vSubs = 0;
var dragParam_vID = 0;
var dragParam_xpos = 0;
var dragParam_ypos = 0;
var dragParam_xmax = 0;
var dragParam_ymax = 0;
var dragParam_UseMaxMin = 1;

var tikey = 0;

var vImgActive = new Image(8,8);
vImgActive.src = "images/tri_r.gif";

var vImgInactive = new Image(8,8);
vImgInactive.src = "images/pixel.gif";

/*
###################################################
Ajax Funktion
###################################################
*/

function http_req(vLayer, vURL, vLoadingText) {
	/* Optionale Parameter 
	*		"POST"/"GET"
	*		"ASYNC"
	*		"RETURNVALUE"
	*/
	var vLayer = vLayer;
	var ajaxRequest  = null;
	var url = vURL;
	var vResponse; 
	var vResponseXML;
	
	function AjaxCallBack() {
		if (vLayer!='') {
			if (vLoadingText!='') {
				document.getElementById(vLayer).innerHTML = vLoadingText;
			} else {
				/* Prüfen, ob dies der erste AJAX-Aufruf ist...
				* Die Initialisierung des ersten Ajax-Aufrufs kann etwas länger dauern...
				* Für diesen Fall einen kleine Mitteilung ausgeben
				*/
				if (strFirstVisit.toLowerCase() == "true") {
					/* NUR TEMPORÄR AUSKOMMENTIEREN - HIER NOCH EINE LÖSUNG SUCHEN !!! */
					
					
					//document.getElementById(vLayer).innerHTML = "<div style=\"padding:25px;\">"+strInit+"</div>";
				}
			}
		}
				
		if(ajaxRequest.readyState == 4) {
			if (ajaxRequest.status==200) {
				//setScroller();
				vResponse = ajaxRequest.responseText;
				try {
					vResponseXML = ajaxRequest.getResponseHeader("Error");
				} catch(e) {
					vResponseXML = "";
				} 
				
				if (vResponseXML != "" && vResponseXML != null) {
					if (vLayer!='') {
						document.getElementById(vLayer).innerHTML = "Error:<br>"+vResponseXML;
					}
				} else {
					if (vLayer!='' && vLayer!='divCheck') {
						document.getElementById(vLayer).innerHTML = vResponse;
					}
					vStateReturn = 1;
					try {
						if (vLayer=="divCheck") {
							isDbl = vResponse;
						}
					} catch(e) {
					
					}
					try {
						if (isBS=="Lastschrift") {
							LS_OK = vResponse;
							//LS_OK = "true";
						} else if (isBS=="Kreditkarte") {
							KK_OK = vResponse;
						}
					} catch(e) {
						
					}
					setScroller();
				}
			} else {
				try {
					vResponseXML = ajaxRequest.getResponseHeader("Error");
				} catch(e) {
					vResponseXML = "";
				} 
				if (vLayer!='') {
					document.getElementById(vLayer).innerHTML = "Status: "+ajaxRequest.status+" "+ajaxRequest.statusText+"\n\n"+ajaxRequest.responseText;
				}
				ajaxRequest.abort();
				vResponse = "ERROR";
				if (vLayer!='') {
				//	document.getElementById(vLayer).innerHTML = vResponse;
				}
			//LS_OK = "true";
			ajaxRequest = null;
			}
		} 
	}
	
	var vAsync = (arguments[4] == false) ? false : true;
	var formname = (arguments[5]) ? arguments[5] : "editForm";
	try {
		if (arguments[3] == "POST") {
			var postdata = "";
			for (var a=0; a<document.forms[formname].elements.length; a++) {
				postdata = postdata+document.forms[formname].elements[a].name+"="+escape(document.forms[formname].elements[a].value)+"&";
			}
		}
		
		ajaxRequest = new XMLHttpRequest();
		if (arguments[3] == "POST") {
			ajaxRequest.open("POST", url, true);
			ajaxRequest.onreadystatechange = AjaxCallBack;
			ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=iso-8859-1");
   		ajaxRequest.setRequestHeader("Content-length", postdata.length);
   		ajaxRequest.setRequestHeader("Connection", "close");
			ajaxRequest.send(postdata);
			
		} else {
			ajaxRequest.open("GET", url, vAsync);
			
			if (vAsync==false) {
				ajaxRequest.send(null);
				if (ajaxRequest.status==200) {
					vResponse = ajaxRequest.responseText;
					try {
						vResponseXML = ajaxRequest.getResponseHeader("Error");
					} catch(e) {
						vResponseXML = "";
					} 
					
					if (vResponseXML != "" && vResponseXML != null) {
						if (vLayer!='') {
							document.getElementById(vLayer).innerHTML = "Error:<br>"+vResponseXML;
						}
					} else {
						if (vLayer!='') {
							document.getElementById(vLayer).innerHTML = vResponse;
						}
						vStateReturn = 1;
						try {
							if (vLayer=="divCheck") {
								isDbl = vResponse;
							}
						} catch(e) {
						
						}
						try {
							if (isBS=="Lastschrift") {
								LS_OK = vResponse;
								//LS_OK = "true";
							} else if (isBS=="Kreditkarte") {
								KK_OK = vResponse;
							}
						} catch(e) {
							
						}
						setScroller();
					}
				} else {
					try {
						vResponseXML = ajaxRequest.getResponseHeader("Error");
					} catch(e) {
						vResponseXML = "";
					} 
					if (vLayer!='') {
						document.getElementById(vLayer).innerHTML = "Status: "+ajaxRequest.status+" "+ajaxRequest.statusText+"\n\n"+ajaxRequest.responseText;
					}
					ajaxRequest.abort();
					vResponse = "ERROR";
					if (vLayer!='') {
					//	document.getElementById(vLayer).innerHTML = vResponse;
					}
					//LS_OK = "true";
					ajaxRequest = null;
				}
			} else {
				ajaxRequest.onreadystatechange = AjaxCallBack;
				ajaxRequest.send(null);
			}
		}
	} catch(e) {
		try {
			ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			if (ajaxRequest) {
				if (arguments[3] == "POST") {
					ajaxRequest.open("POST", url, vAsync);
					ajaxRequest.onreadystatechange = AjaxCallBack;
					var postdata = "";
					for (var a=0; a<document.forms[formname].elements.length; a++) {
						
						postdata = postdata+document.forms[formname].elements[a].name+"="+escape(document.forms[formname].elements[a].value)+"&";
					}
					ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
      		ajaxRequest.setRequestHeader("Content-Length", postdata.length);
      		//ajaxRequest.setRequestHeader("Connection", "close");
					ajaxRequest.send(postdata);
				} else {
					ajaxRequest.open("GET", url, vAsync);
					ajaxRequest.onreadystatechange = AjaxCallBack;
					ajaxRequest.send();
				}
			}
		} catch(e) {
			if (vLayer!='') {
				document.getElementById(vLayer).innerHTML = e;
			}
		}
	}
}

/*
###################################################
Tu Gar Nichts Funktion
###################################################
*/
function doVoid() { }
function doLink() { }

/*
###################################################
Stellt die Bibliothek per Ajax dar.
###################################################
*/
function setLibrary(vMain, vSubs, vID) {
	try {
		http_req('divLibrary', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'&id='+vID+'','');
	} catch(e) { }
}

/*
###################################################
Erzeugt per Ajax die Vorschau-Grafik auf Basis
aller Baukasten-Aktionen
###################################################
*/
function setPreview() {
	try {
		http_req('divPreview', 'library.asp?do=setPreview','');
	} catch(e) { }
}

/*
###################################################
Aktualisiert per Ajax den Status-Bereich
###################################################
*/
function setStatus() {
	try {
		http_req('divStatus', 'library.asp?do=setStatus','');
	} catch(e) { }
}


/*
###################################################
Initialisierung der Direktlinks
flagge.asp
motiv.asp
text.asp
warenkorb.asp
###################################################
*/
	function initFS(vMain,vSubs) {
		try {
			checkTracking(vMain, vSubs);
			if (vMain == 5) {
				http_req('divPreview', 'kdFuncs.asp?do=showPositions&oid=0','');
				http_req('divLibrary', 'kdFuncs.asp?do=showorder&kid=0','');
			} else {
				checkMenu(vMain,vSubs,'init');
			}
		} catch(e) { }
	}

/*
###################################################
WICHTIG !!!
Erst alle Sessions aktualisieren, da mit diesen
weitergebaut wird.
Erst danach können andere Dinge wie Bibliothek,
Preview, etc. erzeugt werden!!!
Dafür die doXXX() und deie checkXXX()
###################################################
*/

/*
###################################################
Initialisierung Tracking bei Einsprung über
Direktlink
###################################################
*/
function doTracking(vMain, vSubs, vNext) {
	try {
		/* SESSIONS + TRACKING abhängig von der aktuellen Auswahl aktualisieren */
		/* Erst wenn die Sessions neu gesetzt wurden kann es weiter gehen !!! */
		//alert("doTracking:"+vMain+"/"+vSubs+"/"+vNext);
		http_req('', 'library.asp?do=tracking&main='+vMain+'&subs='+vSubs+'&next='+vNext+'','','GET',false);
		checkTracking(vMain,vSubs);
	} catch(e) { }
}

/*
###################################################
Ablaufverfolgung bei Einsprung über Direktlink
###################################################
*/
function checkTracking(vMain, vSubs) {
	//alert("checkTracking:"+vMain+"/"+vSubs);
	http_req('divTools', 'library.asp?do=menu&main='+vMain+'&subs='+vSubs+'','');
	if (vMain>0) {
		if (vMain==4) {
			if (vSubs==0) {
				http_req('divPreview', 'library.asp?do=library&main='+vMain+'&subs=0&dontshow=false','');
				http_req('divLibrary', 'library.asp?do=library&main='+vMain+'&subs=0&shownew=true','');
			} else {
				http_req('divPreview', 'library.asp?do=library&main='+vMain+'&subs=0&dontshow=true','');
				http_req('divLibrary', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'','');
			}
			setStatus();
		} else if (vMain == 5) {
				http_req('divPreview', 'kdFuncs.asp?do=showPositions&oid=0','');
				http_req('divLibrary', 'kdFuncs.asp?do=showorder&kid=0','');
		} else {
			http_req('divLibrary', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'','');
			if (vMain!=5) {
				setStatus();
				setPreview();
			}
		}
	}
}

/*
###################################################
Initialisierung bei Ajax/Menülink
###################################################
*/
function doMenu(vMain, vSubs, vNext) {
//alert("doMenu:"+vMain+"/"+vSubs+"/"+vNext);
	http_req('', 'library.asp?do=tracking&main='+vMain+'&subs='+vSubs+'&next='+vNext+'','','GET',false);
	checkMenu(vMain,vSubs);
}

/*
###################################################
Ablaufverfolgung bei Ajax/Menülink
###################################################
*/
function checkMenu(vMain, vSubs) {
	if (vMain==4) {
		if (vSubs==0) {
			http_req('divPreview', 'library.asp?do=library&main='+vMain+'&subs=0&dontshow=false','');
		} else {
			http_req('divPreview', 'library.asp?do=library&main='+vMain+'&subs=0&dontshow=true','');
		}
		if (vSubs!=0) {
			http_req('divLibrary', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'','');
		} else {
			http_req('divLibrary', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'&shownew=true','');
		}
		try {
			document.getElementById("divCart_change").style.display="none";
			document.getElementById("divCart_nochange").style.display="block";
			document.getElementById("divPreview").innerHTML = "&nbsp;";
			document.getElementById("trCart").vAlign="top";
			document.getElementById("tdCart").align="left";
		} catch (e) { }
		
		try {
			http_req('IDNavDesc', 'library.asp?do=setNavigationDesc&main='+vMain+'&subs='+vSubs+'','');
			http_req('IDNav', 'library.asp?do=setNavigation&main='+vMain+'&subs='+vSubs+'','');
		} catch(e) { alert(e); }
		
	} else if (vMain!=5)  {
		if (arguments[2] == 'init') {
		} else {
			if (vMain!=0) {
				http_req('divLibrary', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'','');
			}
		}
		try {
			http_req('IDNavDesc', 'library.asp?do=setNavigationDesc&main='+vMain+'&subs='+vSubs+'','');
			http_req('IDNav', 'library.asp?do=setNavigation&main='+vMain+'&subs='+vSubs+'','');
		} catch(e) { alert(e); }
		
	}
	//setValueMain	= parseInt(vMain);
	//setValueSub	= parseInt(vSubs)+1;
	if (document.getElementById("divHelp").style.display=="block") {
		displaySub(parseInt(vMain));
		displayHelp(parseInt(vMain),parseInt(vSubs)+1);
	}
}

/*
###################################################
Textwerte mit allen Sonderzeichen und Umlauten 
richtig encoden
###################################################
*/
function encodeURL(s) { 
	var s_temp = ""; 
	if (s.length > 1) {
		for (var a=0; a< s.length; a++) { 
			s_temp += "%"+((s.charCodeAt(a).toString(16).length == 1) ? '0'+s.charCodeAt(a).toString(16) : s.charCodeAt(a).toString(16)); 
		} 
	} else {
		s_temp = s;
	}
	
	return s_temp; 
}

/*
###################################################
Das Herzstück!
Erst ein paar Sessions aktualisieren und dann 
- abhängig von den übergebenen Refresh-Parametern -
die anderen Baukasten-/Seitenelemente aktualisieren
###################################################
*/
function setValue(vRefreshTools, vRefreshPreview, vRefreshLibrary, vRefreshStatus, vMain, vSubs, vID,vImgID,vImgIDPrefix) {

var vPrefix = "ID";
setValueMain	= vMain;
setValueSub	= vSubs;

	
	try {
		if (typeof vImgIDPrefix!='undefined') {
			vPrefix = vImgIDPrefix;
		}
		if (typeof vImgID!='undefined') {
			if (vRefreshPreview==1) {
				document.getElementById("divProcess").style.display = "block";
			}
			
			for (var a=1; document.getElementById(vPrefix+a)!=null; a++) {
				if (document.getElementById(vPrefix+a).tagName=="IMG" || document.getElementById(vPrefix+a).tagName=="TD") {
					if (String(vID).indexOf("setClipart") >= 0) {
						document.getElementById(vPrefix+a).style.border = "0px solid #000000";
					} else {
						if (vMain==3 && vSubs==1) {
							document.getElementById(vPrefix+a).style.border = "3px solid #FFFFFF";
						} else {
							document.getElementById(vPrefix+a).style.border = "1px solid #000000";
							document.getElementById(vPrefix+a).style.backgroundColor = "#FFFFFF";
						}
					}
				} else {
					if (document.getElementById(vPrefix+a).tagName=="SPAN") {
						document.getElementById(vPrefix+a).style.border = "0px solid #000000";
						document.getElementById(vPrefix+a).className = "kons";
						try {
							document.getElementById("A"+vPrefix+a).style.color = "#"+ color2;
							document.images["I"+vPrefix+a].src = vImgInactive.src;
						} catch(e) { }
					}
				}
			}
			if (document.getElementById(vPrefix+vImgID).tagName=="IMG" || document.getElementById(vPrefix+vImgID).tagName=="TD") {
				document.getElementById(vPrefix+vImgID).style.border = "3px solid #000000";
				if (vMain==3 && vSubs==1) { 
				} else {
					document.getElementById(vPrefix+vImgID).style.backgroundColor = "#CCCCCC";
				}
			} else {
				if (document.getElementById(vPrefix+vImgID).tagName=="SPAN") {
					document.getElementById(vPrefix+vImgID).className = "konsf";
					try {
						document.getElementById("A"+vPrefix+vImgID).style.color = "#000000";
						document.images["I"+vPrefix+vImgID].src = vImgActive.src;
					} catch(e) {  }
				}
			}
		}
	} catch (e) {

	}
	
	if (vMain==3 && vSubs==0 && vID.indexOf("set") == -1) {
		clearTimeout(tikey);
		tikey = 0;
		var vValueTxt = encodeURL(document.getElementById("txtvalue").value);
		vValueTxt = vValueTxt.replace(/%0d%0a/,'%0a');
		vValueTxt = vValueTxt.replace(/%0d/,'%0a');
		http_req('', 'library.asp?do=setvalue&main='+vMain+'&subs='+vSubs+'&id='+vValueTxt+'','','GET',false);
	} else if (vMain==4 && vSubs==0 && vID.indexOf("set") >=-1) {
		http_req('', 'library.asp?do=setvalue&main='+vMain+'&subs='+vSubs+'&id='+encodeURL(vID)+'','','GET',false);
	} else {
		http_req('', 'library.asp?do=setvalue&main='+vMain+'&subs='+vSubs+'&id='+encodeURL(vID)+'','','GET',false);
	}
	checkValue(vMain,vSubs,vRefreshTools,vRefreshPreview,vRefreshLibrary,vRefreshStatus);
	if (document.getElementById("divDetail")!=null) {
		if (vMain==1 && vSubs == 2 && (vID == 2 || String(vID).indexOf("-1") == 0)) {
			if (strUA!="gecko") {
				document.getElementById("divDetail").style.display = "block";
			} else {
				document.getElementById("divDetail").style.display = "table-row";
			}
		} else {
			if (vID == -1 || (vMain==1 && vSubs==1)) {
				document.getElementById("divDetail").style.display = "block";
			} else if (String(vID).indexOf("-1") == 0) {
				if (vMain==4) {
					try {
						if (String(vID).indexOf("Vorkasse") > 0) {
							document.getElementById("divDetail").style.display = "none";
						} else {
							if (strUA!="gecko") {
								document.getElementById("divDetail").style.display = "block";
							} else {
								document.getElementById("divDetail").style.display = "table-row";
							}
							if (String(vID).indexOf("set") == -1) {
								http_req('divZA','zahlungsart.asp?za='+String(vID).replace(/-1\//,"")+'','');
							}
						}
					} catch(e) { }
				} else {
					document.getElementById("divDetail").style.display = "block";
				}
			}	else {
				if (String(vID).indexOf("set")==-1) {
					document.getElementById("divDetail").style.display = "none";
				}
			}
		}
	} 
}

/*
###################################################
Ablaufverfolgung vom Herzstück und Darstellung
der anderen Baukasten-/Seitenbereiche abhängig von
den übergebenen Refresh-Parametern
###################################################
*/
function checkValue(vMain, vSubs, vRefreshTools, vRefreshPreview, vRefreshLibrary, vRefreshStatus) {
	if (vRefreshTools==1) {
		if (document.getElementById('IDNav')) {
			//alert("checkvalue:"+vMain+"/"+vSubs);
			http_req('', 'library.asp?do=tracking&main='+vMain+'&subs='+vSubs+'&next=no','','GET',false);
			http_req('divTools', 'library.asp?do=menu&main='+vMain+'&subs='+vSubs+'','');
			try {
				http_req('IDNavDesc', 'library.asp?do=setNavigationDesc&main='+vMain+'&subs='+vSubs+'','');
				http_req('IDNav', 'library.asp?do=setNavigation&main='+vMain+'&subs='+vSubs+'','');
			} catch(e) { alert(e); }
		} else {
			http_req('divTools', 'library.asp?do=menu&main='+vMain+'&subs='+vSubs+'','');
		}		
	}
	if (vRefreshLibrary==1) {
		if (vMain==4 && vSubs==0) {
			http_req('divPreview', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'','');
			setStatus();
		} else {
			http_req('divLibrary', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'','');
		}
	}
	
	if (vRefreshStatus==1) {
		setStatus();
	}
	if (vRefreshPreview==1) {
		if (vMain!=4) {
			setPreview();
		}
	} else {
		try {
			closeProgress();
		} catch (e) { }
	}
	vStateReturn = 0;
}

/*
###################################################
Clientseitiger Check auf korrekte Dateiendungen 
beim Upload
###################################################
*/


var _count = 0;
	var _root = null;
	var _interval = null;
	
	doProgress = function() {
		_root = document.getElementById('divProcess');
		if (_root) {
			_interval = setInterval('doInterval()',500);
		}
	}
	
	doInterval = function() {
		_count+=1;
		if (_count==1 || (_count % 4 == 0)) {
			_root.innerHTML = 'Lade';
		} else {
			_root.innerHTML += '.';
		}

			

		if (_count>=200) {
			clearInterval(_interval);
		}
	}

function checkFile() {
	var vFile = document.forms["uplForm"].elements["filename"].value;
	var vExt = vFile.substr(vFile.lastIndexOf(".")+1,vFile.length-vFile.lastIndexOf(".")+1);
	vExt = vExt.toLowerCase();
	if (vExt=="bmp" || vExt=="jpg" || vExt=="jpeg" || vExt=="png" || vExt=="eps" || vExt=="tif") {
		if (strUA=="ie" && (strUAVersion=="7.0" || strUAVersion=="8.0")) {
			document.getElementById('divProcess').style.fontWeight = "bold";
			document.getElementById('divProcess').style.paddingTop = "15px";
			document.getElementById('divProcess').innerHTML = 'Lade';
			doProgress();		
			document.getElementById('divProcess').style.display = 'block';
			document.forms["uplForm"].submit();
		} else {
			document.getElementById('divProcess').style.display = 'block';
			document.forms["uplForm"].submit();
			if (document.getElementById('pImg')) {
				document.getElementById('pImg').src = 'images/progress.gif';
			}
		}
		
		
	} else {
		alert (errWrongFormat);
	}
}	

/*
###################################################
Fenster für die große Vorschau erstellen und 
große Vorschau laden
###################################################
*/
function openPreview() {
	var winOpen = window.open("preview.asp","preview","width=800,height=600,scrollbars=yes");
	winOpen.focus();
}

/*
###################################################
Drag & Drop Positionierung Motiv/Text
Initialisierung
###################################################
*/
function fDragStart(event,vRefreshTools, vRefreshPreview, vRefreshLibrary, vRefreshStatus, vMain, vSubs, vID, vXMax, vYMax,vUseMaxMin) {
	var x,y;
	var vPos;
	vPos = vID.split("/");
	dragParam_xpos = vPos[0];
	dragParam_ypos = vPos[1];
	dragParam_RefreshTools = vRefreshTools;
	dragParam_RefreshPreview = vRefreshPreview;
	dragParam_RefreshLibrary = vRefreshLibrary;
	dragParam_RefreshStatus = vRefreshStatus;
	dragParam_vMain = vMain;
	dragParam_vSubs = vSubs;
	dragParam_vID = vID;
	//alert (document.getElementById("divPositionMain").offsetLeft);
	//dragParam_xmax = parseInt(vXMax-document.getElementById("divPositionMain").offsetLeft-10);
	//dragParam_ymax = parseInt(vYMax-document.getElementById("divPositionMain").offsetTop-15);
	dragParam_xmax = vXMax;
	dragParam_ymax = vYMax;
	dragParam_UseMaxMin = vUseMaxMin;
	if (strUA!="gecko") {
		elNode = window.event.srcElement;
		elNode = document.getElementById("divPosition");
		x = window.event.clientX + window.document.documentElement.scrollLeft + window.document.body.scrollLeft;
    y = window.event.clientY + window.document.documentElement.scrollTop + window.document.body.scrollTop;
	} else {
		elNode = event.target;
		elNode = document.getElementById("divPosition");
		x = event.clientX + window.scrollX;
    y = event.clientY+ window.scrollY;
	}
	cursorStartX = x;
	cursorStartY = y;
	if (strUA!="gecko") {
		elStartLeft  = parseInt(window.document.getElementById("divPosition").style.left, 10);
  	elStartTop   = parseInt(window.document.getElementById("divPosition").style.top,  10);
	} else {
		elStartLeft  = parseInt(window.document.getElementById("divPosition").style.left, 10);
  	elStartTop   = parseInt(window.document.getElementById("divPosition").style.top,  10);
	}
	if (isNaN(elStartLeft)) elStartLeft = 0;
	if (isNaN(elStartTop)) elStartTop  = 0;
	if (strUA!="gecko") {  
		window.document.attachEvent("onmousemove", fDragGo);
		window.document.attachEvent("onmouseup", fDragStop);
		window.event.cancelBubble = true;
    window.event.returnValue = false;
	} else {
		window.document.addEventListener("mousemove", fDragGo,   true);
	    window.document.addEventListener("mouseup",   fDragStop, true);
	    event.preventDefault();
	}
}
		
/*
###################################################
Drag & Drop Positionierung Motiv/Text
Verschieben
###################################################
*/
function fDragGo(event) {
	var x,y;
	if (window.event) {
		var xMin = 0;
		var xMax = parseInt(vFlagge_Width)  - (dragParam_xmax+2);
		var yMin = 0;
		var yMax = parseInt(vFlagge_Height) - (dragParam_ymax+2);
	} else {
		var xMin = 0;
		var xMax = parseInt(vFlagge_Width)  - (dragParam_xmax+2);
		var yMin = 0;
		var yMax = parseInt(vFlagge_Height) - (dragParam_ymax+2);
	}
	if (strUA!="gecko") {
		x = window.event.clientX + window.document.documentElement.scrollLeft + window.document.body.scrollLeft;
    y = window.event.clientY + window.document.documentElement.scrollTop + window.document.body.scrollTop;
 		//window.status = dragParam_UseMaxMin + " - " + dragParam_vMain;
		if ((elStartLeft + x - cursorStartX)<xMin) {
			window.document.getElementById("divPosition").style.left = xMin+"px"
		} 
		if ((elStartLeft + x - cursorStartX)>xMax) {
			window.document.getElementById("divPosition").style.left = xMax+"px"
		} 
		if (dragParam_UseMaxMin == 1) {
			if ((elStartLeft + x - cursorStartX)>xMin && (elStartLeft + x - cursorStartX)<xMax) {
				window.document.getElementById("divPosition").style.left = (elStartLeft + x - cursorStartX)+"px";
			} 
		} else {
			window.document.getElementById("divPosition").style.left = (elStartLeft + x - cursorStartX)+"px";
		}
		
		if ((elStartTop + y - cursorStartY)<yMin) {
			window.document.getElementById("divPosition").style.top = yMin+"px"
		} 
		if ((elStartTop + y - cursorStartY)>yMax) {
			window.document.getElementById("divPosition").style.top = yMax+"px"
		} 
		if (dragParam_UseMaxMin == 1) {
			if ((elStartTop + y - cursorStartY)>yMin && (elStartTop + y - cursorStartY)<yMax) {
				window.document.getElementById("divPosition").style.top = (elStartTop + y - cursorStartY)+"px";
			} 
		} else {
			window.document.getElementById("divPosition").style.top = (elStartTop + y - cursorStartY)+"px";
		}

		window.event.cancelBubble = true;
	 	window.event.returnValue = false;
	} else {
		x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
 		if ((elStartLeft + x - cursorStartX)<xMin) {
			window.document.getElementById("divPosition").style.left = xMin+"px"
		} 
		if ((elStartLeft + x - cursorStartX)>xMax) {
			window.document.getElementById("divPosition").style.left = xMax+"px"
		} 
		if (dragParam_UseMaxMin == 1) {
			if ((elStartLeft + x - cursorStartX)>xMin && (elStartLeft + x - cursorStartX)<xMax) {
				window.document.getElementById("divPosition").style.left = (elStartLeft + x - cursorStartX)+"px";
			} 
		} else {
			window.document.getElementById("divPosition").style.left = (elStartLeft + x - cursorStartX)+"px";
		}
		
		if ((elStartTop + y - cursorStartY)<yMin) {
			window.document.getElementById("divPosition").style.top = yMin+"px"
		} 
		if ((elStartTop + y - cursorStartY)>yMax) {
			window.document.getElementById("divPosition").style.top = yMax+"px"
		} 
		if (dragParam_UseMaxMin == 1) {
			if ((elStartTop + y - cursorStartY)>yMin && (elStartTop + y - cursorStartY)<yMax) {
				window.document.getElementById("divPosition").style.top = (elStartTop + y - cursorStartY)+"px";
			} 
		} else {
			window.document.getElementById("divPosition").style.top = (elStartTop + y - cursorStartY)+"px";
		}
		event.preventDefault();
	}
}

/*
###################################################
Drag & Drop Positionierung Motiv/Text
Beenden und Werte zurück
Preview neu erzeugen
###################################################
*/
fDragStop = function (event) {
	if (strUA!="gecko") {
		window.document.detachEvent("onmousemove", fDragGo);
    window.document.detachEvent("onmouseup",   fDragStop);
	} else {
		window.document.removeEventListener("mousemove", fDragGo,   true);
    window.document.removeEventListener("mouseup",   fDragStop, true);
	}
	setValue(dragParam_RefreshTools, dragParam_RefreshPreview, dragParam_RefreshLibrary, dragParam_RefreshStatus, dragParam_vMain, dragParam_vSubs, window.document.getElementById("divPosition").style.left +"/" +window.document.getElementById("divPosition").style.top);

}


function closeProgress() {
	setTimeout("closePFuncs();",500); 
}

function closePFuncs() {
	try {
		document.getElementById("divProcess").style.display = "none";
	} catch (e) {
	
	}
	try {
		document.getElementById("divProcessCart1").style.display = "none";
		document.getElementById("divProcessCart").style.display = "none";
	} catch (e) {
	
	}
}


function setScroller() {
	var vStrHeight = 0;
	if (document.getElementById("scroller") || document.getElementById("divCart_change") || document.getElementById("scrollera1")) {
		if (document.getElementById("pathID")) {
			/* Pfad vorhanden - also bin ich bei den Motiven */
			if (document.body.clientHeight > 200) {
				vStrHeight = (strUA=='gecko') ? 135 : 144 ;
				document.getElementById("scroller").style.height = document.body.clientHeight-vStrHeight+'px';
			}
		} else {
			if (document.getElementById("divCart_change") || document.getElementById("scrollera1")) {
				if (document.body.clientHeight > 350) {
					try {
						vStrHeight = (strUA=='gecko') ? 135 : 144 ;
						document.getElementById("scrollera1").style.height = document.body.clientHeight-vStrHeight+'px';
						
					} catch(e) { }
					try {
						vStrHeight = (strUA=='gecko') ? 306 : 297 ;
						document.getElementById("scrollera").style.maxHeight = document.body.clientHeight-vStrHeight+'px';
						if (document.getElementById("scrollera").offsetHeight >=document.body.clientHeight-306) {
							document.getElementById("scrollera").style.height = document.body.clientHeight-vStrHeight+'px';
						}
					} catch(e) { }
					//window.status = document.body.clientHeight + "/"+document.getElementById("scrollera1").style.height +" / "+document.getElementById("scrollera").offsetHeight
				}
				
			} else {
				if (document.body.clientHeight > 200) {
					vStrHeight = (strUA=='gecko') ? 135 : 144 ;
					document.getElementById("scroller").style.height = document.body.clientHeight-vStrHeight+'px';
				}
			}
		}
	}
}

function toCart(vChange) {
	try {
		http_req('divPreview', 'library.asp?do=tocart&change='+vChange+'','','GET',false);
		checkCart();
	} catch (e) { }
}

function checkCart() {
	var oldHTML = document.getElementById("divWarenkorb").innerHTML;
	var newHTML = "<a href=\"javascript:doLink();\" onclick=\"check('warenkorb.asp');\">"+oldHTML+"</a>";
	if (document.getElementById("linkWarenkorb")) {
	} else {
		document.getElementById("divWarenkorb").innerHTML = newHTML;
	}
	if (window.event) {
		var e1 = window.event;
		e1.returnValue = false;
	}
	window.location.href = vHTTPS+vAbsPath+"/warenkorb.asp";
}

function deleteObject(vPID, vMain, vSubs) {
	try {
		http_req('divPreview', 'library.asp?do=deleteobject&id='+vPID+'','','GET',false);
		checkDelete(vMain,vSubs);
	} catch (e) { }
}

function checkDelete(vMain, vSubs) {
	http_req('divPreview', 'library.asp?do=library&main='+vMain+'&subs='+vSubs+'','');
	setStatus();
}


function loadObject(vPID, vMain, vSubs) {
	if (window.event) {
		window.event.returnValue = false;
	}
	try {
		http_req('divLibrary', 'library.asp?do=loadobject&main='+vMain+'&subs='+vSubs+'&id='+vPID+'','','GET',false);
		checkLoaded(vMain,vSubs);
	} catch (e) { }
}

function checkLoaded(vMain,vSubs) {
	window.location.href = vHTTP+vAbsPath+"/flagge.asp";
}

function reloadObject(vPID, vMain, vSubs) {
	if (window.event) {
		window.event.returnValue = false;
	}
	try {
		http_req('divPreview', 'library.asp?do=moveobject&main=5&subs=0&id='+vPID+'','','GET',false);
		http_req('divPreview', 'library.asp?do=reloadobject&main=5&subs=0&id='+vPID+'','','GET',false);
		recheckLoaded(vMain,vSubs);
	} catch (e) { }
}

function recheckLoaded(vMain,vSubs) {
	window.location.href = vHTTP+vAbsPath+"/flagge.asp";
}


function newFlag(vMain,vSubs) {
	if (window.event) {
		window.event.returnValue = false;
	}
	try {
	http_req('','library.asp?do=newflag&main='+vMain+'&subs='+vSubs+'','','GET',false);
		checkFlag(vMain,vSubs);
	} catch (e) {
	
	}
}

function checkFlag(vMain, vSubs) {
	window.location.href = vHTTP+vAbsPath+"/flagge.asp";
}



function fOrderSub() {
	try {
		document.getElementById("divProcessCart").style.display = "block";
		document.getElementById("divProcessCart1").style.display = "block";
		document.getElementById("btnSubmitID1").style.display = "none";
		document.getElementById("btnSubmitID2").style.display = "block";
	} catch (e) {
	}
}

function fOrder(vMain,vSubs,vKID) {
	if (window.event) {
		window.event.returnValue = false;
	}
	try {
		http_req('divPreview', 'library.asp?do=order&main='+vMain+'&subs='+vSubs+'','','GET',false);
		checkOrder(vMain,vSubs,vKID);
	} catch (e) { }
}

function checkOrder(vMain, vSubs,vKID) {
	closeProgress();
	window.location.href = vHTTP+vAbsPath+"/index.asp?new=true&order=true&kid="+vKID;
}

function setLiefer() {
	try {
		if (document.getElementById("divLiefer").style.display=="none") {
			document.getElementById("divLiefer").style.display = "block";
			http_req('divrLand','land.asp?change=true','');
		} else {
			document.getElementById("divLiefer").style.display = "none";
			http_req('divrLand','land.asp?change=false','');
		}
	} catch (e) { }
}


var xposScr = 0;
var starterScr = 0;
var vDir=0; /* 0 = runter; 1 = rauf */

function fScroller(vShow,vMain,vSubs) {
	if (window.event) {
		window.event.returnValue = false;
	}
	if (starterScr != 0) {
		clearInterval(starterScr);
		starterScr = 0;
		vDir = (vDir == 0) ? 1 : 0 ;
	}
	if (vShow==2) {
		starterScr = setInterval("fScroller1(0,"+vMain+","+vSubs+")",1);
	} else {
		starterScr = setInterval("fScroller1("+vShow+","+setValueMain+","+setValueSub+")",1);
	}
}
	
function fScroller1(vShow,vMain,vSubs) {
	var vElementToShow = (vDir == 1)  ? ((document.getElementById("divHelp").style.display=="block") ? document.getElementById("divHelp") : document.getElementById("divLogin")) : ((vShow==0) ? document.getElementById("divHelp") : document.getElementById("divLogin"));
	var xposScrMax =  (vDir == 1)  ? ((document.getElementById("divHelp").style.display=="block") ? 130 : 55) : ((vShow==0) ? 130 : 55);
//window.status = xposScrMax;
	if (vDir == 0) {
		if (xposScr ==0) {
			displaySub(vMain);
			if(vMain!=0) {
				displayHelp(vMain,vSubs);
			} else {
				setValueMain = 0;
				setValueSub = 0;
			}
			vElementToShow.style.display = "block";
		}
		if (xposScr < xposScrMax) {
		} else {
			vDir = 1;
			clearInterval(starterScr);
			starterScr = 0;
		}
	} else {
		if (xposScr > 0) {
		} else {
			document.getElementById('tblScroll').style.height = "6px";
			vElementToShow.style.height = "0px";	
			vDir = 0;
			xposScr = 0;
			clearInterval(starterScr);
			starterScr = 0;
			vElementToShow.style.display = "none";
		}
	}
	if (starterScr!=0) {
		var vLayerMain = document.getElementById("tblScrollMain");
		if (vDir==0) {
			xposScr += 10;
			document.getElementById('tblScroll').style.height = parseInt(document.getElementById('tblScroll').style.height) + 10 +"px";
			vElementToShow.style.height = (parseInt(document.getElementById('tblScroll').style.height)-7 < 0) ? "0px" : parseInt(document.getElementById('tblScroll').style.height)-7+"px" ;
		} else {
			xposScr -= 10;
			document.getElementById('tblScroll').style.height = (parseInt(document.getElementById('tblScroll').style.height) - 10 < 0) ? "0px" : parseInt(document.getElementById('tblScroll').style.height) - 10 +"px";
			(parseInt(document.getElementById('tblScroll').style.height) == 0) ? xposScr = -10 : xposScr = xposScr;
			vElementToShow.style.height = (parseInt(document.getElementById('tblScroll').style.height)-7 < 0) ? "0px" : parseInt(document.getElementById('tblScroll').style.height)-7+"px" ;	
		}
	}
	return false;
}

function showPopup(vShow) {
	var vPopup = document.getElementById("divPopup");
	var vWidth = document.getElementsByTagName("body")[0].offsetWidth-100;
	var vHeight = document.getElementsByTagName("body")[0].offsetHeight-100;
	if (vPopup.style.display == "block" && vShow!=5) {
		vPopup.style.display = "none";
	} else {
		document.getElementById("divPopupContent").innerHTML = "";
		document.getElementById("divPopup").style.top = document.body.scrollTop + "px";
		if (vShow==4) {
			document.getElementById("divPopupContent").style.padding = "20px";
			document.getElementById("tdPreview").align = "center";
			document.getElementById("trPreview").vAlign = "middle";
			document.getElementById("divPopup").style.width=(parseInt(document.getElementById("divPositionMain").style.width)*2)+100+"px";
			document.getElementById("divPopup").style.height=(parseInt(document.getElementById("divPositionMain").style.height)*2)+100+"px";
			document.getElementById("divPopup").style.left=(document.getElementsByTagName("body")[0].offsetWidth-parseInt(document.getElementById("divPopup").style.width)-100)/2+"px";
			document.getElementById("divPopup").style.top=parseInt(document.getElementById("divPopup").style.top)+30+"px";
			document.getElementById("divPopupContent1").style.width = parseInt(document.getElementById("divPopup").style.width)+"px";
			document.getElementById("divPopupContent1").style.height = parseInt(document.getElementById("divPopup").style.height)-26+"px";
		} else if (vShow==5 || vShow==8) { 
			document.getElementById("divPopupContent").style.padding = "0px";
			document.getElementById("divPopupContent").style.paddingTop = "10px";
			document.getElementById("divPopupContent").style.paddingBottom = "10px";
			document.getElementById("tdPreview").align = "left";
			document.getElementById("trPreview").vAlign = "top";
			if (vShow==8) {
				document.getElementById("divPopup").style.width = "300px";
				document.getElementById("divPopup").style.height = "150px";	
			} else {
				document.getElementById("divPopup").style.width = "300px";
				document.getElementById("divPopup").style.height = vHeight+"px";
			}
			if (vShow==8) {
				document.getElementById("divPopup").style.left = parseInt(document.getElementById("divPreview").offsetWidth)+"px";
				document.getElementById("divPopup").style.top = parseInt(document.getElementById("divPopup").style.top)+250+"px";
			} else {
				document.getElementById("divPopup").style.left = parseInt(document.getElementById("divLibrary").offsetWidth)+150+"px";
				document.getElementById("divPopup").style.top = parseInt(document.getElementById("divPopup").style.top)+50+"px";
			}
			
			if (vShow==8) {
				document.getElementById("divPopupContent1").style.width = "300px";
				document.getElementById("divPopupContent1").style.height = 150-26+"px";
			} else {
				document.getElementById("divPopupContent1").style.width = "300px";
				document.getElementById("divPopupContent1").style.height = vHeight-26+"px";
			}
		}  else if (vShow==6) { 
			document.getElementById("tdPreview").align = "center";
			document.getElementById("trPreview").vAlign = "middle";
			document.getElementById("divPopupContent").style.padding = "20px";
			document.getElementById("divPopup").style.width = 800+"px";
			document.getElementById("divPopup").style.height = 350+"px";
			document.getElementById("divPopup").style.left = "50px";
			document.getElementById("divPopup").style.top = parseInt(document.getElementById("divPopup").style.top)+50+"px";
			document.getElementById("divPopupContent1").style.width = 800+"px";
			document.getElementById("divPopupContent1").style.height = 350-26+"px";
		
		} else { 
			if (vShow==9) {
				document.getElementById("divPopupContent").style.padding = "20px";
				document.getElementById("tdPreview").align = "center";
				document.getElementById("trPreview").vAlign = "middle";
				/*	document.getElementById("divPopup").style.width=(parseInt(document.getElementById("divPositionMain").style.width)*2)+100+"px";
				document.getElementById("divPopup").style.height=(parseInt(document.getElementById("divPositionMain").style.height)*2)+100+"px";
				document.getElementById("divPopup").style.left=(document.getElementsByTagName("body")[0].offsetWidth-parseInt(document.getElementById("divPopup").style.width)-100)/2+"px";
				document.getElementById("divPopup").style.top=parseInt(document.getElementById("divPopup").style.top)+30+"px";
				document.getElementById("divPopupContent1").style.width = parseInt(document.getElementById("divPopup").style.width)+"px";
				document.getElementById("divPopupContent1").style.height = parseInt(document.getElementById("divPopup").style.height)-26+"px";
*/
			} else {
				document.getElementById("divPopupContent").style.padding = "20px";
				document.getElementById("tdPreview").align = "left";
				document.getElementById("trPreview").vAlign = "top";
			}
			document.getElementById("divPopup").style.width = vWidth+"px";
			document.getElementById("divPopup").style.height = vHeight+"px";
			document.getElementById("divPopup").style.left = "50px";
			document.getElementById("divPopup").style.top = parseInt(document.getElementById("divPopup").style.top)+50+"px";
			document.getElementById("divPopupContent1").style.width = vWidth+"px";
			document.getElementById("divPopupContent1").style.height = vHeight-26+"px";
		}
		vPopup.style.display = "block";
		
		if (vShow==1) {
			http_req('divPopupContent','agbs.asp','');
		} else if (vShow==2) {
			http_req('divPopupContent','datenschutz.asp','');
		} else if (vShow==3) {
			http_req('divPopupContent','imprint.asp','');
		} else if (vShow==4) {
			if (arguments[1]=="") {
				http_req('divPopupContent','preview.asp','');
			} else {
				window.open('preview1.asp');
			}
		} else if (vShow==5) {
			http_req('divPopupContent','material.asp?id='+encodeURL(arguments[1])+'','');
		} else if (vShow==6) {
			//http_req('divPopupContent','material.asp?do=showkonf&id='+encodeURL(arguments[1])+'','');
		} else if (vShow==7) {
			http_req('divPopupContent','widerruf.asp','');
		} else if (vShow==8) {
			http_req('divPopupContent','library.asp?do=showrabatt','');
		} else if (vShow==9) {
			http_req('divPopupContent','preview.asp?kc=true&pid='+arguments[1]+'','');
		}
	}
	
}

function closePopUp() {
	try {
		document.getElementById('divPopup').style.display = 'none';
	} catch (e) {
		
	}
}

function fSetTextInterval(vMain,vSubs,vID) {
	setValue(0,1,0,0,vMain,vSubs,vID);
}

function checkEigenesFormat(vMain,vSubs) {
	vError = 0;
	vErrorMsg = "";
	if (isNaN(document.getElementById('txtWidth').value) || isNaN(document.getElementById('txtHeight').value) || document.getElementById('txtWidth').value==0 || document.getElementById('txtHeight').value==0) {
		vError = 1;
		alert(errEigenesFormat);
	} else {
	var width = parseInt(document.getElementById('txtWidth').value);
	var height = parseInt(document.getElementById('txtHeight').value);

		/*
		Alte prüfung
		if (parseInt(document.getElementById('txtWidth').value) > 1000) {
			vErrorMsg+="Breite \> 0 und \< 1000\n";
			vError = 1;
		}
		if (parseInt(document.getElementById('txtHeight').value) > 500) {
			vErrorMsg+="Höhe \> 0 und \< 500\n";
			vError = 1;
		}
		*/
	
		if ((width >=15 && height >=25) || (height>=15 && width >=25)) {
			/* OK */
			if (width>=200 && height<=200) {
				/* OK */
				if (width >= 200 && width <=1000) {
					/* OK */
					if (height<=200) {
						/* OK */
					} else {
						/* FEHLER */
						alert (errFormatInvalid);
						vError=1;
					}
				} else {
					alert (errFormatInvalid);
					vError=1;
				}
			} else if (height>=200) {
				/* OK */
				if (height>=200 && height <=1000) {
					/* OK */
					if (width<=200) {
						/* OK */
					} else {
						/* FEHLER */
						alert (errFormatInvalid);
						vError=1;
					}
				} else {
					alert (errFormatInvalid);
					vError=1;
				}
			}
		} else {
			alert (errFormatInvalid);
				vError=1;
		}
		
	}
	if (vError==0) { 
		setValue(0,1,1,1,vMain,vSubs,'-1/w'+document.getElementById('txtWidth').value+'/h'+document.getElementById('txtHeight').value); 
	}
}

function checkKonfektionierung(vMain,vSubs) {
	vError = 0;
	vErrorMsg = "";
	if (isNaN(document.getElementById('txtKonf').value.replace(/,/,".")) || document.getElementById('txtKonf').value==0) {
		vError = 1;
		alert(lang_js_eigenesformat);
	} 
	if (vError==0) { 
		setValue(0,1,0,1,vMain,vSubs,'-1/w'+document.getElementById('txtKonf').value.replace(/\./,",")); 
	}
}

function fHome(vID) {
	if (vID==0) {
		http_req('divLibrary','library.asp?do=getRedContent&id='+vID,'');
	} else if (vID==1) {
		//var newWin = window.open("Standardflaggen","about:blank","");
		//newWin.location.href="http://www.flag.de/";
		http_req('divLibrary','standardflagge.asp','');
	} else if (vID==2) {
		http_req('divLibrary','library.asp?do=getRedContent&id='+vID,'');
	} else if (vID==3) {
		http_req('divLibrary','kontakt.asp','');
	} else {
		http_req('divLibrary','library.asp?do=getRedContent&id='+vID,'');
	} 
}

function showPreview(event,vWhat,vSrc) {
	if (strUA!="gecko") {
		x = window.event.clientX + window.document.documentElement.scrollLeft + window.document.body.scrollLeft;
	    y = window.event.clientY + window.document.documentElement.scrollTop + window.document.body.scrollTop;
	} else {
		x = event.clientX + window.scrollX;
    	y = event.clientY+ window.scrollY;
	}
	var divOut = "";
	if (arguments[3]=="TEXT" && arguments[4]!="") {
		divOut = "divFont1"
	} else {
		divOut = "divFont"
	}
	var vPreviewDIV = document.getElementById(divOut);
	if (vPreviewDIV!=null) {
		if (arguments[3]=="TEXT" && arguments[4]!="") {
			if (vWhat=="show")  {
				vPreviewDIV.style.left = (x+parseInt(vPreviewDIV.style.width)) >= parseInt(document.getElementsByTagName("body")[0].offsetWidth) ? x+(-parseInt(vPreviewDIV.style.width)-5)+"px" : x+5+"px";
				vPreviewDIV.style.top = (y+parseInt(vPreviewDIV.style.width)) >= parseInt(document.getElementsByTagName("body")[0].offsetHeight) ? y+(-parseInt(vPreviewDIV.style.height)-5)+"px" : y+5+"px";
				vPreviewDIV.style.display = "block";
				if (isNaN(parseInt(arguments[4]))) {
					if (arguments[4]=="show:Rabatt") {
						http_req(divOut,'library.asp?do=showrabatt','');
					} else {
						document.getElementById(divOut).innerHTML = arguments[4];
					}
				
				} else {
					http_req(divOut,'library.asp?do=showMaterial&id='+arguments[4],'');
				}
			} else if (vWhat=="hide")  { 
				vPreviewDIV.style.display = "none";
			} else {
				vPreviewDIV.style.left = (x+parseInt(vPreviewDIV.style.width)) >= parseInt(document.getElementsByTagName("body")[0].offsetWidth) ? x+(-parseInt(vPreviewDIV.style.width)-5)+"px" : x+5+"px";
				vPreviewDIV.style.top = (y+parseInt(vPreviewDIV.style.width)) >= parseInt(document.getElementsByTagName("body")[0].offsetHeight) ? y+(-parseInt(vPreviewDIV.style.height)-5)+"px" : y+5+"px";
			}
		} else {
			if (vWhat=="show")  {
				vPreviewDIV.firstChild.src = "images/"+vSrc;
				vPreviewDIV.style.left = x+5+"px"; 
				vPreviewDIV.style.top = y+5+"px";
				vPreviewDIV.style.display = "block";
			} else if (vWhat=="hide")  { 
				vPreviewDIV.style.display = "none";
			} else {
				vPreviewDIV.style.left = x+5+"px";
				vPreviewDIV.style.top = y+5+"px";
			}
		}
	}
}		


var vMouseDownSize = 0;
var vDragLayerMain = "";
var vDragLayer = "";
var elSize;
var elNameSize;
var vLayerSize;
var dragXSize = 0;
var dragYSize = 0;

startDragSize = function(e,vMain, vID) {
	vMouseDownSize = 1;
	vDragLayerMain = vMain;
	vDragLayer = vID;
	if (strUA!="gecko") {  
		window.document.attachEvent("onmousemove", doDragSize);
		window.document.attachEvent("onmouseup", stopDragSize);
		window.event.cancelBubble = true;
	  window.event.returnValue = false;
	} else {
		window.document.addEventListener("mousemove", doDragSize,   true);
    window.document.addEventListener("mouseup",   stopDragSize, true);
    e.preventDefault();
	}
}

stopDragSize = function(e) {
	vMouseDownSize = 0;
	if (strUA!="gecko") {
		window.document.detachEvent("onmousemove", doDragSize);
    	window.document.detachEvent("onmouseup",   stopDragSize);
	} else {
		window.document.removeEventListener("mousemove", doDragSize,   true);
	  window.document.removeEventListener("mouseup",   stopDragSize, true);
	}
	
	var elSize = (window.event) ? window.event : e;
	var elNameSize = (window.event) ? window.event.srcElement : e.target;
	var vLayerSize = document.getElementById("sliderDrag"+vDragLayerMain+vDragLayer);
	var vLayerSlideSize = document.getElementById("slider"+vDragLayerMain+vDragLayer);
	
	var vSize = 1;
	x = parseInt(vLayerSize.style.left);
	//window.status = x;
	var isRadius = document.getElementById("sizeR1") ? true : false;
	var isRotate = document.getElementById("sizeRotate1") ? true :  false;
	var isMRotate = document.getElementById("sizeMRotate1")&& vDragLayerMain==7 ? true : false;
	if (isRadius==true && vDragLayerMain!=6) {
		if (x>=0 && x<60) {
			vSize = 1;
		} else if (x>=61 && x<140) {
			vSize = 2;
		} else if (x>=141 && x<210) {
			vSize = 3;
		}
	} else if (isRotate==true || isMRotate==true) {
		if (x>=0 && x<35) {
			vSize = 1;
		} else if (x>=35 && x<70) {
			vSize = 2;
		} else if (x>=70 && x<105) {
			vSize = 3;
		} else if (x>=105 && x<140) {
			vSize = 4;
		} else if (x>=140 && x<175) {
			vSize = 5;
		} else if (x>=175 && x<210) {
			vSize = 6;
		} else if (x>=175 && x<210) {
			vSize = 7;
		}
		
		var vSize_temp = 0;
		if (x>=179/2) {
			vSize_temp=Math.round((x-8)-(179)*(179/360))*2 ;
		} else {
			vSize_temp=Math.round((x-9)-(179)*(179/360))*2 ;
		}
		
		
	} else {
		if (x>=0 && x<35) {
			vSize = 1;
		} else if (x>=35 && x<70) {
			vSize = 2;
		} else if (x>=70 && x<105) {
			vSize = 3;
		} else if (x>=105 && x<140) {
			vSize = 4;
		} else if (x>=140 && x<175) {
			vSize = 5;
		} else if (x>=175 && x<210) {
			vSize = 6;
		}
		
		var vSize_temp = 0;
		if (x>=179/2) {
			vSize_temp=Math.round((x-8)-(179)*(179/360))*2 ;
		} else {
			vSize_temp=Math.round((x-9)-(179)*(179/360))*2 ;
		}
		
	}
	if (isRadius==true && vDragLayerMain!=6) {
		setValue(0,1,1,1,3,2,'setRadius:'+vSize+'');
	} else if (isRotate==true)  {
		setValue(0,1,0,0,3,2,'setRotate:'+vSize_temp+'');
	} else if (isMRotate==true)  {
		setValue(0,1,0,0,2,1,'setMotivRotate:'+vSize_temp+'');
	} else if (vDragLayerMain==6) {
		setValue(0,1,1,1,3,2,'setStart:'+vSize_temp+'');
	} else {
		if (document.getElementById("isMotivDIV"+vDragLayerMain+vDragLayer)) {
			setValue(0,1,1,1,2,1,'setGroesse:'+vSize+'');
		} else if (document.getElementById("isTextDIV"+vDragLayerMain+vDragLayer)) {
			setValue(0,1,1,1,3,0,'setGroesse:'+vSize+'');
		} 
	}
}


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return curleft;
}


doDragSize = function(e) {
	var elSize = (window.event) ? window.event : e;
	var elNameSize = (window.event) ? window.event.srcElement : e.target;
	var vLayerSize = document.getElementById("sliderDrag"+vDragLayerMain+vDragLayer);
	var vLayerSlideSize = document.getElementById("slider"+vDragLayerMain+vDragLayer);
	var isRadius = document.getElementById("sizeR1") ? true : false;
	var isRotate = document.getElementById("sizeRotate1") ? true : false;
	//var vOff = vLayerSlideSize.offsetLeft;
	var vOff = findPos(vLayerSlideSize);
	
	//window.status = vOff;
	if (vMouseDownSize == 1) {
		if (window.event) {
			var x = elSize.clientX + window.document.documentElement.scrollLeft + window.document.body.scrollLeft-vOff-5;
		} else {
			var x = elSize.clientX+window.scrollX-vOff-5;
		}
		x = (parseInt(x)>8) ? parseInt(x) : 8;
		x = (parseInt(x)<187) ? parseInt(x) : 187;
		vLayerSize.style.left = x+"px";
		//window.status = x;
		/*
		if (isRadius == true) {
			if (x>=0 && x<60) {
				//resetAll();
				//(document.getElementById("sizeR1").style.color=="#FF0000") ? void(0) : document.getElementById("sizeR1").style.color="#FF0000";
			} else if (x>=61 && x<140) {
				//resetAll();
				//(document.getElementById("sizeR2").style.color=="#FF0000") ? void(0) : document.getElementById("sizeR2").style.color="#FF0000";
			} else if (x>=141 && x<210) {
				//resetAll();
				//(document.getElementById("sizeR3").style.color=="#FF0000") ? void(0) : document.getElementById("sizeR3").style.color="#FF0000";
			}
		} else if (isRotate==true) {
			if (x>=0 && x<35) {
					//resetAll();
					//(document.getElementById("sizeRotate1").style.color=="#FF0000") ? void(0) : document.getElementById("sizeRotate1").style.color="#FF0000";
				} else if (x>=35 && x<70) {
					//resetAll();
					//(document.getElementById("sizeRotate2").style.color=="#FF0000") ? void(0) : document.getElementById("sizeRotate2").style.color="#FF0000";
				} else if (x>=70 && x<105) {
					//resetAll();
					//(document.getElementById("sizeRotate3").style.color=="#FF0000") ? void(0) : document.getElementById("sizeRotate3").style.color="#FF0000";
				} else if (x>=105 && x<140) {
					//resetAll();
					//(document.getElementById("sizeRotate4").style.color=="#FF0000") ? void(0) : document.getElementById("sizeRotate4").style.color="#FF0000";
				} else if (x>=140 && x<175) {
					//resetAll();
					//(document.getElementById("sizeRotate5").style.color=="#FF0000") ? void(0) : document.getElementById("sizeRotate5").style.color="#FF0000";
				} else if (x>=175 && x<210) {
					//resetAll();
					//(document.getElementById("sizeRotate6").style.color=="#FF0000") ? void(0) : document.getElementById("sizeRotate6").style.color="#FF0000";
				} else if (x>=175 && x<210) {
					//resetAll();
					//(document.getElementById("sizeRotate7").style.color=="#FF0000") ? void(0) : document.getElementById("sizeRotate7").style.color="#FF0000";
				}
		} else {
				if (x>=0 && x<35) {
					//resetAll();
					//(document.getElementById("size1").style.color=="#FF0000") ? void(0) : document.getElementById("size1").style.color="#FF0000";
				} else if (x>=35 && x<70) {
					//resetAll();
					//(document.getElementById("size2").style.color=="#FF0000") ? void(0) : document.getElementById("size2").style.color="#FF0000";
				} else if (x>=70 && x<105) {
					//resetAll();
					//(document.getElementById("size3").style.color=="#FF0000") ? void(0) : document.getElementById("size3").style.color="#FF0000";
				} else if (x>=105 && x<140) {
					//resetAll();
					//(document.getElementById("size4").style.color=="#FF0000") ? void(0) : document.getElementById("size4").style.color="#FF0000";
				} else if (x>=140 && x<175) {
					//resetAll();
					//(document.getElementById("size5").style.color=="#FF0000") ? void(0) : document.getElementById("size5").style.color="#FF0000";
				} else if (x>=175 && x<210) {
					//resetAll();
					//(document.getElementById("size6").style.color=="#FF0000") ? void(0) : document.getElementById("size6").style.color="#FF0000";
				}
			}*/
	}
	return false;
}

resetAll = function() {
	var isRadius = document.getElementById("sizeR1") ? true : false;
	var isRotate = document.getElementById("sizeRotate1") ? true : false;
	if (isRadius==true) {
		for (var a=1; a<=3;a++) {
			document.getElementById("sizeR"+a).style.color="#000000";
		}
	} else if (isRotate==true) {
		for (var a=1; a<=7;a++) {
			document.getElementById("sizeRotate"+a).style.color="#000000";
		}
	} else {
		for (var a=1; a<=6;a++) {
			document.getElementById("size"+a).style.color="#000000";
		}
	}
}


var oCheck = new Object();

oCheck = {
	fehler:0,
	vReturn:0,
	
	check: function(vCheck) {
		switch(vCheck) {
			case 0:
				oCheck.fehler = 0;
				oCheck.fehler = oCheck.checkMail(document.getElementsByName("txtEmail")[0].value);
				if (oCheck.fehler==-1) {
					alert(errWrongEmail)
				} else if (oCheck.fehler==0) {
					alert (errMandatory);
				} else {
					http_req('divContact', 'kontakt_danke.asp', 'Sende Mail...','POST',true,'contForm');
				}
				break;
			case 1:
				oCheck.fehler = 0;
				if (document.getElementsByName("email")[0]) {
					try {
						if (document.getElementById("rowUstid").style.display!='none' && document.getElementById("rowUstidhidden")) {
							if (document.getElementById("isMan").value == "true") {
								oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("ustid")[0].value=="") ? 1 : 0) : 1;
								oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("firma1")[0].value=="") ? 1 : 0) : 1;
							} else {
								oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("firma1")[0].value=="") ? 1 : 0) : 1;
							}
						//oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("firma2")[0].value=="") ? 1 : 0) : 1;
						} else {
							oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("vorname")[0].value=="") ? 1 : 0) : 1;
							oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("nachname")[0].value=="") ? 1 : 0) : 1;
						}
						

						oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("strasse")[0].value=="") ? 1 : 0) : 1;
						oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("plz")[0].value=="") ? 1 : 0) : 1;
						oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("ort")[0].value=="") ? 1 : 0) : 1;
						oCheck.fehler = oCheck.fehler!=1 ? ((oCheck.checkMail(document.getElementsByName("email")[0].value)==1) ? 0 : 1) : 1;
						//oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("email")[0].value=="") ? 1 : 0) : 1;
						if (document.getElementsByName("checkLiefer")[0].checked == true) {
							if (document.getElementById("lGeschlecht")[document.getElementById("lGeschlecht").selectedIndex].value=="f") {
								//if (document.getElementById("isManL").value == "true") {
									//oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("lUstid")[0].value=="") ? 1 : 0) : 1;
									//oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("lFirma1")[0].value=="") ? 1 : 0) : 1;
								//} else {
									oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("lFirma1")[0].value=="") ? 1 : 0) : 1;
								//}
							} else {
								oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("lVorname")[0].value=="") ? 1 : 0) : 1;
								oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("lNachname")[0].value=="") ? 1 : 0) : 1;
							}
							oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("lstrasse")[0].value=="") ? 1 : 0) : 1;
							oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("lplz")[0].value=="") ? 1 : 0) : 1;
							oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("lort")[0].value=="") ? 1 : 0) : 1;
						}
						if (oCheck.fehler!=1) {
							http_req('divCheck','library.asp?do=setAdress','','POST',false,'shopForm');
						}
						/* check for doppelte anmeldungen */
						if (document.getElementsByName("txtPassword")[1]) {
							oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("txtUsername")[1].value=="" || document.getElementsByName("txtUsername")[1].value.length < 6) ? 1 : 0) : 1;
							oCheck.fehler = oCheck.fehler!=1 ? ((document.getElementsByName("txtPassword")[1].value=="" || document.getElementsByName("txtPassword")[1].value.length < 6 || document.getElementsByName("txtPassword")[1].value!=document.getElementsByName("txtPasswordCheck")[0].value) ? 1 : 0) : 1;
							
							/* Neue Fehlermeldungen für Username + Passwort */
							if (document.getElementsByName("txtUsername")[1].value.length < 6) {
								alert(errUsernameError);
							} else if (document.getElementsByName("txtPassword")[1].value.length < 6) {
								alert(errPasswordError);
							} else if (document.getElementsByName("txtPassword")[1].value != document.getElementsByName("txtPasswordCheck")[0].value) {
								alert(errPasswordError1);
							} else {
								/* Ab hier der alte Check */
								if (oCheck.fehler != 1) {
									http_req('divCheck','library.asp?do=checkdouble&username='+document.getElementsByName("txtUsername")[1].value+'&password='+document.getElementsByName("txtPassword")[1].value+'','','',false);
									if (isDbl=="true") {
										alert(errDblAccount);
									} else {
												
								http_req('divCheck','library.asp?do=setPass','','POST',false,'shopForm');
										if (oCheck.fehler != 1) {
											oCheck.vReturn = 1;
											//oSet.doSubMenu(arguments[1],arguments[2],arguments[3]);
										} else {
											alert(errMandatory);
										}
									}
								} else {
									alert(errMandatory);
								}
							}
							
						} else {
							if (oCheck.fehler != 1) {
								oCheck.vReturn = 1;
								//oSet.doSubMenu(arguments[1],arguments[2],arguments[3]);
							} else {
								alert(errMandatory);
							}
						}
					} catch(e) { }
				} else if (document.getElementsByName("zahlungsart")[0]) {
					
					if (document.getElementsByName("zahlungsart")[0].value == "Kreditkarte") {
						/* PRÜFEN */
						isBS = "Kreditkarte";
						vKK1 = document.getElementsByName("txtKK1")[0].value;
						vKK2 = document.getElementsByName("txtKK2")[0].value;
						vKK3 = document.getElementsByName("txtKK3")[0].value;
						vKK4 = document.getElementsByName("txtKK4")[0].value;
						vKK5 = document.getElementsByName("txtKK5")[0].value;
						http_req('', 'zahlungsart.asp?do=checkKK&kk1='+vKK1+'&kk2='+vKK2+'&kk3='+vKK3+'&kk4='+vKK4+'&kk5='+vKK5+'', '','',false);
						
						if (KK_OK == "true") {
							oCheck.vReturn = 1;
							//oSet.doSubMenu(arguments[1],arguments[2],arguments[3]);
						} else {
							oCheck.vReturn = 0;
							alert (errKKCheck+"\n\nReturncode:\n"+KK_OK);
						}
					} else if (document.getElementsByName("zahlungsart")[0].value == "Lastschrift") {
						/* PRÜFUEN */
						isBS = "Lastschrift";
						vLS1 = document.getElementsByName("txtLS1")[0].value;
						vLS2 = document.getElementsByName("txtLS2")[0].value;
						vLS3 = document.getElementsByName("txtLS3")[0].value;
						http_req('', 'zahlungsart.asp?do=checkLS&ls1='+vLS1+'&ls2='+vLS2+'&ls3='+vLS3+'', '','',false);
						if (LS_OK == "true") {
							oCheck.vReturn = 1;
							//oSet.doSubMenu(arguments[1],arguments[2],arguments[3]);
						} else {
							oCheck.vReturn = 0;
							alert (errLSCheck+"\n\nReturncode:\n"+LS_OK);
						}
					} else {
						isBS = "";
						oCheck.vReturn = 1;
						//oSet.doSubMenu(arguments[1],arguments[2],arguments[3]);
					}
				} else {
					if (arguments[1]==4 && (arguments[2]==2 || arguments[2]==3) && arguments[3]=='next') {
						oCheck.vReturn = 0;
					} else {
						oCheck.vReturn = 1;
						//oSet.doSubMenu(arguments[1],arguments[2],arguments[3]);
					}
				}
				break;
			case 3:
				oCheck.vReturn = 1;
				document.getElementById("btnSubmitID2").style.display="block";
				document.getElementById("btnSubmitID1").style.display="none";
				var vBSOK = true;
				if (isBS!="") {
					if (isBS == "Kreditkarte") {
						/* PRÜFEN */
						http_req('', 'zahlungsart.asp?do=checkKK&bs=debit&kk1='+vKK1+'&kk2='+vKK2+'&kk3='+vKK3+'&kk4='+vKK4+'&kk5='+vKK5+'', '','',false);
						if (KK_OK == "true") {
							vBSOK = true;
							oCheck.vReturn = 1;
						} else {
							vBSOK = false;
							oCheck.vReturn = 0;
							alert (errKKCheck);
						}
					} else if (isBS == "Lastschrift") {
						/* PRÜFUEN */
						http_req('', 'zahlungsart.asp?do=checkLS&bs=debit&ls1='+vLS1+'&ls2='+vLS2+'&ls3='+vLS3+'', '','',false);
						
						if (LS_OK == "true") {
							vBSOK = true;
							oCheck.vReturn = 1;
						} else {
							vBSOK = false;
							oCheck.vReturn = 0;
							alert (errLSCheck);
						}
					}
				}
				
				if (vBSOK==true) {
					if (document.getElementsByName("check4")[0]) {
						if (document.getElementsByName("check1")[0].checked == true && document.getElementsByName("check2")[0].checked == true && document.getElementsByName("check4")[0].checked == true) {
							document.getElementById("btnSubmitID2").style.display="none";
							document.getElementById("btnSubmitID1").style.display="block";
							oCheck.vReturn = 1;
							oSet.setProgress(arguments[1],arguments[2],arguments[3]);
						} else {
							document.getElementById("btnSubmitID2").style.display="block";
							document.getElementById("btnSubmitID1").style.display="none";
							oCheck.vReturn = 0;
							alert(errMandatoryCheck);
						}
					} else {
						if (document.getElementsByName("check1")[0].checked == true && document.getElementsByName("check2")[0].checked == true) {
							document.getElementById("btnSubmitID2").style.display="none";
							document.getElementById("btnSubmitID1").style.display="block";
							oCheck.vReturn = 1;
							oSet.setProgress(arguments[1],arguments[2],arguments[3]);
						} else {
							document.getElementById("btnSubmitID2").style.display="block";
							document.getElementById("btnSubmitID1").style.display="none";
							oCheck.vReturn = 0;
							alert(errMandatoryCheck);
						}
					}
				}
				break;
			default:
		}
		if (vCheck!=3) {
			//alert (oCheck.vReturn);
			return oCheck.vReturn;
		}
	},
	
	checkMail: function(vStr) {
		if (vStr == "") {
			return 0;
		} else {
			if (vStr.indexOf("@") > -1 && vStr.indexOf(".") > -1){
				return 1;
	    } else {
				return -1;
	    }
		}
	}
	
}


var oSet = new Object();
oSet = {
	vDiv: '',
	Kundenbereich: function (vMain, vSubs) {
		try {
			vDiv = ((vMain == 4) ? ((vSubs == 0) ? 'divPreview' : 'divLibrary') : 'divLibrary');
			document.getElementById("divKundencenter").innerHTML = "<a href=\"javascript:doLink();\" id=\"linkKundencenter\" onclick=\"check('kundenbereich.asp');\"><div id=\"divKundencenter\">" + vKCenter + "</div></a>";
			if (vMain == 0 && vSubs == 0) {
			} else {
				//alert(vDiv);
				http_req(vDiv, 'library.asp?do=library&main=' + vMain + '&subs=' + vSubs + '', '');
				if (vMain == 4 && vSubs == 0) {
				} else {
					if (vMain == 4) {
						http_req('divPreview', 'library.asp?do=library&main=4&subs=0', '');
					} else {
						setPreview();
					}
				}
				setStatus();
			}
		} catch (e) { }
	},

	Manuell: function (vID, vMain, vSubs) {
		setValue(0, 0, 1, 0, vMain, vSubs, 'setManuell:' + vID + '/' + document.getElementById("iCheck" + vID).checked + '');
		if (document.getElementById("iCheck" + vID).checked) {
			document.getElementById("divRemarks" + vID + "1").style.display = "block";
			document.getElementById("divRemarks" + vID + "2").style.display = "block";
		} else {
			document.getElementById("divRemarks" + vID + "1").style.display = "none";
			document.getElementById("divRemarks" + vID + "2").style.display = "none";
		}
	},

	fDL: function (vMain, vSubs) {
		if (document.getElementById("divHelp").style.display != "block") {
			fScroller(2, vMain, vSubs);
		} else {
			displaySub(vMain);
			displayHelp(vMain, vSubs);
		}
	},

	setSubmit: function () {
		if (document.getElementsByName("check4")[0]) {
			if (document.getElementsByName("check1")[0].checked == true && document.getElementsByName("check2")[0].checked == true && document.getElementsByName("check4")[0].checked == true) {
				document.getElementById("btnSubmitID2").style.display = "none";
				document.getElementById("btnSubmitID1").style.display = "block";
			} else {
				document.getElementById("btnSubmitID2").style.display = "block";
				document.getElementById("btnSubmitID1").style.display = "none";
			}
		} else {
			if (document.getElementsByName("check1")[0].checked == true && document.getElementsByName("check2")[0].checked == true) {
				document.getElementById("btnSubmitID2").style.display = "none";
				document.getElementById("btnSubmitID1").style.display = "block";
			} else {
				document.getElementById("btnSubmitID2").style.display = "block";
				document.getElementById("btnSubmitID1").style.display = "none";
			}
		}
	},

	loadOrder: function (vKID) {
		http_req('divPreview', 'kdFuncs.asp?do=showPositions&oid=' + vKID + '', '');
	},

	clearOwn: function () {
		document.getElementsByName('fWidth')[0].value = '';
		document.getElementsByName('fHeight')[0].value = '';
	},

	swapCompany: function (vShow) {
		var vDisplay = (window.event) ? 'block' : 'table-row';
		if (strUA == 'gecko') vDisplay = 'table-row';
		if (vShow == 'f') {

			document.getElementById('rowNachname').style.display = 'none';
			document.getElementById('rowVorname').style.display = 'none';
			document.getElementById('rowFirma').style.display = 'none';

			document.getElementById('rowFirma1').style.display = vDisplay;
			document.getElementById('rowFirma2').style.display = vDisplay;
			document.getElementById('rowAnsprechpartner').style.display = vDisplay;
			document.getElementById('rowUstid').style.display = vDisplay;
		} else {
			document.getElementById('rowNachname').style.display = vDisplay;
			document.getElementById('rowVorname').style.display = vDisplay;
			document.getElementById('rowFirma').style.display = vDisplay;

			document.getElementById('rowFirma1').style.display = 'none';
			document.getElementById('rowFirma2').style.display = 'none';
			document.getElementById('rowAnsprechpartner').style.display = 'none';
			document.getElementById('rowUstid').style.display = 'none';
		}
	},

	swapCompanyL: function (vShow) {
		var vDisplay = (window.event) ? 'block' : 'table-row';
		if (strUA == 'gecko') vDisplay = 'table-row';
		if (vShow == 'f') {
			document.getElementById('rowNachnameL').style.display = 'none';
			document.getElementById('rowVornameL').style.display = 'none';
			document.getElementById('rowFirmaL').style.display = 'none';

			document.getElementById('rowFirma1L').style.display = vDisplay;
			document.getElementById('rowFirma2L').style.display = vDisplay;
			document.getElementById('rowAnsprechpartnerL').style.display = vDisplay;
			//document.getElementById('rowUstidL').style.display = vDisplay;
		} else {
			document.getElementById('rowNachnameL').style.display = vDisplay;
			document.getElementById('rowVornameL').style.display = vDisplay;
			document.getElementById('rowFirmaL').style.display = vDisplay;

			document.getElementById('rowFirma1L').style.display = 'none';
			document.getElementById('rowFirma2L').style.display = 'none';
			document.getElementById('rowAnsprechpartnerL').style.display = 'none';
			//document.getElementById('rowUstidL').style.display = 'none';
		}
	},

	setLS: function (vBool) {
		LS_OK = vBool;
	},
	setKK: function (vBool) {
		KK_OK = vBool;
	},

	setProgress: function () {
		document.getElementById("btnSubmitID2").style.display = "block";
		document.getElementById("btnSubmitID1").style.display = "none";
		document.getElementById("divProcessCart").style.display = "block";
		document.getElementById("divProcessCart1").style.display = "block";
		var vOrder = setTimeout("fOrder(" + arguments[1] + "," + arguments[2] + "," + arguments[3] + ")", 500);
	},

	setMainPath: function (vMain, vSubs) {
		try {
			http_req('IDNavDesc', 'library.asp?do=setNavigationDesc&main=' + vMain + '&subs=' + vSubs + '', '');
			http_req('IDNav', 'library.asp?do=setNavigation&main=' + vMain + '&subs=' + vSubs + '', '');
		} catch (e) { alert(e); }
	},

	doTrack: function (vMain, vSubs, vNext) {
		try {
			var vSubsNav = 0;
			vSubsNav = (vNext == 'next') ? parseInt(vSubs) + 1 : parseInt(vSubs);
			var vGetVal = 0;

			if (vMain == 4) {
				if (vSubs == 4 && vNext == 'next') {
					vGetVal = oCheck.check(3, vMain, vSubs, vNext);
				} else if ((vSubs == 3 && vNext == 'next') || vSubs == 4) {
					vGetVal = oCheck.check(1, vMain, vSubs, vNext);
				} else if ((vSubs == 2 && vNext == 'next') || vSubs == 3) {
					vGetVal = oCheck.check(1, vMain, vSubs, vNext);
				} else {
					/* Tracking setzen */
					http_req('', 'library.asp?do=tracking&main=' + vMain + '&subs=' + vSubsNav + '', '', 'GET', false);

					/* Menü links */
					http_req('divTools', 'library.asp?do=menu&main=' + vMain + '&subs=' + vSubsNav + '', '');

					/* Menü oben */
					try {
						http_req('IDNavDesc', 'library.asp?do=setNavigationDesc&main=' + vMain + '&subs=' + vSubsNav + '', '');
						http_req('IDNav', 'library.asp?do=setNavigation&main=' + vMain + '&subs=' + vSubsNav + '', '');
					} catch (e) { }


					if (vSubs == 0 && vNext != 'next') {
						http_req('divPreview', 'library.asp?do=library&main=' + vMain + '&subs=0&dontshow=false', '');
						http_req('divLibrary', 'library.asp?do=library&main=' + vMain + '&subs=0&shownew=true', '');
					} else if (vSubs == 1 || (vSubs == 0 && vNext == 'next')) {
						http_req('divPreview', 'library.asp?do=library&main=' + vMain + '&subs=0&dontshow=true', '');
						http_req('divLibrary', 'library.asp?do=library&main=' + vMain + '&subs=' + vSubsNav + '', '');
					} else {
						http_req('divLibrary', 'library.asp?do=library&main=' + vMain + '&subs=' + vSubsNav + '', '');
					}

				}
				if (vGetVal == 1) {
					/* Tracking setzen */
					http_req('', 'library.asp?do=tracking&main=' + vMain + '&subs=' + vSubsNav + '', '', 'GET', false);

					/* Menü links */
					http_req('divTools', 'library.asp?do=menu&main=' + vMain + '&subs=' + vSubsNav + '', '');

					/* Menü oben */
					try {
						http_req('IDNavDesc', 'library.asp?do=setNavigationDesc&main=' + vMain + '&subs=' + vSubsNav + '', '');
						http_req('IDNav', 'library.asp?do=setNavigation&main=' + vMain + '&subs=' + vSubsNav + '', '');
					} catch (e) { }
					http_req('divLibrary', 'library.asp?do=library&main=' + vMain + '&subs=' + vSubsNav + '', '');
				}
			} else {
				/* Tracking setzen */
				if (vNext != 'no') {
					http_req('', 'library.asp?do=tracking&main=' + vMain + '&subs=' + vSubsNav + '', '', 'GET', false);

				} else {
					setPreview();
				}


				/* Menü links */
				http_req('divTools', 'library.asp?do=menu&main=' + vMain + '&subs=' + vSubsNav + '', '');

				/* Menü oben */
				try {
					http_req('IDNavDesc', 'library.asp?do=setNavigationDesc&main=' + vMain + '&subs=' + vSubsNav + '', '');
					http_req('IDNav', 'library.asp?do=setNavigation&main=' + vMain + '&subs=' + vSubsNav + '', '');
				} catch (e) { }

				http_req('divLibrary', 'library.asp?do=library&main=' + vMain + '&subs=' + vSubsNav + '', '');

				/*setPreview();
				setLibrary();
				setStatus();*/

				//if (document.getElementById("divHelp").style.display=="block") {
				try {
					displaySub(parseInt(vMain));
					displayHelp(parseInt(vMain), parseInt(vSubsNav) + 1);
				} catch (e) { }
				//}
			}

		} catch (e) { }
	},

	setTextValue: function () {
		try {
			document.getElementById('txtvalue').value = document.getElementById('txtvalue').value.substr(0, 500);
			document.getElementById('txtvalue').focus();
		} catch (e) { }
	}

}



function showMore(vRefreshTools, vRefreshPreview, vRefreshLibrary, vRefreshStatus, vMain, vSubs, vID,vImgID,vImgIDPrefix) {
	var vPrefix = "ID";
	setValueMain	= vMain;
	setValueSub	= vSubs;

	try {
		if (typeof vImgIDPrefix!='undefined') {
			vPrefix = vImgIDPrefix;
		}
		if (typeof vImgID!='undefined') {
			for (var a=1; document.getElementById(vPrefix+a)!=null; a++) {
				if (document.getElementById(vPrefix+a).tagName=="IMG" || document.getElementById(vPrefix+a).tagName=="TD") {
					if (String(vID).indexOf("setClipart") >= 0) {
						document.getElementById(vPrefix+a).style.border = "0px solid #000000";
					} else {
						if (vMain==3 && vSubs==1) {
							document.getElementById(vPrefix+a).style.border = "3px solid #FFFFFF";
						} else {
							document.getElementById(vPrefix+a).style.border = "1px solid #000000";
							document.getElementById(vPrefix+a).style.backgroundColor = "#FFFFFF";
						}
					}
				} else {
					if (document.getElementById(vPrefix+a).tagName=="SPAN") {
						document.getElementById(vPrefix+a).style.border = "0px solid #000000";
						document.getElementById(vPrefix+a).className = "kons";
						try {
							document.getElementById("A"+vPrefix+a).style.color = "#"+color2;
							document.getElementById("I"+vPrefix+a).src = "images/pixel.gif";
						} catch(e) { }
					}
				}
			}
			if (document.getElementById(vPrefix+vImgID).tagName=="IMG" || document.getElementById(vPrefix+vImgID).tagName=="TD") {
				document.getElementById(vPrefix+vImgID).style.border = "3px solid #000000";
				if (vMain==3 && vSubs==1) { 
				} else {
					document.getElementById(vPrefix+vImgID).style.backgroundColor = "#CCCCCC";
				}
			} else {
				if (document.getElementById(vPrefix+vImgID).tagName=="SPAN") {
					document.getElementById(vPrefix+vImgID).className = "konsf";
					try {
						document.getElementById("I"+vPrefix+vImgID).src = "images/tri_r.gif";
					} catch(e) { }
				}
			}
		}
	} catch (e) {
	
	}
	showPopup(5,vID);
} 

function setAlign(vWhat,vID) {
	if (vWhat==1) {
	/* Motiv */
		setValue(0,1,0,0,2,1,'setAlign:'+vID+'');
		
	} else {
	/* Text */
		setValue(0,1,0,0,3,0,'setAlign:'+vID+'');
	}
}

function killSession() {
	if (window.event) {
		var e1 = window.event;
		e1.returnValue = false;
	}
	var conf = confirm(lang_killsession);
	if (conf==true) {
		window.location.href = vHTTP+vAbsPath+"/index.asp?new=true";
	}
}

