
  
  
/*
 * Formularfeld fkt (search)
 */
  	function clickclear(thisfield, defaulttext) {
		if (thisfield.value == defaulttext) {
			thisfield.value = "";
		}
	}
	
	function clickrecall(thisfield, defaulttext) {
		if (thisfield.value == "") {
			thisfield.value = defaulttext;
		}
	}

  
/*
Syntax:

string htmlspecialchars ( string str , [int typ] )

Quelltext:

1: function htmlspecialchars(str,typ) { 2: if(typeof str=="undefined") str=""; 3: if(typeof typ!="number") typ=2; 4: typ=Math.max(0,Math.min(3,parseInt(typ))); 5: var html=new Array(); 6: html[38]="&amp;"; html[60]="&lt;"; html[62]="&gt;"; 7: if(typ==1 || typ==3) html[39]="&#039;"; 8: if(typ==2 || typ==3) html[34]="&quot;"; 9: for(var i in html) eval("str=str.replace(/"+String.fromCharCode(i)+"/g,\""+html[i]+"\");"); 10: return str; 11: }
Durch Klick in das Textfeld markieren Sie den Quelltext, um ihn zu kopieren.

Erläuterungen:

2: 	Stelle sicher, dass die Variable str vorhanden und vom Typ String ist.
3: 	Wenn Variable typ vom Typ nicht Zahl ist, setze sie auf Standardwert 2.
4: 	Stelle sicher, dass die Variable typ eine Ganzzahl zwischen 0 und 3 ist.
5: 	Definiere kombiniertes Suchmuster- und Ersetzungs-Array html.
6: 	Fülle das Array html mit den ersten drei Suchmustern (Schlüssel) und Ersetzungszeichenfolgen (Wert).
7: 	Wenn typ den Wert 1 oder 3 hat, füge ein weiteres Element (Ersetzung für einfache Anführungszeichen) in das Array html ein.
8: 	Wenn typ den Wert 2 oder 3 hat, füge ein weiteres Element (Ersetzung für doppelte Anführungszeichen) in das Array html ein.
9: 	Evaluiere über die Schleifendurchläufe für jedes Element im Array html und ersetze in str mit Hilfe eines regulären Ausdruck das aktuelle Suchmuster (Schlüssel) durch die aktuelle Ersatzzeichenfolge (Wert).
10: 	Gibt den String str zurück.

Gestestet mit:

    * Netscape Navigator 6.2
    * Microsoft Internet Explorer 5.0 , 5.5 und 6.0
    * Mozilla Firefox 1.0 und 1.5

Anmerkungen:

Mit dem optionalen Parameter typ steuern Sie - wie in der originalen PHP-Funktion - die Maskierung von einfachen und doppelten Anführungszeichen. Dabei sind folgende Werte definiert:

0 = Keine Anführungszeichen umwandeln
1 = Nur einfache Anführungszeichen umwandeln
2 = Nur doppelte Anführungszeichen umwandeln (Standardeinstellung)
3 = Beide Arten (einfache und doppelte Anführungszeichen) umwandeln 
*/
  function htmlspecialchars(str,typ) {
    if(typeof str=="undefined") str="";
    if(typeof typ!="number") typ=2;
    typ=Math.max(0,Math.min(3,parseInt(typ)));
    var html=new Array();
    html[38]="&amp;"; html[60]="&lt;"; html[62]="&gt;";
    if(typ==1 || typ==3) html[39]="&#039;";
    if(typ==2 || typ==3) html[34]="&quot;";
    for(var i in html) eval("str=str.replace(/"+String.fromCharCode(i)+"/g,\""+html[i]+"\");");
    return str;
    }
  
function SetFocus(TargetFormName) {
  var target = 0;
  if (TargetFormName != "") {
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target=i;
        break;
      }
    }
  }
}

function RemoveFormatString(TargetElement, FormatString) {
  if (TargetElement.value == FormatString)
    TargetElement.value = "";
    TargetElement.select();
}

function CheckDateRange(from, to) {
  if (Date.parse(from.value) <= Date.parse(to.value))
    return true;
  else
    return false;
}

function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i = 0; i < strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i = 0; i < strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }
  
  if (intDateSeparatorIdx != intFormatSeparatorIdx)
    return false;

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i = 0; i < strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm')
        strMonth = strDateToCheckArray[i];
      if (strFormatArray[i] == 'dd')
        strDay = strDateToCheckArray[i];
      if (strFormatArray[i] == 'yyyy')
        strYear = strDateToCheckArray[i];
    }
  }
  else {
    if (FormatString.length>7) {
      if (strFormatString.indexOf('mmm') == -1)
        strMonth = strDateToCheck.substring( strFormatString.indexOf('mm'), 2 );
      else
        strMonth = strDateToCheck.substring( strFormatString.indexOf('mmm'), 3 );
      strDay = strDateToCheck.substring( strFormatString.indexOf('dd'), 2 );
      strYear = strDateToCheck.substring( strFormatString.indexOf('yyyy'), 2 );
    }
    else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }
  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i = 0;i < strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth>12 || intMonth<1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0)
      return true;
  }
  else {
    if ((intYear % 4) == 0)
      return true;
  }

  return false;
}





