function get_schedule(typ)
{
	$.get("info_schedule_new.php", { typ: typ }, function(data){$('#schedule').html(data);$( "#dialog-modal" ).dialog({height: 400,width: 600,modal: true});});
}

function get_compare_ap()
{
	$.get("info_compare_ap.php", {}, function(data){$('#schedule').html(data);$( "#dialog-modal" ).dialog({height: 400,width: 700,modal: true});});
}


function show_dialog(titel, content)
{
	myPanel.show();
//	alert("huhu");

}

function change_img(c, stat)
{
	alert("blub" + c);
	datei = c + "_" + stat + ".png";
	wert = document.getElementById("" + c + "");
	alert(wert);
	alert(wert.src);	
}

function get_rkv(errmsg)
{
	rpreis = parseInt($("#rkv_wert").val());
//	rpreis = rpreis.replace(/./, "");
//	rpreis = rpreis.replace(/,/, "");
	
	if(rpreis > 3000)
	{
		alert(errmsg);	
		$("#reisepr").html() = "";
	}
	else
	{
		debdat = $("#depdat").val();
		$.get("get_rkv.php", { rpreis: rpreis, debdat: debdat }, function(data){$('#reisepr').html(data);});
	}
}

function openpolice()
{
	//wert = document.forms[0].polang.options[document.forms[0].polang.selectedIndex].value;
	error = 1;
	if(document.forms[0].polang.length == undefined)
	{
		//if(document.forms[0].polang[0].checked == true)
		//{
			wert = document.forms[0].polang.value;
			error = 0;
		//}		
	}
	else
	{
		for(i=0;i<document.forms[0].polang.length;i++)
		{
			if(document.forms[0].polang[i].checked == true)
			{
				wert = document.forms[0].polang[i].value;
				error = 0;
			}
		}
	}
	//wert = document.forms[0].polang.selectedIndex = 1;
	//alert(wert);
	if(error == 0)
	{
		datei = "pdf/" + wert;
		window.open(datei, "dwin", "width=800,height=600,resizeable=yes");
		document.forms[0].readit.value = 0;
	}
	else
	{
		alert("Please select a language!");	
	}
}

function openpolicesh()
{
	//wert = document.forms[0].polang.options[document.forms[0].polang.selectedIndex].value;
	error = 1;
	if(document.forms[0].posh.length == undefined)
	{
		//if(document.forms[0].polang[0].checked == true)
		//{
			wert = document.forms[0].posh.value;
			error = 0;
		//}		
	}
	else
	{
		for(i=0;i<document.forms[0].posh.length;i++)
		{
			if(document.forms[0].posh[i].checked == true)
			{
				wert = document.forms[0].posh[i].value;
				error = 0;
			}
		}
	}
	//wert = document.forms[0].polang.selectedIndex = 1;
	//alert(wert);
	if(error == 0)
	{
		datei = "pdf/" + wert;
		pwin = window.open(datei, "owin", "width=800,height=600,resizeable=yes");
		document.forms[0].readit.value = 0;
	}
	else
	{
		alert("Please select a language!");	
	}
}

function readpolice()
{
	error = 1;
	//wert = document.forms[0].polang.options[document.forms[0].polang.selectedIndex].value;
	for(i=0;i<document.forms[0].polang.length;i++)
	{
		if(document.forms[0].polang[i].checked == true)
		{
			wert = document.forms[0].polang[i].value;
			error = 0;
		}
	}
	//wert = document.forms[0].polang.selectedIndex = 1;
	//alert(wert);
	if(error == 0)
	{
		datei = "html/download.php?pldatei=" + wert;
		window.open(datei, "dwin", "width=150,height=100");
		document.forms[0].readit.value = 0;
	}
	else
	{
		alert("Please select a language!");	
	}	
}

function readpolicesh()
{
	error = 1;
	//wert = document.forms[0].polang.options[document.forms[0].polang.selectedIndex].value;
	for(i=0;i<document.forms[0].posh.length;i++)
	{
		if(document.forms[0].posh[i].checked == true)
		{
			wert = document.forms[0].posh[i].value;
			//alert(wert);
			error = 0;
		}
	}
	//wert = document.forms[0].polang.selectedIndex = 1;
	//alert(wert);
	if(error == 0)
	{
		datei = "html/download.php?pldatei=" + wert;
		pwin = window.open(datei, "rwin", "width=150,height=100");
		document.forms[0].readit.value = 0;
	}
	else
	{
		alert("Please select a language!");		
	}	
}

