function setGoto(){
	login.setAttribute('action','/php/details.php');
	login.submit();
}

function ShowMenu(type){

		cats.style.display = "none";
		podrank.style.display = "none";
		sixpacks.style.display = "none";
		infos.style.display = "none";
		//placeholder.style.display = "none";

		switch (type) {
		  case "cats":
		    cats.style.display = "block";
		    break;
		  case "podrank":
		    podrank.style.display = "block";
		    break;
		  case "sixpacks":
		    sixpacks.style.display = "block";
		    break;
		  case "infos":
		    infos.style.display = "block";
		    break;
		  default:
		    placeholder.style.display = "block";
		    break;
		}
	
}

function checkImages() {
	var img = document.getElementsByName('pi_30');
	for(var i=0;i<img.length;++i) {
		if(img[i].complete == false) {
			img[i].src = '/podimages/non_30.jpg';
		}
	}

	var img = document.getElementsByName('pi_140');
	for(var i=0;i<img.length;++i) {
		if(img[i].complete == false) {
			img[i].src = '/podimages/non_140.jpg';
		}
	}
}

function show_hide(theme){

	if (theme.style.display == "none"){
		theme.style.display = "block";
		document.getElementById("img_" + theme.id).setAttribute("src","/images/" + theme.id + "_up.jpg");
	}
	else{
		theme.style.display = "none";
		document.getElementById("img_" + theme.id).setAttribute("src","/images/" + theme.id + "_dwn.jpg");
	}
}

// Define the callback function for when the asynchronous request is complete
function RssDownloadComplete(response, part, amount) {


	// code for IE
	if (window.ActiveXObject) {
	  var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
	  var feed = xmlDoc.loadXML(response);
	}
	// code for Mozilla, Firefox, Opera, etc.
	else if (document.implementation && document.implementation.createDocument) {
	  var xmlDoc = document.implementation.createDocument("","",null);
	  var feed = xmlDoc.load(response);
	} else {
	  alert('Your browser cannot handle this script');
	}

	if (part == "userfavs"){

		var allimages = xmlDoc.getElementsByTagName("image");
		var alertString = "<table width=\"100%\"><tr>";

		if (allimages.length == 0){
			var alertString = "<table width=\"100%\"><tr><td class=\"white_l\"><p align=\"center\">Diesen Podcast haben bislang keine User zu Ihren Favoriten hinzugefügt.</td>";
			amount = 0;
		}
		else {
			if (allimages.length < amount){
				amount = allimages.length;
			}
		}

	} else {
	    var alertString = "<table>";
	}

	if (part == "news_all") {
		var i = 0;
		while ( xmlDoc.getElementsByTagName("title")[i+1] != null) {
		        alertString += "<tr><td vAlign=\"top\" width=\"202\" height=\"41\"><div style=\"PADDING-LEFT: 20px; PADDING-TOP: 0px\"><table style=\"BORDER-COLLAPSE: collapse\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\"><tr><td width=\"40\" valign=\"top\">";
		        alertString += "<a class=\"ahjz\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
		        alertString += "<img name=\"pi_30\" alt=\"" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "\" src=\"/images/news_dot.jpg\" border=\"0\"></a></td>";
		        alertString += "<td width=\"130\"><a class=\"ahjz\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
		        alertString += "<strong>" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "</strong></a></td></tr></table></div></td></tr>";
		        i++;
		}
	} else {

	    for (var i = 0; i < amount; i++)
	    {
		switch (part){
		   case "news_feed":
		        alertString += "<tr><td vAlign=\"top\" width=\"202\" height=\"41\"><div style=\"PADDING-LEFT: 20px; PADDING-TOP: 0px\"><table style=\"BORDER-COLLAPSE: collapse\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\"><tr><td width=\"40\" valign=\"top\">";
		        alertString += "<a class=\"ahjz\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
		        alertString += "<img name=\"pi_30\" alt=\"" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "\" src=\"/images/news_dot.jpg\" border=\"0\"></a></td>";
		        alertString += "<td width=\"130\"><a class=\"ahjz\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
		        alertString += "<strong>" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "</strong></a></td></tr></table></div></td></tr>";
		        break;
		   case "newusers_feed":
		        alertString += "<tr><td vAlign=\"top\" width=\"202\" height=\"20\"><div style=\"PADDING-LEFT: 20px; PADDING-TOP: 0px\"><table style=\"BORDER-COLLAPSE: collapse\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\"><tr><td width=\"40\" valign=\"top\">";
		        alertString += "<a class=\"ahjz\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
		        alertString += "<img name=\"ui_30\" alt=\"" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "\" src=\"/images/" + xmlDoc.getElementsByTagName("description")[i+1].childNodes[0].nodeValue + ".jpg\" border=\"0\"></a></td>";
		        alertString += "<td width=\"130\"><a class=\"ahjz\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
		        alertString += "<strong>" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "</strong></a></td></tr></table></div></td></tr>";
		        break;
		   case "userfavs":
			alertString += "<td><p align=\"center\"><a class=\"white_b\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
			alertString += "<img name=\"pi_30\" border=\"0\" src=\"" + xmlDoc.getElementsByTagName("image")[i].childNodes[0].nodeValue + "\" width=\"53\" height=\"53\"><br>" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "</a></td>";
		        break;
		   default:
				//alert(xmlDoc.getElementsByTagName("link")[i+1].childNodes[1].length);
		        alertString += "<tr><td vAlign=\"top\" width=\"202\" height=\"41\"><div style=\"PADDING-LEFT: 20px; PADDING-TOP: 0px\"><table style=\"BORDER-COLLAPSE: collapse\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\"><tr><td width=\"40\">";
		        alertString += "<a class=\"ahjz\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
		        alertString += "<img name=\"pi_30\" src=\"" + xmlDoc.getElementsByTagName("image")[i].childNodes[0].nodeValue + "\" border=\"0\"></a></td>";
		        alertString += "<td width=\"130\"><a class=\"ahjz\" href=\"" + xmlDoc.getElementsByTagName("link")[i+1].childNodes[0].nodeValue + "\">";
		        alertString += "<strong>" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "</strong></a></td></tr></table></div></td></tr>";
		        break;
		   }
	    }
	}
	if (part == "userfavs"){
	    alertString += "</tr></table>";
	} else {
	    alertString += "</table>";
	}
	
    document.getElementById(part).innerHTML = alertString;

}

