// Diese Funktion wird für die Status verfolgung verwendet.
// rk 22.04.2005
function DatumValue(NameRadio,Wert,NameDate,Datum,Init,NameInit)
{

if (this.document.OCForm[NameRadio].value != Wert)
   { 
   this.document.OCForm[NameDate].value = Datum;
   this.document.OCForm[NameInit].value = Init; 

   }
 else
this.document.OCForm[NameDate].value = Wert;

}

function setFirstLetter(field)
{
//	alert('Vorher: ' + document.OCForm[field].value);
	sValue = document.OCForm[field].value;
	sFirst = sValue.substr(0,1);
	sValue = sFirst.toUpperCase() + sValue.substr(1,sValue.length);	
	document.OCForm[field].value = sValue;
//	alert('Nachher: ' + sValue);
}


/* sh 16.08.07 function doQuickSearch(searchlink) {
		
		sAction = "showpage.asp?id=" + searchlink;
		this.document.quickbar.action = sAction;
		this.document.quickbar.submit(); 
	}*/

//function doQuickSearch(form) {
//	sDiv = escape("¦");
//	sSearchText = this.document[form].txtQuickSearch.value;
//	if(sSearchText.length > 0) {
//		sAction = "showlc.asp?FAL=lc-090-010.cnf&TAB=020&LEV=010&param=lc-090-020.cnf" + sDiv + "1" + sDiv + sSearchText + ";;";
//		this.document[form].action = sAction;
//		this.document[form].submit(); 
//	}
//}

function doDirectOrder() {
	this.document.lc090010.txtEventName.value='SendOrder';
	this.document.lc090010.submit()
}

function clearFormFields() {
	// Löscht alle Formular-Felder (text, checkbox, select)
	for(a=0; a < this.document.OCForm.elements.length; a++) {
		switch(this.document.OCForm.elements[a].type) {
			case "text":
				this.document.OCForm.elements[a].value = "";
				break;
			case "checkbox":
				this.document.OCForm.elements[a].checked = false;
				break;
			case "select-one":
				this.document.OCForm.elements[a].selectedIndex = -1;
				break;
		}
	}
}

function clearOtherFormFields(fieldname) {
	// Löscht Textfelder
	for(a=0; a < this.document.OCForm.elements.length; a++) {
		switch(this.document.OCForm.elements[a].type) {
			case "text":
				if(this.document.OCForm.elements[a].name != fieldname){
					this.document.OCForm.elements[a].value = "";
				}
				break;
		}
	}
}    

/*                                                                                                                                                                                                                                                                                                                                                                                                                                         
function checkNegValues(sErrNaN,sErrNeg){
	// überprüft negative, ungültige Eingaben
	for(a=0; a < this.document.OCForm.elements.length; a++) {
		switch(this.document.OCForm.elements[a].type) {
			case "text":
				if(isNaN(this.document.OCForm.elements[a].value) == true){
					// this.document.OCForm.elements[a].value = "";
					alert(sErrNaN);
					this.document.OCForm.elements[a].focus();						
					return;
				}
				else { 
					if(this.document.OCForm.elements[a].value != ""){
						if(this.document.OCForm.elements[a].value<=0){
							// this.document.OCForm.elements[a].value = "";		
							alert(sErrNeg);
							this.document.OCForm.elements[a].focus();
							return;
						}
					}
				}
				break;
		}
	}

	this.document.OCForm.submit()
}
*/


function clearGFRaster() {
//--------------------------------------------------------------------------------
//  Löscht alle Mengenfelder im G/F Raster
//  13.05.2004 - cvd
//--------------------------------------------------------------------------------
	for(a=0; a < document.OCForm.elements.length; a++) {
		if (document.OCForm.elements[a].name.indexOf('-ART:') != -1) {
                           document.OCForm.elements[a].value="0";
		} else {
//
		}
	}

}


function createOrderData(textBlockId) 
{
	neuMut = '';
    orderString = '';
    fieldName ='';
	for(a=0; a < document.OCForm.elements.length; a++) 
	{
		if (document.OCForm.elements[a].name.indexOf('-ART:') != -1) 
		{
			fieldName = document.OCForm.elements[a].name;
            neuMut = fieldName.substr(0,1);
            fieldName = fieldName.substring(6,100);
            if ( (document.OCForm.elements[a].value > 0) || (neuMut == 'M') ) 
			{
				orderString = orderString + fieldName + document.OCForm.elements[a].value + "\r";
            }
		} 
		else 
		{
//
		}
	}
          document.OCForm[textBlockId].value = orderString;
}

function doUserLogin(formularname, sTargetPage) 
{
  	this.document[formularname].action = sTargetPage;
  	this.document[formularname].submit(); 
}

