/*
	Auf Cookies checken und ggf. Formular sichbar machen
*/

 var hasCookies=false;
function getCookie(name)
{/* get cookie von torsten unger */
  var index = document.cookie.indexOf(name + "=");
  if (index == -1) return null;
  index = document.cookie.indexOf("=", index) + 1;
  var endstr = document.cookie.indexOf(";", index);
  if (endstr == -1) endstr = document.cookie.length;
  return unescape(document.cookie.substring(index, endstr));
}
/* cookie-check */
function noCookie()
{
    if (getCookie("ruv")==null) {
//	alert("Keine Sorge, ich bin ein Debugger von Matthias Cookie :-)\n\n"+getCookie("ruv"))
	document.cookie = "ruv=CheckCookie"
	}
    if (getCookie("ruv")==null) {
    return true;
	}
    else
    return false;
}  
if (!noCookie()) { 
document.write("<style\>"+
"#adressaenderung, #bestellservice {"+
"display:inline;"+
"}"+
"#CookiesJaNein {display:none;}"+
"<\/style\>");
} else {
//document.write("DEBUG: keine Kekse :-(");
}

//alert("Test in S-Test");

/*
	Ende Workarround
*/




/*
CheckVal: diese Funktion setzt beim Focus das Suchfeld zurueck
*/

function checkVal(el,val,cursor) {
	if (cursor) {
		if (el.value==val)
		el.value="";
	} else {
		if (el.value=="")
		el.value=val;
	}
}

function openWin(newURL,params) {
openwin(newURL,params);
}
function OpenWin(newURL,params) {
openwin(newURL,params);
}
function openwin(newURL,params)
{
		/*if (newURL.indexOf("http:")==-1 && newURL.indexOf("/formulare")!=-1)
		{
			if(newURL.indexOf("Forum")==-1)
			{
	
			if(eval(location.port)==8080)
			newURL = "http://"+location.hostname+":"+location.port+newURL;
			else
			newURL = "https://"+location.hostname+location.port+newURL;
	
			params = params.replace(/status=no/g,"status=yes");
			}
		}*/
	
	if (!params) {
	var temp=window.open(newURL);
	return;
	}
	if (params=="null") {
	params='height=600,width=400,resizable=yes,menubar=yes,status=no,loactionbar=no,scrollbars=yes';
	}	
	var weite=params.indexOf("width=");
	var hoehe=params.indexOf("height=");
	var resWeite=params.substring(weite+6,weite+9);
	var resHoehe=params.substring(hoehe+7,hoehe+10);
	
	var WindowName=escape(newURL).replace(/\%/g,"");
		WindowName=WindowName.replace(/\//g,'')
		WindowName=WindowName.replace(/\./g,'')
		WindowName=WindowName.replace(/-/g,'')
		WindowName=WindowName.replace(/\+/g,'')
	

	var temp= "window.open('"+newURL+"','"+WindowName+"','"+params+"')";
	  var newWin = eval(temp)
		if (!isNaN(resWeite) && (!isNaN(resHoehe)))
		{
		//if (newURL.indexOf("https:")==-1)
//			newWin.resizeTo(resWeite,resHoehe)
		}
	//if (newURL.indexOf("https:")==-1 && (document.getElementById || !document.all))
	if (document.getElementById || !document.all)
		newWin.focus();
	temp="";
	newWin="";
}





/* --------------------------------------------------------------------- 
  Produktinformationen laden GA-Seiten. Manche nennen es AJAX ;)
 ---------------------------------------------------------------------- */

var http_request = false;
var neuwin;
var zwischentext=""; //wird in die Box geladen

function InfoFloater(url,ka) {
if (!ka)
ka="";
url=url.replace("https","http");
zwischentext="";
neuwin = window.open('http://www.ruv.de/de/help/infofenster'+ka+'.html?'+url,'InfoPopup','height=600,width=800,resizable=yes,menubar=yes,status=no,locationbar=no,scrollbars=yes');
//neuwin = window.open(url);
return; // stop: wg. status 302 im Fenster weiter machen. ohne https.

http_request = false;

    if (window.XMLHttpRequest) { // Gecko u.a.
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // ie...
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
            http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert("Es ist ein Fehler aufgetreten.");
		neuwin.close();
        return false;
    }
http_request.onreadystatechange = InhaltExtrahieren;
http_request.open('GET', url, true);
http_request.send(null);
}

function InhaltExtrahieren() {
var LadeStr="";
var reqStr="";
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
		reqStr=http_request.responseText;
		LadeStr=reqStr.substring(reqStr.indexOf("<div id=\"wrap"),reqStr.indexOf("</body"));
		var cont=document.getElementById("textLinker1");
		document.getElementById("textLinker1").innerHTML="";
		document.getElementById("textLinker1").innerHTML=LadeStr;
		var divsInCont=cont.getElementsByTagName("DIV");
		var aInCont=cont.getElementsByTagName("A");
			for (var i=0;i<divsInCont.length;i++) { //unerwuenschte divs leer machen
				if (divsInCont[i].className == "plzIndent")
				divsInCont[i].parentNode.removeChild(divsInCont[i]);
				if (divsInCont[i].className == "nachoben")
				divsInCont[i].parentNode.removeChild(divsInCont[i]);
				if (divsInCont[i].id == "cFooter")
				divsInCont[i].parentNode.removeChild(divsInCont[i]);
			}
			for (var i=0;i<aInCont.length;i++) { // Hyperlinks leeren
			aInCont[i].removeAttribute("href");
			aInCont[i].removeAttribute("onclick");
			aInCont[i].style.color="black";
			aInCont[i].style.textDecoration="none";
			}
			for (var i=0;i<divsInCont.length;i++) {
			// div auswaehlen....
				if (divsInCont[i].id == "ContentTitle") {
				var tmpTagH1=divsInCont[i].getElementsByTagName("h1");
				var tmpTagH2=divsInCont[i].getElementsByTagName("h2");
					for (var k=0;k<tmpTagH1.length;k++)
					zwischentext+="<h1>"+tmpTagH1[k].innerHTML+"</h1>";
					for (var k=0;k<tmpTagH2.length;k++)
					zwischentext+="<h2>"+tmpTagH2[k].innerHTML+"</h2>";
				} 
				if (divsInCont[i].id == "Content") {
				zwischentext+=divsInCont[i].innerHTML;
				}
			}
	} else	{
	alert(http_request.status);
			}
	}
