



var items = new Array();
var trigger = true;
var cb;
function init() {
	// initialize the combobox widget, and pass in the callback function.
	cb = new ComboBox("s", nameCallback);
	

	  
	document.getElementById("s").setAttribute( "autocomplete", "off" );
}

function nameCallback(value /*, comboBox*/) {
	items = new Array();
	var text = "";
	trigger = true;

	if (value.length > 1) { // if no value, we'll not provide anything
		value = value.toLowerCase();
	    http.open("GET", 'ajax/AJAXHandler.php?action=livesearch&amp;string='+value, true);
	    http.onreadystatechange = function() {
	    			if (http.readyState == 4) {
						results = http.responseText.split("%");

						for (var i = 0;i < results.length; i++) {
							items.push(results[i]);
						}
						cb.setItems(items);
					}
	    };

	  	http.send(null);

	}

	return items; // equiv to: comboBox.setItems(items);
}






function menu(id) {
var d = document.getElementById(id);

  if (d.style.display=='block') {
    d.style.display='none';
  } else {
    d.style.display='block';

  }
 // d.onMouseOut = d.style.display='none';
}


function checkSuche(f) {

	if(f[0].value == '' || f[0].value == 'Suchbegriff') {
		alert('Bitte Suchbegriff eingeben');
		return false; 
	} else {
		form.submit();
	}
}


function submenu(div,page_item) {
	document.getElementById(div).style.display = "block";

	//page_item.className = "current_page_item";
}

function unsubmenu(div,page_item) {
	document.getElementById(div).style.display = "";
	page_item.className = "page_item";
}

infobox = null;

function showInfoBox(id) {
  if(infobox != null) {
   infobox.style.display = "none";
  }
	infobox = document.getElementById(id);
  infobox.style.display = "block";
}


function bild(id) {
var klein = document.getElementById('bilder');
var gross = document.getElementById('bild'+id);


  if (gross.style.display=='block') {
    gross.style.display='none';
    klein.style.display='block';
  } else {
    gross.style.display='block';
    klein.style.display='none';
  }
}
/*
 Bilder in einem PopUp laden in dem Ordner "/Bilder" liegen.
*/
function zeigePflegeHinweise(datei) {
	openWindow(datei,550,600);
}

function showPanorama() {
	var datei = 'html/panorama.html';
	openWindow(datei,550,600);
}

function zeigeBild(datei,height,width) {
	var window_url='img/bilder/'+datei;
	x=window.open(window_url,'xx','width='+width+',height='+height+',scrollbars=1,resizable=1');
	x.focus()
}


function openWindow(datei,height,width) {
	var window_url= datei;
	x=window.open(window_url,'xx','width='+width+',height='+height+',scrollbars=1,resizable=1');
	x.focus()
}



function highlight_aktuelles(div,id) {

	var pic, headline, content;

	pic = document.getElementById("aktuelles_pic_"+id);
	headline = document.getElementById("aktuelles_headline_"+id);
	content = document.getElementById("aktuelles_content_"+id);

	div.style.cursor = 'pointer';

	headline.style.color = '#000';
	content.style.color = '#000';
	pic.src = "img/aktuelles/"+id+"/tn_"+id+".jpg";
}

function unhighlight_aktuelles(div,id) {

	var pic, headline, content;

	pic = document.getElementById("aktuelles_pic_"+id);
	headline = document.getElementById("aktuelles_headline_"+id);
	content = document.getElementById("aktuelles_content_"+id);

	div.style.cursor = 'auto';

	headline.style.color = '#444444';
	content.style.color = '#444444';
	pic.src = "img/aktuelles/"+id+"/tn_"+id+"_1.jpg";

}



function highlight(div,section,id) {

	var pic, headline, content;

	pic = document.getElementById(section+"_pic_"+id);
	headline = document.getElementById(section+"_headline_"+id);
	content = document.getElementById(section+"_content_"+id);

	div.style.cursor = 'pointer';

	headline.style.color = '#000';
	content.style.color = '#000';
	pic.src = "img/right/"+section+""+id+"_1.jpg";
}