// Title: Timestamp picker
// Description: See the demo at url
// URL: http://us.geocities.com/tspicker/
// Script featured on: http://javascriptkit.com/script/script2/timestamp.shtml
// Version: 1.0
// Date: 12-05-2001 (mm-dd-yyyy)
// Author: Denis Gritcyuk <denis@softcomplex.com>; <tspicker@yahoo.com>
// Notes: Permission given to use this script in any kind of applications if
//    header lines are left unchanged. Feel free to contact the author
//    for feature requests and/or donations
//
// ----------------------------------------------------
// Modified by Christoph von Däniken, OPACC Software AG
// ----------------------------------------------------

function show_calendar(sFieldName, str_datetime, language) {
	str_target = "document.OCForm['" + sFieldName + "']";
	if (str_datetime == "") {
		str_datetime = document.OCForm[sFieldName].value;		
	}
	switch (language) {
		case 2:
			var arr_months = ["Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Décembre"];
			var week_days = ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"];
			next_month = "le mois prochain";
			prev_month = "mois précédent";
		break;
		case 4:
			var arr_months = ["Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembri", "Ottobre", "Novembre", "Dicembre"];
			var week_days = ["Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa"];
			next_month = "il mese prossimo";
			prev_month = "mese precedente";
		break;
		default:
			var arr_months = ["Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"];
			var week_days = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
			next_month = "nächster Monat";
			prev_month = "vorheriger Monat";
		break;
	}


	var n_weekstart = 1; // day week starts from (normally 0 or 1)

	var dt_datetime = (str_datetime == null || str_datetime =="" ?  new Date() : str2dt(str_datetime));
	var dt_prev_month = new Date(dt_datetime);
	dt_prev_month.setMonth(dt_datetime.getMonth()-1);
	var dt_next_month = new Date(dt_datetime);
	dt_next_month.setMonth(dt_datetime.getMonth()+1);
	var dt_firstday = new Date(dt_datetime);
	dt_firstday.setDate(1);
	dt_firstday.setDate(1-(7+dt_firstday.getDay()-n_weekstart)%7);
	var dt_lastday = new Date(dt_next_month);
	dt_lastday.setDate(0);
	
	// html generation (feel free to tune it for your particular application)
	// print calendar header
	var str_buffer = new String (
		"<html>\n"+
		"<head>\n"+
		"	<title>Calendar</title>\n"+
		"</head>\n"+
		"<body bgcolor=\"White\">\n"+
		"<table class=\"clsOTable\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n"+
		"<tr><td bgcolor=\"#61757f\">\n"+
		"<table cellspacing=\"1\" cellpadding=\"3\" border=\"0\" width=\"100%\">\n"+
		"<tr>\n	<td bgcolor=\"#61757f\"><a href=\"javascript:window.opener.show_calendar('"+
		sFieldName+"', '"+ dt2dtstr(dt_prev_month)+"',"+language+");\">"+
		"<img src=\"config/layout/include/kalender/prev.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt='" + prev_month + "'></a></td>\n"+
		"	<td bgcolor=\"#61757f\" colspan=\"5\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"
		+arr_months[dt_datetime.getMonth()]+" "+dt_datetime.getFullYear()+"</font></td>\n"+
		"	<td bgcolor=\"#61757f\" align=\"right\"><a href=\"javascript:window.opener.show_calendar('"
		+sFieldName+"', '"+dt2dtstr(dt_next_month)+"',"+language+");\">"+
		"<img src=\"config/layout/include/kalender/next.gif\" width=\"16\" height=\"16\" border=\"0\""+
		" alt='"+ next_month +"'></a></td>\n</tr>\n"
	);

	var dt_current_day = new Date(dt_firstday);
	// print weekdays titles
	str_buffer += "<tr>\n";
	for (var n=0; n<7; n++)
		str_buffer += "	<td bgcolor=\"#ffb400\">"+
		"<font color=\"white\" face=\"tahoma, verdana\" size=\"2\">"+
		week_days[(n_weekstart+n)%7]+"</font></td>\n";
	// print calendar table
	str_buffer += "</tr>\n";
	while (dt_current_day.getMonth() == dt_datetime.getMonth() ||
		dt_current_day.getMonth() == dt_firstday.getMonth()) {
		// print row heder
		str_buffer += "<tr>\n";
		for (var n_current_wday=0; n_current_wday<7; n_current_wday++) {
				if (dt_current_day.getDate() == dt_datetime.getDate() &&
					dt_current_day.getMonth() == dt_datetime.getMonth())
					// print current date
					str_buffer += "	<td bgcolor=\"#FFB6C1\" align=\"right\">";
				else if (dt_current_day.getDay() == 0 || dt_current_day.getDay() == 6)
					// weekend days
					str_buffer += "	<td bgcolor=\"#e1e1e1\" align=\"right\">";
				else
					// print working days of current month
					str_buffer += "	<td bgcolor=\"white\" align=\"right\">";

				if (dt_current_day.getMonth() == dt_datetime.getMonth())
					// print days of current month
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'; window.close();\">"+
					"<font color=\"black\" face=\"tahoma, verdana\" size=\"2\">";
				else 
					// print days of other months
					str_buffer += "<a href=\"javascript:window.opener."+str_target+
					".value='"+dt2dtstr(dt_current_day)+"'; window.close();\">"+
					"<font color=\"gray\" face=\"tahoma, verdana\" size=\"2\">";
				str_buffer += dt_current_day.getDate()+"</font></a></td>\n";
				dt_current_day.setDate(dt_current_day.getDate()+1);
		}
		// print row footer
		str_buffer += "</tr>\n";
	}
	// print calendar footer
	str_buffer +=
		"<form name=\"cal\">\n<tr><td colspan=\"7\" bgcolor=\"#ffb400\">"+
		"<font color=\"White\" face=\"tahoma, verdana\" size=\"2\">"+
		"&nbsp;<input type=\"hidden\" name=\"time\" value=\""+dt2tmstr(dt_datetime)+
		"\" size=\"8\" maxlength=\"8\"></font></td></tr>\n</form>\n" +
		"</table>\n" +
		"</tr>\n</td>\n</table>\n" +
		"</body>\n" +
		"</html>\n";

	var vWinCal = window.open("", "Calendar", 
		"width=200,height=250,status=no,resizable=yes,top=200,left=200");
	vWinCal.opener = self;
	var calc_doc = vWinCal.document;
	calc_doc.write (str_buffer);
	calc_doc.close();
}


