// Artist Area
function sort_songs_artist(){
  document.location.href="/de/disco.html?artistareatabs=1&id="+document.getElementById('id').value+"&sort_by="+document.getElementById('sort_by').value;
}

var Fenster = null;
function popup(meineSeite,meinName,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=NO'
	Fenster = window.open(meineSeite,meinName,settings)
}

function setFlashSize(divid, newW, newH){
	//document.getElementById('adtuner_content_div').style.display = "none";
	//document.getElementById('adtuner_content').src = "/de/blank.html";
	document.getElementById(divid).style.width = newW+"px";
	document.getElementById(divid).style.height = newH+"px";
}

function setIframeHeight(frameid,plusheight){
	if(parent.frames.length && document.documentElement && document.documentElement.scrollHeight) {
		var iframe = parent.document.getElementsByTagName('iframe')[frameid];
		if(frameid.substr(-5)=="_frame"){
			var divframe = parent.document.getElementsByTagName('div')[frameid.substr(-5)];
			alert(divframe.style.height);
		}
		if(!isNaN(parseFloat(plusheight))){
			newheight = plusheight;
		}else{
			newheight = 10;
		}
		iframe.style.height = (document.documentElement.scrollHeight + newheight) + 'px';
		if(frameid.substr(-5)=="_frame"){
			divframe.style.height = (document.documentElement.scrollHeight + newheight) + 'px';
		}
	}
	mainheight = (top.document.documentElement.scrollHeight + newheight)+"px";
	top.document.getElementById('content_container').style.height = mainheight;
	top.document.getElementById('background_container').style.height = mainheight;
}

function setIframeHeight_light(frameid,newheight){
	if(parent.frames.length && document.documentElement && document.documentElement.scrollHeight) {
		var iframe = parent.document.getElementsByTagName('iframe')[frameid];
		mainheight = newheight+"px";
		iframe.style.height = mainheight;
		alert(""+iframe.style.height+":"+mainheight+"");
	}
	//mainheight = (top.document.documentElement.scrollHeight + newheight)+"px";
	//alert(""+mainheight+"");
	//top.document.getElementById('content_container').style.height = mainheight;
	//top.document.getElementById('background_container').style.height = mainheight;
}

function setIframeHeight_v3() {
 	if(parent.frames.length && document.body && document.body.scrollHeight) {
        var iframe = parent.document.getElementById('contentframe');
        mainheight = (document.body.scrollHeight) + 'px';
        iframe.style.height = (document.body.scrollHeight) + 'px';
		topheight = (top.document.body.scrollHeight) + 'px';
 	}
 	if(parent.frames.length && document.documentElement && document.documentElement.scrollHeight) {
        var iframe = parent.document.getElementById('contentframe');
        mainheight = (document.documentElement.scrollHeight) + 'px';
        iframe.style.height = (document.documentElement.scrollHeight) + 'px';
		topheight = (top.document.documentElement.scrollHeight) + 'px';
 	}
 	parent.document.getElementById('content_container').style.height = topheight;
	parent.document.getElementById('background_container').style.height = topheight;
}

function getPageHeight(){
        var windowHeight;
        if (self.innerHeight) { // all except Explorer
                windowHeight = self.innerHeight;
        } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
                windowHeight = document.documentElement.clientHeight;
        } else if (document.body) { // other Explorers
                windowHeight = document.body.clientHeight;
        }

        var pageHeight = 0;
        if(document.body.clientHeight && pageHeight < document.body.clientHeight) pageHeight = document.body.clientHeight;
        if(document.body.scrollHeight && pageHeight < document.body.scrollHeight) pageHeight = document.body.scrollHeight;
        if(document.documentElement.scrollHeight && pageHeight < document.documentElement.scrollHeight) pageHeight = document.documentElement.scrollHeight;
        if(document.documentElement.clientHeight && pageHeight < document.documentElement.clientHeight) pageHeight = document.documentElement.clientHeight;
        if(document.documentElement.offsetHeight && pageHeight < document.documentElement.offsetHeight) pageHeight = document.documentElement.offsetHeight;
        if(document.body.offsetHeight && pageHeight < document.body.offsetHeight) pageHeight = document.body.offsetHeight;
        if(window.innerHeight && pageHeight < window.innerHeight) pageHeight = window.innerHeight;

        return pageHeight;
}

