// if(document.layers) window.open('hinweis_browser.html','hinweis','menubar=no,scrollbars=no,resizable=yes,width=400,height=400');

var userInformation = new Array();
var localeInformation = new Array();


/**
 * LUHN Algorithmus um Kreditkartennummern auf Plausibilitaet zu Pruefen
 *
 */
function ccCheckSumOK (s) {
	// remove non-numerics
	var v = "0123456789";
	var w = "";
	for (i = 0; i < s.length; i++) {
		x = s.charAt (i);
		if (v.indexOf (x, 0) != -1)
		w += x;
	}
	
	// validate number
	j = w.length / 2;
	if (j < 6.5 || j > 8 || j == 7) return false;
	k = Math.floor (j);
	m = Math.ceil (j) - k;
	c = 0;
	for (i = 0; i < k; i++) {
		a = w.charAt (i * 2 + m) * 2;
		c += a > 9 ? Math.floor (a / 10 + a % 10) : a;
	}
	for (i = 0; i < k + m; i++) c += w.charAt(i * 2 + 1 - m) * 1;
	return (c % 10 == 0);
}

/**
 * Setzt einen Cookie mit den angegebenen Eigenschaften
 *
 * name       Name des Cookies
 * value      Wert des Cookies
 * [expires]  G?ltigkeitszeitraum des Cookies (default: g?ltig bis zum Ende der Session)
 * [path]     Pfad f?r den der jeweiligen Cookie gilt (default: path of calling document)
 * [domain]   Dom?ne f?r den der jeweilige Cookie gilt
 *              (default: domain of calling document)
 * [secure]   Boolscher Ausdruck, falls der Cookie eine sichere Transkation verlangt
 */
