var popupProperties = "directories=no,menubar=yes,toolbar=yes,status=no,resizable=yes,scrollbars=yes,hotkeys=no,width=483,height=400,left=186,top=120";
var popupPropertiesFull = "directories=no,menubar=yes,toolbar=yes,status=no,resizable=yes,scrollbars=yes,hotkeys=no,width=575,height=400,left=186,top=120";
var popupCalcProperties = "directories=no,menubar=yes,toolbar=yes,status=no,resizable=yes,scrollbars=yes,hotkeys=no,width=503,height=460,left=186,top=120";
var popupfonds = "directories=no,menubar=yes,toolbar=yes,status=no,resizable=yes,scrollbars=yes,hotkeys=no,width=685,height=560  ,left=186,top=10";
var popupdat = "directories=no,menubar=yes,toolbar=yes,status=no,resizable=no,scrollbars=yes,hotkeys=no,width=455,height=560  ,left=186,top=10";
var popupkarte = "directories=no,menubar=no,toolbar=no,status=no,resizable=no,scrollbars=no,hotkeys=no,width=700,height=597  ,left=50,top=1";

var strFav = "";
var isHome = false;

function Check_Winlist(pHref,pTarget){	
	tWin = (location.href.indexOf("search.gothaer")!=-1||location.href.indexOf("webvisit.gothaer")!=-1)?window:top;
	var bool1 = false;	
	var pProps= "";
	//alert(pHref + ' ' + pTarget + ' ' + pProps);
	if (pTarget.indexOf("_full")!=-1)   {pProps = popupPropertiesFull;}
	if (pTarget.indexOf("_calc")!=-1)   {pProps = popupCalcProperties;}
	if (pTarget.indexOf("_fonds")!=-1)   {pProps = popupfonds;}
	if (pTarget.indexOf("_dat")!=-1)   {pProps = popupdat;}
	if (pTarget.indexOf("_karte")!=-1)   {pProps = popupkarte;}	
	if (pProps.length > 0){
		//alert(pHref + ' ' + pTarget + ' ' + pProps);
		if(tWin.popupWin!=null && !tWin.popupWin.closed)top.popupWin.close();		
		tWin.popupWin = window.open(pHref,pTarget,pProps);
		tWin.popupWin.focus();		
		return true;
	}	
	return false;
}


function openPopup(pHref){
	tWin = (location.href.indexOf("search.gothaer")!=-1||location.href.indexOf("webvisit.gothaer")!=-1)?window:top;
	var pProps=(arguments.length>1)?arguments[1]:(pHref.indexOf(".do")!=-1)?popupCalcProperties:popupProperties;
	if(tWin.popupWin!=null && !tWin.popupWin.closed)tWin.popupWin.close();
	tWin.popupWin = window.open(pHref,'Popup',pProps);
	tWin.popupWin.focus();
}



function isEqualFile(whref,whost){
	if(whref.charAt(0)=="#"||whref.indexOf("javascript:")==0) return true;
	if((whost.indexOf(location.host)!=-1||whost==location.host)&&eObj.href.indexOf("#")!=-1){
		var tmp = location.href.substring(location.href.indexOf(location.host)+location.host.length);
		tmp=replaceStr(tmp,"_main","");
		tmp=replaceStr(tmp,"_top","");
		tmp=replaceStr(tmp,"_sad","");
		tmp = (tmp.indexOf("#")!=-1)?tmp.substring(0,tmp.lastIndexOf("#")):tmp;
		//&&whref.substring(location.protocol.length)==-1 hinzugekommen für IE im Fall von Port != 80
		whost = (whost.indexOf(":")!=-1&&whref.substring(location.protocol.length).indexOf(":")==-1)?whost.substring(0,whost.indexOf(":")):whost;
		var tmp2 = whref.substring(whref.indexOf(whost)+whost.length);
		tmp2=replaceStr(tmp2,"_main","");
		tmp2=replaceStr(tmp2,"_top","");
		tmp2=replaceStr(tmp2,"_sad","");
		tmp2 = tmp2.substring(0,tmp2.lastIndexOf("#"));
		return (tmp2==tmp)?true:false;
	}
	return false;
}