function setIframeHeight2(frameid,plusheight){
	if(parent.frames.length && document.documentElement && document.documentElement.scrollHeight) {
		var iframe = parent.document.getElementsByTagName('iframe')[frameid];
		if(frameid.substr(-5)=="_frame"){
			var divframe = parent.document.getElementsByTagName('div')[frameid.substr(-5)];
			alert(divframe.style.height);
		}
		if(!isNaN(parseFloat(plusheight))){
			newheight = plusheight;
		}else{
			newheight = 10;
		}
		iframe.style.height = (document.documentElement.scrollHeight + newheight) + 'px';
		if(frameid.substr(-5)=="_frame"){
			divframe.style.height = (document.documentElement.scrollHeight + newheight) + 'px';
		}
	}
}

function mychannels(){
	//document.getElementById('adtuner').style.width = "280px";
	//document.getElementById('adtuner').style.height = "170px";
	document.getElementById('adtuner_content_div').style.display = "";
	document.getElementById('adtuner_content').style.height = "1px";
	document.getElementById('adtuner_content').src = "/de/mychannels.html";
}

function mychannels_new(){
	document.getElementById('adtuner').style.width = "222px";
	//document.getElementById('adtuner').style.height = "170px";
	document.getElementById('adtuner_content_div').style.display = "";
	document.getElementById('adtuner_content').style.height = "1px";
	document.getElementById('adtuner_content').src = "/de/mychannels.html";
}

function playchan(id,fheight){
	document.getElementById('adtuner_scale').innerHTML='<div id="adtuner_player" style="position:absolute;z-index:4;overflow:hidden;width:537px;height:260px;padding-left:1px;overflow:hidden">Loading Flash...</div>';
	swfobject.embedSWF("/media/flash/rocca_v2.swf", "adtuner_player", "537", "260", "9.0.0", "",{playlist_inode:""+id+"",user:"yes"},{wmode:"transparent",menu:"false",allowscriptaccess:"always"});
	new Effect.Tween(null, 0, 0, function(p){ scrollTo(0,p) });
}

function playchanclose(id,fheight){
	document.getElementById('adtuner_scale').innerHTML='<div id="adtuner_player" style="position:absolute;z-index:4;overflow:hidden;width:537px;height:260px;padding-left:1px;overflow:hidden">Loading Flash...</div>';
	swfobject.embedSWF("/media/flash/rocca_v2.swf", "adtuner_player", "537", "260", "9.0.0", "",{playlist_inode:""+id+"",user:"yes"},{wmode:"transparent",menu:"false",allowscriptaccess:"always"});
	new Effect.Tween(null, 0, 0, function(p){ scrollTo(0,p) });
}

function playpre(id){
	document.getElementById('adpreplayer').SetVariable('streamstop', Math.random());
	document.getElementById('adpreplayer').SetVariable('inode', id);
	document.getElementById('adpreplayer').SetVariable('trackstart', Math.random());
	document.getElementById('prelink_'+id).href="javascript:prestop('"+id+"')";
	document.getElementById('playpre_'+id).src="/media/gfx/icons/stop.gif";
}

function playadpre(id,fheight){
	//document.getElementById('adtuner_player').SetVariable('unloadtrack', Math.random());	
	document.getElementById('adtuner_scale').innerHTML='<div id="adtuner_player" style="position:absolute;z-index:4;overflow:hidden;width:537px;height:260px;padding-left:1px;overflow:hidden">Loading Flash...</div>';
	swfobject.embedSWF("/media/flash/rocca_v2.swf", "adtuner_player", "537", "260", "9.0.0", "",{playhistory_inode:""+id+"",playhistory:"yes",user:"yes"},{wmode:"transparent",menu:"false",allowscriptaccess:"always"});
	new Effect.Tween(null, 0, 0, function(p){ scrollTo(0,p) });
	//document.getElementById('layerframe').src="/de/layerad.html";
}