function setCookie(name, value, expires, path, domain, secure)
{
   var expiryDate = new Date();
   var expiryInt = expiryDate.getTime() + (expires * 24 * 60 * 60 * 1000);
   expiryDate.setTime(expiryInt);
   
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expiryDate.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


/**
 * Ermittelt den Wert des angegebenen Cookies
 *
 * name  Name des Cookies
 *
 * Liefert den Wert des Cookies als String zur?ck
 *   oder null wenn der Cookie nicht exisiiert
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * L?scht den angegebenen Cookie
 *
 * name      Name des Cookies
 * [path]    Pfad zum Cookie (muss identisch mit dem Pfad beim Anlegen sein)
 * [domain]  domain of the cookie (muss identisch mit der Domain beim Anlegen sein)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

/**
 * Interne Funktion zur Auswertung der Cookies
 * cookies "UserInformation" und "LocaleInformation"
 *
 */
function evaluateCookieInformation() {
    var cookie = getCookie("UserInformation");
    if (cookie!=null) {
        var tokens = cookie.split("|");
        for (var i=0;i<tokens.length;i++) {
            var tmp = tokens[i].split("=");
            userInformation[tmp[0]]=tmp[1];
        }
    }
    
    cookie = getCookie("LocaleInformation");
    if (cookie!=null) {
        tokens = cookie.split("|");
        for (i=0;i<tokens.length;i++) {
            tmp = tokens[i].split("=");
            localeInformation[tmp[0]]=tmp[1];
        }   
    }
}

/**
 * Liefert einen Wert aus dem Cookie UserInfo
 *
 * key          Schl?ssel unter dem der Wert im Cookie gespeichert ist
 * defaultvalue R?ckgabewert wenn der Cookie nicht gelesen werden kann
 *
 */
function getUserInfo(key, defaultvalue) {
    if (userInformation.length==0) evaluateCookieInformation();
    if (userInformation[key] == null) {
        return  defaultvalue;
    } else {
        return  userInformation[key];
    }
}

/**
 * Liefert einen Wert aus dem Cookie LocaleInformation
 *
 * key          Schl?ssel unter dem der Wert im Cookie LocaleInformation gespeichert ist
 * defaultvalue R?ckgabewert, falls der Cookie nicht gelesen wertn kann
 *
 */
function getLocaleInfo(key, defaultvalue) {
    if (localeInformation.length==0) evaluateCookieInformation();
    if (localeInformation[key] == null) {
        return defaultvalue;
    } else {
        return localeInformation[key] ;
    }
}

function popup(pname)
{
	var popupOptionen = "";
	switch(pname)
	{
		 case "Druckansicht":
		 popupOptionen='menubar=yes,scrollbars=yes,resizable=yes,width=300,height=300';
		 break;
		 case "CVVPopup":
		 popupOptionen='menubar=no,scrollbars=no,toolbar=no,resizable=no,location=no,directories=no,status=no,width=300,height=300';
		 break;
		 case "Geschenkverpackung":
		 popupOptionen='menubar=no,scrollbars=no,toolbar=no,resizable=no,location=no,directories=no,status=no,width=300,height=300';
		 break;
		 case "Newsletter":
		 popupOptionen='menubar=no,scrollbars=yes,toolbar=no,resizable=yes,location=no,directories=no,status=no,width=300,height=300';
		 break;
		 case "newcollection":
		 popupOptionen='menubar=no,scrollbars=no,toolbar=no,resizable=no,location=no,directories=no,status=no,width=300,height=300';
		 break;
		 case "VoucherGeneral":
		 popupOptionen='menubar=no,scrollbars=no,toolbar=no,resizable=no,location=no,directories=no,status=no,width=300,height=300';
		 break;
		 case "VoucherCash":
		 popupOptionen='menubar=no,scrollbars=no,toolbar=no,resizable=no,location=no,directories=no,status=no,width=300,height=300';
		 break;
		 case "Slideshow": 
		 popupOptionen='toolbar=no,location=no,directories=0,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=300,left=0,top=0';
		 break;
		 default:
		 alert("Popup noch nichtdefiniert");
		 break;	
	}
	window.open('',pname,popupOptionen);
}

// KA-2004-09-10: Count Linebreaks in Objekt
/*function countLinebreaks(obj) {
	var count = 0;

	var str    = obj.value;
	var substr = "";
	var result = "";
	
	alert (str.length);

	while (str.length > 0) {
		if (str.indexOf("\n") != -1) {
			alert ("if");
			result += str.substring(0,str.indexOf("\n")+1)
			str = str.substring(str.indexOf("\n")+1, str.length);
			alert ("str: " +  str);
		} else if (str.indexOf(" ") != -1) {
			alert ("else if");
			result += str.substring(0,str.indexOf(" "));
			result += "\n";
			str = str.substring(str.indexOf(" ")+1, str.length);
			alert ("str: " +  str);
		} else {
			alert ("else if");
			result += str.substring(0,str.length);
			str = "";
			alert ("str: " +  str);
		}
		alert (result);
	}
	

	var result = str.match(/.\n|\r/g);
	if (result) {
		alert (result);
		count = result.length;
	}
	alert (count);
}*/

// SW-2004-05-18: Determine if value is valid email adress
// SW-2004-07-30: verbesserte Abfrage (regexp)
// OR-2004-09-21: nochmals verbesserte Abfrage
// HS-2004-10-06: und nochmals verbesserte Abfrage TT#381
// HL-2005-03-28: 125. Anpassung, wir haben ja sonst nichts zu tun
function isValidEmail(obj) {
	//var strok = /^\w+(-\w+)*(\.\w+)*(_\w+)*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	var strok = /^[\w\.\-]+\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	return ( strok.exec( obj.value ) );
}

// KA-2004-05-25: Determine if value is a valid E-Mail Array
function isEmail(obj) {
	var check = true;

	var str = obj.value;
	str = str + ",";
	//result = str.match(/.+?[@].+?\s*?,\s*?/g);
	result = str.match(/.+?.+?\s*?[;,]\s*?/g);

	if (result) {
		for(i=0 ; i<result.length ; ++i) {
			var string = result[i];
			if (!isValidEmailString ( string ) ) {
				check = false;
			}
		}
	}
	else { return(false); }
	return (check);
}

// KA-2004-05-24: Determine if value is valid email adress from a string
// SW-2004-07-30: verbesserte Abfrage (regexp)
// OR-2004-09-21: nochmals verbesserte Abfrage
// HL-2005-03-28: 125. Anpassung, wir haben ja sonst nichts zu tun
function isValidEmailString(str) {
	str = str.substring(0, str.indexOf(","))
	str = Trim(str);
	var strok = /^[\w\.\-]+\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	return ( strok.exec( str ) );
}

// KA-2004-05-18: Determine if value is valid Titel
function isValidTitel(obj) {
	if (  obj.value == "" ) return false;
		else return true;
}

// KA-2004-05-24: Determine if value is valid Country
function isValidCountry(obj) { return true; }

// KA-2004-05-18: Determine if value is valid NextRenevalMonth
function isValidNextRenevalMonth(obj) {
	var len = obj.value.length;
	var val = obj.value;
	
	if (len < 2 && len != 0) {
		for (i=len; i<2; i++) {
			val='0'+val;
		}
	}
	obj.value = val;
	var strok = /^\d{2}$/;
	if ( strok.exec( val ) ) {
		if ( val < 13 ) return true;
		else return false;
	}
	else return false;
}

// KA-2004-05-18: Determine if value is valid NextRenevalYear
function isValidNextRenevalYear(obj) {
	var len = obj.value.length;
	var val = obj.value;
	
	if (len < 2 && len != 0) {
		for (i=len; i<2; i++) {
			val='0'+val;
		}
	}
	obj.value = val;
	var strok = /^\d{2}$/;
	return ( strok.exec( val ) );
}

// KA-2004-05-19: Determine if value is valid CreditcardNumber
function isValidKreditCardNumber(obj) {
	var strok = /^\d{13,16}$/;
	return ( strok.exec( obj.value ) );
}

// KA-2004-05-19: Determine if value is valid CardChecksum
function isValidCVC2Number(obj) {
	var strok = /^\d{3,4}$/;
	return ( strok.exec( obj.value ) );
}

// KA-2004-05-18: Determine if a checkbox is checked
function isCheckBoxChecked(obj) {
	if (obj.checked == true) return true;
	else return false;
}

// SW-2004-05-18: Determine if value is number
function isNumber(obj) {
	var strok = /^\D$/;
	return ( strok.exec( obj.value ) );
}

// SW-2004-05-18: Determine if value is empty
function isEmpty(obj) {
	return ( obj.value=="" );
}

/* 	KA-2004-05-27: Checkes value of radiobutton group -> 
	return number of RadioButton which is checked
	returns "undefined" if nothing is checked  */
function getRadioInput(myObj) {
	var myVal = 'undefined';
	if((typeof myObj =='object') || (typeof myObj =='function')) {
		for (var i=0; i<myObj.length; i++) {
			if(myObj[i].checked) {
				myVal = myObj[i].value;
			} 
		}
	}
	return myVal;
}

// 	KA-2004-05-27: Checkes if given Object is a radio Button
function isRadioButton(myObj) {
	if ( myObj == null ) { return false; }
	else {
		if (myObj.type == 'radio') return true;
		else return false;
	}
}

/*	Checks which Radio Button in selected
	If no one is selected, the return value is -1
	else the return value is the listed number of the button
*/
function checkRadioButtons(myObj, NumberOfRadioButtons) {
	var iRet = -1;
	
	for (var i=0 ; i<NumberOfRadioButtons; i++)	{
		if (myObj[i].checked == true)
			iRet = i;
	}
	return iRet;
}

/*	Checks the quantity of an input field
	If the quantity is 0, an confirmation will be alerted
	If it will be confirmed, the form will be submitted  */
function checkQuantity(quantity, formname, fieldname) {
	if (quantity >= 0) {
		if (quantity == 0) {
			check = confirm("<!--{-->{Wollen Sie dieses Produkt wirklich l?schen?}<!--}-->");
			if(check == true) {
				doSubmit('update', formname);
			}
			else {
				//setFocus();
			}
		}
	}
	else { alert ("<!--{-->{Sie m?ssen eine Ziffer eingeben}<!--}-->"); }
}

/*	Submit an Form with the the given value */
function doSubmit(act, formname) {
	Wert = eval ('document.' + formname + '.dispatchaction' );
	Wert.value = act;
	
	eval ('document.' + formname + '.submit()')
}

/*	Submit an Form with the the given action */
//	myForm: Formular als Objekt, z.B. aus Button heraus aufgerufen -> onclick="doSubmitForm(this.form)"
//	myAction: optional, enth?lt die ActionURL und wird nur ?bergeben, wenn vorhandene ActionURL ge?ndert werden soll
function doSubmitForm(myForm,myAction) {
	if ( myAction != null ) myForm.action = myAction;
	myForm.submit();
}

// 	KA-2004-05-27: Checkes if given Object is a valid Amount (>0)
function isValidAmount(obj) 
{
	return ( obj.value>0 );
}

// 	KA-2004-05-27: Checkes if given Object is a valid Amount (>=0)
function isValidAmount2(obj) 
{
	return ( obj.value>=0 );
}

// 	KA-2004-05-27: Checkes if given Object is a valid ReturnReason (>0)
function isValidReturnReason(obj) {
	return ( obj.value>0 );
}

// KA-2004-05-26: Determine if value is valid PLZ
// HS-2004-10-29: Sonderbehandling, postalcode not mandatory
function isValidPostalCode(obj, cor) {
	var strok;

	switch (cor) {
		case "AUS":
			strok = /^\d{3,5}$/;
			break;
		case "AUT":
			strok = /^\d{4}$/;
			break;
		case "BEL":
			strok = /^\d{4}$/;
			break;
		case "CAN":
			strok = /^[A-Z]{1}\d{1}[A-Z]{1}[\ ]\d{1}[A-Z]{1}\d{1}$/;
			break;
		case "DNK":
			strok = /^\d{3,4}$/;
			break;
		case "FIN":
			strok = /^\d{1,5}$/;
			break;
		case "FRA":
			strok = /^\d{4,5}$/;
			break;
		case "DEU":
			strok = /^\d{5}$/;
			break;
		case "GRC":
			strok = /^\d{5}$/;
			break;
		case "ITA":
			strok = /^\d{5}$/;
			break;
		case "LUX":
			strok = /^\d{4}$/;
			break;
		case "NLD":
			strok = /^\d{4}[\ ][A-Z]{2}$/;
			break;
		case "PRT":
			strok = /^\d{4}$/;
			break;
		case "ESP":
			strok = /^\d{5}$/;
			break;
		case "SWE":
			strok = /^\d{5}$|^\d{3}[\ ]\d{2}$/;
			break;
		case "CHE":
			strok = /^\d{4}$/;
			break;
		case "GBR":
			strok = /^[A-Z0-9]{2,4}[\ ][A-Z0-9]{3}$/;
			break;
		case "USA":
			strok = /^\d{5}$|^\d{5}[\-]\d{4}$/;
			break;
		default:
			strok = /.*/;
			break;
	}
	// Sonderbehandling, postalcode not mandatory
	if(cor=="ARG" || cor=="HKG" || cor=="IRL") {
		if ( zip=="" || ( zip>=1 && zip<=24 ) ) { return true; }
		else { return false; }
	}
	else {
		return ( strok.exec( obj.value ) );	
	}
}

// KA-2004-05-26: Determine if given value has a Correct Value (Only A-Z, a-z, 0-9 is allowed)
function hasCorrectValue(obj)
{
	var allowedChars=/[a-zA-Z0-9]/;
	if (allowedChars.test( obj.value) ) { return true; } 
	else { return false; }
}

// KA-2004-05-18: Determine if value is valid MemberNumber1
function isValidMemberNumber1(obj) {
	var strok = /^[0-9]{3}$/;
	return ( strok.exec( obj.value ) );
}

// KA-2004-05-18: Determine if value is valid MemberNumber2
function isValidMemberNumber2(obj) {
	var len = obj.value.length;
	var val = obj.value;
	
	if (len < 7 && len != 0) {
		for (i=len; i<7; i++) {
			val='0'+val;
		}
	}
	obj.value = val;
	var strok = /^[0-9]{7}$/;
	return ( strok.exec( val ) );
}


// KA-2004-05-27: Calculates the possible delivery days for the next 30 Days
// Possible: Monday to Friday; Impossible: Saturday and Sunday
function writeDeliveryDays()
{
	myDate = new Date();
	myDate.setDate(myDate.getDate()+3); //fr?hestens in 3 Tagen
	
	for (i=0; i<27; i++)
	{
		if (myDate.getDay() != 0 && myDate.getDay() != 6) //Wochenende ausnehmen
			document.write('<option>' + myDate.getDate() + '.' + (myDate.getMonth()+1) + '.' + myDate.getYear() + '</option>');

		myDate.setDate(myDate.getDate()+1);
	}
}


// Ist der eingegebene Wert eine Ziffer <= maximum?
// obj: Eingabefeld 
// defaultwert: urspr?nglicher Wert vor der Ver?nderung
// maximum: maximaler Wert, optional
function validNumber(obj,defaultwert,maximum) {
	regx = /^[0-9]*$/;
	var ok = true;
	
	if ( !regx.exec( obj.value ) ) 
	{	
		alert(obj.value + ' ist keine Ziffer');
		obj.value = defaultwert;
		ok = false;	
	}
	else
	{
		if( maximum !=null )
		{
			if( obj.value > maximum ) 
			{
				alert('Bitte geben Sie einen Wert unter ' + (maximum + 1) + ' ein.');
				obj.value = defaultwert;
				ok = false;
			}
		}
	}
	return ok;
}
// KA-2004-05-19: Determine if value is valid Day of Birthday
function isValidBirthdayDay(obj) {
	var strok = /^\d{2}$/;
	if ( strok.exec( obj.value ) && obj.value > 0 && obj.value < 32 )
		return true;
	else
		return false;
}

// KA-2004-05-19: Determine if value is valid Month of Birthday
function isValidBirthdayMonth(obj) {
	var strok = /^\d{2}$/;
	if ( strok.exec( obj.value ) && obj.value > 0 && obj.value < 13 )
		return true;
	else
		return false;
}

// KA-2004-05-19: Determine if value is valid Year of Birthday
function isValidBirthdayYear(obj) {
	var strok = /^\d{4}$/;
	return ( strok.exec( obj.value ) );
}


// Remove leading and trainling spaces and carriage returns
function Trim(s) {
	// Remove leading spaces and carriage returns
	while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')) {
	    s = s.substring(1,s.length);
	}

  // Remove trailing spaces and carriage returns
	while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')) {
    	s = s.substring(0,s.length-1);
	  }
	return s;
}

