
var activid;
var PrivatchatTon = false;

/*
var startscroller = false;
var scrollertext = "";

NS6=false;
IE4=(document.all);
if (!IE4) {NS6=(document.getElementById);}
NS4=(document.layers);
var isMac = (navigator.userAgent.indexOf("Mac") != -1);
var olOp = (navigator.userAgent.toLowerCase().indexOf('opera') > -1 && document.createTextNode);  // Opera 7
var olNs4 = (navigator.appName=='Netscape' && parseInt(navigator.appVersion) == 4);
var olNs6 = (document.getElementById) ? true : false;
var olKq = (olNs6 && /konqueror/i.test(navigator.userAgent));
var olIe4 = (document.all) ? true : false;
var olIe5 = false; 
var olIe55 = false;
var ie=typeof document.all=='object';
var dom=document.getElementById;
var docRoot = 'document.body';
*/

var timesaygoodbye ="";


function PrintChatTeaser(usrid,usrlogin,code,bild)
{
	URL = "/happy/user_privatchat/"+usrid+"?client=1&popup=1";

	ChatTeaser = true;

	annehmen = 'javascript:openPopup(\''+URL+'\',\'Chat\',\'600\',\'500\'); hide(document.getElementById(\'PrivatChatmsg\')); ';
	ablehen 	= 'javascript:hide(document.getElementById(\'PrivatChatmsg\'),\''+usrid+'\',\''+code+'\',\'Leider wurde Deine Chatanfrage abgelehnt\');cleartime();';

	if(PrivatchatTon == true)
	{	
		ton =  '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="1" height="1" id="getMp3" align="middle">';
		ton += '<param name="allowScriptAccess" value="sameDomain" />';
		ton += '<param name="movie" value="/inc/swf/getmp3.swf?file=/inc/swf/sound1.mp3" />';
		ton += '<param name="quality" value="high" />';
	 	ton += '<embed src="/inc/swf/getmp3.swf?file=/inc/swf/sound1.mp3" quality="high" width="1" height="1" name="getMp3" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
		ton += '</object>';
	}
	else
	{
		ton = '';
	}


	var info =  '<div style="width:260px; height:120px; background-color:#000; padding:5px;"><div style="float:left;background-color:#FFF; padding:3px 3px 7px 3px;"><img src="'+bild+'"></div>';
		info += '<div style="margin-left: 4px; float:left; color:#FFF;">';
		info +='<b>'+usrlogin+'</b> will mit dir chatten!';
		info += '<div style="margin:15px 0 6px 0;"><a href="'+annehmen+'"><img src="/images/default/chatbtn.annehmen.jpg" border="0"></a></div>';
		info += '<div><a href="'+ablehen+'"><img src="/images/default/chatbtn.ablehnen.jpg" border="0"></a></div>';
		info += '</div></div>'+ton;

	Nachricht(info);
	

	time = "hide(parent.document.getElementById('chathinweis'),'"+usrid+"','"+code+"','Leider ist der User nicht vorm Rechner +++')";
	timesaygoodbye = setTimeout("eval(time)",60000);

}

function Nachricht(anfrage)
{ 	

	obj = document.getElementById('PrivatChatmsg');
	obj.innerHTML = anfrage;

	showme();
}

function showme() 
{	
	myobj = document.getElementById('PrivatChatmsg');
	myobj.style.visibility = "visible";
}


function hideme() 
{	
	myobj = document.getElementById('PrivatChatmsg');
	myobj.style.visibility = "hidden";
	ChatTeaser = false;			
}


function hideok(obj)
{		
	ChatTeaser = false;	
	myobj = document.getElementById('PrivatChatmsg');
	myobj.style.visibility = "hidden";
	clearTimeout(timesaygoodbye);		
}


function hide(obj,usr_id_empf , chatcode , text)
{		
		ChatTeaser = false;
		myobj = document.getElementById('PrivatChatmsg');
		myobj.style.visibility = "hidden";
		SendChatMsg(text , usr_id_empf , chatcode)
		clearTimeout(timesaygoodbye);
}


function cleartime()
{	
	clearTimeout(timesaygoodbye);
}