// datetime parsing and formatting routimes. modify them if you wish other datetime format


function str2dt (str_datetime) {
	var re_date = /^(\d+)\.(\d+)\.(\d+)/;
	if (!re_date.exec(str_datetime))
		return alert("Invalid Datetime format: "+ str_datetime);
	return (new Date (RegExp.$3, RegExp.$2-1, RegExp.$1, RegExp.$4, RegExp.$5, RegExp.$6));
}


function dt2dtstr (dt_datetime) {
	if (String(dt_datetime.getDate()).length == 1) {
		tag = "0" + dt_datetime.getDate();
	} else {
		tag = dt_datetime.getDate();
	}

	if (String((dt_datetime.getMonth()+1)).length == 1) {
		monat = "0" + (dt_datetime.getMonth()+1);
	} else {
		monat = (dt_datetime.getMonth()+1);
	}

	return (new String (tag + "."+ monat +"."+dt_datetime.getFullYear()) );
//	return (new String ("0"+dt_datetime.getDate()+"."+(dt_datetime.getMonth()+1)+"."+dt_datetime.getFullYear()+" "));
}


function dt2tmstr (dt_datetime) {
	return (new String (
			dt_datetime.getHours()+":"+dt_datetime.getMinutes()+":"+dt_datetime.getSeconds()));
}

function passCheck()
{
if(document.OCForm.Password.value != document.OCForm.PasswordConfirmation.value &  document.OCForm.PasswordConfirmation.value != document.OCForm.Password.value)
{
	alert("Die angegebenen Passwörter stimmen nicht überein!");
	document.OCForm.PasswordConfirmation.focus();
	return false;
}
else
{
        return true;
}
}


// ***************  JS für Saferpay *********************** //
//global variables
	var objRef;
	var strUrl;
	var strMode;
	
	// ///////////////////////////////////////////////////////////////
	// OpenSaferpayTerminal
	//
	// if java script is enabled this function sets a javascript code 
	// in the executive space of the open call or calls the 
	// OpenSaferpayTerminalWindow function directly (in case of BUTTON 
	// - works only with enabled java script)
	// ///////////////////////////////////////////////////////////////
	function OpenSaferpayTerminal(url, obj, mode) 
	{
		window.onerror = DoNothing;
		
		//open a window for these browsers
		if(
			(
				(window.navigator.appName.indexOf("Microsoft Internet Explorer") != -1 &&
					window.navigator.appVersion.substring(0,1) >= 4
				) 
				||
				(window.navigator.appName.indexOf("Netscape") != -1 &&
					window.navigator.appVersion.substring(0,1) >= 4
				)
			)
			&&
			(window.navigator.userAgent.indexOf("Opera") == -1)	
		)
		{
			objRef = obj;
			strUrl = url;
			strMode = mode;
		
			if(mode == "LINK")
			{
				obj.href = "javascript:OpenSaferpayTerminalWindow()";
			}
			else if(mode == "FORM")
			{
				obj.action = "javascript:OpenSaferpayTerminalWindow()";
			}
			else if(mode == "BUTTON")
			{
				OpenSaferpayTerminalWindow();
			}
		}
	}

	// ///////////////////////////////////////////////////////////////
	// OpenSaferpayTerminalWindow
	//
	// the java script code that was set thru OpenSaferpayTerminal
	// function will call this function. OpenSaferpayTerminalWindow 
	// then creates the saferpay window.
	// ///////////////////////////////////////////////////////////////
	function OpenSaferpayTerminalWindow() 
	{
		window.onerror = DoNothing;

		//reset the url for the next click
		if(strMode == "LINK") objRef.href = strUrl;
		else if(strMode == "FORM") objRef.action  = strUrl;
		
		//add the standalone attribute to deliver the window state to the server
		if(strUrl.indexOf("WINDOWMODE=Standalone") == -1) strUrl += "&WINDOWMODE=Standalone";
	
		w = window.open(
			strUrl,
			'SaferpayTerminal',
			'scrollbars=1,resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,width=580,height=400'
		);
		
		w.focus();
	}
	
	
	// ///////////////////////////////////////////////////////////////
	// OpenSaferpayWindowJScript(strUrl)
	//
	// this function provides the open window functionality for
	// using form javascript
	// ///////////////////////////////////////////////////////////////
	function OpenSaferpayWindowJScript(strUrl) 
	{
		window.onerror = DoNothing;
		
		//add the standalone attribute to deliver the window state to the server
		if(strUrl.indexOf("WINDOWMODE=Standalone") == -1) strUrl += "&WINDOWMODE=Standalone";
	
		w = window.open(
			strUrl,
			'SaferpayTerminal',
			'scrollbars=1,resizable=0,toolbar=0,location=0,directories=0,status=1,menubar=0,width=580,height=400'
		);
		
		w.focus();
	}

	// ///////////////////////////////////////////////////////////////
	// DoNothing
	//
	// error handler does nothing.
	// ///////////////////////////////////////////////////////////////
	function DoNothing(sMsg,sUrl,sLine)
	{
		//if the error handler returns true the error will not be 
		//displayed except InterDev error handling is enabled.
		return true;
	}