// setzt die Felder für die abweichende Lieferadresse beim ändern der Checkbox aktiv bzw. passiv
function changed(){
	if (!document.one.waehrung[0].checked==true && document.one.waehrung[1].checked==true){
		document.one.zahlung[0].checked=true;
//		document.one.zahlung[1].disabled=true;
	} //else 
//		document.one.zahlung[1].disabled=false;
	if (document.one.zahlung[0].checked==true){
		document.one.kreditnr.disabled=false;
		document.one.karteninh.disabled=false;
		document.one.gueltigM.disabled=false;
		document.one.gueltigJ.disabled=false;
		document.one.karte.disabled=false;
		document.one.ktnr.disabled=true;
		document.one.blz.disabled=true;
		document.one.bank.disabled=true;
		document.one.kontoinh.disabled=true;
		$("creditwin").style.visibility ="visible";
		$("creditwin").style.height ="180px";
		$("lswin").style.visibility ="hidden";
		$("lswin").style.height ="0px";
		
		
	}else {
		document.one.kreditnr.disabled=true;
		document.one.karteninh.disabled=true;
		document.one.gueltigM.disabled=true;
		document.one.gueltigJ.disabled=true;
		document.one.karte.disabled=true;
		document.one.ktnr.disabled=false;
		document.one.blz.disabled=false;
		document.one.bank.disabled=false;
		document.one.kontoinh.disabled=false;
		$("creditwin").style.visibility ="hidden";
		$("creditwin").style.height ="0px";
		$("lswin").style.visibility ="visible";
		$("lswin").style.height ="170px";

	}
}

function setZahlung()
{
	if($("#zahlung1").attr('checked') == true)
	{
		//$("creditwin").css('visibility', "visible");
		$("#creditwin").css('height', "160px");
		$("#creditwin").show();
		//$("lswin").css('visibility', "hidden");
		$("lswin").css('height', "0px");
		$("lswin").hide();
		
	}
	else if($("#zahlung2").attr('checked') == true)
	{
//		$("creditwin").css('visibility', "hidden");
		$("#creditwin").css('height',"0px");
		$("#creditwin").hide();
	//	$("lswin").css('visibility', "visible");
		$("#lswin").css('height',"160px");
		$("#lswin").show();
	}
	else
	{
	//	$("creditwin").css('visibility',"hidden");
		$("#creditwin").css('height', "0px");
		$("#creditwin").hide();
//		$("lswin").css('visibility',"hidden");
		$("#lswin").css('height',"0px");
		$("#lswin").hide();
	}
	rhoehe = $("#cont_var").height();
	//$("sublinks").style.top = (rhoehe + 270) + "px";	
}

function changeMyCmd2(which, icon)
{
	if($(which).style.visibility == "visible")
	{
		//$(which).style.visibility ="hidden";
		//$(which).style.visibility ="hidden";
		$(which).style.display ="inline";
		$(which).style.height ="0px";
		$(icon).src = 'images/add.png';
	}
	else
	{
		//$(which).style.visibility ="visible";
		$(which).style.display ="none";
	//	$(which).style.height = $(which + "_height").value + "px";
	//	$(which).style.display = "inline";
		$(icon).src = 'images/subtract.png';
	}
}

function changeMyCmd(which, icon)
{

	if(isNaN($("changement")) && $("changement").style.display == "inline" && which != "changement")
	{
		$("changement").style.display = "none";
		$("icon_6").src = 'images/add.png';
	}
	if(isNaN($("coverage")) && $("coverage").style.display == "inline" && which != "coverage")
	{
		$("coverage").style.display = "none";
		$("icon_1").src = 'images/add.png';
	}
	if(isNaN($("emergency")) && $("emergency").style.display == "inline" && which != "emergency")
	{
		$("emergency").style.display = "none";
		$("icon_2").src = 'images/add.png';
	}
	if(isNaN($("claim")) && $("claim").style.display == "inline" && which != "claim")
	{
		$("claim").style.display = "none";
		$("icon_3").src = 'images/add.png';
	}
	if(isNaN($("claimcontact")) && $("claimcontact").style.display == "inline" && which != "claimcontact")
	{
		$("claimcontact").style.display = "none";
		$("icon_4").src = 'images/add.png';
	}	
	if(isNaN($("tripcan")) && $("tripcan").style.display == "inline" && which != "tripcan")
	{
		$("tripcan").style.display = "none";
		$("icon_5").src = 'images/add.png';
	}
	if($(which).style.display == "inline")
	{
		//$(which).style.visibility ="hidden";
		$(which).style.display ="none";
//		$(which).style.height ="0px";
		$(icon).src = 'images/add.png';
	}
	else
	{
		$(which).style.display ="inline";
//		$(which).style.height = $(which + "_height").value + "px";
	//	$(which).style.display = "inline";
		$(icon).src = 'images/subtract.png';
	}
}