function unhighlight(div,section,id) {

	var pic, headline, content;

	pic = document.getElementById(section+"_pic_"+id);
	headline = document.getElementById(section+"_headline_"+id);
	content = document.getElementById(section+"_content_"+id);

	div.style.cursor = 'pointer';

	headline.style.color = '#444444';
	content.style.color = '#444444';
	pic.src = "img/right/"+section+""+id+"_2.jpg";

}
function shop_galerie(artikel_nr, windowname) {
  var url = "files/shop_galerie.php?artikel=" + artikel_nr;
	wind = window.open(url, '_blank','title="blabla blabla",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no, width=520, height=400, left=100, top=100, alwaysRaised=true');
	wind.focus();
}

function checkMail(s) {

 var a = false;
 var res = false;
 if(typeof(RegExp) == 'function') {
      var b = new RegExp('abc');
      if(b.test('abc') == true){a = true;}
 }

 if(a == true) {
  reg = new RegExp('^([a-zA-Z0-9\\-\\.\\_]+)'+
                   '(\\@)([a-zA-Z0-9\\-\\.]+)'+
                   '(\\.)([a-zA-Z]{2,4})$');
  res = (reg.test(s));
 } else {
  res = (s.search('@') >= 1 &&
         s.lastIndexOf('.') > s.search('@') &&
         s.lastIndexOf('.') >= s.length-5)
 }
 return(res);
}

tooltip = null;

document.onmousemove = updatePos;

function updatePos(e) {
	x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
	if (tooltip != null) {
    tooltip.style.left = (x + 20) + "px";
	}
}

function showToolTip(id) {
	tooltip = document.getElementById(id);
	tooltip.style.display = "block";
}

function hideToolTip() {
	tooltip.style.display = "none";
}

function switchColor(nr) {
var farbgrafik = document.getElementById('farbgrafik'+nr);
var farbtext = document.getElementById('farbtext'+nr);
  if (farbgrafik.style.display=='block') {
    farbgrafik.style.display='none';
    farbtext.style.display='block';
  } else {
    farbgrafik.style.display='block';
    farbtext.style.display='none';
  }
}

function showImage(url,windowname) {
  var nwl = (screen.width-400)/2;
  var nwh = (screen.height-100)/2;
  popUp=window.open('img/bilder/'+url, windowname, 'toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=530,height=380,left='+nwl+',top='+nwh+'');
  popUp.window.focus();
}

function zeigeAktuellesBild(id,url,windowname) {
  var nwl = (screen.width-400)/2;
  var nwh = (screen.height-100)/2;
  popUp=window.open('../img/aktuelles/'+id+'/'+url, windowname, 'toolbar=no,location=yes,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=530,height=380,left='+nwl+',top='+nwh+'');
  popUp.window.focus();
}





function checkKontaktAnfrage() {
	var errormsg = ''
  var email = document.forms['kontakt'].elements['kontakt_email'];
  var text = document.forms['kontakt'].elements['kontakt_text'];

  if(email.value == '') {
    errormsg += 'Bitte überprüfen Sie das "Email"-Textfeld.\n';
     email.className = "kontakt_textfeld_fehler";
  } else {
   	email.className = "kontakt_textfeld";
  }

  if(text.value == '') {
    errormsg += 'Bitte überprüfen Sie das "Ihr Text"-Textfeld.\n';
     text.className = "kontakt_textarea_fehler";
  } else {
  	text.className = "kontakt_textarea";
  }

  if(errormsg == '') {
   // return true;
  } else {
    alert(errormsg);
    return false;
  }
}




function increase(bild) {
	bild.style.width = parseInt(bild.style.width) + 5;
	bild.style.height = parseInt(bild.style.height) + 5;
}

function decrease(bild) {
 bild.style.width = parseInt(bild.style.width) - 5;
	bild.style.height = parseInt(bild.style.height) - 5;
}