// ********************  JS fuer TinyMCE FileBrowser ******************** //

var mceWin;

function tinymceFileBrowser (field_name, url, type, win)
{
	// alert("Field_Name: " + field_name + "\nURL: " + url + "\nType: " + type + "\nWin: " + win);   // debug
	
	mceWin = win;
	var fileBrowserWindow = new Array();
	
	/* If you work with sessions in PHP and your client doesn't accept cookies you might need to carry
	the session name and session ID in the request string (can look like this: "?PHPSESSID=88p0n70s9dsknra96qhuk6etm5").
	These lines of code extract the necessary parameters and add them back to the filebrowser URL again. */
	
	var cmsURL = window.location.pathname;      // script URL               //  /Webportal/showpage.asp
	var searchString = window.location.search;  // possible parameters   //  ?id=79F9529E5F884510B2B8109D16E02246
	if (searchString.length < 1)
	{
		// add "?" to the URL to include parameters (in other words: create a search string because there wasn't one before)
		searchString = "?id=xxx&type=yyy";
	}
	
	// fileBrowserWindow["file"] = cmsURL + searchString + "&type=" + type; // PHP session ID is now included if there is one at all
	fileBrowserWindow["file"] = "../../../../../../../../../tinymcefileupload.asp" + searchString + "&type=" + type;
	
	fileBrowserWindow["title"] = "File Browser";
	fileBrowserWindow["width"] = "495";
	fileBrowserWindow["height"] = "200";
	fileBrowserWindow["close_previous"] = "no";
	tinyMCE.openWindow(fileBrowserWindow, {
		window : win,
		input : field_name,
		resizable : "no",
		inline : "yes",
		editor_id : tinyMCE.getWindowArg("editor_id")
	});
	
    return false;
}

function mceInsertImage(url) 
{
	// Insert link, field: href
	if (mceWin.document.URL.substring((mceWin.document.URL.length) - 8, mceWin.document.URL.length) == 'link.htm')
	{
		mceWin.document.getElementById('href').value = url;
	}
	// Insert image, field: src
	if (mceWin.document.URL.substring((mceWin.document.URL.length) - 9, mceWin.document.URL.length) == 'image.htm')
	{
		mceWin.document.getElementById('src').value = url;
		mceWin.showPreviewImage(url);
	}
	mceWin.focus();
}

/** ********************  JS fuer PleaseWait Message ********************
* Author:			Mathias Chastonay, Opacc Software AG
* Funktionsweise:	Beim Aufruf der Funktion pleaseWaitShow() wird im Vordergrund
*					eine "Bitte warten" Meldung angezeigt bis die Seite neu geladen ist.
* Einbindung:		Untenstehende Funktionen kopieren und bei gewünschtem Event (onclick, onchange...)
*					die Funktion pleaseWaitShow() aufrufen.
*/

function pleaseWaitShow(messageText)
{
	// Falls IE6 oder tiefer müssen die SelectionBoxes wegen eines IE Bugs ausgeblendet werden
	var index=navigator.appVersion.indexOf("MSIE");
    if (index>-1)
    {
		var version=parseFloat(navigator.appVersion.substring(index+5));
		if(version <= 6) 
		{
			hideSelectBoxes();
		}
    }
	// Please Wait Box erstellen
	writeHTML(messageText);


	//Position der Message bestimmen
	centerMessage(200,100);
	//document.getElementById("loading").style.visibility="visible";
}

