function load_box(file) {
	document.getElementById("div_overlay_header").innerHTML = '<a class="close_box" href="javascript:close_box()">OK</a>';
	document.getElementById("div_overlay").style.display = "block";
	document.getElementById("div_overlay_wrapper").style.display = "block";
	var req = new Request.HTML({url:file, 
			onSuccess: function(html) {
				$('div_overlay_content').set('text', '');
				$('div_overlay_content').adopt(html);
			}
		}).send();
}

function load_box_v2(file) {
	$('div_overlay_header').innerHTML = '<a class="close_box" href="javascript:close_box()"><div id="close_box"></div></a>';
	$('div_overlay').style.display = "block";
	$('div_overlay_wrapper').style.display = "block";
	var req = new Request.HTML({url:file, 
			onSuccess: function(html) {
				$('div_overlay_content').set('text', '');
				$('div_overlay_content').adopt(html);
			}
		}).send();
}

var lbv3 = "";
function load_box_v3(file) {
	if ($('div_overlay_content')!=null) {
		lbv3 = $('div_overlay_content');
	} else {
		lbv3 = new Element('div', {id: 'div_overlay_content'});
		lbv3.inject(document.body);
	}
	lbv3.style.display = "block";
	$('div_overlay_wrapper').style.display="block";
	var req = new Request.HTML({url:file, 
			onSuccess: function(html) {
				lbv3.set('text', '');
				lbv3.adopt(html);
			}
		}).send();
}

function load_box_img(img) {
	$('div_overlay_header').innerHTML = '<a class="close_box" href="javascript:close_box()"><div id="close_box"></div></a>';
	$('div_overlay').style.display = "block";
	$('div_overlay_wrapper').style.display = "block";
	$('div_overlay_content').innerHTML = "<a href=\"javascript:close_box();\"><img src=\""+img+"\" border=\"0\"></a>";
}

function load_box_img_v2(img) {
	$('div_overlay_header').innerHTML = '<a class="close_box" href="javascript:close_box()"><div id="close_box"></div></a>';
	$('div_overlay').style.display = "block";
	$('div_overlay_wrapper').style.display = "block";
	$('div_overlay_content').innerHTML = "<center><a href=\"javascript:close_box();\"><img src=\""+img+"\" border=\"0\"></a></center>";
}



function load_box_with_refresh(file) {
	document.getElementById("div_overlay_header").innerHTML = '<a href="javascript:close_box_with_refresh()">OK</a>';
	document.getElementById("div_overlay").style.display = "block";
	document.getElementById("div_overlay_wrapper").style.display = "block";
	var req = new Request.HTML({url: file, 
			onSuccess: function(html) {
				$('div_overlay_content').set('text', '');
				$('div_overlay_content').adopt(html);
			}
		}).send();
}



function load_box_with_refresh_v2(file) {
	var req = new Request.HTML({url: file, 
			onSuccess: function(html) {
				$('content').set('text', '');
				$('content').adopt(html);
				$('menu_left').set('style', 'display:none;');
				$('menu_left').set('style', 'width:0px;');
				$('menu_left').set('style', 'position:absolute;');
				$('menu_left').set('style', 'left:-1000px;');
				$('content').set('style', 'margin-left:120px;');
			}
		}).send();
}


function update_warenkorb(file, div) {
	compat_proto(file,div);
}

function compat_proto(file,div) {
	var req = new Request.HTML({url: file, 
		onSuccess: function(html) {
			$(div).set('text', '');
			$(div).adopt(html);
		}
	}).send();
}

function check_zahlungsart(zahlungsart) {
	if (zahlungsart==9&&document.getElementById('lastschrift_daten')) {
		show_div('lastschrift_daten');
	} else if(document.getElementById('lastschrift_daten')) {
		hide_div('lastschrift_daten');
	}
}

function close_box() {
	if ($('div_overlay')) { $('div_overlay').style.display = "none"; }
	if ($('div_overlay_content')) { $('div_overlay_content').style.display = "none"; }
	if ($('div_overlay_wrapper')) { $('div_overlay_wrapper').style.display = "none"; }
}

