
  var alleBilder = new Object();
  var numberToPreload = 6;
  var preloadCount = 0;
  function preloadBild( id, image, html, caption ) {
	alleBilder[id] = new Object();
	alleBilder[id].image = image;
	alleBilder[id].html = html;
	alleBilder[id].caption = caption;
	if ( preloadCount < numberToPreload ) {
	  var imagePreloader = new Image();
	  imagePreloader.src = image;
	  preloadCount++;
	}
  }
  var allPreloaded = 0;
  var selectedImageID = "haupt_bild";
  function displayImage( id ) {
	if ( id == selectedImageID ) return;
	if (alleBilder[selectedImageID].ciuAnnoContainer) {
	  alleBilder[selectedImageID].ciuAnnoContainer.hide();
	}
	selectedImageID = id;
	document.getElementById('productBild').innerHTML = alleBilder[id].html;
	for ( elementID in alleBilder ) {
	  var imageThumbnail = document.getElementById(elementID);
	  if ( !allPreloaded ) {
		var imagePreloader = new Image();
		imagePreloader.src = alleBilder[elementID].image;
	  }
	}
	allPreloaded = 1;
	if (alleBilder[id].ciuAnnoContainer) {
	  alleBilder[id].ciuAnnoContainer.show();
	}
  }
  
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 pfrom = document.advanced_search.pfrom.value;
  var pto = document.advanced_search.pto.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_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.pfrom;
	  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.pto;
	  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();
}