function playartistradio(id,fheight){
	document.getElementById('adtuner_scale').innerHTML='<div id="adtuner_player" style="position:absolute;z-index:4;overflow:hidden;width:537px;height:260px;padding-left:1px;overflow:hidden">Loading Flash...</div>';
	swfobject.embedSWF("/media/flash/rocca_v2.swf", "adtuner_player", "537", "260", "9.0.0", "",{artist_inode:""+id+"",playartistradio:"yes",user:"yes"},{wmode:"transparent",menu:"false",allowscriptaccess:"always"});
	new Effect.Tween(null, 0, 0, function(p){ scrollTo(0,p) });
}

function playadradio(id,fheight){
	document.getElementById('adtuner_scale').innerHTML='<div id="adtuner_player" style="position:absolute;z-index:4;overflow:hidden;width:537px;height:260px;padding-left:1px;overflow:hidden">Loading Flash...</div>';
	swfobject.embedSWF("/media/flash/rocca_v2.swf", "adtuner_player", "537", "260", "9.0.0", "",{adradio_inode:""+id+"",playadradio:"yes",user:"yes"},{wmode:"transparent",menu:"false",allowscriptaccess:"always"});
	new Effect.Tween(null, 0, 0, function(p){ scrollTo(0,p) });
}

function playpretops(id){
	document.getElementById('adpreplayer').SetVariable('streamstop', Math.random());
	document.getElementById('adpreplayer').SetVariable('inode', id);
	document.getElementById('adpreplayer').SetVariable('trackstart', Math.random());
	document.getElementById('prelink_'+id).href="javascript:prestoptops('"+id+"')";
	document.getElementById('prelink_'+id).innerHTML="Stop";
}

function prestop(id){
	document.getElementById('adpreplayer').SetVariable('streamstop', Math.random());
	document.getElementById('prelink_'+id).href="javascript:playpre('"+id+"')";
	document.getElementById('playpre_'+id).src="/media/gfx/icons/play.gif";
}

function prestoptops(id){
	document.getElementById('adpreplayer').SetVariable('streamstop', Math.random());
	document.getElementById('prelink_'+id).href="javascript:playpretops('"+id+"')";
	document.getElementById('prelink_'+id).innerHTML="Play";
}

function lb_setlnk(lnk){
	tb_remove();
	document.getElementById('contentframe').src=lnk;
}

function soundcomplete_tops(id){
	document.getElementById('prelink_'+id).href="javascript:playpretops('"+id+"')";
	document.getElementById('prelink_'+id).innerHTML="Play";
}

function soundcomplete(id){
	document.getElementById('prelink_'+id).href="javascript:playpre('"+id+"')";
	document.getElementById('playpre_'+id).src="/media/gfx/icons/play.gif";
}

function close_foldouts(frameid,id){
	alert("Frameid: "+frameid+" | ID:"+id);
	alert(document.getElementById('adtuner_content').contentWindow.document.documentElement.scrollHeight);
	//document.getElementById('adtuner_content').style.height=document.getElementById('adtuner_content').contentWindow.document.documentElement.scrollHeight;
	//alert(document.getElementById('adtuner_content').contentWindow.getElementById(''+id+'').contentWindow.getElementById(''+frameid+'').style.height);
	alert(document.getElementById('adtuner_content').contentWindow.getElementById(''+id+'').contentWindow.getElementById(''+frameid+'').document.documentElement.offsetHeight);
	alert(document.getElementById('adtuner_content').contentWindow.getElementById(''+id+'').contentWindow.getElementById(''+frameid+'').contentWindow.document.documentElement.scrollHeight);
}

