function show_morereports (id) {
	document.getElementById("more_"+id+"link").style.display = "none";
	document.getElementById("more_"+id).style.display = "block";
	document.getElementById(id+"_headline_close").style.display = "none";
	document.getElementById(id+"_headline_open").style.display = "block";
}

function close_morereports (id) {
	document.getElementById("more_"+id+"link").style.display = "block";
	document.getElementById("more_"+id).style.display = "none";
	document.getElementById(id+"_headline_close").style.display = "block";	
	document.getElementById(id+"_headline_open").style.display = "none";
}

function hoverNavigation (zustand,id,lang) {

    if (zustand==1) {
        document.getElementById(id).src = "/site_img/"+lang+"/"+id+"_hover.gif";
    }
    else {
        document.getElementById(id).src = "/site_img/"+lang+"/"+id+"_off.gif";
    }
}


function wcPopup(url,breite,hoehe) {
	var wstat
	var ns4up = (document.layers) ? 1 : 0
	var ie4up = (document.all) ? 1 : 0
	var xsize = screen.width
	var ysize = screen.height
	var xpos=(xsize-breite)/2
	var ypos=(ysize-hoehe)/2
	wstat=window.open(url,"wcPopup","scrollbars=no,status=no,toolbar=no,location=no,directories=no,resizable=no,menubar=no,width="+breite+",height="+hoehe+",screenX="+xpos+",screenY="+ypos+",top="+ypos+",left="+xpos)
}

function wcPopup2(url,breite,hoehe) { 
	var positionX=((screen.availWidth / 2) - breite / 2); 
	var positionY=((screen.availHeight / 2) - hoehe / 2); 
	pop=window.open('','','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,fullscreen=0,width='+breite+',height='+hoehe+',top=0,left=0'); 
	//pop.resizeTo(breite,hoehe); 
	pop.moveTo(positionX,positionY); 
	pop.location=url; 
}

function showHelpStep (which) {
	if (which==1) {
		document.getElementById("step2a").style.display = "block";
	    document.getElementById("step2b").style.display = "none";
	    document.getElementById("step2Tab1").className = "helfenTab activeTab";
	    document.getElementById("step2Tab2").className = "helfenTab inactiveTab";
	}
    else {
	    document.getElementById("step2a").style.display = "none";
	    document.getElementById("step2b").style.display = "block";
	    document.getElementById("step2Tab1").className = "helfenTab inactiveTab";
	    document.getElementById("step2Tab2").className = "helfenTab activeTab";
	}

}		    	

function spendenvalue(which,createlist) {
	var aktuell = parseInt(document.getElementById("spendencounter").value);
	
	if (which=="up") {
		aktuell += 5;
	}
	else if (which=="down") {
		if (aktuell>5) {
			aktuell -= 5;
		}
	}		
	document.getElementById("spendencounter").value = aktuell;
	//if (createlist==true) step3generatefriendlist();
}

function step3clear (who,which) {
	document.getElementById(who).style.display = which;
}

function step3acceptspende () {
	if (document.getElementById('teameinladen_freunde')) { step3generatefriendlist() };
	//document.getElementById('spendencounter').disabled = true;
	document.getElementById('spendencounter').readOnly = true;
    step3clear("okbutton","none");
    step3clear("finishbutton","block");
	step3clear("spendencounter_updown","none");
	step3clear("afteraccept","block");
}

function step3generatefriendlist () {
	var bisher = parseInt(document.getElementById("spendencounter").value);	
	var html = "";
	
	//alert(bisher);
	
	html = '<table>';
	for (i=1; i<Math.floor(bisher/5); i++) {
		html += '<tr>'+
			'<td style="width:25px;font-size:18px;line-height:30px;color:#75815D;text-align:right;"><b>'+i+'&#160;</b></td>'+
			'<td><b>Vorname:*</b><br/><input type="text" name="step3freunde['+i+'][0]" class="formklasse_short" /></td>'+
			'<td><b>Name:*</b><br/><input type="text" name="step3freunde['+i+'][1]" class="formklasse_short" /></td>'+
			'<td><b>E-Mail Adresse:*</b><br/><input type="text" name="step3freunde['+i+'][2]" class="formklasse_short" /></td>'+
			'</tr>';
	}
	html += '</table>';
	
	document.getElementById("anzahl").innerHTML = Math.floor((bisher/5)-1);
	document.getElementById("teameinladen_freunde").innerHTML = html;
}





// RIDERS VIRTUELL
//CONNECTION
function doRequest(){
    var ajaxRequest;

	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}

function loadView(getAction,getValue,getPage){
    
    var action = getAction;
    var value = getValue;
    var page = getPage;
    
    ajaxRequest = doRequest();
    var queryString = "action="+action+"&value="+value+"&page="+page+"";
    // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){

            document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
		}
	}


    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}

function loadViewCountry(getAction,getValue,getValue2,getPage){
    
    var action = getAction;
    var value = getValue;
    var value2 = getValue2;
    var page = getPage;
    
    ajaxRequest = doRequest();
    var queryString = "action="+action+"&value="+value+"&value2="+value2+"&page="+page+"";
    // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){

            document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
		}
	}


    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}