function showHochzeitsserviettenStickart(stickart){
 var wert = stickart.options[stickart.options.selectedIndex].value;


 if(wert == 'Text mit Motiv' || wert == 'Nur mit Motiv') {
 	document.getElementById('logo').style.display = "";
 } else {
 	document.getElementById('logo').style.display = "none";
 }

}


function showAnfrageProduktInfo() {
	var box = document.getElementById('anfrage_produkt_info');
	if(box.style.display == '') {
		box.style.display  = "none";
		document.getElementById('aufklappen').innerHTML = "aufklappen";

	} else {
		box.style.display  = "";
		document.getElementById('aufklappen').innerHTML = "zuklappen";
	}
}

function hs_select(item,type) {
	showInfoBox('info_'+type);

	document.forms['hs_anfrage'].elements['anfrage_'+type][item].checked = true;
	if(type == 'motiv') {
		if(item == 2) {
			document.getElementById("logohochladen").style.display = "";
		} else {
			document.getElementById("logohochladen").style.display = "none";
		}
	}
}


function showInfoBoxExtra(tf,id,text) {
	if(infobox != null) {
		infobox.style.display = "none";
	}

	var infobox = document.getElementById("info_"+id);

	if(tf.value == "") {
	tf.style.color = '#ACACAC'
		tf.value = text;
		tf.style.color = '#ACACAC';
		infobox.style.display = "none";

	} else if(tf.value == text) {

		tf.value = "";
		tf.style.color = '#000000';

	  infobox.style.display = "block";
	}
}


function checkHSAnfrage() {

  var errormsg = '';

  var name = document.forms['hs_anfrage'].elements['anfrage_name'];
  var strasse = document.forms['hs_anfrage'].elements['anfrage_strasse'];
  var plzort = document.forms['hs_anfrage'].elements['anfrage_plzort'];
  var email = document.forms['hs_anfrage'].elements['anfrage_email'];
  var menge = document.forms['hs_anfrage'].elements['anfrage_menge'];


 if(email.value == '') {
    errormsg += 'Bitte überprüfen Sie das "Email"-Textfeld.\n';
     email.className = "anfrage_textfeld_fehler";
  } else {
  	email.className = "anfrage_textfeld";
  }

  if(name.value == '') {
    errormsg += 'Bitte überprüfen Sie das "Name"-Textfeld.\n';
    name.className = "anfrage_textfeld_fehler";
  } else {
  	name.className = "anfrage_textfeld";
  }


  if(strasse.value == '') {
    errormsg += 'Bitte überprüfen Sie das "Straße"-Textfeld.\n';
     strasse.className = "anfrage_textfeld_fehler";
  } else {
  	strasse.className = "anfrage_textfeld";
  }


  if(plzort.value == '') {
    errormsg += 'Bitte überprüfen Sie das "PLZ u. Ort"-Textfeld.\n';
     plzort.className = "anfrage_textfeld_fehler";
  } else {
  	plzort.className = "anfrage_textfeld";
  }


  if(menge.value != '') {
    if(menge.value < 20) {
      errormsg += 'Bitte beachten Sie eine Mindestbestellmenge von 20 Stück.\n';
       menge.className = "anfrage_textfeld_fehler";
    }
    if(isNaN(menge.value)) {
      errormsg += 'Bitte überprüfen Sie Ihre Stickmenge.\n';
       menge.className = "anfrage_textfeld_fehler";
    }
  }
	if(menge.value == '') {
      errormsg += 'Bitte überprüfen Sie Ihre Stickmenge.\n';
       menge.className = "anfrage_textfeld_fehler";
   }

  if(errormsg == '') {
   // return true;
  } else {
    alert(errormsg);
    return false;
  }
}


/* AJAX FUNKTIONEN */

























/* AJAX OBJEKT */

function getHTTPObject() {

  if(window.XMLHttpRequest) {
    var req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    var req = new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    var req = false;
  }
  return req;
}

var http = getHTTPObject();