function replaceStr(sStr,str1,str2){
	var strParsed = "";
	var strToParse = sStr;
	var pos1 = 0;
	var pos2 = str1.length;
	while(strToParse.indexOf(str1)!=-1){
		var pos1 = strToParse.indexOf(str1);
		strParsed+=strToParse.substring(0,pos1)+str2;
		strToParse = strToParse.substring(pos1+pos2,strToParse.length);
	}
	return strParsed+strToParse;
}

function restoreFrameset(){
	if (arguments[0]!=null){
		var thisHash="";
		var thisURL = replaceStr(location.href,arguments[0],"");
		if(thisURL.indexOf("#")!=-1){
			thisHash = thisURL.substring(thisURL.lastIndexOf("#"));
			thisURL = thisURL.substring(0,thisURL.lastIndexOf("#"));
		}
		thisURL=(location.search!=null&&location.search!="")?replaceStr(thisURL,location.search,""):thisURL;
		var topURL = top.location.href;
		topURL = (topURL.indexOf("#")!=-1)?topURL.substring(0,topURL.lastIndexOf("#")):topURL;
		topURL=(top.location.search!=null&&top.location.search!="")?replaceStr(topURL,top.location.search,""):topURL;
		if(parent.frames.length==0||(thisURL!=topURL&&!isHome)){
			searchPage = getParam(location.href,"searchPage");
			if(searchPage!="")document.cookie = "searchPage=" + searchPage;
			top.location.replace(thisURL+thisHash);
		}
	}
}

function getParam(tUrl,param){
   var tParam = "";
   param+="=";
   if(tUrl.indexOf(param)!=-1){
      pos1 = tUrl.indexOf(param)+param.length;
      pos2 = pos1 + tUrl.substring(pos1).indexOf("&");
      pos2 = (pos2>pos1)?pos2:tUrl.length;
      tParam = tUrl.substring(pos1,pos2);
   }
   return tParam;
}

function execHash(){
	if(top.location.hash!=""&&top.location.hash!="#"){
		self.location.hash=(top.location.hash.charAt(0)=="#")?top.location.hash.substring(1):top.location.hash;
	}
}

function bookmark(wLocation,wTitle){
	if(navigator.userAgent.indexOf("MSIE")!=-1 && navigator.userAgent.indexOf("Mac")==-1){
		window.external.AddFavorite(wLocation,unescape(wTitle));
	}
	else{
		alert("Funktion wird von Ihrem Browser nicht unterstützt.");
	}
	return false;
}

function printPage(wHref,wWidth){
	var pProp=(wWidth==0)?popupProperties:popupPropertiesFull;
	//if (theDO2.length>3) wHref = theDO2 + "&xsl=../../.." + wHref.substring(0,wHref.lastIndexOf("?"));
	openPopup(wHref,pProp);
	return false;
}

function rollOverC(id,media){
    if(document.layers&&document.layers.length>0){
		document.layers[1].document.images[id].src=media;
    }
	if(document.all||document.getElementById){
		document.images[id].src=media;
	}
}

function iconLinkSuche(){
	if(window.SADDir!=null){
		self.location.href = "http://www."+sadWin.SAD.v_host+".gothaer.de/gothaer/"+replaceStr("../../de/allgemeines/interaktiv/suche/Suche_neu_sad.htm","../","")+"?sad="+window.SADDir;
	}else{
		top.location.href = "http://www.gothaer.de/de/allgemeines/interaktiv/suche/Suche_neu.htm";
	}
	return false;
}

function iconLinkFreund(){
	if(window.SADDir!=null){
		self.location.href = "https://webvisit.gothaer.de/recommendpage.nsf/Sendtofriends/Send-to-friend?open&foreignURL=http://www."+sadWin.SAD.v_host+".gothaer.de/gothaer/de/allgemeines/interaktiv/alle_services_neu/Seiteempfehlen_sad.htm&url=http://www."+sadWin.SAD.v_host+".gothaer.de/gothaer/de/ErrorPopup.htm" 
		"http://www."+sadWin.SAD.v_host+".gothaer.de/gothaer/"+replaceStr("../../de/allgemeines/interaktiv/suche/Suche_neu_sad.htm","../","")+"?sad="+window.SADDir;
	}else{
		self.location.href = "https://webvisit.gothaer.de/recommendpage.nsf/Sendtofriends/Send-to-friend?open&foreignURL=" + escape("http://www.gothaer.de/de/allgemeines/interaktiv/alle_services_neu/Seiteempfehlen_main.htm") + "&url=" + escape(replaceStr(location.href,"_main",""));
	}
	return false;
}

 
