//functions.js
function pf_createPopUpBox(child){
	var outerBox=document.createElement("div");
	outerBox.style.position="absolute";
	outerBox.style.padding="5px";
	outerBox.style.visibility="visible";
	outerBox.style.background="#BBBBBB";
	outerBox.style.width="auto";
	outerBox.style.height="auto";
	var innerBox=document.createElement("div");
	innerBox.style.padding="10px";
	innerBox.style.background="#F5F5f5";
	innerBox.style.border="1px";
	innerBox.borderstile="solidx";
	innerBox.style.bordercolor="#3C64A0";
	innerBox.appendChild(child);
	outerBox.appendChild(innerBox);
	return outerBox;
}
function pf_splitData(content) {
    var fields= new Array;
    var lines=content.split("\n");
    for (i=0; i<lines.length;i++){
        fields[i]=lines[i].split("\t");
    }
    return fields;
}
function pf_removePopUpBox(){
	document.body.removeChild(popUpBox);
}
function pf_createLink(txt,url){
	var ret= document.createElement("a");
	ret.setAttribute("href",url);
	ret.appendChild(document.createTextNode(txt));
	return ret;
}
function pf_getDataAsync(sourceURL,func_ToDo) {;
	try { 
		var requester = new XMLHttpRequest(); 
	} catch (error) { 
		var requester = new ActiveXObject("Microsoft.XMLHTTP");
	}	
	requester.onreadystatechange = function(){
		//try {
			if (requester.readyState == 4) {
				if (requester.status == 200) {
					func_ToDo(requester.responseText);
				} else {
				}
			} else {
			}
	}
	requester.open("GET", sourceURL, true);
	requester.send(null);
}
function pf_searchBox(){
	var div_searchBox = document.createElement("h4");
	  var div_search = document.createElement("div");
	    div_search.appendChild(document.createTextNode("Suche"));
	    var div_searchInput = document.createElement("input");
		div_searchInput.setAttribute("name","sucheInput");
		div_searchInput.setAttribute("type","text");
		div_searchInput.setAttribute("id","sucheInput");
		div_searchInput.setAttribute("onkeyup","pf_t_searchBandArray();");
	  div_search.appendChild(div_searchInput);
	    var div_list = document.createElement("div");
		div_list.setAttribute("id","listBox");
	  div_searchBox.appendChild(div_search);
	  div_searchBox.appendChild(div_list);
	return div_searchBox;
}
function pf_searchBoxList(){
	
}
function pf_browserCheck()
{
	if(document.ids)x='Netscape 4';
	else if( document.all && !document.getElementById )x='Internet Explorer 4';
	else if( window.opera && !document.createElement )x='Opera 5';
	else if( window.opera && window.getComputedStyle ){
	if(document.createRange)x='Opera 8';
				else if(window.navigate)x='Opera 7.5';
								 else x='Opera 7.2';                   
	}else if( window.opera && document.compatMode )x='Opera 7';
	else if( window.opera && document.releaseEvents )x='Opera 6';
	else if( document.contains && !window.opera )x='Konqueror 3';
	else if(window.pkcs11&&window.XML)x=window.external?'FireFox 2 / Gecko' : 'FireFox / Gecko Deer Park ';
	else if( window.getSelection && window.atob )x='Netscape 7';
	else if( window.getSelection && !document.compatMode )x='Netscape 6';
	else if( window.clipboardData && document.compatMode )
	  x=window.XMLHttpRequest? 'Internet Explorer 7' : 'Internet Explorer 6';
	else if( window.clipboardData ){
		x='Internet Explorer 5';
		 if( !document.createDocumentFragment ) x+='.5';
		 if( document.doctype && !window.print ) x+='Mozilla';
	}else if( document.getElementById && !document.all ) x='Opera 4';
	else if( document.images && !document.all ) x='Netscape 3';
	else if(document.clientWidth&&!window.RegExp)x='Konqueror 2';
	else x='Unbekannt';
	return x;
}
function pf_onlyFF(){
	if(window.pkcs11&&window.XML){
		return true;
	}else{
		return false;
	}
}
function pf_messagedelayWindow(){
	var waitWindow = document.body;
    waitWindow.appendChild(pf_delayMessage('Deine Nachricht wird versendet','den text sollte man aendern')); 
}
function pf_disabledelayWindow(){
	document.getElementById('warteMeldung').style.display='none';
}
function pf_delayMessage(sTitel,sText){
	var outterDiv = document.createElement('div');
	outterDiv.setAttribute('class','warteMeldung');
	outterDiv.setAttribute('id','warteMeldung');
	var innerDiv = document.createElement('div');
	innerDiv.setAttribute('class','textgr');
	var firstText = document.createElement('p');
	var waitImage = document.createElement('img');
	waitImage.setAttribute('src','http://static.partyfans.com/static/pics/layout/laden.gif');
	waitImage.setAttribute('alt','Load-Image');
	firstText.appendChild(waitImage);
	var secondText = document.createElement('p');
	var secondTextBold = document.createElement('b');
	secondTextBold.appendChild(document.createTextNode(sTitel));
	secondText.appendChild(secondTextBold);
	//var thirdText = document.createElement('p');
	//thirdText.appendChild(document.createTextNode(sText));
	innerDiv.appendChild(firstText);
	innerDiv.appendChild(secondText);
	//innerDiv.appendChild(thirdText);
	outterDiv.appendChild(innerDiv);
	return outterDiv;
}