// KA-2004-07-30: Shows a descrioption of HTML
function ShowWhatIsHTML(text) {
	alert (text);
}

// KA-2004-07-30: Shows a descrioption of Plaintext
function ShowWhatIsPlain(text) {
	alert (text);
}

// HS-2004-10-29: Shows and Hide an PostalCode-Div-Layer
function CheckPostalCodeVisibility(cor, divid) {
	//alert(document.getElementById(divid).style.visibility);
	if (document.getElementById(divid)) {
		if(cor=="ARG" || cor=="HKG" || cor=="IRL") {
			document.getElementById(divid).style.visibility='hidden';
		} else {
			document.getElementById(divid).style.visibility='visible';
		}
	}
}

// Show / Hide Search Layer and Go-Buttons
function changeSearchLayers () {
	// Change QuickSearchLayer
	MM_showHideLayers('Schnellsuche','','hide');
	MM_showHideLayers('SchnellsucheAlt','','show');
	
	// check if getElementById is allowed
	if (document.getElementById) {
		// check if extendet search is shown
		if (document.getElementById("ErweiterteSuche")) {
			// If detailed Search is shown, hide the Go-Button
			if (document.getElementById("GoButExtSearch")) {
				MM_showHideLayers('GoButExtSearch','','hide');
			}
			// If article Search is shown, hide the Go-Button
			if (document.getElementById("GoButArtID")) {
				MM_showHideLayers('GoButArtID','','hide');
			}
		}
		if (document.getElementById("GiftFind")) {
			MM_showHideLayers('GiftFind','','hide');
		}
	}
}