function move(){
	if(document.getElementById('content_ad') && (document.getElementById('adtuner_content').style.height > document.getElementById('content_ad').style.height)){
		posy = getY(document.getElementById('adtuner_content'));
		var scrollPos;
		if (typeof window.pageYOffset != 'undefined') {
   			scrollPos = window.pageYOffset;
		}else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
			scrollPos = document.documentElement.scrollTop;
		}else if (typeof document.body != 'undefined') {
			scrollPos = document.body.scrollTop;
		}
		grenze = (parseInt(document.getElementById('adtuner_content').style.height)-parseInt(document.getElementById('content_ad').style.height));
		//alert((parseInt(document.getElementById('adtuner_content').style.height) - parseInt(document.getElementById('content_ad').style.height)));
		if((scrollPos>posy)){
				if((scrollPos)>parseInt(document.getElementById('adtuner_content').style.height)){
																	 
				}else{
					document.getElementById('content_ad').style.marginTop = (scrollPos-posy)+"px";
				}
		}else{
			document.getElementById('content_ad').style.marginTop = "0px";
		}
		//document.getElementById('content_ad').innerHTML = '<font style="color:#FFFFFF">Posy: '+posy+'<br>Scroll: '+scrollPos+'<br>grenze:'+document.getElementById('content_ad').style.marginTop+' <'+grenze+'</font>';
	}
	
	if(document.getElementById('skyscraper_ad')){
		posy = getY(document.getElementById('skyscraper_ad_frame'));
		var scrollPos;
		if (typeof window.pageYOffset != 'undefined') {
   			scrollPos = window.pageYOffset;
		}else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {
			scrollPos = document.documentElement.scrollTop;
		}else if (typeof document.body != 'undefined') {
			scrollPos = document.body.scrollTop;
		}
		//grenze = (parseInt(document.getElementById('skyscraper_ad_frame').style.height)-parseInt(document.getElementById('skyscraper_ad').style.height));
		//alert((parseInt(document.getElementById('adtuner_content').style.height) - parseInt(document.getElementById('content_ad').style.height)));
		if((scrollPos>posy)){
			document.getElementById('skyscraper_ad').style.marginTop = (scrollPos-posy)+"px";
		}else{
			document.getElementById('skyscraper_ad').style.marginTop = "0px";
		}
		//document.getElementById('content_ad').innerHTML = '<font style="color:#FFFFFF">Posy: '+posy+'<br>Scroll: '+scrollPos+'<br>grenze:'+document.getElementById('content_ad').style.marginTop+' <'+grenze+'</font>';
	}
}

function getY(obj,relative){
	var y=0;
	if(typeof(obj)=="object" && document.getElementById) {
		y=obj.offsetTop;
		if(obj.offsetParent && !relative) {
			y+=getY(obj.offsetParent);
		}
		return y;
	}else{
		return false;
	}
}

function adloader(adurl,mode,main,sub,maingenre,id,mid){
	query="?";
	query+="url="+adurl+"&";
	query+="mode="+mode+"&";
	query+="main="+main+"&";
	query+="sub="+sub+"&";
	query+="maingenre="+maingenre+"&";
	query+="id="+id+"&";
	query+="mid="+mid+"";
	document.getElementById('skyscraper_ad').src='/de/ad/skyscraper.html'+query;
	document.getElementById('banner_ad').src='/de/ad/banner.html'+query;
}

function play_nxt_ad(){
    //document.getElementById('layerframe').src="/de/layerad.html";
	document.getElementById('skyscraper_ad').src='/de/ad/skyscraper.html?url=play_next';
	document.getElementById('banner_ad').src='/de/ad/banner.html?url=play_next';
	document.getElementById('tracking_ad').src='/de/ad/track.html?url=play_next';
}

function file_name_only(str){ 
	var slash = '/' 
	if(str.match(/\\/)){ 
		slash = '\\' 
	} 
	return str.substring(str.lastIndexOf(slash) + 1, str.lastIndexOf('.')) 
}

function scrolly(y){
	window.scrollTo(y);
}

function artistbranding(image){
	//var timestamp = Date.parse(new Date());
	//new Effect.Fade('branding_content', {duration:1.5,afterFinish: function(){
		//document.getElementById('branding_content').innerHTML = '<img src="'+image+'" alt="" onload="new Effect.Appear(\'branding_content\', { duration: 1.5 });">';
	//}});
}

function artistfadeout(){
	new Effect.Fade('branding_content', {duration:0});
	new Effect.Fade('right_navi', {duration:0});
	new Effect.Fade('adpano', {duration:0});
}

function panofadeout(){
	new Effect.Fade('adpano', {duration:0});
}

function load_wallpaper(wallpaper,clickurl){
    document.getElementById('wallpaper').src=wallpaper;
    if(document.getElementById('wallpaper_clickurl')!="undefined"){
        if(clickurl!=""){
            if(document.getElementById('wallpaper_clickurl')){
                document.getElementById('wallpaper_clickurl').innerHTML='<a href="'+clickurl+'" title="Click Here" target="_blank"><img src="/media/gfx/blank.gif" style="width:808px;height:500px" alt="Click Here"></a>';
            }
        }else{
            if(document.getElementById('wallpaper_clickurl')){
                document.getElementById('wallpaper_clickurl').innerHTML='';
            }
        }
    }
}

