// JavaScript Document
function getDCode(p_caller){
	var res="";
	var html;
	//get HTML
	for(var i=0;i<document.childNodes.length;i++){
		if(document.childNodes[i].tagName){
			if(document.childNodes[i].tagName.toLowerCase()=="html"){
				html=document.childNodes[i];
			}else{
				res=res+getTagV(document.childNodes[i]);
			}
		}
	}
	res=res+"<html>";
	for(var i=0;i<html.childNodes.length;i++){
		if(html.childNodes[i].tagName){
			res=res+getTagV(html.childNodes[i]);	
		}
	}
	res=res+"</html>";
	if(p_caller!=null){
		p_caller.getDCodeFinished(res);
	}
}
function getTagV(p_obj){
	var res="";
	var setbr=false;
	if(p_obj.tagName!=null){
		if(p_obj.tagName.toLowerCase()=="!"){
			res="<!--"+p_obj.nodeValue+"-->";
		}else if(p_obj.tagName.toLowerCase()=="br"){
			res="<br>";
		}else if(p_obj.tagName.toLowerCase()=="body"){
			setbr=true;
			res="<body";
			res=res+getUAttV(p_obj);
			for(var i=0;i<p_obj.attributes.length;i++){	
				if(p_obj.attributes[i].nodeName.toLowerCase()=="onload"){
					res=res+" onLoad=\"ie()\"";
				}else{
					res=res+getAttV(p_obj,p_obj.attributes[i]);
				}
			}
			res=res+">";
			var i=0;
			if(p_obj.childNodes[0].tagName){
				if((p_obj.childNodes[0].tagName.toLowerCase()=="img")&&(p_obj.childNodes[0].id=="bg")){
					i++;
					if((res.lastIndexOf("background-image:")>-1)&&(res.lastIndexOf("background-image:")>res.indexOf("<body"))){
						var tmp;
						if(isIE()){
							tmp="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='";
							if(p_obj.style.filter.indexOf(tmp)>-1){
								tmp=p_obj.style.filter.substring(p_obj.style.filter.indexOf(tmp)+tmp.length);
								for(var i=0;i<tmp.length;i++){
									if(tmp.substr(i,1)=="'"){
										tmp=tmp.substring(0,i);
										break;
									}
								}
							}
							else{
								tmp=p_obj.childNodes[0].src;
							}
						}else{
							tmp=p_obj.childNodes[0].src;
						}
						res=res.substring(0,res.lastIndexOf("background-image:"))+"background-image:url('"+rlPh(tmp)+"')"+res.substring(res.lastIndexOf("background-image:")+17+p_obj.style.backgroundImage.length);
					}
				}
			}
			for(i;i<p_obj.childNodes.length;i++){				
				res=res+getTagV(p_obj.childNodes[i]);
			}
			res=res+"<\/body>";
			setbr=false;
		}else if(p_obj.tagName.toLowerCase()=="head"){
			res="<head>";
			for(var i=0;i<p_obj.childNodes.length;i++){
				res=res+getTagV(p_obj.childNodes[i]);
			}
			res=res+"<\/head>";
		}else if(p_obj.tagName.toLowerCase()=="script"){
			res="<script";
			for(var i=0;i<p_obj.attributes.length;i++){				
				res=res+getAttV(p_obj,p_obj.attributes[i]);
			}
			res=res+"><\/script>";
		}else if(p_obj.tagName.toLowerCase()=="tbody"){
			for(var i=0;i<p_obj.childNodes.length;i++){
				res=res+getTagV(p_obj.childNodes[i]);
			}
		}else if(p_obj.tagName.toLowerCase()=="title"){
			res="<title>"+addHTxt(document.title,null)+"<\/title>";
		}else if(isTagOf(p_obj.tagName,new Array("img","input","link","meta"))){
			// if navi img
			if(p_obj.tagName.toLowerCase()=="img"){
				if(isIE()){
					var tmp="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='";
					if(p_obj.style.filter.indexOf(tmp)>-1){
						tmp=p_obj.style.filter.substring(p_obj.style.filter.indexOf(tmp)+tmp.length);
						for(var i=0;i<tmp.length;i++){
							if(tmp.substr(i,1)=="'"){
								tmp=tmp.substring(0,i);
								break;
							}
						}
						if(tmp.indexOf("local/nv/")>-1){
							return res;
						}
					}
				}else{
					if(p_obj.src.indexOf("local/nv/")>-1){
						return res;	
					}
				}
			}
			res="<"+p_obj.tagName.toLowerCase();
			res=res+getUAttV(p_obj);
			for(var i=0;i<p_obj.attributes.length;i++){				
				res=res+getAttV(p_obj,p_obj.attributes[i]);
			}
			res=res+"\/>";
		}else if(isTagOf(p_obj.tagName,new Array("a","div","form","table","td","textarea","tr"))){
			res="<"+p_obj.tagName.toLowerCase();
			res=res+getUAttV(p_obj);
			for(var i=0;i<p_obj.attributes.length;i++){
				if(p_obj.tagName.toLowerCase()=="a"){
					if(p_obj.attributes[i].nodeName.toLowerCase()=="href"){
						if(p_obj.getAttribute(p_obj.attributes[i].nodeName).indexOf("nIF('")>-1){
							var tmp=p_obj.getAttribute(p_obj.attributes[i].nodeName).substring(p_obj.getAttribute(p_obj.attributes[i].nodeName).indexOf("nIF('")+5);																											   						res=res+" href=\""+tmp.substring(0,tmp.indexOf("'"))+"\" target=\"_blank\"";
						}else{
							res=res+getAttV(p_obj,p_obj.attributes[i]);
						}
					}else{
						res=res+getAttV(p_obj,p_obj.attributes[i]);
					}
				}else if(p_obj.tagName.toLowerCase()=="form"){
					if(p_obj.attributes[i].nodeName.toLowerCase()=="onsubmit"){
						res=res+" onSubmit=\"return false\"";
					}else{
						res=res+getAttV(p_obj,p_obj.attributes[i]);
					}
				}else{
					res=res+getAttV(p_obj,p_obj.attributes[i]);
				}
			}
			res=res+">";
			for(var i=0;i<p_obj.childNodes.length;i++){
				res=res+getTagV(p_obj.childNodes[i]);
			}
			res=res+"<\/"+p_obj.tagName.toLowerCase()+">";
		}
	}else if(p_obj.nodeType==3){
		res=addHTxt(p_obj.nodeValue,setbr,null);	
	}else if(p_obj.nodeType==8){
		res="<!--"+p_obj.nodeValue+"-->";
	}
	return res;
}
function getUAttV(p_obj){
	var res="";
	if((p_obj.className!=null)&&(p_obj.className!="")){
		res=" class=\""+p_obj.className+"\"";
	}
	if(p_obj.style){
		res=res+" style=\"";
		var indx=bc_isAllObj(p_obj);
		if(indx>-1){
			for(var i=0;i<bc_allobjs[indx][1].length;i++){
				if(bc_allobjs[indx][1][i][3]==true){
					if(bc_allobjs[indx][1][i][2]!=null){
						res=res+String(bc_allobjs[indx][1][i][0])+":"+String(bc_allobjs[indx][1][i][1])+String(bc_allobjs[indx][1][i][2])+";";
					}else{
						res=res+String(bc_allobjs[indx][1][i][0])+":"+String(bc_allobjs[indx][1][i][1])+";";
					}
				}
			}
		}
		if(res.substr(res.length-8,8)==" style=\""){
			res=res.substring(0,res.indexOf(" style=\""));
		}else{
			res=res+"\"";
		}
	}
	return res;
}
function getAttV(p_obj,p_attr){
	var res="";
	if((p_obj.getAttribute(p_attr.nodeName)!=null)&&(p_obj.getAttribute(p_attr.nodeName)!="")){
		if(p_attr.nodeName.toLowerCase()=="alt"){
			res=" alt=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="border"){
			res=" border=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="cols"){
			res=" cols=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="colspan"){
			res=" colspan=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="content"){
			res=" content=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="id"){
			res=" id=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="href"){			
			res=" href=\""+rlPh(p_obj.getAttribute(p_attr.nodeName))+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="http-equiv"){
			res=" http-equiv=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="language"){
			res=" language=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="name"){
			res=" name=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="rel"){
			res=" rel=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="rows"){
			res=" rows=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="rowspan"){
			res=" rowspan=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="src"){
			if(isIE()){
				var tmp="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='";
				if(p_obj.style.filter.indexOf(tmp)>-1){
					tmp=p_obj.style.filter.substring(p_obj.style.filter.indexOf(tmp)+tmp.length);
					for(var i=0;i<tmp.length;i++){
						if(tmp.substr(i,1)=="'"){
							tmp=tmp.substring(0,i);
							break;
						}
					}
					res=" src=\""+rlPh(tmp)+"\"";
				}
				else{
					res=" src=\""+rlPh(p_obj.getAttribute(p_attr.nodeName))+"\"";
				}
			}else{
				res=" src=\""+rlPh(p_obj.getAttribute(p_attr.nodeName))+"\"";
			}
		}else if(p_attr.nodeName.toLowerCase()=="tabindex"){
			res=" tabindex=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="target"){
			res=" target=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="title"){
			res=" title=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="type"){
			res=" type=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else if(p_attr.nodeName.toLowerCase()=="value"){
			res=" value=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}else{
			//res=" "+p_attr.nodeName.toLowerCase()+"=\""+p_obj.getAttribute(p_attr.nodeName)+"\"";
		}
	}
	return res;
}
function isTagOf(p_tag,p_tags){
	for(var i=0;i<p_tags.length;i++){
		if(p_tag.toLowerCase()==String(p_tags[i]).toLowerCase()){
			return true;	
		}
	}
	return false;
}
function sendPHP(p_data,p_script,p_caller){
	var rqst = null;
	try{
		rqst = new XMLHttpRequest();
	}
	catch (e){
		try{
			rqst = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e){
			try{
				rqst = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e){
				rqst = null;
			}
		}  
	}
	if (rqst == null){
		 //nothing
	} 
	rqst.open("POST", rtPh()+"scripts/php/"+p_script, true);
	rqst.onreadystatechange = function(){
		switch(rqst.readyState) {
			case 4:
			if(rqst.status!=200) {
				alert("Ein Fehler:"+rqst.status);
			}else{ 
				if(p_caller!=null){
					p_caller.phpSended(rqst);	
				}
			}
			break;
	
			default:
				return false;
			break;     
		}
	};
	rqst.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	rqst.send(p_data);
}
function rtPh(){
	if(location.pathname.indexOf("/local/")>-1){
		var tmpurl=cPh();
		tmpurl=tmpurl.substring(tmpurl.lastIndexOf("/local/"));
		var reslt="";
		for(var i=1;i<tmpurl.length;i++){
			if(tmpurl.substr(i,1)=="/"){
				reslt=reslt+"../";
			}
		}
		return reslt;
	}else if(location.pathname.indexOf("\\local\\")>-1){
		var tmpurl=cPh();
		tmpurl=tmpurl.substring(tmpurl.lastIndexOf("\\local\\"));
		var reslt="";
		for(var i=1;i<tmpurl.length;i++){
			if((tmpurl.substr(i,1)=="\\")||(tmpurl.substr(i,1)=="/")){
				reslt=reslt+"../";
			}
		}
		return reslt;
	}
	return "";
}
function cPh(){
	var url=parseFilSp(document.URL);
	for(var i=url.length;i>0;i--){
		if(url.substr(i,1)=="/"){
			return url.substring(0,i)+"/";	
		}
	}
	return "";
}
function remProt(p_url){
	return p_url;
}
function rlPh(p_url){
	if(p_url==null){
		if(parseFilSp(location.pathname).lastIndexOf("/local/")>-1){
			return remProt(parseFilSp(location.pathname).substring(parseFilSp(location.pathname).lastIndexOf("/local/")));
		}else{
			return remProt(parseFilSp(location.pathname));	
		}
	}else{
		p_url=parseFilSp(p_url);
		if(p_url.substring(0,3)=="../"){
			return p_url;
		}else if(p_url.substring(p_url.length-1)=="#"){
			return "#";	
		}else if(parseFilSp(location.pathname).lastIndexOf("/local/")>-1){
			var local=parseFilSp(location.pathname).substring(parseFilSp(location.pathname).lastIndexOf("/local/"));
			if(p_url.lastIndexOf("/local/")>-1){
				p_url=p_url.substring(p_url.lastIndexOf("/local/"));
				if(p_url==local){
					return getFName(p_url);
				}
				var fldr=p_url.substr(0,1);
				var indx=0;
				for(var i=1;i<p_url.length;i++){
					if(p_url.substr(i,1)=="/"){
						fldr=fldr+p_url.substr(i,1);
						if(fldr!=local.substr(i-fldr.length+1,fldr.length)){
							local=local.substring(indx);
							p_url=p_url.substring(indx+1);
							break;
						}else{
							fldr="/";
							indx=i;
						}
					}else{
						fldr=fldr+p_url.substr(i,1);
					}
				}
				for(var i=0;i<local.length;i++){
					if((local.substr(i,1)=="/")&&(i!=local.lastIndexOf("/"))){
						p_url="../"+p_url;
					}else{
						return p_url;	
					}
				}
			}else{
				if(getFName(p_url).indexOf("index")>-1){
					p_url=getFName(p_url);
					for(var i=0;i<local.length;i++){
						if((local.substr(i,1)=="/")&&(i!=local.lastIndexOf("/"))){
							p_url="../"+p_url;
						}
					}
					return p_url
				}else{
					return p_url;
				}
			}
		}else{
			return remProt(p_url);
		}
	}
}
function getFName(p_url){
	for(var i=p_url.length;i>0;i--){
		if((p_url.substr(i,1)=="/")||(p_url.substr(i,1)=="\\")){
			return p_url.substring(i+1);	
		}
	}
	return p_url;
}
function parseFilSp(p_url){
	for(var i=0;i<p_url.length;i++){
		if(p_url.substr(i,1)=="\\"){
			p_url=p_url.substring(0,i)+"/"+p_url.substring(i+1);	
		}
	}
	return p_url;
}
function parseToPHP(p_string){
	for(var i=0;i<p_string.length;i++){
		if(p_string.substr(i,1)=="&"){
			p_string=p_string.substring(0,i)+"#nd#"+p_string.substring(i+1);
		}else if(p_string.substr(i,1)=="+"){
			p_string=p_string.substring(0,i)+"#pl#"+p_string.substring(i+1);
		}
	}
	return p_string;
}
function addHTxt(p_string,p_setbr,p_cont){	
	var res="";
	for(var i=0;i<p_string.length;i++){
		if(p_string.substr(i,1)=="\n"){
			if(p_setbr==true){
				if(p_cont!=null){	
					p_cont.appendChild(document.createTextNode(res));
					res="";
					p_cont.appendChild(document.createElement("br"));
				}else{
					res=res+"<br>";
				}
			}else{
				//nothing	
			}
		}else if(p_string.substr(i,1)=="\r"){
			//nothing
		}else{
			if(p_cont!=null){
				res=res+p_string.substr(i,1);
			}else{
				if(p_string.substr(i,1)==" "){
					res=res+"&nbsp;";
				}else if(p_string.substr(i,1)=="<"){
					res=res+"&lt;";
				}else if(p_string.substr(i,1)==">"){
					res=res+"&gt;";
				}else if(p_string.substr(i,1)=="&"){
					res=res+"&amp;";
				}else if(p_string.substr(i,1)=="\""){
					res=res+"&quot;";
				}else if(p_string.substr(i,1)=="\\"){
					res=res+"&frasl;";
				}else if(p_string.substr(i,1)=="ä"){
					res=res+"&auml;";
				}else if(p_string.substr(i,1)=="Ä"){
					res=res+"&Auml;";
				}else if(p_string.substr(i,1)=="ö"){
					res=res+"&ouml;";
				}else if(p_string.substr(i,1)=="Ö"){
					res=res+"&Ouml;";
				}else if(p_string.substr(i,1)=="ü"){
					res=res+"&uuml;";
				}else if(p_string.substr(i,1)=="Ü"){
					res=res+"&Uuml;";
				}else if(p_string.substr(i,1)=="ß"){
					res=res+"&szlig;";
				}else if(p_string.substr(i,1)=="€"){
					res=res+"&euro;";
				}else{
					res=res+p_string.substr(i,1);
				}
			}
		}
	}
	if(p_cont!=null){
		p_cont.appendChild(document.createTextNode(res));
	}else{
		return res;	
	}
}