function previewRider(){
    
	var action = 'previewRider';
    var jerseyColor = document.riderconfig.rgbjerseyColor.value;
    var jerseyPattern = document.riderconfig.jerseyPattern.value;
    var jerseyPatternColor = document.riderconfig.rgbjerseyPatternColor.value;
    var helmetColor = document.riderconfig.rgbhelmetColor.value;
    var pantsColor = document.riderconfig.rgbpantsColor.value;
    
    ajaxRequest = doRequest();
    var queryString = "action="+action+"&jerseyColor="+jerseyColor+"&jerseyPattern="+jerseyPattern+"&jerseyPatternColor="+jerseyPatternColor+"&helmetColor="+helmetColor+"&pantsColor="+pantsColor+"";
    // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){

            document.getElementById('riderImage').innerHTML = ajaxRequest.responseText;
		}
	}


    ajaxRequest.open('POST', 'wp-content/themes/burmariders/rider_config.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}

function loadTeam(teamCode){

    var queryString = '?id=13&action=team&code='+teamCode+'';
    ajaxRequest = doRequest();
    // Create a function that will receive data sent from the server
 	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
            document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
		}
	}

    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}

								
function wcSearch (name,team) {
	var suche = false;
	
	if (team=="Team" && name!="Name") {
		//alert("suche nach name");
		sucheNach = name;
		suchart = "person";
		suche = true;
	}
	else if (name=="Name" && team!="Team") {                     
		//alert("suche nach team");
		sucheNach = team;
		suchart = "team";
		suche = true;
	}
	else
		alert("Bitte gib einen Suchbegriff an");
	
	if (suche==true) {
			
	    var queryString = '?id=13&action=suche&suchart='+suchart+'&suchbegriff='+sucheNach+'';
	    ajaxRequest = doRequest();
	    // Create a function that will receive data sent from the server
	 	ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
	            document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
			}
		}
	
	    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
	    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	    ajaxRequest.send(queryString);
	}
}

function wcGeworbeneRider (geworbenvon) {
    var queryString = '?id=13&action=suche&suchart=geworben&suchbegriff='+geworbenvon+'';
    ajaxRequest = doRequest();
    // Create a function that will receive data sent from the server
 	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
            document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
		}
	}

    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}

function loadTeamPage(teamCode,page){

    var queryString = '?id=13&action=team&code='+teamCode+'&page='+page;
    ajaxRequest = doRequest();
    // Create a function that will receive data sent from the server
 ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
            document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
		}
	}


    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}


function loadFahrer(fahrerCode){

    var queryString = '?id=13&action=fahrer&code='+fahrerCode+'';
    ajaxRequest = doRequest();
    // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
            alleFahrerDetailsLoeschen();
            
			
			
			zeigeFahrerDetailsEinzeln('riderContent');
            document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
            //zeigeFahrerDetailsEinzeln('fahrerdetail_'+fahrerCode);
            //document.getElementById('fahrerdetail_'+fahrerCode).innerHTML = ajaxRequest.responseText;
		}
	}


    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}


function loadFahrerSingle(fahrerCode){

    //var queryString = '?id=13&action=fahrer&code='+fahrerCode+'';
    ajaxRequest = doRequest();
    if(!document.getElementById('rv_navigation')) var queryString = '?id=13&action=fahrer&code='+fahrerCode+'&navi=weg';
    else var queryString = '?id=13&action=fahrer&code='+fahrerCode+'';

    // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
            if(document.getElementById('fahrerDetailsSingle')) document.getElementById('fahrerDetailsSingle').innerHTML = ajaxRequest.responseText;
            else if(document.getElementById('rv_subnavigation')) document.getElementById('rv_subnavigation').innerHTML = ajaxRequest.responseText;
            else  document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
		}
	}


    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}

function loadCountrySingle(countryCode){

    //var queryString = '?id=13&action=fahrer&code='+fahrerCode+'';
    ajaxRequest = doRequest();
    var queryString = '?page_id=13&action=liste&value=country&value2='+countryCode+'';

	//alert(queryString);

    // Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
            document.getElementById('riderContent').innerHTML = ajaxRequest.responseText;
		}
	}


    ajaxRequest.open('POST', 'wp-content/themes/burmariders/ladeRiderContent.php');
    ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    ajaxRequest.send(queryString);
}

function alleFahrerDetailsLoeschen(){
         var elems = document.getElementsByClassName("fahrerdetails"); // yes, wildcards do exist
         for (var i=0;i<elems.length;i++) {
                elems[i].style.display="none";
            }
}

function zeigeFahrerDetailsEinzeln(id) {
         document.getElementById(id).style.display = 'block';
}


function checkSubmit () {
	if (document.getElementById('postreply').forumsubject.value!='' && document.getElementById('postreply').forumtext.value!='') {
		return true
	} else {
		alert('Bitte alle Felder ausf&#252;llen.');
		return false;
	}
}