infoText_produktinfo(zwischentext);
}

function infoText_produktinfo(txt) {
if (txt)
zwischentext=txt;
	if (neuwin.document.getElementById("floaterwrap")) {
	neuwin.document.getElementById("floaterwrap").innerHTML=zwischentext;
	}
	else {
	setTimeout("infoText_produktinfo()",2000);
	}
}
/* --------------------------------------------------------------------- 
  E: Produktinformationen laden GA-Seiten
 ---------------------------------------------------------------------- */








/*  abgeloest, s.o.

function prodLaden(w,uri) {
	uri=uri.substr(uri.indexOf("/de/"));
	var uriStr="/de/RuVContentServlet?url="+uri+"&contentcss=/de/styles/ncd/import_druck.css&partner=1";

w.document.getElementById("info").innerHTML="<iframe style=\"border:0px; margin:0px; padding:0px;\" onload=\"opener.sessionReset(document.getElementById('ifr'),'"+uri+"');\" width=100% height=100% src=\""+uriStr+"\"></iframe>";
}
function sessionReset(w, uri) {
	var uriStr="/de/RuVContentServlet?url="+uri+"&contentcss=/de/styles/import_cd.css&partner=0";
w.innerHTML="<iframe src=\""+uriStr+"\"></iframe>";
}

function InfoFloater(uri) {
	var prodwin=window.open("/de/help/leer.html","InfoWin", "height=600,width=650,resizable=yes,menubar=yes,status=no,locationbar=no,scrollbars=no");
	with (prodwin.document) {
	open();

writeln("<!DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Strict\/\/EN\""+
	"\n\"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-strict.dtd\"\>"+

"\n<html\>"+
"\n<head\>"+
"\n<title\>Produktinformation<\/title\>"+
"\n<\/head\>"+
"\n<body style=\"margin:0px;padding:0px;\" onload=\"opener.prodLaden(this,'"+uri+"');\"\>");
if (document.all)
writeln("\n<div id=\"info\"\ style=\"width:100%; position:relative;left:0px;top:0px; height:100%;\"><\/div\>");
else
writeln("\n<div id=\"info\"\ style=\"width:100%; position:absolute;left:0px;top:0px; height:100%;\"><\/div\>");

writeln("\n<div id=\"ifr\"\ style=\"display:none;\"><\/div\>"+
"\n<\/body\>"+
"\n<\/html\>");


	close();
	}
}
 -- */ 