function openPopup(theURL,winName,winX,winY) 
{		
	posX=(screen.width/2)-(winX/2);
	posY=(screen.height/2)-(winY/2)-30;
	
	if (posY < 0)
	{
		posY = 0;
	}
	
	winFeatures='width='+winX+', height='+winY+',innerHeight=580,innerWidth=0, left='+posX+', screenX='+posX+', top='+posY+', screenY='+posY+', toolbar=0, location=0, directories=0, status=0, menuBar=0, resizable=0, scrollbars=yes';
	win = window.open(theURL,winName,winFeatures);
	win.focus();
}


function Info(anfrage)
{ 	
	obj = document.getElementById('Userinfo');	
	obj.innerHTML = anfrage;
}


function InfoAusgabe(obj,ausgabe)
{
 	obj = document.getElementById(obj);	
 
	if(isObject(obj))
	{
 		obj.innerHTML = ausgabe;
	}
}


function pause(millisecondi)
{
	var now = new Date();
	var exitTime = now.getTime() + millisecondi;
	while(true)
	{
        	now = new Date();
        	if(now.getTime() > exitTime) return;
	}
}


function isObject(a) 
{
	return (typeof a == 'object' && !!a) || isFunction(a);
}


function postcolor(color,obj)
{	
	insert('[color:'+color+']', '[/color]');
}
 
function addSmilie(text)
{
	insert(text,'');
}


function postcode(tag,obj)
{
	switch(tag)
	{
	case "b":
		insert('[b]', '[/b]');
		break;
	case "i":
		insert('[i]', '[/i]');
		break;
	case "u":
		insert('[u]', '[/u]');
		break;
	case "center":
		insert('[center]', '[/center]');
		break;
	case "quote":
		insert('[quote]', '[/quote]');
		break;
	}
}