// Checks if the SearchTerm has at least a special 'length'
function checkSearchTermLength (SearchTerm, length)
{
	if (SearchTerm.length < length) {
		return false;
	}
}

// Checks if at least 2 Characters are in the SearchTerm
function checkSearchTermCharLength (SearchTerm)
{
	var Str = SearchTerm;
	while (Str.search(/[^a-z]/i) != -1) {
		Str = Str.replace(/[^a-z]/i,"");
	}
	var Suche = /([a-z]{2})/i;
	var Ergebnis = Suche.exec(Str);
	if (Ergebnis && Ergebnis.length) {
		return true;
	}
	else {
		return false;
	}
}

// Checks if the SearchTerm is '' oder equals the StopWord
function checkStopWord (SearchTerm, StopWord)
{
	if ((SearchTerm == StopWord) || (SearchTerm == "")) {
		return false;
	}
	return true;
}

function replaceSpecialChars(SearchTerm, isArtNumber, formname)
{
	//  Return Values:
	//
	//	0-> String was not modified
	//	1-> String was modified
	//	2-> String is not 3 Chars length
	//	3-> String has no 2 Chars

	var ret = 0; 
	var vormals = SearchTerm;
	var nachher = "";
	var FirstChar = "";

	// RegEx for Chars which should be replaces with a " "
	var regex_leerzeichen = /[ :;<=>??@()*+,.\/!"#$%&\[\\\]^?`{|}~?]/g;

	// RegEx for Chars which should be replaces with a "_"
	var regex_wildcard = /[-'??]/g;

	// Replace Chars with a " " except the First Char
	if (vormals.search(regex_leerzeichen) != -1) {
		ret = 1;
		var index = vormals.search(regex_leerzeichen);
		if (index == 0) {
			FirstChar = vormals.substring(0,1);
			vormals = vormals.replace(regex_leerzeichen ," ");
		} else {
			vormals = vormals.replace(regex_leerzeichen ," ");
		}
	}
	// Replace Chars with a "_" except the First Char
	if (vormals.search(regex_wildcard) != -1) {
		ret = 1;
		var index = vormals.search(regex_wildcard);
		if (index == 0) {
			FirstChar = vormals.substring(0,1);
			vormals = vormals.replace(regex_wildcard ,"_");
		} else {
			vormals = vormals.replace(regex_wildcard ,"_");
		}
	}
	
	// Replace First Char with the Original Char, if it was replaced
	if (FirstChar != "") {
		nachher = FirstChar + vormals.substring(1);
	} else {
		nachher = vormals.substring(0);
	}

	// Checks SearchTerm for Special-Characters not filteres by Regular Expression
	for (var i=1; i<nachher.length; i++) {

		// Start at Position 1 because the First Chat shouldn't be replaced!
		var test = nachher.charCodeAt(i);
	
		// Replaces Characters with a " "
		if ( ( test == 127 || test ==141 || test ==155 || test ==157 || test ==160 || test ==143 || test ==144 ) 
			 || ((test >= 1) && (test <=32)) 
			 || ((test >= 129) && (test <= 139)) 
			 || ((test >= 147) && (test <= 153)) 
			 || ((test >= 163) && (test <= 191))
			 || (test > 255 )) {

			ret = 1;
			nachher = nachher.substring(0,i) + ' ' + nachher.substring(i+1,nachher.length);
		}

		// Replaces Characters with a "_"
		if ((test == 140 || test == 142 || test == 145 || test == 146 || test == 154 || test == 156 || test == 158 || test == 159 || test == 161 || test == 162  ) || (test >= 192 && test <= 255)) {

			ret = 1;
			nachher = nachher.substring(0,i) + '_' + nachher.substring(i+1,nachher.length);
		}
	}

	// If SearchTerm is modified, change hidden Field
	if (nachher != SearchTerm) {
		var obj = eval ( 'document.' + formname + '.extended_search_result');
		obj.value = nachher;
	}

	if (!isArtNumber) {
		// Checks SearchTermLength < 3
		if ( checkSearchTermLength(nachher, 3) == false ) {
			ret = 2;
		}
		else {
			// Checks SearchTermCharLength < 2
			/* 
			#397 - Filter at least 2 characters
			if ( checkSearchTermCharLength(nachher) == false ) {
				ret = 3;
			}
			*/
		}
	}
	return ret;
}

function showPageRecommandation () {
	if (document.getElementById) {
	
		var PageRecObj = document.getElementById("TellAFriend");

		// position the layer to middle
		var height = getHeight()- 10;
		PageRecObj.style.top = height+"px"; 
		
		// set overlaylayer visible
		createOverlayLayer ();
		toggleOverlayLayer("block");

		// set tellafriend layer visible
		PageRecObj.style.display = "block"; 
	}
} 

function showSuccessLayer() {
	if (document.getElementById) {
		var PageRecObj = document.getElementById("TellAFriendSuccess");

		// position the layer to middle
		var height = getHeight ();
		PageRecObj.style.top = height+"px"; 
		
		// set overlaylayer visible
		createOverlayLayer ();
		toggleOverlayLayer("block");

		// set tellafriend layer visible
		PageRecObj.style.display = "block"; 
	}
}


function closePageRecommandation() {
	document.getElementById('TellAFriend').style.display = "none";
	toggleOverlayLayer("none");
}
function closeSuccessLayer() {
	document.getElementById('TellAFriendSuccess').style.display = "none";
	toggleOverlayLayer("none");
}

/* Flash Impl */
function isFlashInstalled() {
	var MM_contentVersion = 6;
	var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
	if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
			for (var i = 0; i < words.length; ++i) 	{
			if (isNaN(parseInt(words[i])))
			continue;
			var MM_PluginVersion = words[i];
		}
		var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
	}
	else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.appVersion.indexOf("Win") != -1)) {
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
		document.write('on error resume next \n');
		document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
		document.write('</SCR' + 'IPT\> \n');
	}
	
	return MM_FlashCanPlay;
}