function changeRQform(which)
{

//	if(isNaN($("can")) && $("can").style.display == "inline" && which != "can")
	if(which != "can")
	{
		$("#can").hide();
	}
//	if(isNaN($("early")) && $("early").style.display == "inline" && which != "early")
	if(which != "early")
	{
		$("#early").hide();
	}
//	if(isNaN($("ext")) && $("ext").style.display == "inline" && which != "ext")
	if(which != "ext")
	{
		$("#ext").hide();
	}
	if($("#" + which).css('display') == "inline")
	{
		//$(which).style.visibility ="hidden";
		$("#" + which).hide();
//		$(which).style.height ="0px";
	}
	else
	{
		$("#" + which).show();
//		$(which).style.height = $(which + "_height").value + "px";
	//	$(which).style.display = "inline";
	}
}

function changeFAQ(nr, m)
{
	$("faq_answ").style.visibility = "hidden";
	which = "fragen_" + nr;
	icon = "icon_" + nr;
	if($(which).style.display == "inline")
	{
		//$(which).style.visibility ="hidden";
		$(which).style.display ="none";
//		$(which).style.height ="0px";
		$(icon).src = 'images/add.png';
	}
	else
	{
		$(which).style.display ="inline";
//		$(which).style.height = $(which + "_height").value + "px";
	//	$(which).style.display = "inline";
		$(icon).src = 'images/subtract.png';
	}
	for(i=0;i<m;i++)
	{
		if(i != nr)
		{
			which = "fragen_" + i;
			icon = "icon_" + i;
			$(which).style.display ="none";
			$(icon).src = 'images/add.png';
		}
	}	
}

function highlightFrage(i, k, m, ffid, sid)
{
	$("faq_answ").style.visibility = "hidden";
	for(g=0;g<m;g++)
	{
		$("efrage_" + i + "_" + g).style.backgroundColor= '#FFFFFF';
	}
	$("efrage_" + i + "_" + k).style.backgroundColor= '#D1EB94';
	koord = $("efrage_" + i + "_" + k).positionedOffset();
	hoehe = $("efrage_" + i + "_" + k).getHeight();
	//alert(koord[1] + " hoehe = " + hoehe);
	$("faq_answ").style.top = hoehe + "px";
	koord_box = $("faq_answ").positionedOffset();
	
	//alert(koord[0] + " " + koord[1]);
	$("faq_answ").style.position = "absolute";
//	$("faq_answ").style.left = (parseInt(koord[0]) + 280) + "px";
//	$("faq_answ").style.left = (300) + "px";
	//alert($("faq_answ").style.backgroundImage);
//	alert(((parseInt(koord_box[1]) * (-1)) + parseInt(koord[1])));

	if(koord[1] > 229)
	{
		ntop = (koord[1]-192) + "px";
		$("faq_answ").style.backgroundImage = "url(images/faq_as_down.png)";
	}
	else
	{
		ntop = (koord[1]-42) + "px";
		$("faq_answ").style.backgroundImage = "url(images/faq_as_up.png)";
	}
	$("faq_answ").style.top = "0px";
	test = $("faq_answ_text").positionedOffset();
//	alert(test[0]);
	
//	$("faq_answ").style.top = ntop;
	$("faq_answ").style.top = "0px";
	//alert(koord_box[1]);
	$("faq_answ").style.top = ntop;
	$("faq_answ").style.visibility = "visible";
	get_faq(ffid, sid);
//	alert($("faq_answ").style.top);
	//alert($("faq_answ").style.top);
}

function runde(x, n) 
{
  if (n < 1 || n > 14) return false;
  var e = Math.pow(10, n);
  var k = (Math.round(x * e) / e).toString();
  if (k.indexOf('.') == -1) k += '.';
  k += e.toString().substring(1);
  nv = k.substring(0, k.indexOf('.') + n+1);
 // nv = nv.replace(/\./, ",");
  return nv.replace(/\./,",");
}

function setagb()
{
	//if($("agbok").checked && $("plread").value == 1)
	if($("#agbok").attr('checked'))
	{
		$("#vsbuch").attr('disabled', false);
	}
	else
	{
		$("#vsbuch").attr('disabled', true);
	}
}

function check_agbpl(hwt)
{
	if($("#agbok").attr('checked') && $("#plread").val() == 1)
	{
		$("#anmd").submit();
	}
	else
	{
		alert(hwt);
	}
}

