// quick.js

var qLeftGlobal=""; //

function qform_isMulticlick(idNa,ms) {
// ################################### 0904
// F gibt true falls Ereignis auf Basis hidden Element m. idNa nach <= Millisek ms wiederholt wurde
// Setzt hidden timer bei JEDER Abfrage neu, benutzt value! ( <input type="hidden" id="idNa"> )

	var jetztMs = new Date().getTime();
	var el = document.getElementById(idNa);
	var lastMs = el.value; el.value = jetztMs;
	if ((jetztMs - lastMs) <= ms) return true; else return false;

} // end F ###

function qLeft(txt,trennz) {
// #########################
// Liefert Teilstring bis trennz
// Kuerzt txt auf Inhalt nach trennz und setzt ihn als qLeftGlobal !!

	qLeftGlobal = "";
	var p = 0; var lenTr = 0; var ret = "";
	var lenTx = txt.length; if (lenTx < 1) { return ""};
	if (trennz > "") {p = txt.indexOf(trennz); lenTr = trennz.length}

	if (p > 0) {
		ret = txt.substring(0,p);
		txt = txt.substr(p+lenTr);
	} else { ret = txt; txt = ""; }
	qLeftGlobal = txt; return ret;

} //##

function qReplace(txt,su,ers) {
// ############################
	return txt.replace(new RegExp(su,"gi"),ers);
} //##

function qTrim(str) {
// ##################
	return qRtrim(qLtrim(str));
} //##

function qLtrim(str) {
// ###################

	var whitespace = new String(" \t\n\r");
	var s = new String(str);
	if (whitespace.indexOf(s.charAt(0)) != -1) {
		// We have a string with leading blank(s)...
		var j=0, i = s.length;
		// Iterate from the far left of string until we
		// don't have any more whitespace...
		while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
			j++;
		// Get the substring from the first non-whitespace
		// character to the end of the string...
		s = s.substring(j, i);
	}
	return s;
} //##

function qRtrim(str) {
// ###################

  // trip spaces, but also tabs, line feeds, etc.  Add anything else you want
  var whitespace = new String(" \t\n\r"); var s = new String(str);
  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
		// We have a string with trailing blank(s)...
		var i = s.length - 1;       // Get length of string
		// Iterate from the far right of string until we don't have any more whitespace...
		while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
			i--;
		// Get the substring from the front of the string to where the last non-whitespace character is...
		s = s.substring(0, i+1);
	}
	return s;
} //##

function createXMLhttpObject() {
// #############################
// ### Liefert XMLhttpObject (getestet mit ie6,mozilla1.5, opera geht nicht)

	var XMLhttpObject = null
	try { XMLhttpObject = new XMLHttpRequest() } 
	catch(e) { try { XMLhttpObject = new ActiveXObject("Msxml2.XMLHTTP") } 
	catch(e) { try { XMLhttpObject = new ActiveXObject("Microsoft.XMLHTTP") } 
	catch(e) { return null }}}
	return XMLhttpObject
} // end function 2006/05

function qCheckCookie(){
// #####################
// ### Gibt true wenn Cookie probeweise gesetzt und geloescht werden konnte

   qSetCookie("cookieTest","ok",1)
   if (!qGetCookie("cookieTest"))
      return false
   else { qDelCookie("cookieTest"); return true }
} //##

function qSetCookie(name,value,days) {
// ###################################
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
} //##

function qGetCookie(name) {
// ########################

	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
} //##

function qDelCookie(name) {
// ########################

	qSetCookie(name,"",-1);
} //##

function qSleep(ms) { 
// ##################

	var zeit=(new Date()).getTime(); 
	var stoppZeit=zeit+ms; 
	while((new Date()).getTime()<stoppZeit){}; 

} //##