function createContainerlist(posLeft,posTop){
	var oContainer=$("<div></div>");
	var oList=$("<ul></ul>");
	oContainer//.css("margin-top",oDistLink.attr("offsetHeight"))
		.css("position","absolute")
		.css("left",posLeft)
		.css("top",posTop)
		.css("display","none");
	if($.browser.msie && gOldIE){
		oContainer.css("width","200px");
	}
	oContainer.addClass("suggestList").addClass("text");
	oList.css("padding-left","2px").css("padding-right","2px").css("margin","0").css("position","static");
	oContainer.append(oList);
	

	oContainer.addItem=function(oLI,f){
			oLI.addClass("tStyleInactive")
			oLI.css("padding-top","3px");

			if(typeof f === "function"){
				oLI.css("cursor","pointer");
				
				oLI.click(function(){
					f();
					oContainer.slideUp("fast");
				});

				oLI.hover(function(){
					$(this).removeClass("tStyleInactive").addClass("tStyleActive");
				},function(){
					$(this).removeClass("tStyleActive").addClass("tStyleInactive");
				});
			}


			$(this).find("ul").append(oLI);
		};

	oContainer.removeItems=function(){
		$(this).find("ul").html("");
	}

	oContainer.setTitle=function(sTitle){
		//TODO: nur ein mal zulassen
			var oTitle=$("<p></p>");
			oTitle.css("margin","2px")
				.html(sTitle);
			$(this).prepend(oTitle);
		};


	oContainer.toggle=function(e){
		if ($(this).css("display")=="none"){
			$(this).slideDown("fast");
			e.stopPropagation();
		}else{
			$(this).slideUp("fast");
		}
	}

	$("body").click(function(){
		oContainer.slideUp("fast");
	});

	return oContainer;


}

function openSBWindow(iUserId){
	window.open('/community/details.php?detid='+iUserId,'','scrollbars=yes,width=640,height=450');
}
function openPfWindow(sURL){
	window.open(sURL,'','scrollbars=yes,width=640,height=450');
}

function changePage(sDest,oData,sLoadDiv){
		oData.noHead=1;
	$.get(sDest,oData,function() {return function(dat){
		$("#inhaltsDiv").html(dat);alert("test");
		/*if(sLoadDiv!=null) {
			//$("#".sLoadDiv).remove();
		}*/
	}}(sLoadDiv));
}

	function dynamicNickSort(iNickColumn){
		return function (a,b){
			if(a[iNickColumn]>b[iNickColumn]){
				return 1;
			}else if(a[iNickColumn]>b[iNickColumn]){
				return -1;
			} else {
				return 0;
			}
		}
	}

	function getUserId(oInput){ //gibt die id zu dem in ein inputfeld getippten nick zurueck, verwendet hierfuer das array aus auotcomplete.js
		var sNick=oInput.val();

		for(var i=0;i<flArray.length;i++){
			if(flArray[i][2]===sNick){
				return flArray[i][1];
			}
		}
		return null;

	}