/*************


function Datenuebertragen(objForm)
{
	obj = document.getElementById('overDiv');

	define();

	obj.style.background = "#FFFFFF";
	obj.style.backgroundImage = 'url(/images/default/loading.gif)';
	obj.style.left = floatX;
	obj.style.top =  floatY;
	obj.style.width 	= 218+"px";
	obj.style.height  = 71+"px";
	obj.style.border = "";
	obj.style.padding  = 0;
 
	showObject(obj);

	if(ie && !olOp)zeigVersteckIframe(obj);

 	adjust2(); 
  
	for (var i = 0; i < objForm.length; ++i)
	{
		if(objForm.elements[i].type == "submit" && objForm.elements[i].type == "image")
		{
			objForm.elements[i].disabled = true;
		}

	}
}


function DatenuebertragenPayment(objForm)
{
 	
obj = document.getElementById('overDiv');

define();

obj.style.background = "#FFFFFF";
obj.style.backgroundImage = 'url(/images/default/PaymentLoading.gif)';
obj.style.left = floatX;
obj.style.top =  floatY;
obj.style.width 	= 218+"px";
obj.style.height  = 71+"px";
obj.style.border = "";
obj.style.padding  = 0;

showObject(obj);

if(ie && !olOp)zeigVersteckIframe(obj);

adjust2(); 

 for (var i = 0; i < objForm.length; ++i) {
  
	  if(objForm.elements[i].type == "submit" && objForm.elements[i].type == "image"){
	
	  		objForm.elements[i].disabled = true;
	
		}
  
	}
 
}


function checkLoginAGB(dummy)
{
	if(dummy.checked!=true){
		alert('Du musst Die Agb akzeptieren.');
		return false;
	}
}


function adjust() 
{
	if ((NS4) || (NS6)) {
	if (lastX==-1 || delayspeed==0)
	{
		lastX=window.pageXOffset + floatX;
		lastY=window.pageYOffset + floatY;
	}
	else
	{
		var dx=Math.abs(window.pageXOffset+floatX-lastX);
	var dy=Math.abs(window.pageYOffset+floatY-lastY);
	var d=Math.sqrt(dx*dx+dy*dy);
	var c=Math.round(d/10);
	if (window.pageXOffset+floatX>lastX) {lastX=lastX+delayspeed+c;}
	if (window.pageXOffset+floatX<lastX) {lastX=lastX-delayspeed-c;}
	if (window.pageYOffset+floatY>lastY) {lastY=lastY+delayspeed+c;}
	if (window.pageYOffset+floatY<lastY) {lastY=lastY-delayspeed-c;}
	}
	if (NS4){
		document.layers['PrivatChatmsg'].pageX = lastX;
		document.layers['PrivatChatmsg'].pageY = lastY;
	}
	if (NS6){
		document.getElementById('PrivatChatmsg').style.left=lastX;
		document.getElementById('PrivatChatmsg').style.top=lastY;
	}
	}
	else if (IE4)
	{
		if (lastX==-1 || delayspeed==0)
{
	lastX=document.body.scrollLeft + floatX;
	lastY=document.body.scrollTop + floatY;
}
else
{
	var dx=Math.abs(document.body.scrollLeft+floatX-lastX);
	var dy=Math.abs(document.body.scrollTop+floatY-lastY);
	var d=Math.sqrt(dx*dx+dy*dy);
	var c=Math.round(d/10);
	if (document.body.scrollLeft+floatX>lastX) {lastX=lastX+delayspeed+c;}
	if (document.body.scrollLeft+floatX<lastX) {lastX=lastX-delayspeed-c;}
	if (document.body.scrollTop+floatY>lastY) {lastY=lastY+delayspeed+c;}
	if (document.body.scrollTop+floatY<lastY) {lastY=lastY-delayspeed-c;}
	}
	document.all['PrivatChatmsg'].style.posLeft = lastX;
	document.all['PrivatChatmsg'].style.posTop = lastY;
	document.getElementById('killSelect').style.posLeft = lastX;
	document.getElementById('killSelect').style.posTop = lastY;
	} 
	setTimeout('adjust()',50);
}






function adjust2() 
{
	if ((NS4) || (NS6)) {
	if (lastX==-1 || delayspeed==0)
	{
		lastX=window.pageXOffset + floatX;
		lastY=window.pageYOffset + floatY;
	}
	else
	{
		var dx=Math.abs(window.pageXOffset+floatX-lastX);
		var dy=Math.abs(window.pageYOffset+floatY-lastY);
		var d=Math.sqrt(dx*dx+dy*dy);
		var c=Math.round(d/10);
		
		if (window.pageXOffset+floatX>lastX) {lastX=lastX+delayspeed+c;}
		if (window.pageXOffset+floatX<lastX) {lastX=lastX-delayspeed-c;}
		if (window.pageYOffset+floatY>lastY) {lastY=lastY+delayspeed+c;}
		if (window.pageYOffset+floatY<lastY) {lastY=lastY-delayspeed-c;}
	}
if (NS4)
{
	document.layers['overDiv'].pageX = lastX;
	document.layers['overDiv'].pageY = lastY;
}
if (NS6)
{
	document.getElementById('overDiv').style.left=lastX;
	document.getElementById('overDiv').style.top=lastY;
}
}
else if (IE4){

if (lastX==-1 || delayspeed==0)
{
	lastX=document.body.scrollLeft + floatX;
	lastY=document.body.scrollTop + floatY;
}
else
{
	var dx=Math.abs(document.body.scrollLeft+floatX-lastX);
	var dy=Math.abs(document.body.scrollTop+floatY-lastY);
	var d=Math.sqrt(dx*dx+dy*dy);
	var c=Math.round(d/10);
if (document.body.scrollLeft+floatX>lastX) {lastX=lastX+delayspeed+c;}
if (document.body.scrollLeft+floatX<lastX) {lastX=lastX-delayspeed-c;}
if (document.body.scrollTop+floatY>lastY) {lastY=lastY+delayspeed+c;}
if (document.body.scrollTop+floatY<lastY) {lastY=lastY-delayspeed-c;}
}
document.all['overDiv'].style.posLeft = lastX;
document.all['overDiv'].style.posTop = lastY;
document.getElementById('killSelect').style.posLeft = lastX;
document.getElementById('killSelect').style.posTop = lastY;

} 
setTimeout('adjust2()',50);
}




function openpayment(URL) 
{
	winX=500;
	winY=580;
	posX=(screen.width/2)-(winX/2);
	posY=(screen.height/2)-(winY/2)-30;
	
	if (posY < 0)
	{
		posY = 0;
	}
	
	winFeatures='width='+winX+', height='+winY+',innerHeight='+winY+',innerWidth='+winX+', left='+posX+', screenX='+posX+', top='+posY+', screenY='+posY+', toolbar=0, location=0, directories=0, status=0, menuBar=0, scrollBars=0, resizable=0';
	win = window.open(URL,'Payment',winFeatures);
	win.focus();
}




function high(LinkName,color)
{ 
	document.getElementById(LinkName).style.background=color;
	document.getElementById(LinkName).style.cursor='pointer';
}
	
function low(LinkName,color)
{ 
	document.getElementById(LinkName).style.background=color; 
}

function storeCaret(textEl)
{
	if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}

function checkcount(o1,o2,o3,o4)
{
	CountTextarea(o1,'lcount',300);
	CountTextarea(o2,'vcount',300);
	CountTextarea(o3,'acount',300);
	CountTextarea(o4,'fcount',300);
}




function checkCheckBox(obj2,dummy, text)
{
	eval("obj = document.getElementById('"+dummy+"');");
	
	if(obj.checked!=true)
	{
		alert(text);
		return false;
	}
	
	Datenuebertragen(obj2)
	return true;
}

function CheckAgb(obj2,dummy, text)
{
	 eval("obj = document.getElementById('"+dummy+"');");

	if(obj.checked!=true){
		alert(text);
		return false;
	}

	DatenuebertragenPayment(obj2)
	return true;
}



function forumsuche(){
	
	sendurl = "User_ForumSuch_Ergebnis?noframe=1&";
		
		
		
		if(document.forms[0].suchtyp[0].checked == true){
		  
		  if(document.forms[0].Bdate.value != ""){
		 	datecheck = checkDate(document.forms[0].Bdate.value)
		 
		  }else{
		  datecheck = true;
		  }
		  
		 }else if(document.forms[0].suchtyp[1].checked == true){
		  
		  if(document.forms[0].Tdate.value != ""){
		 	datecheck = checkDate(document.forms[0].Tdate.value)
		  }else{
		  datecheck = true;
		  }
		}
		
		if(datecheck == true){
		
				for (i=0;i< document.forms[0].length;i++){
				
				if(document.forms[0].elements[i].type != "button"){
				
				if(document.forms[0].elements[i].type == "radio"){
					
					if(document.forms[0].elements[i].checked == true){
					
					sendurl += document.forms[0].elements[i].name+"="+document.forms[0].elements[i].value;
					
					}
					
					if(i < (document.forms[0].length-2)){sendurl += "&";}
				
				}else{
				sendurl += document.forms[0].elements[i].name+"="+document.forms[0].elements[i].value;
				}
			
			if(i < (document.forms[0].length-2)){sendurl += "&";}
			
			 }
		}
		
		parent.treads.location.href=sendurl
		
		}else{
		alert('Das angegebene Datums Format ist Falsch bitte ändern (Beispiel:01.03.2004)');
		}
}
********************* */