function writeHTML(messageText)
{
	theBody = document.getElementsByTagName('BODY')[0];
	messageContainer = document.createElement('div');
	messageContainer.id = 'loading';

	messageContainer.innerHTML = ''+
		'<table class="loadingtable" cellpadding="0" cellspacing="0">'+
			'<tr>'+
				'<td class="loadingcell">'+
					'<b>'+messageText+'</b><br/>'+
				'</td>'+
			'</tr>'+
		'</table>';
	theBody.appendChild(messageContainer);
}

function centerMessage(width, height) 
{
		var theBody = document.getElementsByTagName("BODY")[0];
		var scTop = parseInt(getScrollTop(),10);
		var scLeft = parseInt(theBody.scrollLeft,10);
		
		var fullHeight = getViewportHeight();
		var fullWidth = getViewportWidth();
		document.getElementById("loading").style.left=(scLeft + ((fullWidth - width) / 2)) + "px";
		document.getElementById("loading").style.top=(scTop + ((fullHeight - height) / 2)) + "px";
}


function pleaseWaitHide()
{
	document.getElementById("loading").style.visibility="hidden";
 }

/**
* Bei IE 6 müssen wegen einem Fehler die Dropdowns ausgeblendet werden.
*/

function hideSelectBoxes() 
{
		for(var e = 0; e < document.OCForm.length; e++)
		{
			if(document.OCForm.elements[e].tagName == "SELECT") 
			{
				document.OCForm.elements[e].style.visibility="hidden";
			}
		}
	
}


function getScrollTop() 
{
	if (self.pageYOffset) // all except Explorer
	{
		return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollTop;
	}
}

function getScrollLeft() 
{
	if (self.pageXOffset) // all except Explorer
	{
		return self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollLeft)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollLeft;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollLeft;
	}
}

function getViewportHeight() 
{
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 

	return window.undefined; 
}
function getViewportWidth() 
{
	var offset = 17;
	var width = null;
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
}

/* ********************  Ende JS fuer PleaseWait Message ******************** */

function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].display = "none"
else if (document.all) document.all[''+id+''].style.display = "block"
else if (document.getElementById) document.getElementById(''+id+'').style.display = "block"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].display = "block"
else if (document.all) document.all[''+id+''].style.display = "none"
else if (document.getElementById) document.getElementById(''+id+'').style.display = "none"
}
}

function checkUserID(UserID, Email){

	if(UserID.toUpperCase()==Email.toUpperCase())
	{	
		toggleDiv("infoBox",1);
	}
	else
	{
		toggleDiv("infoBox",0);
	}
}


function PosSelect(feld,wert)
{

 if(document.OCForm[wert].value == 1) 
 {
 	document.OCForm[wert].value = 0;
 } else {
 	document.OCForm[wert].value = 1;
 }
 
 
 
  if(feld.length>1)
  {
    if(document.OCForm[wert].value == 1) 
    {
      for (i = 0; i < feld.length; i++) 
      {3
        feld[i].checked = true;
      }
    }
    else 
    {
      for (i = 0; i < feld.length; i++) 
      {
        feld[i].checked = false;
      }
    }
  }
  else
  {
    if(document.OCForm[wert].value == 1) 
    {
      feld.checked=true;
    }
    else
    {
      feld.checked=false;
    }
  }
}


function PosDelete(feld,Link,txtArea)
{
  var Mark = "";
  if(feld.length>1)
  {
    for (i = 0; i < feld.length; i++) 
    {
      if(feld[i].checked == true)
      {
        var del = feld[i].value + "\n";
      } 
      else
      {
        del = "";
      }
      Mark = Mark + del;
    }
  }
  else
  {
    if(feld.checked == true)
    {
      var del = feld.value + "\n";
    } 
    else
    {
      del = "";
    }
    Mark = Mark + del;
  }

  document.OCForm[txtArea].value = Mark;

  if (Mark != "")
  { 
	document.OCForm.txtTargetLevel.value = Link;
    document.OCForm.submit();
  }
  else
	  document.OCForm.submit();
}


function editColor(){
var tableRows = document.getElementsByTagName("tr");
var j = 1;
	for(var i = 0, n = tableRows.length; i < n; ++i) {
			var elem = tableRows[i];
			if(((i%2)==1)&&(elem.className == 'TR1')){	
			elem.style.backgroundColor='#FFFFFF';			
			}						
	}
}