function Load_Part_New(type){

	if (type == "userfavs"){
	    document.getElementById(type).innerHTML = "<table width=\"100%\"><tr><td>&nbsp;<p align=\"center\"><img src=\"/images/wait.gif\"></td></tr></table>";
	} else {
	    document.getElementById(type).innerHTML = "&nbsp;<p align=\"center\"><img src=\"/images/wait.gif\">";
	}
	Load_Part(type);
}

function Load_Part_old(type){
	var xmlHttp = false;
	
	// Mozilla, Opera, Safari sowie Internet Explorer 7
	//if (typeof XMLHttpRequest != 'undefined') {
	if (window.XMLHttpRequest) {
	    xmlHttp = new XMLHttpRequest();
	}
	
	if (!xmlHttp) {
	    // Internet Explorer 6 und älter
	    try {
	        xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch(e) {
	        try {
	            xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch(e) {
	            xmlHttp  = false;
	        }
	    }
	}
	
	if (xmlHttp) {
		
		if (type == "top_5"){
		    var amount = 5;
		    xmlHttp.open('GET', '/php/top_xml.php?amount=5', true);
		}
		if (type == "last_played"){
		    var amount = 5;
		    xmlHttp.open('GET', '/php/lastplayed_xml.php?amount=5', true);
		}
		if (type == "last_added"){
		    var amount = 5;
		    xmlHttp.open('GET', '/php/lastadded_xml.php?amount=5', true);
		}
		if (type == "special_pods"){
		    var amount = 2;
		    xmlHttp.open('GET', '/php/specials_xml.php?amount=2', true);
		}
		if (type == "specials"){
		    var amount = 2;
		    xmlHttp.open('GET', '/php/specials_xml.php?amount=2', true);
		}
		if (type == "featured_pods"){
		    var amount = 1;
		    xmlHttp.open('GET', '/php/featured_xml.php?amount=1', true);
		}
		if (type == "recommend"){
		    var amount = 1;
		    xmlHttp.open('GET', '/php/featured_xml.php?amount=1', true);
		}
		if (type == "newusers_feed"){
		    var amount = 5;
		    xmlHttp.open('GET', '/php/newusers_xml.php?amount=5', true);
		}
		if (type == "news_feed"){
		    var amount = 5;
		    xmlHttp.open('GET', '/php/news_xml.php', true);
		}
		if (type == "news_all"){
		    var amount = 0;
		    xmlHttp.open('GET', '/php/news_xml.php', true);
		}
		if (type == "userfavs"){
		    var amount = 7;
		    xmlHttp.open('GET', '/php/userfavs_xml.php?amount=7&pid=' + pod_id, true);
		}

		
		if (document.implementation && document.implementation.createDocument) {
		    // code for Mozilla, Firefox, Opera, etc.
		    xmlHttp.onload = RssDownloadComplete(xmlHttp.responseText, type, amount);
		} else if (window.ActiveXObject) {
		    // code for IE
		    xmlHttp.onreadystatechange = function () {
		        if (xmlHttp.readyState == 4) {
			    	RssDownloadComplete(xmlHttp.responseText, type, amount);
		        }
		    }
		}

	    xmlHttp.send(null);
	}
}

function Load_Part(type) {

	document.getElementById(type).innerHTML = "&nbsp;<p align=\"center\"><img src=\"/images/wait.gif\">";

	switch (type) {
		case "top_5": file2call = "/php/top_json.php?amount=5";
			break;
		case "last_played": file2call = "/php/lastplayed_json.php?amount=5";
	        	break;
		case "last_added": file2call = "/php/lastadded_json.php?amount=5";
	        	break;
		case "special_pods": file2call = "/php/specials_json.php?amount=2";
	        	break;
		case "specials": file2call = "/php/specials_json.php?amount=2";
	        	break;
		case "featured_pods": file2call = "/php/featured_json.php?amount=1";
	        	break;
		case "recommend": file2call = "/php/featured_json.php?amount=1";
	        	break;
		case "newusers_feed": file2call = "/php/newusers_json.php?amount=5";
	        	break;
		case "news_feed": file2call = "/php/news_json.php?amount=5";
	        	break;
		case "news_all": file2call = "/php/news_json.php";
	        	break;
		case "userfavs": file2call = "/php/userfavs_json.php?amount=7&pid=" + pod_id;
	        	break;
	}

	new Ajax.Request(file2call, {method: 'get', onSuccess: function(transport, json) { 
		
		if (json.part == "userfavs"){
	
			/*
			var allimages = xmlDoc.getElementsByTagName("image");
			var cont = "<table width=\"100%\"><tr>";
	
			if (allimages.length == 0){
				var cont = "<table width=\"100%\"><tr><td class=\"white_l\"><p align=\"center\">Diesen Podcast haben bislang keine User zu Ihren Favoriten hinzugefügt.</td>";
				amount = 0;
			}
			else {
				if (allimages.length < amount){
					amount = allimages.length;
				}
			}
			*/
	
		} else {
		    var cont = "<table>";
		}


		if (json.part == "news_all") {
			for (i=0; i < json.amount; i++) {
			        cont += "<tr><td vAlign=\"top\" width=\"202\"><div style=\"PADDING-LEFT: 20px; PADDING-TOP: 0px\"><table style=\"BORDER-COLLAPSE: collapse\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\"><tr><td width=\"40\" valign=\"top\">";
			        cont += "<a class=\"ahjz\" href=\"" + json.results[i].link + "\">";
			        cont += "<img name=\"pi_30\" alt=\"" + json.results[i].title + "\" src=\"/images/news_dot.jpg\" border=\"0\"></a></td>";
			        cont += "<td width=\"130\"><a class=\"ahjz\" href=\"" + json.results[i].link + "\">";
			        cont += "<strong>" + json.results[i].title + "</strong></a></td></tr></table></div></td></tr>";
			}
		} else {
	
			for (i=0; i < json.amount; i++) {
				switch (json.part){
				   case "news_feed":
				        cont += "<tr><td vAlign=\"top\" width=\"202\"><div style=\"PADDING-LEFT: 20px; PADDING-TOP: 0px\"><table style=\"BORDER-COLLAPSE: collapse\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\"><tr><td width=\"40\" valign=\"top\">";
				        cont += "<a class=\"ahjz\" href=\"" + json.results[i].link + "\">";
				        cont += "<img name=\"pi_30\" alt=\"" + json.results[i].title + "\" src=\"/images/news_dot.jpg\" border=\"0\"></a></td>";
				        cont += "<td width=\"130\"><a class=\"ahjz\" href=\"" + json.results[i].link + "\">";
				        cont += "<strong>" + json.results[i].title + "</strong></a></td></tr></table></div></td></tr>";
				        break;
				   case "newusers_feed":
				        cont += "<tr><td vAlign=\"top\" width=\"202\"><div style=\"PADDING-LEFT: 20px; PADDING-TOP: 0px\"><table style=\"BORDER-COLLAPSE: collapse\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\"><tr><td width=\"40\" valign=\"top\">";
				        cont += "<a class=\"ahjz\" href=\"" + json.results[i].link + "\">";
				        cont += "<img name=\"ui_30\" alt=\"" + json.results[i].title + "\" src=\"/images/" + json.results[i].gender + ".jpg\" border=\"0\"></a></td>";
				        cont += "<td width=\"130\"><a class=\"ahjz\" href=\"" + json.results[i].link + "\">";
				        cont += "<strong>" + json.results[i].title + "</strong></a></td></tr></table></div></td></tr>";
				        break;
				   case "userfavs":
					cont += "<td><p align=\"center\"><a class=\"white_b\" href=\"" + json.results[i].link + "\">";
					cont += "<img name=\"pi_30\" border=\"0\" src=\"" + json.results[i].image_url + "\" width=\"53\" height=\"53\"><br>" + xmlDoc.getElementsByTagName("title")[i+1].childNodes[0].nodeValue + "</a></td>";
				        break;
				   default:
				        cont += "<tr><td vAlign=\"top\" width=\"202\"><div style=\"PADDING-LEFT: 20px; PADDING-TOP: 0px\"><table style=\"BORDER-COLLAPSE: collapse\" cellSpacing=\"0\" cellPadding=\"0\" width=\"100%\" border=\"0\"><tr><td width=\"40\">";
				        cont += "<a class=\"ahjz\" href=\"" + json.results[i].link + "\">";
				        cont += "<img name=\"pi_30\" src=\"" + json.results[i].image_url + "\" border=\"0\"></a></td>";
				        cont += "<td width=\"130\"><a class=\"ahjz\" href=\"" + json.results[i].link + "\">";
				        cont += "<strong>" + json.results[i].title + "</strong></a></td></tr></table></div></td></tr>";
				        break;
				   }
			}
		}
	
		if (json.part == "userfavs"){
		    cont += "</tr></table>";
		} else {
		    cont += "</table>";
		}
	
		document.getElementById(json.part).innerHTML = cont;

	} });

}

function EpisodeComplete(pod_id) {
	var xmlHttp = false;
	
	// Mozilla, Opera, Safari sowie Internet Explorer 7
	if (typeof XMLHttpRequest != 'undefined') {
	    xmlHttp = new XMLHttpRequest();
	}
	
	if (!xmlHttp) {
	    // Internet Explorer 6 und älter
	    try {
	        xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
	    } catch(e) {
	        try {
	            xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	        } catch(e) {
	            xmlHttp  = false;
	        }
	    }
	}
	
	if (xmlHttp) {

		xmlHttp.open('POST', '/php/ep_compl.php?pid=' + pod_id, true);
	    xmlHttp.send(null);

	}
}

function addToOneview() {
     
    var QuickAdd=window.open("about:blank","QuickAdd","height=630,width=500,toolbar=no,scrollbars=yes");
    var d=document;
    var s=d.createElement("script");
      
    s.type="text/javascript";
    s.src="http://beta.oneview.de:80/js/bookmarklet.jsp";
    h=d.getElementsByTagName("head")[0];
     
    if(!h){h=d.createElement("head");
        d.appendChild(h)
    }
      
    h.appendChild(s);
    QuickAdd.focus();
}

function toggle(theme){

	if (theme.style.display == "none"){
		Effect.SlideDown(theme);
		document.getElementById("img_" + theme.id).setAttribute("src","/images/up.jpg");
	}
	else{
		Effect.SlideUp(theme);
		document.getElementById("img_" + theme.id).setAttribute("src","/images/down.jpg");
	}
}