function checkDate(string)
{
    if(!string) return null;
    string += '';

    string = string.replace(/[^0-9^\.]/g, '');

    var split = string.split(".");
    var day = parseInt(split[0], 10);
    var month = parseInt(split[1] || 0, 10);
    var year = parseInt(split[2] || 0, 10);

    if(isNaN(year)) year = getFullYear();;

    var check = new Date(year, month - 1, day);
    var day2 = check.getDate();
    var year2 = getFullYear(check);
    var month2 = check.getMonth() + 1;

    if ( year2 == year && month == month2 && day == day2 ) return true;
    return false;
}


function getFullYear(date)
{
    if(!date) date = new Date();
    if(typeof date.getFullYear != 'undefined') return date.getFullYear();
    var year = date.getYear();
    if(year < 1000) year += 2000;
    return year;
}







function findePos(el,r)
{
	var pos=0;
	if(el.offsetParent)
	{
		while(el.offsetParent)
		{
			pos+=r?el.offsetTop:el.offsetLeft;
			el=el.offsetParent;
		}
	}
	else if(el.y)pos+=r?el.y:el.x;
return pos;
}





function insert(aTag, eTag) {
  var input = document.forms['posting'].elements['text'];
  input.focus();
  /* für Internet Explorer */
  if(typeof document.selection != 'undefined') {
    /* Einfügen des Formatierungscodes */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = aTag + insText + eTag;
    /* Anpassen der Cursorposition */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -eTag.length);
    } else {
      range.moveStart('character', aTag.length + insText.length + eTag.length);      
    }
    range.select();
  }
  /* für neuere auf Gecko basierende Browser */
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Einfügen des Formatierungscodes */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
    /* Anpassen der Cursorposition */
    var pos;
    if (insText.length == 0) {
      pos = start + aTag.length;
    } else {
      pos = start + aTag.length + insText.length + eTag.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* für die übrigen Browser */
  else
  {
    /* Abfrage der Einfügeposition */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Einfügen des Formatierungscodes */
    var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
    input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
  }
}