function artistfadein(image,type){
	document.getElementById('branding_content').innerHTML = '<img src="/covers/828x828/'+image+'/'+image+'.jpg" alt="" onload="new Effect.Appear(\'branding_content\', { duration: 1.5 });">';
    document.getElementById('wallpaper_frame').src="/de/ad/wallpaper.html";
    if(document.getElementById('wallpaper_clickurl')){
        document.getElementById('wallpaper_clickurl').innerHTML='';
    }
}

function artistfadein_first(image,type){
	document.getElementById('branding_content').innerHTML = '<img src="/covers/828x828/'+image+'/'+image+'.jpg" alt="" onload="new Effect.Appear(\'branding_content\', { duration: 1.5 });">';
    document.getElementById('wallpaper_frame').src="/de/ad/wallpaper.html";
}

function add_channel(){
	 new LITBox('/de/add_channel.html', {zindex:1500, type:'window', overlay:false, height:600, width:500, resizable:false, opacity:.6});
}
function scrollcontent(){
	new Effect.Tween(null, 0, 520, function(p){ scrollTo(0,p) });
}

function loadpano(inode,title){
    var so = new SWFObject("/media/flash/adpano2.swf", "adpanoslider", "576", "176", "9", "#336699");
    so.addParam("quality", "high");
    so.addParam("wmode", "transparent");
    so.addParam("allowscriptaccess", "always");
    so.addVariable("promobox_inode", ""+inode+"");
    so.write("adpano");
}

function submitenter(myfield,e){
	var keycode;
	if (window.event){
		keycode = window.event.keyCode;
	}else if (e){
		keycode = e.which;
	}else{
		return true;
	}
	
	if (keycode == 13){
	   check('logpw');
	   return false;
	}else{
	   return true;
	}
}

function clear_search(obj){
    if(obj.value=="Suche"){
        obj.value="";
    }
}

function maximize_adctrl(){
	new Effect.Appear('adtuner_v2', { duration: 1 });
	//new Effect.Scale( "adtuner", 100,{scaleMode: {originalHeight: 260, originalWidth: 537}});
	document.getElementById('adtuner_scale').style.height="260px";
}

function minimize_adctrl(){
	new Effect.Fade('adtuner_v2', { duration: 1 });
	//new Effect.Scale( "adtuner", 100,{scaleMode: {originalHeight: 50, originalWidth: 537}});
	document.getElementById('adtuner_scale').style.height="50px";
}

function info_adctrl(){
	document.getElementById('adtuner_player').SetVariable('minmax', Math.random());
	new Effect.Fade('adtuner_v2', { duration: 1 });
	new Effect.Tween(null, 0, 0, function(p){ scrollTo(0,p) });
	//new Effect.Scale( "adtuner", 100,{scaleMode: {originalHeight: 50, originalWidth: 537}});
	document.getElementById('adtuner_scale').style.height="50px";
}

function show_videoad_layer(){
    document.getElementById('headernavi').style.display="none";
    document.getElementById('mainnavi').style.display="none";
    document.getElementById('company').style.display="none";
    document.getElementById('contentframe').style.display="none";
    document.getElementById('layerframe').style.display="";
}

function hide_videoad_layer(){
    document.getElementById('headernavi').style.display="";
    document.getElementById('mainnavi').style.display="";
    document.getElementById('company').style.display="";
    document.getElementById('layerframe').style.display="none";
    document.getElementById('contentframe').style.display="";
}

function load_videoad(){
    document.getElementById('layerframe').src="/de/videolayer.html";
}

function launch_play(id){
	document.getElementById('adtuner_scale').innerHTML='<div id="adtuner_player" style="position:absolute;z-index:4;overflow:hidden;width:537px;height:260px;padding-left:1px;overflow:hidden">Loading Flash...</div>';
	swfobject.embedSWF("/media/flash/rocca_v2.swf", "adtuner_player", "537", "260", "9.0.0", "",{playhistory_inode:""+id+"",playhistory:"yes",user:"yes"},{wmode:"transparent",menu:"false",allowscriptaccess:"always"});
}