// Funktion löscht über asynchronen Request die temporären XML-Dateien des Auswertungstools
// Benötigt wird die Datei delTempFiles.asp (muss im Ordner "projekt"/home liegen
// Relativer Pfad zum Ordner mit den XML-Dateien als Parameter übergeben
var req=null;
function delTempFiles(globalKey)
{
	try
	{
		req = new XMLHttpRequest();
	}
	catch (ms)
	{
		try
		{
			req = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (nonms)
		{
			try
			{
				req = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (failed)
			{
				req = null;
			}
		}
	}
	
	if (req == null)
	{
		alert("Error creating request object!");
	}
	
	// Anfrage erstellen (GET, url ist localhost, request ist asynchron !!
	var url = '../del/delTempFiles.aspx?globalKey='+globalKey;
	
	req.open("GET",url,true);
	// Beim Abschliessen des Request wird diese Funktion ausgefuehrt
	req.onreadystatechange = function()
	{
        switch(req.readyState)
		{
			case 4:
				if(req.status!=200)
				{
					alert("Fehler:"+req.status);
				}
				else
				{
					// Hier könnte auf den Output der ASP-Seite zugegriffen werden mit req.responseText
					document.getElementById("delDebug").innerHTML =req.responseText;
				}
				break;
			default:
				return false;
				break;
		}
    }
	  
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	req.send(null);
}

// Funktion löscht über asynchronen Request die temporären XML-Dateien des Auswertungstools
// Benötigt wird die Datei delTempFiles.asp (muss im Ordner "projekt"/home liegen
// Relativer Pfad zum Ordner mit den XML-Dateien als Parameter übergeben
var req=null;
function readFile(FieldName,FilePath)
{
	if(document.OCForm[FieldName].value=="")
	{
		try
		{
			req = new XMLHttpRequest();
		}
		catch (ms)
		{
			try
			{
				req = new ActiveXObject("Msxml2.XMLHTTP");
			}
			catch (nonms)
			{
				try
				{
					req = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (failed)
				{
					req = null;
				}
			}
		}
		
		if (req == null)
		{
			alert("Error creating request object!");
		}
		
		// Anfrage erstellen (GET, url ist localhost, request ist asynchron !!
		var url = FilePath;
		
		req.open("GET",url,true);
		// Beim Abschliessen des Request wird diese Funktion ausgefuehrt
		req.onreadystatechange = function()
		{
			switch(req.readyState)
			{
				case 4:
					if(req.status!=200)
					{
						alert("Fehler:"+req.status);
					}
					else
					{
						//document.OCForm[FieldName].value=req.responseText;
						GenerateImportDataTable(req, true);
					}
					break;
				default:
					return false;
					break;
			}
		}
		  
		req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		req.send(null);
	}
	else
	{
		GenerateImportDataTable(document.OCForm[FieldName],false);
	}
}

function GenerateImportDataTable(data, firstCall)
{
	if(firstCall)
	{
		var dataString=data.responseText;
	}
	else
	{
		var dataString=data.value
	}
	var msg='<table id="dataImportTable">'+
		'<thead>'+
			'<tr>'+
				'<th>Artikelnummer</th>'+
				'<th>Menge</th>'+
			'</tr>'+
		  '</thead>';
	
	var lineValues=dataString.split("\n");
	var artNr;
	var quantity;

	for(i=0;i<lineValues.length;i++)
	{

		if(lineValues[i].length>1)
		{
			var tmp=lineValues[i].split(";");
			
			msg+=''+
				'<tr>'+
					'<td>'+
						'<input type="text" value="'+tmp[0]+'"/>'+
					'</td>'+
					'<td>'+
						'<input type="text" value="'+tmp[1]+'"/>'+
					'</td>'+
				'</tr>';
		}
	}
	msg+='</table></form>';
	messageContainer = document.getElementById("dataTableContainer");
	messageContainer.innerHTML = msg;

}

function ImportDataTable2CondText(fieldname)
{
	dataTable=document.getElementById("dataImportTable");
	dataTableRows=dataTable.rows;
	
	var data="";

	// i=1 damit TableHeader nicht mit angezeigt wird
	for(i=1; i < dataTableRows.length; i++) 
	{
		dataTableCells=dataTableRows[i].cells;
		
		for(j=0; j<dataTableCells.length; j++)
		{
			data+=dataTableCells[j].firstChild.value;

			if(j!=(dataTableCells.length-1))
			{
				data+=";";
			}
		}
		data+="\n";
	}

	document.OCForm[fieldname].value=data;
}

/* ---------------------------------------
	Funktionen zu GreyBox
*/
function GB_showWithReload (caption, url, callback_fn) {
    var options = {
		type: "page",
        caption: caption,
        fullscreen: true,
        show_loading: true,
		// bei True wird das Fenster auch geschlossen, wenn man irgendwo auf den Hintergrund klickt 
        overlay_click_close: false,
		// Urspungsseite wird beim Schliessen neu geladen (NICHT submited!)
		reload_on_close: true,
		callback_fn: callback_fn
    }
    var win = new GB_Window(options);
    return win.show(url);
}

function GB_submitParentPage()
{
	top.window.document.OCForm.submit();
}
/* 
	Ende Funktionen zu GreyBox
--------------------------------------- */

//--------------------------------------------------------------------------------
//  Beim Klick auf einen Radiobutton werden Input Felder gelöscht
//  (Warenkorb - Lieferadresse ändern)
//  08.01.2008 - sh
//--------------------------------------------------------------------------------
function DeleteInputFields(){
	for (i=1; i < 8; i++)
	{
		document.getElementById('AdHocAdrZ'+i).value = "";
	}
}

//--------------------------------------------------------------------------------
//  Bei Klick in Input Feld wird Radio Button Adhoc-Adresse aktiv
//  (Warenkorb - Lieferadresse ändern)
//  08.01.2008 - sh
//--------------------------------------------------------------------------------
function CheckRadio() {
		document.getElementById('RadioAdhoc').checked=true;
}

function setDeliv (Field, TotalWeight) {

	document.OCForm[Field].value = document.OCForm.Delivery.value;
	//alert(TotalWeight);

}

// Bitte warten - Fenster
function blockUIcustom (text)
{

	$.blockUI({ 
		//message: text +'<br><img src="config/layout/images/others/general/ajax-loader.gif" />',
                  message: text,
		css: {
			border: 'none', 
			padding: '15px', 
			backgroundColor: '#000', 
			'-webkit-border-radius': '12px', 
			'-moz-border-radius': '12px', 
			opacity: '.5', 
                        color: '#fff' 
			
	             }
	});
}

function artredirect ()
{
	document.OCForm.txtTargetLevel.value = document.getElementById('txtRedirectOC').value;
	document.OCForm.submit();

}

function checkfield(obj, pw1, pw2, text1, text2, text3, text4, text5, textwait)
{
var checker = "";
var checkerpw = "";

   
    // *************************************************
	// Workaround da FF bei DropDown-Boxen ohne Value (Empty-Wert bei Funktion {gCreateSelection}) den Option-Text als Value nimmt!!
	// IE und Firefox interpretieren DOM-Modell anders / ES, 24.02.2009
	// *************************************************
	var salutno = document.getElementsByName('txtSalutNo');
	
	//alert(isNaN(salutno[0].value));
	//alert(salutno[0].value=="");
	//alert(isNaN(salutno[0].value) || salutno[0].value=="");
	
	if (isNaN(salutno[0].value) || salutno[0].value=="")
	{
		salutno[0].style.backgroundColor="#FF6666";
        checker = 1;
	} else {
		salutno[0].style.backgroundColor="#FFFFFF";
	}

	// ENDE WORKAROUND...
	



	for(var i=0;i<obj.length;i++){
 
            
			currobj = document.getElementsByName(obj[i]);
			
			
			display1 = currobj[0].style.display;
			display2 = currobj[0].style.display;

			 
            if(currobj[0].value=="" && currobj[0].style.display != "none" && currobj[0].parentNode.style.display != "none")
            {
                        currobj[0].style.backgroundColor="#FF6666";
                        checker = 1;
                        
            }  else {
                        currobj[0].style.backgroundColor="#FFFFFF";

            }                  
	}







	if (checker == 1) {
	  alert(text1);
	  return false;

	} else {
		
		//PLZ-Prüfung
		if (document.getElementById('txtZip').value > "")
		{
			//alert('test2');
			var myregexp3 = /^\d{4}$/
			if (myregexp3.test(document.getElementById('txtZip').value) == false)
			{
				alert(text3);
				return false;
			}
		}

		//Email-Adresse muss korrekt sein
		var myregexp4 = /^([a-zA-Z0-9\-\._]+)@([a-zA-Z0-9\-\._]+)\.([a-zA-Z]{2,})$/
        if (document.OCForm.txtAdressTyp[0].checked) {
			//alert(document.getElementById('txtEmail').value);
			if (myregexp4.test(document.getElementById('txtEmail').value) == false)
				{
					alert(text4);
					return false;
				}
        }

		if (document.OCForm.txtAdressTyp[1].checked) {
			//alert(document.getElementById('txtEmailB').value);
			if (myregexp4.test(document.getElementById('txtEmailB').value) == false)
				{
					alert(text4);
					return false;
				}
        }

	
	register = document.getElementsByName('Register');
	if (register[0].checked) 
	{


		//PW muss mindestens 6 Zeichen lang sein
		if (document.OCForm[pw1].value > "") {
			var myregexp5 = /^.{6,}$/
				if (myregexp5.test(document.OCForm[pw1].value) == false)
				{
					alert(text5);
					return false;
				}
		}

		//PW müssen gleich lang sein
		if (document.OCForm[pw2].value > "") {

				   if (document.OCForm[pw1].value == document.OCForm[pw2].value) {
					 //do nothing
				   } else {
					   document.OCForm[pw1].style.backgroundColor="#FF6666";
					   document.OCForm[pw2].style.backgroundColor="#FF6666";
					   alert(text2);
					   return false;
					   }
				   }
	}

		


		
	}


 	blockUIcustom(textwait);
	document.OCForm.submit();
}


function checkAGB (text,link) 
{


	if (document.getElementById('AGB').checked) {
		document.OCForm.txtEventConfirmationURL.value=link;
		document.OCForm.txtEventName.value='SendOrder';
		document.OCForm.submit();
	} else 
	{
		alert(text);
	}
	
}


function checkAGB2 (text,link) 
{
	if (document.getElementById('AGB').checked) {
		document.OCForm.txtTargetLevel.value=link;
		document.OCForm.submit();
	} else 
	{
		alert(text);
	}
	
}


function RoundValue(MisC2No,sId,sValue) 
{


	var sValue1 =  parseFloat(sValue);
	var Zeichen = sValue1.toString().indexOf(".");

	if (sValue1.toString().indexOf(".") > 0 && MisC2No == '1')
	{
		//alert(MisC2No);
		sValue1 = sValue1.toString() + "00";
		sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);	
		sValue1 =  parseFloat(sValue1);
	}

	if (Zeichen > 0)
	{
		sValue1 = sValue1 * 100;
		sValue1 = Math.round(sValue1);
		sValue1 = sValue1 / 100;

		if (sValue1.toString().indexOf(".") > 0)
		{
			sValue1 = sValue1.toString() + "0";
			sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
		}	
	} 
	 sValue1 = sValue1.toString();
	 Zeichen = sValue1.indexOf(".");


	if (Zeichen > 0)
	{
		switch(sValue1.slice(sValue1.length -1,sValue1.length)) {
			case "9":
				sValue1 = parseFloat(sValue1) + 0.01;
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "8":
				sValue1 = parseFloat(sValue1) + 0.02;
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "7":
				sValue1 = parseFloat(sValue1) - 0.02;
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "6":
				sValue1 = parseFloat(sValue1) - 0.01;
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "5":
				sValue1 = parseFloat(sValue1);
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "0":
				sValue1 = parseFloat(sValue1);
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "1":
				sValue1 = parseFloat(sValue1) - 0.01;
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "2":	
				sValue1 = parseFloat(sValue1) - 0.02;
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "3":
				sValue1 = parseFloat(sValue1) + 0.02;
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
			case "4":
				sValue1 = parseFloat(sValue1) + 0.01;
				sValue1 = sValue1 * 100;
				sValue1 = Math.round(sValue1);
				sValue1 = sValue1 / 100;

				if (sValue1.toString().indexOf(".") > 0)
				{
					sValue1 = sValue1.toString() + "00";
					sValue1 = sValue1.slice(0,sValue1.toString().indexOf(".") +3);				
				}
				break;
		}
	}
	
	if (sValue1.toString().indexOf(".") < 1)
	{
		sValue1 = sValue1.toString() + ".00";
	}

	$("#"+sId).html(sValue1);
}



function RoundValueNEW (sId,value,percent,client,fix) 
{
	
	if (fix == 1) {
		//alert(value);
		//alert(percent);
		
		rebate = parseFloat(value) * parseFloat(percent) / 100;

		
		if (client == 12) {
			//alert(rebate);
			rebate = Math.round(rebate / 0.01) * 0.01;
			rebate = Math.round(rebate / 0.05) * 0.05;
			//alert(rebate);
			rebate = rebate.toFixed(2);
		}
		//alert(rebate);
		result = parseFloat(value) - rebate;


		if (client == 12) {
			result = Math.round(result / 0.05) * 0.05;
		}

	        result = parseFloat(value) - rebate;
		result = result.toFixed(2);
		$("#"+sId).html(result);
		

	} else {	
 		result = parseFloat(percent);
		result = result.toFixed(2);
		$("#"+sId).html(result);      
        
	}
}


function checkDifferenz(sVal1,sVal2) 
{
	if (this.document.OCForm[sVal2].value == '' || this.document.OCForm[sVal1].value == '')
	{
		document.getElementById('butSearch').style.display = 'none';
		document.getElementById('butSearchMsg').style.display = 'inline';
	}
	else 
	{
		value1 = parseFloat(this.document.OCForm[sVal1].value);
		value2 = parseFloat(this.document.OCForm[sVal2].value);
	
		result = value2 - value1;

		if (result > 20000)
		{
			alert("Der Adresserange ist zu gross!");
			document.getElementById('butSearch').style.display = 'none';
			document.getElementById('butSearchMsg').style.display = 'inline';
			document.getElementById('sVal2').focus();
		}
		else
			document.getElementById('butSearch').style.display = 'inline';
			document.getElementById('butSearchMsg').style.display = 'none';
		
		}
	
/**/
}


function showMessage(divid)
{
 $(divid).css("display","block");

}


function setABGSelection(txtId)
{
	if (txtId == 'X1')
	{
		document.getElementById('Pool_22').checked = false;
		document.getElementById('Pool_1').checked = true;
	}
	else
	{
		document.getElementById('Pool_1').checked = false;
		document.getElementById('Pool_22').checked = true;
	}

}

function setBsave()
{
$("#bSave").val("false");

}