
var baseurl = "http://www.venossi.com/";

var xmlhttp;
	
		
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function suggestion(search,page){
		
		varpage = page;
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=suggestionChanged;
		
		var url= baseurl + "suggestion";
		
		var data = new Array();
		data[0] = search;
		data[1] = page;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function suggestionChanged(){
		if(xmlhttp.readyState==1){
			if(varpage == 0){
			document.getElementById("suggestions").style.display = "block";		
			document.getElementById("suggestions").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' style='float:left; margin-right:10px;' />Searching...";
			} else {	
				document.getElementById("suggestionloader").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' style='float:left;' />";	
			}
		}
		if(xmlhttp.readyState==4){		
			document.getElementById("suggestions").innerHTML = xmlhttp.responseText;
		}	
	}
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function openPlaylist(playlist){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=openPlaylistChanged;
		
		var url="openplaylist";
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("playlist=" + playlist);
	}
	
	function openPlaylistChanged(){
		if(xmlhttp.readyState==1){
			showx('playlistloader');
			document.getElementById('playlistloader').innerHTML = '<img src="images/ajax-loader.gif" />';
		}		
		if(xmlhttp.readyState==4){
			setTimeout("hidex('playlistloader')",300);
			document.getElementById('playlist-content-watch-holder').innerHTML = xmlhttp.responseText;
			showx('playlist-content-watch-holder');
		}	
	}
		
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function add_to_playlist(video_id,playlist_name,video_title,video_duration){
		
		varplaylistname = playlist_name;
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=add_to_playlistChanged;
		
		var url="add-to-playlist";
		
		var data = new Array();
		data[1] = video_id;
		data[2] = playlist_name;
		data[3] = video_title;
		data[4] = video_duration;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function add_to_playlistChanged(){
		if(xmlhttp.readyState==1){
			showx('already-in-playlist');
			document.getElementById('already-in-playlist').innerHTML = "";
		}
		if(xmlhttp.readyState==4){
			document.getElementById('already-in-playlist').innerHTML = xmlhttp.responseText;
			setTimeout("hidex('already-in-playlist')",3000);
			openPlaylist(varplaylistname);		
		}	
	}
	
	
	/*		-------------------------------------------------------------		*/
	
	function drop_add_to_playlist(video_id,playlist_id,video_title,video_duration,source_id){
		
		varsource_id = source_id;
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=drop_add_to_playlistChanged;
		
		var url= baseurl + "drop-add-to-playlist";
		
		var data = new Array();
		data[1] = video_id;
		data[2] = playlist_id;
		data[3] = video_title;
		data[4] = video_duration;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function drop_add_to_playlistChanged(){
		if(xmlhttp.readyState==1){
			document.getElementById('loader-confirm-'+varsource_id).style.display = "block";
			document.getElementById('loader-confirm-'+varsource_id).innerHTML = '<img src="' + baseurl + 'images/ajax-loader.gif" />';		
		}
		if(xmlhttp.readyState==4){
			setTimeout("document.getElementById('loader-confirm-'+varsource_id).innerHTML = xmlhttp.responseText",400);
			setTimeout("document.getElementById('drop-playlist-box-'+varsource_id).style.display = 'none'",400);			
		}	
	}
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function load_drop_playlist(video_id,source_id){
		
		varsource_id = source_id;
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=load_drop_playlistChanged;
		
		var url= baseurl + "load_drop_playlist";
		
		var data = new Array();
		data[0] = video_id;
		data[1] = source_id

		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function load_drop_playlistChanged(){
		if(xmlhttp.readyState==1){
			document.getElementById('loader-confirm-' + varsource_id).innerHTML = '<img src="' + baseurl + 'images/ajax-loader.gif" />';		

		}
		if(xmlhttp.readyState==4){
			document.getElementById('loader-confirm-' + varsource_id).innerHTML = '';
			document.getElementById('drop-playlist-box-' + varsource_id).style.display = "block";
			document.getElementById('drop-playlist-box-' + varsource_id).innerHTML = xmlhttp.responseText;
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	/*		------	REMOVE FROM PLAYLIST	-------------------------		*/
	
	function removeVideo(video_id,playlist_id){
				
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=removeVideoChanged;
		
		var url="remove-from-playlist";
		
		var data = new Array();
		data[0] = video_id;
		data[1] = playlist_id;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function removeVideoChanged(){		
		if(xmlhttp.readyState==4){
			document.getElementById('puca').innerHTML = xmlhttp.responseText;
		}
	}
	

	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function feed_item(content,video_id,feed_action,feed_id,page){
		
		varfeed_id = feed_id;
		varfeed_action = feed_action;
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=feed_itemChanged;
		
		var url= baseurl + "feed-item";
		
		var data = new Array();
		data[0] = content;
		data[1] = video_id;
		data[2] = feed_action;
		data[3] = feed_id;
		data[4] = page;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function feed_itemChanged(){
		
		if(varfeed_action == 'add_feed_item'){
			if(xmlhttp.readyState==1){
				document.getElementById('commentsent').innerHTML = '<img src="images/ajax-loader.gif" />';
			}
			if(xmlhttp.readyState==4){		
				document.getElementById('commentsent').innerHTML = xmlhttp.responseText;
			}
	
		}
		
		if(varfeed_action == 'add_feed_item_home'){
			if(xmlhttp.readyState==1){
				document.getElementById('maincommentloader').style.display = "block";
				document.getElementById('maincommentloader').innerHTML = '<img src="images/ajax-loader.gif" />';
			}
			if(xmlhttp.readyState==4){
				document.getElementById('maincommentloader').style.display = "none";		
				document.getElementById('feed').innerHTML = xmlhttp.responseText;
			}
		}
		
		if(varfeed_action == "remove_feed_item"){
			if(xmlhttp.readyState==1){
				document.getElementById('removefeed-' + varfeed_id).innerHTML = '<img src="images/ajax-loader.gif" />';
			}
			if(xmlhttp.readyState==4){		
				document.getElementById('feed').innerHTML = xmlhttp.responseText;
			}
		}
		
	}
	
	// FEED REPLY
	
	function feed_reply(reply_content, feed_item_id, reply_action, reply_id){
		// reply_id when deleting it
		var_feed_item_id = feed_item_id;
				
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=feed_replyChanged;
		
		var url= baseurl + "feed-reply";
		
		var data = new Array();
		data[0] = reply_content;
		data[1] = feed_item_id;
		data[2] = reply_action;
		data[3] = reply_id;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function feed_replyChanged(){
		if(xmlhttp.readyState==1){
			showx('replyloader-'+var_feed_item_id);
			document.getElementById('replyloader-'+var_feed_item_id).innerHTML = '<img src="' + baseurl + 'images/ajax-loader.gif" />';
		}
		
		if(xmlhttp.readyState==4){
			setTimeout("document.getElementById('reply-'+var_feed_item_id).innerHTML = xmlhttp.responseText;",300);
			setTimeout("hidex('replyloader-'+var_feed_item_id);",300);
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	
	// ADD FAVORITE ARTIST
	
	function favorite(name, action, type, page){
		
		vartype = type;
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=favoriteChanged;
		
		var url= baseurl + "favorite";
		
		var data = new Array();
		data[0] = name;
		data[1] = action;
		data[2] = type;
		data[3] = page;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function favoriteChanged(){	
		if(xmlhttp.readyState==1){
			document.getElementById('favorite-'+vartype+'-loader').style.display = "block";
			document.getElementById('favorite-'+vartype+'-loader').innerHTML = '<img src="' + baseurl + 'images/ajax-loader.gif" />';
		}
		if(xmlhttp.readyState==4){
			document.getElementById('favorite-'+vartype+'-loader').style.display = "none";
			document.getElementById("favorite_" + vartype + "_box").innerHTML = xmlhttp.responseText;
		}
	}
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	
	
	// FAVORITES
	
	function ltfavorite(video_id,action){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=ltfavoriteChanged;
		
		var url="ltfavorite.php";
		
		var data = new Array();
		data[0] = video_id;
		data[1] = action;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function ltfavoriteChanged(){
		if(xmlhttp.readyState==1){
			showx('fvloader');
			document.getElementById('fvloader').innerHTML = '<img src="images/ajax-loader.gif" />';
		}
		if(xmlhttp.readyState==4){
			document.getElementById('ltfavorite').innerHTML = xmlhttp.responseText;
			hidex('fvloader');
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	
	
	function playlistsuggestion(search,playlist,source){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=playlistsuggestionChanged;
		
		var url= baseurl + "playlistsuggestion";
		
		var data = new Array();
		data[0] = search;
		data[1] = playlist;
		data[2] = source;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function playlistsuggestionChanged(){
		if(xmlhttp.readyState==1){
			document.getElementById("playlistloader").style.display = "block";
			document.getElementById("playlistloader").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' />";	
		}
				
		if(xmlhttp.readyState==4){
			document.getElementById("playlistloader").style.display = "none";		
			document.getElementById("playlist-suggestion-box").innerHTML = xmlhttp.responseText;
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function importfromyoutube(username){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=importfromyoutubeChanged;
		
		var url="importfromyoutube.php";
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + username);
	}
	
	function importfromyoutubeChanged(){
		if(xmlhttp.readyState==1){
			document.getElementById("importloader").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' style='float:left; margin-right:10px;' /><p style='font-size:14px;'>Importing data...</p><br /> <p style='margin-left:5px;'>This may take a few seconds or minutes,  please be patient.</p>";	
		}
		
		if(xmlhttp.readyState==4){
			document.getElementById("importloader").style.display = "none";
			document.getElementById("importform").style.display = "none";
			document.getElementById("imported").innerHTML = xmlhttp.responseText;
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function importconfirm(username){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=importconfirmChanged;
		
		var url="importfromyoutube.php";
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("importdata=" + username);
	}
	
	function importconfirmChanged(){
		if(xmlhttp.readyState==1){
			document.getElementById("main-left-content").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' style='float:left; margin-right:10px;' /><p style='font-size:14px;'>Importing playlists...</p><br /> <p style='margin-left:5px;'>This may take a few seconds so please be patient.</p>";	
		}
		
		if(xmlhttp.readyState==4){
			document.getElementById("main-sidebar").style.display = "none";
			document.getElementById("main-left-content").innerHTML = xmlhttp.responseText;
		}	
	}
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function loadbrowsepageloader(tag){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=loadbrowsepageloaderChanged;
		
		var url="browsepage-musicbox.php";
		
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("tag=" + tag);
	}
	
	function loadbrowsepageloaderChanged(){
		if(xmlhttp.readyState==1){
			document.getElementById("hubba").style.display = "block";
			document.getElementById("hubba").innerHTML = "<br /><img src=' " + baseurl + "images/ajax-loader.gif' style='float:left; margin-right:10px;' /> Loading videos...";			
		}
		if(xmlhttp.readyState==4){		
			document.getElementById("hubba").innerHTML = xmlhttp.responseText;
		}	
	}
	
	
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
		
	function clicksearchvideos(name,page){
		
		varpage = page;
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=clicksearchvideosChanged;
		
		var url="loadsimilarvideo.php";
		
		var data = new Array();
		data[0] = name;
		data[1] = page;		
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function clicksearchvideosChanged(){
		
		if(xmlhttp.readyState==1){
			if(varpage == 0){
			document.getElementById("clicksearchvideos").style.display = "block";		
			document.getElementById("clicksearchvideos").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' style='float:left; margin-right:10px;' />Searching...";
			} else {	
				document.getElementById("clicksearchvideosloader").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' style='float:left;' />";	
			}
		}
		
		if(xmlhttp.readyState==4){		
			document.getElementById("clicksearchvideos").innerHTML = xmlhttp.responseText;
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	
	function loadSimilarArtist(artistname,page){
				
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=loadSimilarArtistChanged;
		
		var url="similar-artist-videos";
		
		var data = new Array();
		data[0] = artistname;
		data[1] = page;
	
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function loadSimilarArtistChanged(){
		
		if(xmlhttp.readyState==1){
			document.getElementById("similar-artist-loader").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' />";	
		}
		
		if(xmlhttp.readyState==4){
			document.getElementById("similar-artist-loader").innerHTML = "";
			document.getElementById("similar-artist-videos").style.display = "block";
			document.getElementById("similar-artist-videos").innerHTML = xmlhttp.responseText;
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	

	function loadbrowseplaylists(user_id,playlist_id){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=loadbrowseplaylistsChanged;
		
		var url="browseplaylists.php";
		
		var data = new Array();
		data[0] = user_id;
		data[1] = playlist_id;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function loadbrowseplaylistsChanged(){
		if(xmlhttp.readyState==1){
			document.getElementById("browseplaylists-loader").innerHTML = "<br /><img src=' " + baseurl + "images/ajax-loader.gif' style='float:left; margin-right:10px; margin-left:10px;' /> Loading videos...<div class='clear'></div><br />";
		}
		if(xmlhttp.readyState==4){
			document.getElementById("browseplaylists-loader").innerHTML = "";		
			document.getElementById("browseplaylists").innerHTML = xmlhttp.responseText;
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function playsetting(autoplay,shuffle){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=playsettingChanged;
		
		var url="playsettings";
		
		var data = new Array();
		data[0] = autoplay;
		data[1] = shuffle;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function playsettingChanged(){
		if(xmlhttp.readyState==4){		
			document.getElementById("playsettings").innerHTML = xmlhttp.responseText;
		}	
	}
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	
	/*		FOLLOW		*/
	
	function follow(follow_username,action){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=followChanged;
		
		var url= baseurl + "follow";
		
		var data = new Array();
		data[0] = follow_username;
		data[1] = action;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function followChanged(){
		if(xmlhttp.readyState==1){
			showx('followloader');
			document.getElementById('followloader').innerHTML = '<img src="../images/ajax-loader.gif" />';
		}
		if(xmlhttp.readyState==4){
			document.getElementById('followbox').innerHTML = xmlhttp.responseText;
			hidex('followloader');
		}	
	}
	
	
	
	/*	CREATE NEW PLAYLIST		*/
	
	function newplaylist(playlist_name,video_id){
		// Video ID in case if we are on the videopage
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=newplaylistChanged;
		
		var url= baseurl + "newplaylist";
		
		var data = new Array();
		data[0] = playlist_name;
		data[1] = video_id;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function newplaylistChanged(){
		if(xmlhttp.readyState==1){
			showx('playlistloader');
			document.getElementById('playlistloader').innerHTML = '<img src="' + baseurl + 'images/ajax-loader.gif" />';
		}
		if(xmlhttp.readyState==4){
			setTimeout("document.getElementById('playlistbox').innerHTML = xmlhttp.responseText",400);
			setTimeout("hidex('playlistloader')",400);
		}	
	}
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	
	function artistsearchChanged(){
		if(xmlhttp.readyState==1){		
			document.getElementById("artistsearchloader").style.display = "block";
			document.getElementById("artistsearchloader").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' />";
		}
		if(xmlhttp.readyState==4){		
			document.getElementById("artistsearch").innerHTML = xmlhttp.responseText;
			document.getElementById("artistsearchloader").style.display = "none";	
		}	
	}
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function new_playlist_name(playlist_name,playlist_id){
		
		varplaylist_id 	= playlist_id;
		varplaylistname = playlist_name;
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=new_playlist_nameChanged;
		
		var url="playlist_title.php";
		
		var data = new Array();
		data[0] = playlist_id;
		data[1] = playlist_name;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function new_playlist_nameChanged(){
		if(xmlhttp.readyState==1){
			showx('newplaylistnameloader');
			document.getElementById('newplaylistnameloader').innerHTML = '<img src="images/ajax-loader.gif" />';
		}
		if(xmlhttp.readyState==4){
			setTimeout("document.getElementById('playlist-title').innerHTML = xmlhttp.responseText",600);
			setTimeout("document.getElementById('playlist-title-'+varplaylist_id).innerHTML = '<b>' + varplaylistname + '</b>';",600);
			setTimeout("hidex('newplaylistnameloader')",500);
		}	
	}
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	
	function artistsearchChanged(){
		if(xmlhttp.readyState==1){		
			document.getElementById("artistsearchloader").style.display = "block";
			document.getElementById("artistsearchloader").innerHTML = "<img src=' " + baseurl + "images/ajax-loader.gif' />";
		}
		if(xmlhttp.readyState==4){		
			document.getElementById("artistsearch").innerHTML = xmlhttp.responseText;
			document.getElementById("artistsearchloader").style.display = "none";	
		}	
	}
	
	
	/*		-------------------------------------------------------------		*/
	/*		-------------------------------------------------------------		*/
	
	function unfollow_from_feed(username,feed_page){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=unfollow_from_feedChanged;
		
		var url="unfollow_from_feed";
		
		var data = new Array();
		data[0] = username;
		data[1] = feed_page;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function unfollow_from_feedChanged(){
		if(xmlhttp.readyState==1){
			document.getElementById('maincommentloader').style.display = "block";
			document.getElementById('maincommentloader').innerHTML = '<img src="images/ajax-loader.gif" />';
		}
		if(xmlhttp.readyState==4){
			document.getElementById('maincommentloader').style.display = "none";		
			document.getElementById('feed').innerHTML = xmlhttp.responseText;
		}
	}
	
	
	function playlist_status(playlist_id,status){
		
		xmlhttp=GetXmlHttpObject();
	
		if (xmlhttp==null){
	  		alert ("Browser does not support HTTP Request");
	  		return;
	  	}
		
		xmlhttp.onreadystatechange=playlist_statusChanged;
		
		var url="playlist_status";
		
		var data = new Array();
		data[0] = playlist_id;
		data[1] = status;
		
		xmlhttp.open("POST",url,true);
		
		xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");     
			
		xmlhttp.send("data=" + data);
	}
	
	function playlist_statusChanged(){
		if(xmlhttp.readyState==4){
			document.getElementById('playlist-status').innerHTML = xmlhttp.responseText;
		}
	}
	
	
	function GetXmlHttpObject(){
		
		if (window.XMLHttpRequest){
	  		// code for IE7+, Firefox, Chrome, Opera, Safari
	  		return new XMLHttpRequest();
	  	}
	
		if (window.ActiveXObject){
	 		// code for IE6, IE5
	  		return new ActiveXObject("Microsoft.XMLHTTP");
	  	}
	
		return null;
	}
	
	
