function usertt(div) {
<!--
  if (div != '') div = '#' + div;
  $(div+' a[href*="user/"]').each(function(index,element) {
	var user = element.href.replace("user/","");
	user = user.replace("http://www.music.lt/","");
	if(user.search(/\//) < 0){	//tikrina ar vartotojo nuoroda, t.y. ar nera pu user/..
	    jQuery(element).poshytip({
	    	alignY: 'bottom',
	    	className: 'tip-white',
	    	content: function(updateCallback) {
	    		jQuery.get('/ajax.php?main;user.'+user, function rc(t){updateCallback(t)});
	    		return 'Įkeliama...';
	    	}
	    });
	}
  });
  return true;
//-->
}
function stylett(div) {
	  if (div != '') div = '#' + div;
	  $(div+' a[href*="-stilius-"]').each(function(index,element) {
		var style =  element.href.replace(".html","");
		var patt=/^(.+)-stilius-/g;
		style =  style.replace(style.match(patt),"");
		jQuery(element).poshytip({
			alignY: 'bottom',
	    	className: 'tip-white',
	    	content: function(updateCallback) {
	    		jQuery.get('ajax.php?main;style.'+style, function rc(t){updateCallback(t)});
	    		return 'Įkeliama...';
    		}
		});
	  });
	  return true;
}
function stylett2(div) {
	  if (div != '') div = '#' + div;
	  $(div+' a[href*="stilius/"]').each(function(index,element) {
		var style = '';
		style = element.href.replace("stilius/","");
		style = style.replace("http://www.music.lt/","");
		style = style.replace("{/literal}{$cms_language}{literal}","");
		style = style.split("/");
		style = style[2];;
		jQuery(element).poshytip({
			alignY: 'bottom',
	    	className: 'tip-white',
	    	content: function(updateCallback) {
	    		jQuery.get('ajax.php?main;style.'+style, function rc(t){updateCallback(t)});
	    		return 'Įkeliama...';
    		}
		});
	  });
	  return true;
}
function games_guess_tt(id) {
	  $('a[name*="games_guess_winners"]').each(function(index,element) {
		  jQuery(element).poshytip({
			alignY: 'bottom',
	    	className: 'tip-white',
	    	content: function(updateCallback) {
		  		jQuery.get('ajax.php?games;guess_winners.'+id, function rc(t){updateCallback(t)});
		  		return 'Įkeliama...';
			}
		  });
	  });
	  return true;
}
function comments_tt(modid, itemid) {
	  $('a[name*="m_'+modid+'_i_'+itemid+'_tt"]').each(function(index,element) {
		  jQuery(element).poshytip({
			alignY: 'bottom',
	    	className: 'tip-white',
	    	content: function(updateCallback) {
		/*	  if(jQuery('#calendar').length > 0){
				  	date = jQuery('#calendar').DatePickerGetDate(true);
				  	jQuery.get('ajax.php?favorite;mod.'+modid+';item.'+itemid+';from.'+date[0]+';to.'+date[1], function rc(t){updateCallback(t)});
			  		return 'Įkeliama...';



			  }else{*/

				  	jQuery.get('ajax.php?favorite;mod.'+modid+';item.'+itemid, function rc(t){updateCallback(t)});
			  		return 'Įkeliama...';
			//  }

			}
		  });
	  });
	  return true;
}
function comments_star_tt(modid, itemid) {
	  $('a[name*="m_'+modid+'_i_'+itemid+'_link_tt"]').each(function(index,element) {
		  jQuery(element).poshytip({
			alignY: 'bottom',
	    	className: 'tip-white',
	    	content: function(updateCallback) {
			  	jQuery.get('ajax.php?favorite;modid.'+modid+';itemid.'+itemid, function rc(t){updateCallback(t)});
		  		return 'Įkeliama...';
			}
		  });
	  });
	  return true;
}


function groups_info_tt(id) {
	  $('a[name*="group_'+id+'_tt"]').each(function(index,element) {
		  jQuery(element).poshytip({
			alignY: 'bottom',
	    	className: 'tip-white',
	    	content: function(updateCallback) {
			  	jQuery.get('ajax.php?groups;info.'+id, function rc(t){updateCallback(t)});
		  		return 'Įkeliama...';
			}
		  });
	  });
	  return true;
}

function song_info_tt(div)
{
	if (div != '') div = '#' + div;
	$(div+' a[href*="daina/"]').each(function(index,element) {
		var song = '';
		song = element.href.replace("daina/","");
		song = song.replace("http://www.music.lt/","");
		song = song.replace("{/literal}{$cms_language}{literal}","");
		song = song.split("/");
		song = song[2];
		if(parseInt(song) > 0){
			jQuery(element).poshytip({
				alignY: 'bottom',
				className: 'tip-white',
				content: function(updateCallback) {
					jQuery.get('/ajax.php?main;song.'+song, function rc(t){updateCallback(t)});
					return 'Įkeliama...';
				}
			});
		}
  });
  return true;
//-->
}
function group_info_tt(div)
{
	if (div != '') div = '#' + div;
	$(div+" a[href*='grupe/']").each(function(index,element) {
		var song = '';
		var song = element.href.replace("grupe/","");
		song = song.replace("http://www.music.lt/","");
		song = song.replace("{/literal}{$cms_language}{literal}","");
		song = song.split("/");
		song = song[2];
		if(parseInt(song) > 0){
			jQuery(element).poshytip({
				alignY: 'bottom',
				className: 'tip-white',
				content: function(updateCallback) {
					jQuery.get('/ajax.php?main;group.'+song, function rc(t){updateCallback(t)});
					return 'Įkeliama...';
				}
			});
		}
	});
}
function album_info_tt(div) {
	  if (div != '') div = '#' + div;
	  $(div+' a[href*="-albumas-"]').each(function(index,element) {
		var style =  element.href.replace(".html","");
		var patt=/^(.+)-albumas-/g;
		style =  style.replace(style.match(patt),"");
		if(parseInt(style) > 0){
			jQuery(element).poshytip({
				alignY: 'bottom',
		    	className: 'tip-white',
		    	content: function(updateCallback) {
		    		jQuery.get('ajax.php?main;album.'+style, function rc(t){updateCallback(t)});
		    		return 'Įkeliama...';
	    		}
			});
		}
	  });
	  return true;
}
function album_info_tt2(div) {
	  if (div != '') div = '#' + div;
	  $(div+' a[href*="albumas/"]').each(function(index,element) {
		var album = element.href.replace("albumas/","");
		album = album.replace("http://www.music.lt/","");
		album = album.replace("{/literal}{$cms_language}{literal}/","");
		album = album.split("/");
		album = album[2];
		if(parseInt(album) > 0){
			jQuery(element).poshytip({
				alignY: 'bottom',
		    	className: 'tip-white',
		    	content: function(updateCallback) {
		    		jQuery.get('ajax.php?main;album.'+album, function rc(t){updateCallback(t)});
		    		return 'Įkeliama...';
	    		}
			});
		}
	  });
	  return true;
}


jQuery(document).ready(function()
{
	usertt('');
	stylett('');
	stylett2('');
	song_info_tt('');
	//song_info_tt2('');
	group_info_tt('');
	album_info_tt('');
	album_info_tt2('');

});

//deleting tags
function admin_delete_tag(tag, id, mod)
{
	jQuery.ajax({
		url: "ajax.php?tags;rem_tags."+tag+";item."+id+";mod."+mod,
		success: function( data ) {
			jQuery("#song_tags").html(data);
		}
	});
}

function beta_rate_it(mod, item, action)
{
	string="action="+action+"&mod="+mod+"&item="+item;
	jQuery.ajax({
		url: "ajax.php?beta;rate_it;",
		type: "POST",
		data: string,
		success: function( data ) {
			//do nothing
		}
	});
}
jQuery(document).ready(function(){
	//add title and alt to new_window icons
	//small icon
	jQuery("img[src$='new_window.gif']").attr("alt", "Atidaryti grotuvą naujame lange");
	jQuery("img[src$='new_window.gif']").attr("title", "Atidaryti grotuvą naujame lange");
	//large icon
	jQuery("img[src$='icon_new_window_big.gif']").attr("alt", "Atidaryti grotuvą naujame lange");
	jQuery("img[src$='icon_new_window_big.gif']").attr("title", "Atidaryti grotuvą naujame lange");
})
function update_jp_rates(rate, mod, item)
{
	$("#jp_rate_"+mod+"_"+item).html(rate);
}
function radio_player_album(id)
{
	$.ajax({
		url: '/ajax.php?beta;session_add;item.'+id+';mod.10',
		success: function( data ) {
			jp_change_player();
			jp_change_song();
			window.r_first = 0;
		}
	});
}
function radio_player_group(id)
{
	$.ajax({
		url: '/ajax.php?beta;session_add;item.'+id+';mod.5',
		success: function( data ) {
			jp_change_player();
			jp_change_song();
			window.r_first = 0;
		}
	});
}

function load_more_coments(id)
{
	//alert(id);
	$("#com"+id).poshytip({
		alignY: 'bottom',
		className: 'tip-white',
		content: function(updateCallback) {
			jQuery.get('/ajax.php?beta;more_comments;item.'+id, function rc(t){updateCallback(t)});
			return 'Įkeliama...';
		}
	});
}

function play_list(id)
{
	$.ajax({
		url: '/ajax.php?beta;session_add;item.'+id+';mod.65',
		success: function( data ) {
			jp_change_player();
			jp_change_song();
			window.r_first = 0;
		}
	});
}

function update_thread(id)
{
	page = $("#page_id_"+id).attr("rel");
	mid = $("#comments_"+id+">.comment_id").first().attr("rel");
	if (page == 1){
		$.ajax({
			url: '/ajax.php?forum;update_thread.'+id+';last.'+mid,
			success: function( data ) {
				$("#comments_"+id).prepend(data);
				$('.posh_me').poshytip('destroy');
				$('.posh_me').poshytip({className: 'tip-white'});
			}
		});
	}
}
