function suche2(keyword){
	doHttpRequest('/ajax/suche.php?keyword='+keyword, 'suche_hover');
}


var lightboxOuterWidth;
var lightboxOuterHeight;
var lightboxInnerWidth;
var lightboxInnerHeight;
function lightboxOuterSize(){
	outerSize = getPageSize();
	outerSize = outerSize.toString();
	tmp = outerSize.split(',');
	lightboxOuterWidth = tmp[0];
	lightboxOuterHeight = tmp[1];
}
function lightbox(content, width, height){
	lightboxOuterSize();
	
	lightboxInnerWidth = width;
	lightboxInnerHeight = height;
	doHttpRequest('/ajax/lightbox.php?content='+content, 'lightbox');
}

function warenkorb_in(){
	lightboxOuterSize();
	
	var artikelnr 	= document.getElementById('artikelnr').value;
	var anzahl 		= document.getElementById('number').value;
	
	doHttpRequest('/ajax/warenkorb_in.php?artikelnr='+artikelnr+'&anzahl='+anzahl, 'warenkorb_in');
}

function newsletter(width, height){
	lightboxOuterSize();
	lightboxInnerWidth = width+'px';
	lightboxInnerHeight = height+'px';
	
	email 	= document.getElementById('newsletteremail').value;
	doHttpRequest('/ajax/newsletter.php?email='+email, 'lightbox');
}

function artikelnr_update(){
	if (document.getElementById('variation1')){
		var variation1 = document.getElementById('variation1').options[document.getElementById('variation1').selectedIndex].value;
		var variation2 = '';
		if (document.getElementById('variation2')){
			variation2 = document.getElementById('variation2').options[document.getElementById('variation2').selectedIndex].value;
		}
	}
	
	doHttpRequest('/ajax/artikelnr_update.php?variation1='+variation1+'&variation2='+variation2, 'artikelnr');
	doHttpRequest('/ajax/preis_update.php?variation1='+variation1+'&variation2='+variation2, 'preis');
}

function warenkorb_update_small(){
	doHttpRequest('/ajax/warenkorb_update_small.php', 'warenkorb_small');
	doHttpRequest('/ajax/warenkorb_update_small_hover.php', 'warenkorb_small_hover');
}

function doHttpRequest(url, divid) {
	var page_request = false;
		
   	if(window.XMLHttpRequest){  // Mozilla, Safari,...
       		page_request = new XMLHttpRequest();
  	} else if (window.ActiveXObject){ // IE
       		try {
           		page_request = new ActiveXObject("Msxml2.XMLHTTP");
    		}
       		catch (e) {
           		try {
              			page_request = new ActiveXObject("Microsoft.XMLHTTP");
     			}
          		 catch (e) {}
       		}
   	} else {
		return false
	}
      
	page_request.onreadystatechange = function() {
		if(page_request.readyState == 4 && page_request.status == 200) {
			handleHttpResponse(page_request.responseText, divid);
		} else {
			return false;
		}
	}
	page_request.open('GET', url, true);
	page_request.send(null);
}


function handleHttpResponse(response, divid) {
	if (divid == 'lightbox' && response != ''){
		document.getElementById('lightbox_bg').style.display = 'block';
		document.getElementById('lightbox_bg').style.width = lightboxOuterWidth;
		document.getElementById('lightbox_bg').style.height = lightboxOuterHeight;
		document.getElementById(divid).style.width = lightboxInnerWidth;
		document.getElementById(divid).style.height = lightboxInnerHeight;
		document.getElementById(divid).style.display = 'block';
		document.getElementById(divid).innerHTML=response;
	} else if (divid == 'warenkorb_in' && response != ''){
		document.getElementById('lightbox_bg').style.display = 'block';
		document.getElementById('lightbox_bg').style.width = lightboxOuterWidth;
		document.getElementById('lightbox_bg').style.height = lightboxOuterHeight;
		document.getElementById(divid).style.display = 'block';
		document.getElementById(divid).innerHTML=response;
		
		 warenkorb_update_small();
	} else if (divid == 'suche_hover' && response != ''){
		document.getElementById(divid).style.display = 'block';
		document.getElementById(divid).innerHTML=response;
	} else if (divid == 'artikelnr' && response != ''){
		document.getElementById(divid).value=response;
	} else {
		document.getElementById(divid).innerHTML=response;
	}
}