/* Flash Impl */
function writeObjectTag(data,width,height,noFlashContent) {
	// replace entities
	noFlashContent = noFlashContent.replace(/&lt;/g,'<');
	noFlashContent = noFlashContent.replace(/&gt;/g,'>');
	noFlashContent = noFlashContent.replace(/&quot;/g,'"');
	noFlashContent = noFlashContent.replace(/&amp;/g,'&');

	document.write('<object type="application/x-shockwave-flash" data="' + data + '" width="' + width + '" height="' +  height + '" base="./">');
	document.write('	<param name="movie" value="' + data + '">');
	document.write('	<param name="quality" value="high">');
	document.write('	<param name="bgcolor" value="#FFFFFF">');
	document.write('	' + noFlashContent);
	document.write('</object>');
}

function getPageSize(){
	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} 
	else if (document.body.scrollHeight > document.body.offsetHeight){ 
		// all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} 
	else { 
		// Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	
		// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} 
		else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} 
	else if (document.documentElement && document.documentElement.clientHeight) { 
		// Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} 
	else if (document.body) { 
		// other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} 
	else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} 
	else {
		pageWidth = windowWidth;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getHeight () {
		var x = 80;
		var innerheight = window.innerHeight;
		var bVer = parseInt(navigator.appVersion);
		if (bVer >= 4 && navigator.appName == "Microsoft Internet Explorer") {
			innerheight = document.body.clientHeight;
		}
		var res = ((innerheight - x) / 2);
		return res;
}

function createOverlayLayer () {

	// get pagesize data
	var arrayPageSize = getPageSize();
	
	// get body node
	var body = document.getElementsByTagName("body")[0];

	// create overlay layer
	var overlayDiv = document.createElement("div");

	// create id with value overlay
	var overlayId = document.createAttribute("id");
	overlayId.nodeValue = "overlay";

	// add id-element to overlay layer
	overlayDiv.setAttributeNode(overlayId);
	
	// set width/heigth detected values to layer
	overlayDiv.style.width = arrayPageSize[0];	
	overlayDiv.style.height = arrayPageSize[1];	

	// append layer to body
	body.appendChild(overlayDiv);
}

function toggleOverlayLayer (value) {
	if ( document.getElementById ) {
		var node = document.getElementById("overlay");
		if (value) {
			node.style.display = value;
		}
		else {
			act = node.style.display;
			if ( act == "block" ) {
				node.style.display = "none";
			}
			else {
				node.style.display = "block";
			}
		}
	}
}

/* PixelTracking*/
function replacePixelTrackingParameters(pixel, defaultSID) {

	if (pixel != null && defaultSID != null) {
		// get the current Timestamp
		var nowDate = new Date();
		var Time = nowDate.getTime();
		
		// get the referrer if available
		var ref = document.referrer;
		if (ref == "" || ref == null) {
			ref = null;
		}
		else {
			ref = escape(ref);
		}
		
		// get the Cookie Informations
		var sid = getUserInfo('SESSIONID', null);
		if (sid == null || sid== "") {
			sid = defaultSID;
		}
		
		var tm = nowDate.getTime();
		var is = getLocaleInfo('INITIALSESSION', null);
		var ck = '0';
		var bid = getUserInfo('BANNER_ID', null);
		var chc = getLocaleInfo('COUNTRYHAWKCODE', null);

		// check if Cookies are available
		setCookie('swTime', ''+Time, null, '/', null, false);
		if (getCookie('swTime') == (''+Time)) {
			ck = '1';
		}
		
		// if Cookies are available, replace the Cookie values in the Original-Pixeltrackingstring
		if (ck=='1') {
			pixel = replacePixelTrackingParameter (pixel, 'sid', sid);
			pixel = replacePixelTrackingParameter (pixel, 'tm', tm);
			pixel = replacePixelTrackingParameter (pixel, 'is', is);
			pixel = replacePixelTrackingParameter (pixel, 'ck', ck);
			pixel = replacePixelTrackingParameter (pixel, 'bid', bid);
			pixel = replacePixelTrackingParameter (pixel, 'chc', chc);
			pixel = replacePixelTrackingParameter (pixel, 'ref', ref);
		}
		else {
			pixel = replacePixelTrackingParameter (pixel, 'tm', tm);
			pixel = replacePixelTrackingParameter (pixel, 'ck', ck);
			pixel = replacePixelTrackingParameter (pixel, 'sid', defaultSID);
			pixel = replacePixelTrackingParameter (pixel, 'ref', ref);
		}
	}
	return pixel;
}

function replacePixelTrackingParameter(pixel, variable, value) {
	// if given String and given value is not null
	if (value != null && pixel != null) {
		// if variable are available in String
		if (pixel.indexOf(variable+"=") != -1) {
		
			// get in index of the given Variable
			var index = pixel.indexOf(variable+"=");
			var len = pixel.length;

			// Anfang vom Pixel muss ?bernommen werden
			var begin = pixel.substring(0, index);

			// Ende vom Pixel ?bernehmen ohne die gefilterte Variable inkl. Wert
			var endTemp = pixel.substring(index, len);
			var indexEnd = endTemp.indexOf("&");
			var end = endTemp.substring(indexEnd, len);
			
			// neuen Pixelstring zusammensetzten
			var newPix = begin + variable + "=" + value + end;
			return newPix;
		}
		else {
			// wenn variable nicht im String vorhanden, hinten anh?ngen
			var newPix = pixel + variable + "=" + value + "&";
			return newPix;
		}
	}
	else if (value == null) {
		// wenn value null ist, variable aus dem String entfernen
		var isQuestionmark = false;
		
		// return value from String
		if (pixel.indexOf(variable+"=") != -1) {
		
			var index = pixel.indexOf(variable+"=");
			var len = pixel.length;
			
			// Anfang vom Pixel muss ?bernommen werden
			var begin = pixel.substring(0, index);
			if(begin.substring(index-1, index) == "?") {
				isQuestionmark = true;
			}

			// Ende vom Pixel ?bernehmen ohne die gefilterte Variable inkl. Wert
			var endTemp = pixel.substring(index, len);
			var indexEnd = endTemp.indexOf("&");
			var end = endTemp.substring(indexEnd+1, len);

			// if first char ist a "?" eleminate the "&"
			if (isQuestionmark) {
				end = end.substring (1, end.length);
			}
			
			// neuen Pixelstring zusammensetzten
			var newPix = begin + end;
			return newPix;
		}
		
		return pixel;
	}
	else {
		return pixel;
	}
}

function createLoginStatusNode (content,link,idtoappend) {
	// link element
	
	var linkelement = document.createElement("a");

	var id = document.createAttribute("id");
	id.nodeValue = "hn2-3-1-t";
	linkelement.setAttributeNode(id);

	var title = document.createAttribute("title");
	title.nodeValue = content;
	linkelement.setAttributeNode(title);

	var href = document.createAttribute("href");
	href.nodeValue = link;
	linkelement.setAttributeNode(href);

	var myclass = document.createAttribute("class");
	myclass.nodeValue = "HN";
	linkelement.setAttributeNode(myclass);

	var mouseover = document.createAttribute("onmouseover");
	mouseover.nodeValue = "mhHL(\'hn2-3-1\',1)";
	linkelement.setAttributeNode(mouseover);

	var mouseout = document.createAttribute("onmouseout");
	mouseout.nodeValue = "mhHL(\'hn2-3-1\')";
	linkelement.setAttributeNode(mouseout);

	var content = document.createTextNode(content);
	linkelement.appendChild(content);

	var rootnode = document.getElementById(idtoappend);;
	rootnode.appendChild(linkelement);

}


/* Ersetzt alle '"' durch '\"' */
function escapeQuotationmarks ( str )  {
	return str.replace('/"/g', '\"');
}


/* Variationsprodukte */
function changeVariation(formobj) {
	
	// deaktive form with AddToShoppingBag/Storefinder
	var obj = document.getElementById('Detailansicht');
	var but1 = document.getElementById('warenkorb_button1');
	var but2 = document.getElementById('warenkorb_button2');
	if (obj == null ) {
		obj = document.getElementById('Storefinder');
		but1 = document.getElementById('storefinder_button1');
		but2 = document.getElementById('storefinder_button2');
		if (obj == null ) {
			obj = document.getElementById('Boutiques');
			but1 = document.getElementById('boutiques_button1');
			but2 = document.getElementById('boutiques_button2');
		}
	}

	// check if obj is defined
	if (obj != null) {
		obj.action = "javascript:void(null);";
		obj.onsubmit = "void(null);";
		if (but1 != null)  {
			but1.disabled = "disabled";
		}
		if (but2 != null)  {
			but2.disabled = "disabled";
		}
	}
	
	// deactivate form action from the variation box
	formobj.ProductSKU.onchange = "void(null);";

	// Submit the form
	formobj.submit();
}
