/*===========Function For Showing Recent Songs In Player Window 2=================*/
function getRecentSongs(channel_id){
	new ajax ('ajax.php', {postBody: 'method=recentsongs&channel_id='+channel_id, onComplete: getRecentSongs_callback,userVariable: channel_id});
}

function getRecentSongs_callback(request,uservar){
	if(request!=null){			
		if(request.responseText.isJSON()){					
			response = request.responseText.evalJSON();
			for(i=0;i<response.songs.length;i++){					
				$("song_artist_display"+i).innerHTML=response.songs[i].ArtistName+" / "+response.songs[i].SongName;					
				if(response.songs[i].ArtistImage=='images/hk_no_picture.gif'){
					$("artistimage"+i).innerHTML="<img  src=\"images/hk_no_picture.gif\" alt=\"Artist Image 70x70\" width=\"70\" height=\"70\" border=\"0\">";
				}else{						
					$("artistimage"+i).innerHTML="<a  href=\""+response.songs[i].ArtistDetailsLink+"\" target=\"_blank\"><img  src=\""+response.songs[i].ArtistImage+"\" alt=\"Artist Image 70x70\" width=\"70\" height=\"70\" border=\"0\"></a>";
				}
				$("buylink"+i).src="http://www.hkgfm.net/index.php?p=amazonbuy&ArtistName="+response.songs[i].ArtistName;
			}
			setTimeout(getRecentSongs(uservar), 20000);
		}
	}
}

/*===========Function For Showing Recent Songs In Player Window 2=================*/
/*===========Function For Showing Recent Songs For Differenet Channels In Home Page=================*/
function getHomePageChannelSongs(){
	new ajax ('ajax.php', {postBody: 'method=homepagechannelsongs', onComplete: getHomePageChannelSongs_callback});
}

function getHomePageChannelSongs_callback(request,uservar){
	if(request!=null){
		if(request.responseText.isJSON()){
			response = request.responseText.evalJSON();				
			for(i=0; i<response.channels.length; i++){
				$("channel_"+response.channels[i].channel_id+"_0").innerHTML = response.channels[i].artist_name+"<br><span class='song_info'>"+response.channels[i].song_name+"</span>";
			}
			setTimeout(getHomePageChannelSongs, 20000);		
		}
	}
}
/*===========Function For Showing Recent Songs For Differenet Channels In Home Page=================*/
/*===========Function For Showing Recent Songs For Differenet Channels In Player Window 2 Left======*/
function getPlayerLeftChannelSongs(){
	new ajax ('ajax.php', {postBody: 'method=homepagechannelsongs', onComplete: getPlayerLeftChannelSongs_callback});
}

function getPlayerLeftChannelSongs_callback(request,uservar){
	if(request!=null){
		if(request.responseText.isJSON()){
			response = request.responseText.evalJSON();				
			for(i=0; i<response.channels.length; i++){
					if($("playerLeftChannel"+response.channels[i].channel_id)!=null){
							$("playerLeftChannel"+response.channels[i].channel_id).innerHTML ="<span class='title2'>Playing:</span> "+response.channels[i].artist_name+" / "+response.channels[i].song_name;		
					}
			}
			setTimeout(getPlayerLeftChannelSongs, 20000);		
		}
	}
}

/*===========Function For Showing Recent Songs For Differenet Channels In Player Window 2 Left======*/