
function writeConsole(content) {
 top.consoleRef=window.open('','myconsole',
  'width=416,height=250,left=20,top=20'
   +',menubar=0'
   +',toolbar=1'
   +',status=0'
   +',scrollbars=1'
   +',resizable=1')
 top.consoleRef.document.writeln(
  '<html><head><title>Infofenster</title>'
  +'<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />'
  +'<meta http-equiv="Content-language" content="ger-DE" />'
  +'<style>'
  +'@import url("/design/espumisan/stylesheets/popup.css");'
  +'</style>'
  +'</head>'
  +'<body onLoad="self.focus()">'
  +'<div id="close"><a href="JavaScript:window.close();"><img src="/design/espumisan/images/popup_bg.gif" width="400" height="71" border="0"></a></div>'
  +'<div id="popup">'
  +content+
  '</div></body></html>'
 )
 top.consoleRef.document.close()
}

function pre_fill_order() {
	if (document.orderform.ContentObjectAttribute_ezstring_data_text_531.value != "") {
		var c_value = document.orderform.ContentObjectAttribute_ezstring_data_text_531.value;

		var broschueren = c_value.split(", ");

		for (var a = 0; a < broschueren.length; a++) {
			if (broschueren[a] != "") {
				for (var i=0; i < document.orderform.Broschuere_Bestellung.length; i++) {
					if (document.orderform.Broschuere_Bestellung[i].value == broschueren[a]) {
						document.orderform.Broschuere_Bestellung[i].checked = true;
					}
				}
			}
		}
	}
}

function fill_order() {

	var c_value = "";
	for (var i=0; i < document.orderform.Broschuere_Bestellung.length; i++) {
		if (document.orderform.Broschuere_Bestellung[i].checked) {
			c_value = c_value + document.orderform.Broschuere_Bestellung[i].value + ", ";
		}
	}
	document.orderform.ContentObjectAttribute_ezstring_data_text_531.value = c_value;
	document.orderform.submit();
}

function DummySort(a,b)
{ return a-b; }


//eZOption[622] ...

function auswerten() {

//	alert(document.online_test_form.option_index.value);

	start_index = document.online_test_form.option_index.value;

//	alert(eval("document.online_test_form" + ".option_index" + ".value"));

	punktzahl = 0;

	for(j=0;j<12;++j) {
		int_index = parseInt(start_index) + parseInt(j);
		eZOption_j = "document.online_test_form.eZOption_" +  int_index;

//		alert(eZOption_j);
//		if (eval(eZOption_j)) alert("esistiert: " + eZOption_j);

		if (eval(eZOption_j)) {
			for(i=0;i<eval(eZOption_j+".length");++i) {
//				alert("sdf:"+eval(eZOption_j+"[i].checked"));
				if(eval(eZOption_j+"[i].checked")) {
					// alert("Wert: j "+ j + " und i " +i + " Wert: " +eval(eZOption_j+"[i].value"));
					punktzahl += parseInt(eval(eZOption_j+"[i].value"));
				}
			}
		}
	}
//	alert("Erreichte Punktzahl: " + punktzahl );

	is_done = false;

	var target_values = new Array();

	for(j=0;j<10;++j) {
		if (eval("document.online_test_form.max_" +  j)) {
			max_value = eval("document.online_test_form.max_" +  j + ".value");
			target_values.push(max_value);
		}
	}
	target_values.sort(DummySort);
//	alert(target_values);

	for(j=0;j<target_values.length;++j) {
//		alert("j: " + j + " und target_values[j] = " + target_values[j]);
		if (punktzahl <= target_values[j] && (!is_done)) {
			is_done = true;
			goto_target = target_values[j];
//			alert(goto_target);
		}

	}

// mindestanzahl muss erreicht werden
	//if ((punktzahl < target_values.length) || (!is_done)) alert('Bitte füllen Sie alle Felder aus!');
	//else document.location.href = location.href + "/" + goto_target;
	document.location.href = location.href + "/" + goto_target;
}

function open_window(url) {
	mywin = window.open(url, 'NewWindow', 'menubar,scrollbars,width=416,height=500,left=20,top=20');
}

function close_popup() {
	self.window.close();
}

function manage_link_ez35(url) {
	if ( url.match(/layout\/set\/popup/g) ) {
		//url = url.replace( "popup/", "layout/set/popup/" );
		open_window(url);
	} else {
		if ( url.match(/popup/g) ) {
			url = url.replace( "popup/", "layout/set/popup/" );
			open_window(url);
		} else {
			document.location.href=url;
		}
	}
}

function manage_link(url, v_target) {
	// javascript:manage_link("http://www.intermundia.de","_blank")

	if ( v_target == "_blank")  {
		if ( url.match(/www/g) ) {
			document.location.href=url;
		} else {
			url = "/layout/set/popup" + url;
			open_window(url);
		}
	} else {
		if ( url.match(/popup/g) ) {
			url = url.replace( "popup/", "layout/set/popup/" );
			open_window(url);
		} else {
			document.location.href=url;
		}
	}
}

function open_website_link(myurl) {
    myurl="/"+myurl;
	  opener.document.location.href=myurl;
}


function apothekenfinder() {

  af_win = window.open('', 'ApothekenFinder', 'menubar,scrollbars,width=416,height=500,left=20,top=20');
  window.document.form_apothekenfinder.action="/apothekenfinder.php";
  window.document.form_apothekenfinder.submit();
  af_win.focus();
}

function apothekenfinder_gmaps() {

  af_win = window.open('', 'ApothekenFinder', 'menubar,scrollbars,width=416,height=600,left=20,top=20');
  window.document.form_apothekenfinder.action="/index1.php";
  window.document.form_apothekenfinder.submit();
  af_win.focus();
}