function popup_center(sURL,width,height,sName) {

	void(0);
	
	var str = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,"; 
	str += ",height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		}
	
	if (sName=='popup_extra')
	{
		sURL = sURL + "?bestellung_flag=";
	}
	
	oNewWindow = window.open(sURL, sName, str);
	if (window.focus){	
	oNewWindow.focus();
	}
}

function popup_center_no_scroll(sURL,width,height,sName) {

	void(0);
	
	var str = "toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,"; 
	str += ",height=" + height + ",innerHeight=" + height;
	str += ",width=" + width + ",innerWidth=" + width;
	
	if (window.screen) {
		var ah = screen.availHeight - 30;
		var aw = screen.availWidth - 10;

		var xc = (aw - width) / 2;
		var yc = (ah - height) / 2;

		str += ",left=" + xc + ",screenX=" + xc;
		str += ",top=" + yc + ",screenY=" + yc;
		}
	
	if (sName=='popup_extra')
	{
		sURL = sURL + "?bestellung_flag=";
	}
	
	oNewWindow = window.open(sURL, sName, str);
	if (window.focus){	
	oNewWindow.focus();
	}
}

function haendlerhomepage(id,culture)
{	
	var neues=window.open('Retailer.aspx?Culture=' + culture + '&Retailer=' + id,'haendlerhomepage','height=662,width=920,top=0,left=0,scrollbars=yes,toolbar=yes,location=yes,status=yes, menubar=yes,resizable');
	neues.focus();
}

function chooseRetailer(lang, page) {
	if(lang=="de") {
		msg = "Sie sind dabei, einen anderen Herpa eXtra-Fachhaendler auszuwaehlen.\n\nHinweis: Die Auswahl kann jederzeit neu getroffen werden."
	}
	else {
		msg = "You are about the choose a different Herpa eXtra retailer.\n\nPlease note that you can revise this choice at any time."
	}
	if(confirm(msg)==true) {
		self.location.href = page;
	}
}

function chooseRetailerNext(lang) {
	if(lang=="de") {
		msg = "Wollen Sie wirklich den neuen eXtra Fachhaendler auswaehlen?"
	}
	else {
		msg = "Do you really want to change your eXtra retailer?"
	}
	if(confirm(msg)==true) {
		self.location.href = "Default.aspx?RetailerNext=true";
	}
}

function checkIfIsEmpty() {
	//if(document.all["volltextsuche"].query.value == "") {
	if(document.forms['volltextsuche'].elements['query'].value == "") {
		document.forms['volltextsuche'].elements['query'].value = "eXtra-Neuheiten / New eXtra releases";
	}
	document.forms['volltextsuche'].submit();
}

//Fügt dem document einen neuen EventHandler hinzu. 
if(document.addEventListener){
	document.addEventListener("keypress", HandleEnterKey, true); 
}
else{
	document.attachEvent("onkeypress", HandleEnterKey); 
}


// EventHandler 
// Handelt den "enter-key" Event innerhalb eines FormObjects und 
// löst über die CallSubmit-Function entsprechende Verarbeitung aus.
function HandleEnterKey(event) { 
	var nav = window.Event ? true : false; 
	if (nav) { 
		return NetscapeEventHandler_KeyDown(event); 
	} else { 
		return MicrosoftEventHandler_KeyDown(); 
	} 
} 


function NetscapeEventHandler_KeyDown(e) { // auch für den Feuerfuchs und die Opera
	if (e.which == 13 && e.target.type != 'textarea' && e.target.type != 'submit') { 
		e.returnValue = false; 
		e.cancel = true; 
		e.preventDefault(); 
		var att = e.target.attributes['SubmitControl']; 
		if(att!=null) 
			CallSubmit(att.value) 
		return false; 
	} 
	return true; 
} 


function MicrosoftEventHandler_KeyDown() { 
	if (event.keyCode == 13 && event.srcElement.type != 'textarea' && event.srcElement.type != 'submit') { 
		event.returnValue = false; 
		event.cancel = true; 
		var att = event.srcElement.attributes['SubmitControl']; 
		if(att!=null) 
			CallSubmit(att.value) 
		return false; 
	} 
	return true; 
}


// dies sind die beiden Functions die das Form dann entsprechend verarbeiten
// EventHandler Enter-key
function CallSubmit(val){
	//alert(val);
	if (val=='meta_textFeldsuche')
	{
		metafulltextsearch();
	}
	if (val=='sub_textFeldsuche')
	{
		__doPostBack('Query','');
	}
	if (val=='user' || val=='pass')
	{
		login_cms();
	}
	if (val=='internLoginCustomerNumber')
	{
		__doPostBack('btnUserAccess','');
	}
	if (val=='internLoginShowCustomers')
	{
		__doPostBack('btnShowCustomers','');
	}	
}

// EventHandler onclick der Buttons/imageButtons
function Button(myButtonObj){
	//alert(myButtonObj.name)
	//alert("Submit gestoppt und mach irgendwas");
	metafulltextsearch();
	return false;
}

function metafulltextsearch()
{	
	var filePath	= location.pathname;
	var pos = filePath.lastIndexOf("/");
	// Dateinamen wegschneiden
	var path = filePath.substring(0,pos);
	
	//und jetzt noch die SessionID (z.B.:oiiqww45ym0zbz55jquynlft) aus den Pfad schneiden
	var pos = path.lastIndexOf("/");
	var path = filePath.substring(0,pos);
	
	//hole mir die in eine hidden field geschreibenen Session der ExtraShop-Session des Users
	var myID = document.forms[0].myID.value;
	
	url= "http://"+location.hostname.replace("ssl","www")+path +"/(S("+ myID +"))/hitlist.aspx?query=" + document.forms[0].elements['metaquery'].value;
	//alert(url);
	self.location.href = url;
}

function login_cms()
{	
	url= "login.aspx?";
	user="MetaUserName=" + document.forms[0].elements['MetaUserName'].value;
	pass="&MetaUserPass=" + document.forms[0].elements['MetaUserPass'].value;
	referer="&referer=" + document.forms[0].elements['referer'].value;
	self.location.href = url + user + pass + referer;
}

