function jsGetTimeStr()
{
	DTnow = new Date();
	return DTnow.getDay() + DTnow.getTime();            	 
}

function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

// Wird Netscape benutzt
function NetscapeUser()
{
	return (document.layers); 
}

// Wird InternetExplorer benutzt
function IEUser()
{
	return (document.all); 
}

function getOnlyChars(str)
{
	res = "";
	try
	{
		for (x=0;x<str.length;x++)
		{
			val = str.charCodeAt(x);
			
			if ( ((val>="0".charCodeAt(0)) && (val<="9".charCodeAt(0))) || 
			     ((val>="a".charCodeAt(0)) && (val<="z".charCodeAt(0))) || 
				 ((val>="A".charCodeAt(0)) && (val<="Z".charCodeAt(0))) ||
				 (val==32) || (val=="ä".charCodeAt(0)) || (val=="Ä".charCodeAt(0)) ||
				 (val=="ö".charCodeAt(0)) || (val=="Ö".charCodeAt(0)) ||
				 (val=="ü".charCodeAt(0)) || (val=="Ü".charCodeAt(0)) ||
				 (val=="@".charCodeAt(0)) || (val==",".charCodeAt(0)) ||
				 (val=="<".charCodeAt(0)) || (val==">".charCodeAt(0)) ||
				 (val=="=".charCodeAt(0)) || (val=="\"".charCodeAt(0)) ||
				 (val==".".charCodeAt(0)) || (val=="!".charCodeAt(0)))
				 
			{
				res = res + str.substring(x,x+1);
			}	
		}
	} catch (error)
	{
		return "Fehler in chars" + error;
	}
	return res;
}

function encode_symbols(zInhalt)
{
		var newstr="";
		for (x=0;x<zInhalt.length;x++)
		{
			var tch=zInhalt.charAt(x);
			switch(tch)
			{
				case String.fromCharCode(10):	//'Zeilenwechsel
					tch = "";
					break;
				case String.fromCharCode(13):	//'Zeilenwechsel
					tch = "ï";
					break;
				case String.fromCharCode(38):	//& nach È
					tch = String.fromCharCode(200);
					break;
				case String.fromCharCode(34):	//'Anführung doppelt
					tch = "ë";
					break;
				case String.fromCharCode(37):	//'Prozentzeichen
					tch = "÷";
					break;
				case String.fromCharCode(39):	//'Anführung einfach
					tch = "ÿ";
					break;
				case String.fromCharCode(43):	//'Pluszeichen
					tch = "ù";
					break;
				case String.fromCharCode(60):	//<
					tch = "<";
					break;
				case String.fromCharCode(62):	//>
					tch = ">";
					break;
			}
			newstr = newstr+tch;
		}
		zInhalt = newstr;

	return zInhalt;
}

function decode_symbols(zInhalt)
{
//	zInhalt = zInhalt + Space(100);
						
	if ((zInhalt.indexOf("ï")>-1) ||
	   (zInhalt.indexOf("ë")>-1) ||
   	   (zInhalt.indexOf("÷")>-1) ||
   	   (zInhalt.indexOf("È")>-1) ||
   	   (zInhalt.indexOf("ÿ")>-1) )
	{
		var newstr="";
		for (x=0;x<zInhalt.length;x++)
		{
			var tch=zInhalt.charAt(x);
			switch(tch)
			{
				case "ï":	///	'Zeilenwechsel
					newstr = newstr+String.fromCharCode(13);
					tch = String.fromCharCode(10);
					break;
										
				case "ë":	//'Anführung doppelt
					tch = String.fromCharCode(34);
					break;
										
				case "÷":	//'Prozentzeichen
					tch = String.fromCharCode(37);
					break;
										
				case "ÿ":	//'Anführung einfach
					tch = String.fromCharCode(39);
					break;
										
				case "ù":	//'Pluszeichen
					tch = String.fromCharCode(43);
					break;

				case "È":	//' & Zeichen È
					tch = "&";
					break;

			}
			newstr = newstr+tch;
		}
		zInhalt = newstr;
	}
	return zInhalt;
}

function addToBasket(site, article)
{
	window.open("basket.asp?Time="+jsGetTimeStr()+"&addToBasket="+article, "basket", "left=350,top=100,width=600,height=400,toolbars=0");
}

function switchDetails(from, dest)
{
	var from = document.getElementById(from);
	var dest = document.getElementById(dest);

	if (dest.innerHTML.length == 0)
	{
		dest.innerHTML = from.innerHTML;
	}
	else
	{
		dest.innerHTML = "";
	}
}

function showBasket(win)
{
	window.open("basket.asp?Time="+jsGetTimeStr(), "basket", "left=350,top=100,width=600,height=400,toolbars=0");
}

function removeArticle(dest)
{
	document.Frm.target     = "_self";
	document.Frm.Dest.value = dest;
	document.Frm.Task.value = "Remove";
	document.Frm.action     = "basket.asp?Time="+jsGetTimeStr();
	document.Frm.submit();
}

function closeWindow()
{
	if (navigator.appName != "Microsoft Internet Explorer")
	{
		window.close();
	}
}