var selected;
var newModuleRowName='moduleRow';
var newModuleRowOverName='moduleRowOver';

function selectRowEffect(object, buttonSelect) {
	if (!selected) {
		if (document.getElementById) {
			selected = document.getElementById('defaultSelected');
		} else {
			selected = document.all['defaultSelected'];
		}
	}

	if (selected) selected.className = 'moduleRow';
		object.className = 'moduleRowSelected';
	selected = object;

	// one button is not an array
	//	getObj('cart_quantity').shipping[buttonSelect].obj.checked=true;
	alert(document.cart_quantity.shipping[buttonSelect].checked=true);
}

function rowOverEffect(object) {
	if (object.className == 'moduleRow') object.className = newModuleRowOverName;
}
function rowOutEffect(object) {
	if (object.className == 'moduleRowOver') object.className = newModuleRowName;
}

function check_form() {
  var error_message = "<?php echo JS_ERROR; ?>";
  var error_found = false;
  var error_field;
  var keywords = document.advanced_search.keywords.value;

  if ( ((keywords == '') || (keywords.length < 1))) {
    error_message = error_message + "<?php echo JS_AT_LEAST_ONE_INPUT; ?>";
    error_field = document.advanced_search.keywords;
    error_found = true;
  }

  if (error_found == true) {
    alert(error_message);
    error_field.focus();
    return false;
  } else {
    return true;
  }
}


function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=740,height=840,screenX=150,screenY=150,top=150,left=150')
}
function newWindow(url,wd,ht){
  window.open(url,"bild","width="+wd+",height="+ht+",top=0,left=0,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no");
}

function changeField(FeldID) {
	var x            = new getObj(FeldID);
	var stringText   = x.obj.value;
	var temp         = new Array();
	temp             = stringText.split(' ');
	stringText       = "";
	var stringSpaces = "";
	for(var i=0;i<temp.length;i++) {
		stringText   = stringText + stringSpaces + changeFirstLetter(temp[i]);
		stringSpaces = " ";
	}
	x.obj.value = stringText;
}
function changeFirstLetter(strName) {
		var a = strName.substr(0,1);
		var b = strName.substring(1);
		return a.toUpperCase() + b.toLowerCase();
}
function getObj(name) {
  if (document.getElementById) {
  	if(document.getElementById(name)) {
	  	this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
  } else if (document.all) {
  	if(document.all[name]) {
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
  } else if (document.layers) {
	this.obj = getObjNN4(document,name);
	this.style = this.obj;
  }
}
function getObjNN4(obj,name) {
	var x = obj.layers;
	var foundLayer;
	for (var i=0;i<x.length;i++) {
		if (x[i].id == name)
		 	foundLayer = x[i];
		else if (x[i].layers.length)
			var tmp = getObjNN4(x[i],name);
		if (tmp) foundLayer = tmp;
	}
	return foundLayer;
}



function check_form_advance() {
  var error_message = "<?php echo JS_ERROR; ?>";
  var error_found = false;
  var error_field;
  //var keywords = document.advanced_search.keywords.value;
  var keywords = document.advanced_search.fk.value;
  var pfrom = document.advanced_search.fpfrom.value;
  var pto = document.advanced_search.fpto.value;
  var pfrom_float;
  var pto_float;

  if ( ((keywords == '') || (keywords.length < 1)) ) {
	error_message = error_message + "* <?php echo ERROR_AT_LEAST_ONE_INPUT; ?>\n";
	//error_field = document.advanced_search.keywords;
	error_field = document.advanced_search.fk;
	error_found = true;
  }

  if (pfrom.length > 0) {
	pfrom_float = parseFloat(pfrom);
	if (isNaN(pfrom_float)) {
	  error_message = error_message + "* <?php echo ERROR_PRICE_FROM_MUST_BE_NUM; ?>\n";
	  error_field = document.advanced_search.fpfrom;
	  error_found = true;
	}
  } else {
	pfrom_float = 0;
  }

  if (pto.length > 0) {
	pto_float = parseFloat(pto);
	if (isNaN(pto_float)) {
	  error_message = error_message + "* <?php echo ERROR_PRICE_TO_MUST_BE_NUM; ?>\n";
	  error_field = document.advanced_search.fpto;
	  error_found = true;
	}
  } else {
	pto_float = 0;
  }

  if ( (pfrom.length > 0) && (pto.length > 0) ) {
	if ( (!isNaN(pfrom_float)) && (!isNaN(pto_float)) && (pto_float < pfrom_float) ) {
	  error_message = error_message + "* <?php echo ERROR_PRICE_TO_LESS_THAN_PRICE_FROM; ?>\n";
	  error_field = document.advanced_search.pto;
	  error_found = true;
	}
  }

  if (error_found == true) {
	alert(error_message);
	error_field.focus();
	return false;
  }
}


function session_win() {
  window.open("<?php echo FILENAME_INFO_SHOPPING_CART; ?>","info_shopping_cart","height=460,width=430,toolbar=no,statusbar=no,scrollbars=yes").focus();
}

