//<![CDATA[

	window.id = "artist";
	window.letter = "";
	window.searchfor = "";
	window.isLoaded = false;
	
	
	if(window.XMLHttpRequest){
		window.XMLHTTP1 = new XMLHttpRequest();
		window.XMLHTTP2 = new XMLHttpRequest();
		window.XMLHTTP3 = new XMLHttpRequest();
		window.XMLHTTP4 = new XMLHttpRequest();
		window.XMLHTTP5 = new XMLHttpRequest();
		window.XMLHTTP6 = new XMLHttpRequest();
		window.XMLHTTP7 = new XMLHttpRequest();
	}
	else if(window.ActiveXObject){
		try{
			window.XMLHTTP1 = new ActiveXObject("Msxml2.XMLHTTP");
			window.XMLHTTP2 = new ActiveXObject("Msxml2.XMLHTTP");
			window.XMLHTTP3 = new ActiveXObject("Msxml2.XMLHTTP");
			window.XMLHTTP4 = new ActiveXObject("Msxml2.XMLHTTP");
			window.XMLHTTP5 = new ActiveXObject("Msxml2.XMLHTTP");
			window.XMLHTTP6 = new ActiveXObject("Msxml2.XMLHTTP");
			window.XMLHTTP7 = new ActiveXObject("Msxml2.XMLHTTP");

			}catch(ex){
			try{
				window.XMLHTTP1 = new ActiveXObject("Microsoft.XMLHTTP");
				window.XMLHTTP2 = new ActiveXObject("Microsoft.XMLHTTP");
				window.XMLHTTP3 = new ActiveXObject("Microsoft.XMLHTTP");
				window.XMLHTTP4 = new ActiveXObject("Microsoft.XMLHTTP");
				window.XMLHTTP5 = new ActiveXObject("Microsoft.XMLHTTP");
				window.XMLHTTP6 = new ActiveXObject("Microsoft.XMLHTTP");
				window.XMLHTTP7 = new ActiveXObject("Microsoft.XMLHTTP");

			}
			catch(ex){
				alert (ex);
			}
		}
	}
	window.onload = function(){
		window.isLoaded = true;
		init();
	}
	
	function init(){
		change_search_method('artist');
		napster_features();
		set_top10();
		set_nr();
		set_reco();
	}

	function change_search_method(type){
		var path = "/images/4.0/search_music/";
		window.searchfor = type;
		switch(type){
			case "artist":
				document.getElementById("search_for_artist").src = path+"gfc_suche-kuenstler-on.gif";
				document.getElementById("search_for_album").src = path+"gfc_suche-album.gif";
				document.getElementById("search_for_track").src = path+"gfc_suche-titel.gif";
			break;
			case "album":
				document.getElementById("search_for_artist").src = path+"gfc_suche-kuenstler.gif";
				document.getElementById("search_for_album").src = path+"gfc_suche-album-on.gif";
				document.getElementById("search_for_track").src = path+"gfc_suche-titel.gif";
			break;
			case "track":
				document.getElementById("search_for_artist").src = path+"gfc_suche-kuenstler.gif";
				document.getElementById("search_for_album").src = path+"gfc_suche-album.gif";
				document.getElementById("search_for_track").src = path+"gfc_suche-titel-on.gif";
			break;
		}
	}

	function submitenter(e){
		var keycode;
		if (window.event) keycode = window.event.keyCode;
		else if (e) keycode = e.which;
		else return true;
		
		if (keycode == 13){
		   perform_search();
		   return false;
		}
		else
			return true;
	}

	
	function perform_search(){
		var search_value = document.getElementById("searchtxt").value;
		var search_url = "";
		
		var prefix = "";
		if(document.URL.indexOf("www.napster.de") >-1) prefix = "www.";
		else if (document.URL.indexOf("napster.de") >-1) prefix = "";
		else return false;

		search_url = "http://"+prefix+"napster.de/search-cgi/searchByNameXML?CLIENTTYPE=client&type="+window.searchfor+"&search_string="+search_value+"&enc=utf8&hot_tracks=0&LFM=N&COUNTRYCODE=DE&EXPLICIT=Y&format=json";
		if(window.isLoaded){
			window.XMLHTTP2.open("GET", search_url);
			window.XMLHTTP2.onreadystatechange = show_search_result;
			window.XMLHTTP2.send(null);
		}
		else{
			window.setTimeout("perform_search()",400);
		}
	}

	function show_search_result(){
		if(XMLHTTP2.readyState == 4){
			document.getElementById("search_process").style.visibility = "hidden";
			var s = document.getElementById("search");
			var search_field = '<img src="/images/4.0/search_music/gfc_icon_magnifier.gif" width="43" height="42" align="left" style="margin-right:20px" /><div style="width:310px"><a onclick="change_search_method(\'artist\')" class="hand"><img src="/images/4.0/search_music/gfc_suche-kuenstler';
			if(window.searchfor == "artist") search_field += '-on';
			search_field += '.gif" width="66" height="21" id="search_for_artist" /></a><a onclick="change_search_method(\'album\')" class="hand"><img src="/images/4.0/search_music/gfc_suche-album';
			if(window.searchfor == "album") search_field += '-on';
			search_field += '.gif" id="search_for_album" width="53" height="21" hspace="12" /></a><a onclick="change_search_method(\'track\')" class="hand"><img src="/images/4.0/search_music/gfc_suche-titel';
			if(window.searchfor == "track") search_field += '-on';
			search_field += '.gif" id="search_for_track" width="40" height="21" /></a><div style="background-color:#FFFFFF; width:40px; height:3px; visibility:hidden; margin-left:63px" id="search_process"><img src="/images/spacer.gif" width="1" height="1" /></div></div><div style="width:205px; float:left"><input type="text" id="searchtxt" style="height:21px; width:200px; color:#000000; outline:none; border:none; float:left; " class="font12" onKeyPress="return submitenter(event)" /></div><div style="float:left; width:98px;overflow:hidden"><img src="/images/4.0/search_music/btn_suche.gif" name="searchbtn" width="73" height="24" id="searchbtn" style="line-height:15px; margin-top:1px; margin-left:5px; cursor:hand;" onclick="perform_search()" /></div><div id="mycustomscroll2" class="flexcroll" style="width:304px; height:250px; overflow:hidden; margin-top:10px;margin-left:62px;clear:left"><div id="result_search" style="width:284px; overflow:hidden"></div></div>';
			
			s.innerHTML = search_field;
			
			var sresult = document.getElementById("result_search");
			sresult.innerHTML = "";
			
			var obj = eval("("+XMLHTTP2.responseText+")");
			
			var myarr = obj["result"];
			//myarr.sort();

			for (var x=0;x<myarr.length;x++){
				var ahref = document.createElement("a");
				if(window.searchfor == 'artist'){
					ahref.setAttribute('href','http://www.napster.de/musik-hoeren/');
					var text = document.createTextNode(myarr[x].artist_name);
				}
				else if(window.searchfor == 'album'){
					ahref.setAttribute('href','http://www.napster.de/musik-hoeren/');
					var text = document.createTextNode(myarr[x].album);
				}
				else if(window.searchfor == 'track'){
					ahref.setAttribute('href','http://www.napster.de/musik-hoeren/');
					var text = document.createTextNode(myarr[x].track_sort);
				}
				ahref.className = "cnavilinks";
				var element = document.createElement("img");
				element.setAttribute('src','/images/4.0/gfc_1x1_b4b4b4.gif');
				element.setAttribute('width','300');
				element.setAttribute('height','1');
				element.setAttribute('border','0');
				
				var br = document.createElement("br");
				ahref.appendChild(text);
				
				sresult.appendChild(ahref);
				//sresult.appendChild(text);
				sresult.appendChild(br);
				sresult.appendChild(element);
				var br2 = document.createElement("br");
				sresult.appendChild(br2);
			}
			CSBfleXcroll('mycustomscroll2');
			document.getElementById("mycustomscroll2").style.height = "250px";
		}
		else document.getElementById("search_process").style.visibility = "visible";
	}
	
	function napster_features(){
		var xml_path = "/xml/napster_features.xml";
		window.XMLHTTP3.open("GET", xml_path);
		window.XMLHTTP3.onreadystatechange = show_napster_features;
		window.XMLHTTP3.send(null);
	}
	
	function show_napster_features(){
		if(XMLHTTP3.readyState == 4){
			var napster_features = document.getElementById("napster_features");
			var obj = XMLHTTP3.responseXML;
			//alert(obj.getElementsByTagName("napsterfeatures").length);
			if(obj.getElementsByTagName("napsterfeatures")[0].getElementsByTagName("feature").length>0){
				
				var features = obj.getElementsByTagName("napsterfeatures")[0].getElementsByTagName("feature");
				//var feat_content = "";
				for(var x=0;x<features.length;x++){
					//alert(features[x].getElementsByTagName("headline")[0].hasChildNodes);
					//alert(features[x].getElementsByTagName("section")[0].firstChild.nodeValue);
					napster_features.innerHTML += '<div style="clear:left;">';
					napster_features.innerHTML += '<img align="left" height="76" width="190" src="'+features[x].getElementsByTagName("image")[0].firstChild.nodeValue+'" style="padding-right:10px">';
					napster_features.innerHTML += features[x].getElementsByTagName("section")[0].firstChild.nodeValue+'<br />';
					(features[x].getElementsByTagName("headline")[0].hasChildNodes) ? napster_features.innerHTML += '<div class="csubheadline">'+features[x].getElementsByTagName("headline")[0].firstChild.nodeValue+"</div>" : "";
					napster_features.innerHTML += '</div>';
					if(x != features.length-1){
						napster_features.innerHTML += '<br /><img src="/images/4.0/gfc_1x1_fff.gif" width="350" height="1" style="padding-top:5px; padding-bottom:5px; clear:left" /><br />';
					}
					//napster_features.innerHTML += '<br>'
					//feat_content += "";
				}
				napster_features.innerHTML += '<br />';
				CSBfleXcroll('mycustomscroll3');
				document.getElementById("mycustomscroll3").style.height = "532px";
			}
		}
	}
	
	function set_mood(mood){
		window.mood = mood;
		var mood_div = document.getElementById("mood");
		// black, white, grey, red, orange, yellow, green, blue, purple, pink
		var mood_color = new Array("000000","ffffff","969696","f71e01","f79601","f7ee01","69e701","028af9","a105fc","fd06e0");
		var font_color = new Array("ffffff","000000","ffffff","ffffff","ffffff","000000","000000","ffffff","ffffff","ffffff");
		mood_div.style.backgroundColor = "#"+mood_color[mood];
		mood_div.style.color = "#"+font_color[mood];
		var mood_xml_url = "/xml/mood.xml";
		window.XMLHTTP4.open("GET", mood_xml_url);
		window.XMLHTTP4.onreadystatechange = show_mood;
		window.XMLHTTP4.send(null);
	}
		
	function show_mood(){
		if(XMLHTTP4.readyState == 4){
			var font_color = new Array("cnavilinks","cnavilinks_02","cnavilinks","cnavilinks","cnavilinks","cnavilinks_02","cnavilinks_03","cnavilinks","cnavilinks","cnavilinks");
			var mood_div = document.getElementById("mood");
			mood_div.innerHTML = "";
			var obj = XMLHTTP4.responseXML;
			if(obj.getElementsByTagName("moods")[0].getElementsByTagName("mood").length>0){
				var moods = obj.getElementsByTagName("moods")[0].getElementsByTagName("mood");

				//Mood Track
				mood_div.innerHTML += '<div style="padding-left:10px">';
				mood_div.innerHTML += '<a href="javascript:play_track('+moods[window.mood].getElementsByTagName("track")[0].getElementsByTagName("trackid")[0].firstChild.nodeValue+')"><img align="left" height="99" width="99" border="1" src="'+moods[window.mood].getElementsByTagName("track")[0].getElementsByTagName("image")[0].firstChild.nodeValue+'" hspace="10" style="background-color:#FFFFFF; border-color:#FFFFFF"></a>';
				mood_div.innerHTML += 'Song<br/><br/>';
				mood_div.innerHTML += '<strong><a href="javascript:play_track('+moods[window.mood].getElementsByTagName("track")[0].getElementsByTagName("trackid")[0].firstChild.nodeValue+')" class="'+font_color[window.mood]+'">'+moods[window.mood].getElementsByTagName("track")[0].getElementsByTagName("trackname")[0].firstChild.nodeValue+'<br />'+moods[window.mood].getElementsByTagName("track")[0].getElementsByTagName("artistname")[0].firstChild.nodeValue+'</a></strong></div>';
				mood_div.innerHTML += '<img src="/images/4.0/gfc_1x1_fff.gif" width="368" height="1" style="clear:left; margin-left:10px" vspace="15" />';
				
				//Mood Playlist
				mood_div.innerHTML += '<div style="clear:left; padding-left:10px">';
				mood_div.innerHTML += '<a href="javascript:show_playlist('+moods[window.mood].getElementsByTagName("playlist")[0].getElementsByTagName("id")[0].firstChild.nodeValue+')"><img align="left" height="76" width="190" border="1" src="'+moods[window.mood].getElementsByTagName("playlist")[0].getElementsByTagName("image")[0].firstChild.nodeValue+'" hspace="10" style="background-color:#FFFFFF; border-color:#FFFFFF"></a>';
				mood_div.innerHTML += 'Playlist<br/><br/>';
				mood_div.innerHTML += '<strong><a href="javascript:show_playlist('+moods[window.mood].getElementsByTagName("playlist")[0].getElementsByTagName("id")[0].firstChild.nodeValue+')" class="'+font_color[window.mood]+'">'+moods[window.mood].getElementsByTagName("playlist")[0].getElementsByTagName("name")[0].firstChild.nodeValue+'</a></strong></div>';
				mood_div.innerHTML += '<img src="/images/4.0/gfc_1x1_fff.gif" width="368" height="1" style="clear:left; margin-left:10px" vspace="15" />';

				//Mood Channel
				mood_div.innerHTML += '<div style="clear:left; padding-left:10px">';
				mood_div.innerHTML += '<a href="javascript:channel('+moods[window.mood].getElementsByTagName("channel")[0].getElementsByTagName("id")[0].firstChild.nodeValue+')"><img align="left" height="76" width="190" border="1" src="'+moods[window.mood].getElementsByTagName("channel")[0].getElementsByTagName("image")[0].firstChild.nodeValue+'" hspace="10" style="background-color:#FFFFFF; border-color:#FFFFFF"></a>';
				mood_div.innerHTML += 'Radio Channel<br/><br/>';
				mood_div.innerHTML += '<strong><a href="javascript:channel('+moods[window.mood].getElementsByTagName("channel")[0].getElementsByTagName("id")[0].firstChild.nodeValue+')" class="'+font_color[window.mood]+'">'+moods[window.mood].getElementsByTagName("channel")[0].getElementsByTagName("name")[0].firstChild.nodeValue+'</a></div></strong>';
			}
		}
	}	

	function set_top10(){
		var mood_xml_url = "http://www.napster.de/feeds/rss/1.0/track/popularity/all";
		window.XMLHTTP5.open("GET", mood_xml_url);
		window.XMLHTTP5.onreadystatechange = show_top10;
		window.XMLHTTP5.send(null);
	}
		
	function show_top10(){
		if(XMLHTTP5.readyState == 4){
			var cont = document.getElementById("top10");
			var obj = XMLHTTP5.responseXML;
			if(obj.getElementsByTagName("item").length>0){
				for(var x=0;x<5;x++){
					if(x==0){
						cont.innerHTML = '<table border="0" cellspacing="0" cellpadding="0"><tr style="height:99px"><td><a href="javascript:play_track('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:track_id")[0].firstChild.nodeValue+')"><img src="'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:image_002")[0].firstChild.nodeValue+'" width="99" height="99" border="0" hspace="5" /></a></td><td valign="bottom"><a href="javascript:play_track('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:track_id")[0].firstChild.nodeValue+')" class="cnavilinks"><b>'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:track_name")[0].firstChild.nodeValue+'</b><br />'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:artist_name")[0].firstChild.nodeValue+'</a></td></tr></table>';
						cont.innerHTML += '<img src="/images/4.0/gfc_1x1_fff.gif" width="250" height="1" vspace="5" />';
					}
					else{
						cont.innerHTML += '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="33" align="center"><a href="javascript:play_track('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:track_id")[0].firstChild.nodeValue+')"><img src="/images/4.0/search_music/gfc_'+(x+1)+'.gif" hspace="10" vspace="10" border="0" /></a></td><td valign="bottom"><b><a href="javascript:play_track('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:track_id")[0].firstChild.nodeValue+')" class="cnavilinks">'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:track_name")[0].firstChild.nodeValue+'</b><br />'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:artist_name")[0].firstChild.nodeValue+'</a></td></tr></table>';
						cont.innerHTML += '<img src="/images/4.0/gfc_1x1_fff.gif" width="250" height="1" vspace="5" />';
					}
				}
			}
		}
	}
	
	function set_nr(){
		var mood_xml_url = "http://www.napster.de/feeds/rss/1.0/album/newreleases/all";
		window.XMLHTTP6.open("GET", mood_xml_url);
		window.XMLHTTP6.onreadystatechange = show_nr;
		window.XMLHTTP6.send(null);
	}
		
	function show_nr(){
		if(XMLHTTP6.readyState == 4){
			var cont = document.getElementById("new_releases");
			var obj = XMLHTTP6.responseXML;
			if(obj.getElementsByTagName("item").length>0){
				for(var x=0;x<5;x++){
					if(x==0){
						cont.innerHTML = '<table border="0" cellspacing="0" cellpadding="0"><tr style="height:99px"><td><a href="javascript:play_album('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_id")[0].firstChild.nodeValue+')"><img src="'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:image_002")[0].firstChild.nodeValue+'" border="0" width="99" height="99" border="0" hspace="5" /></a></td><td valign="bottom"><a href="javascript:play_album('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_id")[0].firstChild.nodeValue+')" class="cnavilinks"><b>'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_name")[0].firstChild.nodeValue+'</b><br />'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:artist_name")[0].firstChild.nodeValue+'</a></td></tr></table>';
						cont.innerHTML += '<img src="/images/4.0/gfc_1x1_fff.gif" width="250" height="1" vspace="5" />';
					}
					else{
						cont.innerHTML += '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="33" align="center"><a href="javascript:play_album('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_id")[0].firstChild.nodeValue+')"><img src="/images/4.0/search_music/gfc_'+(x+1)+'.gif" border="0" hspace="10" vspace="10" /></a></td><td valign="bottom"><a href="javascript:play_album('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_id")[0].firstChild.nodeValue+')" class="cnavilinks"><b>'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_name")[0].firstChild.nodeValue+'</b><br />'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:artist_name")[0].firstChild.nodeValue+'</a></td></tr></table>';
						cont.innerHTML += '<img src="/images/4.0/gfc_1x1_fff.gif" width="250" height="1" vspace="5" />';
					}
				}
			}
		}
	}

	function set_reco(){
		var mood_xml_url = "http://www.napster.de/feeds/rss/1.0/album/recommendations/all";
		window.XMLHTTP7.open("GET", mood_xml_url);
		window.XMLHTTP7.onreadystatechange = show_reco;
		window.XMLHTTP7.send(null);
	}

	function show_reco(){
		if(XMLHTTP7.readyState == 4){
			var cont = document.getElementById("recommendations");
			var obj = XMLHTTP7.responseXML;
			if(obj.getElementsByTagName("item").length>0){
				for(var x=0;x<5;x++){
					if(x==0){
						cont.innerHTML = '<table border="0" cellspacing="0" cellpadding="0"><tr style="height:99px"><td><a href="javascript:play_album('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_id")[0].firstChild.nodeValue+')"><img src="'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:image_002")[0].firstChild.nodeValue+'" width="99" height="99" border="0" hspace="5" /></a></td><td valign="bottom"><a href="javascript:play_album('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_id")[0].firstChild.nodeValue+')" class="cnavilinks"><b>'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_name")[0].firstChild.nodeValue+'</b><br />'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:artist_name")[0].firstChild.nodeValue+'</a></td></tr></table>';
						cont.innerHTML += '<img src="/images/4.0/gfc_1x1_fff.gif" width="250" height="1" vspace="5" />';
					}
					else{
						cont.innerHTML += '<table border="0" cellspacing="0" cellpadding="0"><tr><td width="33" align="center"><a href="javascript:play_album('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_id")[0].firstChild.nodeValue+')"><img src="/images/4.0/search_music/gfc_'+(x+1)+'.gif" hspace="10" vspace="10" border="0" /></a></td><td valign="bottom"><a href="javascript:play_album('+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_id")[0].firstChild.nodeValue+')" class="cnavilinks"><b>'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:album_name")[0].firstChild.nodeValue+'</b><br />'+obj.getElementsByTagName("item")[x].getElementsByTagName("nweb:artist_name")[0].firstChild.nodeValue+'</a></td></tr></table>';
						cont.innerHTML += '</a><img src="/images/4.0/gfc_1x1_fff.gif" width="250" height="1" vspace="5" />';
					}
				}
			}
		}
	}
	function play_album(id){
		mywindow = window.open("http://www.napster.de/musik-hoeren/", "Nshop");
		mywindow.focus();
	}
	function play_track(id){
		mywindow = window.open("http://www.napster.de/musik-hoeren/", "Nshop");
		mywindow.focus();
	}
	function show_playlist(id){
		mywindow = window.open("http://www.napster.de/musik-hoeren/", "Nshop");
		mywindow.focus();
	}
	function channel(id){
		mywindow = window.open("http://www.napster.de/musik-hoeren/", "Nshop");
		mywindow.focus();
	}