function close_box_with_refresh() {
	location.href=location.href;
	document.all.div_overlay.style.display = "none";
	document.getElementById("div_overlay_wrapper").style.display = "none";
}

function toggle_div(name) {
	if (document.getElementById(name).style.display=="none") {
		show_div(name);
	} else {
		hide_div(name);
	}
}

function call_serps(name) {
	if (name=="content") {
		show_div('serps_content');
		hide_div('serps_produkte');
		$('ser_pr').src='templates/foerdertechnik/images/suche/result_product_0.png';
		$('ser_pr').set('style','position:absolute; z-index:1;');
		$('ser_con').src='templates/foerdertechnik/images/suche/result_website_1.png';
		$('ser_con').set('style','position:absolute; z-index:2;');
	} else if (name=="produkte") {
		show_div('serps_produkte');
		hide_div('serps_content');
		$('ser_pr').src='templates/foerdertechnik/images/suche/result_product_1.png';
		$('ser_pr').set('style','position:absolute; z-index:2;');
		$('ser_con').src='templates/foerdertechnik/images/suche/result_website_0.png';
		$('ser_con').set('style','position:absolute; z-index:1;');
	}	
}

function hide_div(name) {
	document.getElementById(name).style.display = "none";
	if (document.getElementById(name+'_konter')) {
		document.getElementById(name+'_konter').style.display = "block";
	}
}

function show_div(name) {
	document.getElementById(name).style.display = "block";
	if (document.getElementById(name+'_konter')) {
		document.getElementById(name+'_konter').style.display = "none";
	}
}

function process_update(suid) {
   var company = $('ad_company').value;
   var surname = $('ad_surname').value;
   var name = $('ad_name').value;
   var road = $('ad_road').value;
   var housenb = $('ad_housenb').value;
   var plz = $('ad_plz').value;
   var city = $('ad_city').value;
   var country = $('ad_country').value;
   var adressbox = $('ad_address').value;
   
   var req = new Request.HTML({url:'inc/kasse/func/adressen.php?action=addadress&adress=' + adressbox + '&suid=' + suid + '&company=' + company + '&surname=' + surname + '&name=' + name + '&road=' + road + '&housenb=' + housenb + '&plz=' + plz + '&city=' + city + '&country=' + country, 
			onSuccess: function(html) {
				$('div_overlay_content').set('text', '');
				$('div_overlay_content').adopt(html);
			}
		}).send();
}

function preisvorschlag(product_id) {
	var variables = "form_preisvorschlag_company="+document.all.form_preisvorschlag_company.value+"&form_preisvorschlag_tel="+document.all.form_preisvorschlag_tel.value+"&form_preisvorschlag_email="+document.all.form_preisvorschlag_email.value+"&form_preisvorschlag_newprice="+document.all.form_preisvorschlag_newprice.value+"&form_preisvorschlag_name="+document.all.form_preisvorschlag_name.value;

	 var req = new Request.HTML({url:'inc/products/ajax/preisvorschlag.php?action=sendmail&product_id='+product_id, 
			onSuccess: function(html) {
				$('div_overlay_content').set('text', '');
				$('div_overlay_content').adopt(html);
			}
		}).send(variables);
}

function changeadress(box,amount) {
	var adressid = '';
	for(var i = 0;i<document.forms["chooseaddress"].addressid.length;i++) {
		if(document.forms["chooseaddress"].addressid[i].checked) {
			adressid = document.forms["chooseaddress"].addressid[i].value;
		}
	}
	var req = new Request.HTML({url:'inc/kasse/script/getadress.php?aid='+adressid+'&box='+box, 
			onSuccess: function(html) {
				$(box).set('text', '');
				$(box).adopt(html);
			}
		}).send();
	close_box();
}

function delete_comment(cid) {
		var req = new Request.HTML({url: 'inc/blog/script/delcomment.php?cid='+cid, 
			onSuccess: function(html) {
				$('div_overlay_content').set('text', '');
				$('div_overlay_content').adopt(html);
			}
		}).send();
		
		alert("Kommentar wurde gelöscht");
		location.href=location.href;

}