function infoText_neu(txt) {

var myHtml=""+

"\<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"\>"+

"\n\<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"de\" lang=\"de\"\>"+
"\n\<head\>"+
"\n  "+
"\n"+
"\n\<title\>Hilfe\</title\>"+
"\n"+
"\n\<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" /\>"+
"\n\<meta http-equiv=\"Content-language\" content=\"de\" /\>"+
"\n"+
"\n  \<link href=\"http://www.ruv.de/de/styles/import_cd.css\" rel=\"stylesheet\" type=\"text/css\" media=\"screen\" title=\"R+V Hausstyle\" /\>"+
"\n   "+
"\n  "+
"\n\</head\>"+
"\n"+
"\n\<body id=\"floaterbody\"\> "+
"\n \<div id=\"xblock\"\>"+
"\n \</div\>"+
"\n"+
"\n \<div id=\"Header\"\>"+
"\n  \<img src=\"/de/images/logos/ruvlogo_sw.gif\" width=\"95\" height=\"39\" alt=\"Logo R+V Versicherung\" /\>"+
"\n \</div\>"+
"\n"+
"\n \<div id=\"floaterwrap\"\>"+
"\n    \<h4 class=\"absatzheadline\"\> Hilfe \</h4\>"+
"\n    \<div class=\"standard\"\>"+txt+

"\n    \</div\>"+
"\n "+
"\n \</div\>"+
"\n \<div id=\"floaternav\" class=\"JavaScriptLink\"\>"+
"\n  \<a href=\"javascript:close();\" title=\"Fenster schließen\"\>schließen\</a\>"+
"\n \</div\>"+
"\n\</body\>"+
"\n\</html\>";


var infWin=window.open('','InfoPopup','height=600,width=400,resizable=yes,menubar=yes,status=no,locationbar=no,scrollbars=yes');
	with (infWin.document) {
	open();
	writeln(myHtml);
	close();
	}
}

/* f. Riester */

		function druck(){
			document.rentenpolsterForm.target="Druckfenster";
			PDFwin=window.open("/de/s_rp/intermediate.html","Druckfenster","width=700,height=500,toolbar=no,menubar=no,personalbar=no,resizable=yes,scrollbars=yes,dependent=yes");
			document.rentenpolsterForm.target="Druckfenster";
		}		


var EiWasDann = new Array(
/* ---------------------- Bitte hier die Styles eintragen ------------------- */

"Druckansicht",


/* ---------------------- ab hier nix mehr ändern, bitte -------------------- */

'');



function StyleLinks() {
var tmpStr="";
for (var i =0; i< EiWasDann.length; i++) {
tmpStr+="<a title=\"umschalten auf "+EiWasDann[i]+"\" href=\"JavaScript:StyleWechseln('"+EiWasDann[i]+"')\">"+EiWasDann[i]+"</a>";
}

//document.write(tmpStr);
//	  if (!document.all)
//	  document.getElementById("StyleWechseln").style.position="fixed";
}

function StyleWechseln(welcherDenn) {
  var StyleSheet="";
  for(var i=0; (StyleSheet = document.getElementsByTagName("link")[i]); i++) {
    if(StyleSheet.getAttribute("rel") && StyleSheet.getAttribute("rel").indexOf("style") != -1 && StyleSheet.getAttribute("title")) {
      StyleSheet.disabled = true; //alle abschalten
      if(StyleSheet.getAttribute("title") == welcherDenn) {
	  StyleSheet.disabled = false; //nur der richtige kommt durch :-)
//	  if (!document.all)
//	  document.getElementById("StyleWechseln").style.position="fixed";
	  }
    }
  }

hideLayer(1);
}

// Ansprechpartnersuche

function checkPLZ(el) {
//checkVal(el,'Ihre Postleitzahl',true);
	if (el.value=="Postleitzahl") {
	el.blur(); return false;
	}
	if (isNaN(el.value)) {
	el.value="Postleitzahl";
	return false;
	}
	if (el.value.length<3) {
	el.value+="???";
	el.blur(); return false;
	}
	el.value=el.value.substr(0,5);
	return true;
}

function ChecknSubmit()
{
if(checkPLZ(document.formularAnsprechpartnerSuche.eplKPLZ))
document.formularAnsprechpartnerSuche.submit();
}




document.write ("<style type=\"text/css\"\>.azlink .InfoboxNoScript, .InfoboxNoScript{display:none} .JavaScriptLink{display:inline;} #VBKopfLayer, #GAKopfLayer{position:absolute;}<\/style\>")

