// Array aller Popup-Fenster mit Name und Parameter
var PopupWindows = new Array();
PopupWindows["uebersicht"] = "width=800,height=580,scrollbars=yes,resizable=no";
PopupWindows["detail"] = "width=640,height=520,scrollbars=no,resizable=no";
PopupWindows["teaser"] = "width=615,height=480,scrollbars=no,resizable=no";


function Popup(url, name, parameter) {
	if (PopupWindows[name] != null) {
		parameter = PopupWindows[name];
	} else if (parameter == "" || parameter == null) {
		// undefinierter Name und keine Parameter übergeben => Standard-Parameter
		parameter = PopupWindows["standard"];
	}
	// Popup zentrieren, dazu X und Y Koordinate berechnen
	var width, heigth, left = null, top = null;
	temp = parameter.split(",");
	for (var i = 0; i < temp.length; i++) {
		values = temp[i].split("=");
		if (values[0] == "width") width = parseInt(values[1]);
		if (values[0] == "height") height = parseInt(values[1]);
		if (values[0] == "left") left = parseInt(values[1]);
		if (values[0] == "top") top = parseInt(values[1]);
	}
	if (left == null) {
		left = Math.round((screen.width - width) / 2);
	}
	if (top == null) {
		top = Math.round((screen.height - height) / 3);
	}
	if (left != null) {
		parameter += ",screenX="+left+",left="+left;
	}
	if (top != null) {
		parameter += ",screenY="+top+",top="+top;
	}
	var popuphandler = window.open(url, name, parameter);
	popuphandler.window.focus();
}


/** Hide companion form and reset the input.
 *
 * @access public
 * @return void
 **/
function hideCompanion(id) {

	document.getElementById(id).style.display = "none";

	document.getElementsByName("tx_pilmailform_pi1[select][companion_salutation]")[0].selectedIndex = 0;
	document.getElementsByName("tx_pilmailform_pi1[select][companion_salutation]")[0].options[0].defaultSelected = false;
	document.getElementsByName("tx_pilmailform_pi1[select][companion_salutation]")[0].options[1].defaultSelected = false;
	document.getElementsByName("tx_pilmailform_pi1[select][companion_salutation]")[0].options[2].defaultSelected = false;
	document.getElementsByName("tx_pilmailform_pi1[text][companion_title]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_name]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_surname]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_function]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_email]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_company]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_street]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_hno]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_zipcode]")[0].value = "";
	document.getElementsByName("tx_pilmailform_pi1[text][companion_city]")[0].value = "";

}

/** Show companion form.
 *
 * @access public
 * @return void
 **/
function showCompanion(id) {

	document.getElementById(id).style.display = "block";

}


/**
 *
 * @access public
 * @return void
 **/
function focusOnDealer(land){
	document.getElementById('showBundesland').innerHTML = land;
}

/**
 *
 * @access public
 * @return void
 **/
function focusOutDealer(){
	document.getElementById('showBundesland').innerHTML = '';
}

function showHideNotifyText(id, show) {
	var visibility = (show == 1) ? 'block' : 'none';
	document.getElementById(id).style.display = visibility;
}
