///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Trierische Media Verkaufsgesellschaft mbH //////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tipp eintragen /////////////////////////////////////////////////////////////////////////////////////////////
function insertUserTipp(sid,uid) {

var spielid = sid;
var userid = uid;
var tipp_heim = $('tipp_heim_'+sid).value;
var tipp_gast = $('tipp_gast_'+sid).value;
var mid = $('mid_'+sid).value;
var gid = $('gid_'+sid).value;
var spieltag = $('spieltag_'+sid).value;

	if(tipp_heim != '' && tipp_gast != '' ) {

		if ( !isNaN(tipp_heim) && !isNaN(tipp_gast) ) { // ist eine Zahl
		
		ivwtag('tippspiel'); 
		
		//URL
		var url = '_incl/UsertippUpdate.php';
		// Parameter
		var pars = 'sid='+spielid+'&mid='+mid+'&gid='+gid+'&spieltag='+spieltag+'&uid='+userid+'&tipp_heim='+tipp_heim+'&tipp_gast='+tipp_gast;
		
		var myAjax = new Ajax.Updater(
			'AjaxUpdater',
			url, {
				method: 'post',
				parameters: pars		
			});

			$('button_'+sid).style.display = 'none';
			$('tipp_heim_'+sid).style.display = 'none';
			$('tipp_gast_'+sid).style.display = 'none';
			$('utipp_heim_'+sid).innerHTML = tipp_heim;
			$('utipp_gast_'+sid).innerHTML = tipp_gast;
			$('utipp_heim_'+sid).style.display = 'block';
			$('utipp_gast_'+sid).style.display = 'block';
			$('button_aendern_'+sid).style.display = 'block';
			
		}
	}
	
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tipp updaten ///////////////////////////////////////////////////////////////////////////////////////////////
function updateUserTipp(sid,uid) {
	$('button_'+sid).style.display = '';
	$('tipp_heim_'+sid).style.display = '';
	$('tipp_gast_'+sid).style.display = '';
	$('utipp_heim_'+sid).style.display = 'none';
	$('utipp_gast_'+sid).style.display = 'none';
	$('button_aendern_'+sid).style.display = 'none';
	ivwtag('tippspiel');
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Usertipp überprüfen ////////////////////////////////////////////////////////////////////////////////////////
function checkedUserTipp(sid,uid) {

	var spielid = sid;
	var userid = uid;
	if($('button_'+sid)) {
		$('button_'+sid).style.display = 'none';
	}
	if($('tipp_heim_'+sid)) {
		$('tipp_heim_'+sid).style.display = 'none';
	}
	if($('tipp_gast_'+sid)) {
		$('tipp_gast_'+sid).style.display = 'none';
	}
	if($('utipp_heim_'+sid)) {
		$('utipp_heim_'+sid).style.display = 'block';
	}
	if($('utipp_gast_'+sid)) {
		$('utipp_gast_'+sid).style.display = 'block';
	}
	if($('button_aendern_'+sid)) {
		$('button_aendern_'+sid).style.display = 'block';
	}

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IVW TAG PER JAVASCRIPT AUFRUFEN ////////////////////////////////////////////////////////////////////////////
function ivwtag(val) {
	var ivwbereich = "interaktiv/" + val;
	var element = document.getElementById("ivwtagbox");
	
	// IVW
	var IVW = 'http://trieronl.ivwbox.de/cgi-bin/ivw/CP/' + ivwbereich;
	element.innerHTML = '<IMG SRC="'+IVW+'?r='+escape(document.referrer)+'&d='+(Math.random()*100000)+'" WIDTH="1" HEIGHT="1">';
	
	// FRABO
	var szmvars = 'trieronl//CP//' + ivwbereich;
	element.innerHTML += '<script src="http://trieronl.ivwbox.de/2004/01/survey.js" language="Javascript"><\/scr'+'ipt>';
	
	// GOOGLE
	var pageTracker = _gat._getTracker("UA-5236650-1");
	pageTracker._trackPageview();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Usernachricht vor Senden checken ///////////////////////////////////////////////////////////////////////////
function msgSend() {
	var msg_an = document.getElementById('uid_an').value;
	var msg_betreff = document.getElementById('msg_betreff').value;
	var msg_text = document.getElementById('msg_text').value;
	var err = 0; errtxt = '';
	
	if(msg_an == '') {
		err = 1;
		errtxt += 'Ein Empfänger muss ausgewählt sein.<br>';
	}
	if(msg_betreff == '') {
		err = 1;
		errtxt += 'Der Betreff fehlt.<br>';
	}
	if(msg_text == '') {
		err = 1;
		errtxt += 'Die Nachricht hat keinen Text.<br>';
	}
	
	if(err == 1) {
		document.getElementById('msg_error').innerHTML = errtxt;
		document.getElementById('msg_error').style.display = 'block';
	} else {
		document.msg_form.submit();
	}

}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DIV ein- und ausblenden ////////////////////////////////////////////////////////////////////////////////////
function showDiv(id) { 
	$(id).style.display = 'block'; 
	new Effect.Highlight(id);
	
}
function hideDiv(id) { 
	$(id).style.display = 'none'; 

	//new Effect.Fade(id);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AJAX Request Einladung (Friend) ////////////////////////////////////////////////////////////////////////////
function ioFriend(fromid, toid, io, fid) {
	var thisfrom = fromid;
	var thisto = toid;
	var thisio = io;
	var fid = fid;
	var url = '_incl_freunde/friend_io.php';
	var params = 'f_from_id='+thisfrom+'&f_to_id='+thisto+'&io='+thisio+'&fid='+fid;
	var myAjax = new Ajax.Updater(
	'AjaxUpdater',
	url, {
	method: 'post',
	parameters: params		
	});
	if(io == 'in') {
		$('friend_in').style.display = 'none';
		showDiv('friend_in_send');
		hideDiv('friend_in_link');
	} 
	if(io == 'out') {
		$('friend_out').style.display = 'none';
		showDiv('friend_out_send');		
		hideDiv('friend_out_link');
	}
	ivwtag('community');
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AJAX Request Friend //////////////////////////////////////////////////////////////////////////////////////
function friend(fromid, toid, id, todo) {
	var thisfrom = fromid;
	var thisto = toid;
	var thistodo = todo;
	var url = '_incl_freunde/set_friend_status.php';
	var params = 'f_from_id='+thisfrom+'&f_to_id='+thisto+'&f_todo='+todo;
	var myAjax = new Ajax.Updater(
	'AjaxUpdater',
	url, {
	method: 'post',
	parameters: params		
	});
	$('anfrage_' + id).style.display = 'none';
	if(todo == 1) { $('angenommen_' + id).style.display = 'block'; }
	if(todo == 0) { $('abgelehnt_' + id).style.display = 'block'; }
	ivwtag('community');
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AJAX Request Friend (Pager) ////////////////////////////////////////////////////////////////////////////////
function showFriends(param, anz) {
	var url = '_incl_freunde/ajax_friendlist.php';
	var params = param + '&anz=' + anz;
	var myAjax = new Ajax.Updater(
	'ProfilFriends',
	url, {
	method: 'post',
	evalScripts: true,
	parameters: params		
	}); 
}
function showOnlineUser(param, anz) {
	var url = '_incl_community/ajax_onlineuser.php';
	var params = param + '&anz=' + anz;
	var myAjax = new Ajax.Updater(
	'OnlineUser',
	url, {
	method: 'post',
	evalScripts: true,
	parameters: params		
	}); 
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AJAX QUICKMEMBERSEARCH /////////////////////////////////////////////////////////////////////////////////////
var suche = "";
function MemberSearch(value,target) {
	if(suche) {window.clearTimeout(suche); } suche = window.setTimeout("MemberSearchAction('"+value+"','"+target+"')",500);
}
function MemberSearchAction(value,target) {
		var url = '_incl_benutzersuche/benutzersuche_navigation_autocomplete.php';
		var params = 'value='+value;
		var myAjax = new Ajax.Updater(
			target,
			url, {
			method: 'post',
			evalScripts: true,
			parameters: params		
		});
		ivwtag('community');
}
function membersearchclose() {
	document.getElementById('membersearch').value = '';
	document.getElementById('membersearchdiv').style.display = 'none';
	ivwtag('community');
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FREISTOSS //////////////////////////////////////////////////////////////////////////////////////////////////
function twitterText(text) {
var text = text;
var maxchar = 120;
var anz = document.getElementById("twitter_text").value.length;
var rest = maxchar-anz;
document.getElementById("twitter_text").value = text;
	if(anz > maxchar) {
		var newtext = text.substr(0, 120);
		document.getElementById("twitter_text").value = newtext;
		document.getElementById("twitter_text").style.color = '#cc0000';
	} else {
		document.getElementById("ta_chars").innerHTML = 'Zeichen: ' + rest;
		document.getElementById("twitter_text").style.color = '#616161';
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
function formfocus(e) {
	e.style.backgroundImage = 'url(img/formfeldbg.png)';
}
function formblur(e) {
	if(e.value.length==0) {	e.style.backgroundImage = 'url(img/login/pw_bg.png)';	}
}
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// "RAND" DER LINKS ENTFERNEN /////////////////////////////////////////////////////////////////////////////////
function LinkNoBorder() {
	a = document.getElementsByTagName('a'); for (var i = 0; i < a.length; i++) { var aOnFocus = document.createAttribute("onFocus"); aOnFocus.nodeValue = "if(this.blur)this.blur();";	a[i].setAttributeNode(aOnFocus); }
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// STATISTIK DIAGRAM //////////////////////////////////////////////////////////////////////////////////////////
function switchDiagr(b,c) {	
	var box = document.getElementById('diagrambox').childNodes;
		for (var i=0; i<box.length; i++ ) {
			box[i].style.display = 'none';
		}
	var elem = document.getElementById('diagrambox_nav').childNodes;
		for (var i=0; i<elem.length; i++ ) {
			elem[i].firstChild.style.background = '#ffffff';
			elem[i].firstChild.style.borderBottom = '1px solid #ccdab4';
		}	
	if(!b) b = 	document.getElementById('diagrambox_nav').firstChild.firstChild;
	b.style.background = '#e8efde';
	b.style.borderBottom = '1px solid #e8efde';

	if(c) {
		document.getElementById(c).style.display = 'block';
	} else {
		var e = document.getElementById('diagrambox').firstChild;
		e.style.display = 'block';
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
