var buying = new Array();

$(document).ready(function(){
	$("#artistname").focus();
	$("a").not(".noTip").tooltip();

	$().ajaxStart(ajaxStart);
	$().ajaxStop(ajaxStop);

	var loader = $("body").append("<div id='mainLoader'><div>" + ajaxMessages.wait + "</div></div>");

	$(window).scroll(function()
	{
	   	$('#mainLoader').css('top', $(this).scrollTop() + "px");
	});
});

function ajaxStart()
{
	var loader = $('#mainLoader');

   	loader.show();
}

function ajaxStop()
{
	$("#mainLoader").hide();
}

function buy(id)
{
	if(id > 0 && jQuery.inArray(id,buying) == -1)
	{
		buying.push(id);

		var oldSrc = $("#buyimg_" + id).attr("src");
		$("#buyimg_" + id).hide();
		var loader = $("#buyimg_" + id).parent().after("<img class='loader' align='absmiddle' src='/images/loader.gif' />");
		$("#basket_small").load("/buy_ajax.php?buy_id=" + id, false, function() {
    		$(".loader").remove();
			$("#buyimg_" + id).show();

			len = buying.length;

			for(i = 0; i < len; i++)
			{
				if(buying[i] == id)
					buying.splice(i,1);
			}
		} );
	}
}

function openCommentForm() {

  if(document.getElementById("review_add").style.display == "block")
    document.getElementById("review_add").style.display = "none";
  else
    document.getElementById("review_add").style.display = "block";

}


function openplayer(id)
{
  var win = open("/player.php?id="+id,'player',"width=295,height=200,toolbar=no,status=no,menubar=no");

}

function change(el1,el2txt, elid)
{
  el2 = $("#" + el2txt);
  if(el2)
  {
    if(el1.selectedIndex != 0)
    {
      el2.val(el1.options[el1.selectedIndex].text);

      hidEl = $("#" + elid);
      if(hidEl)
        hidEl.val(el1.options[el1.selectedIndex].value);
    }
    else
    {
      el2.value = "";
    }
  }
  el1.selectedIndex = 0;
}


function PShowWaitMessage(arg1, arg2)
{
	ajaxStart();
}

function PCloseWaitMessage(arg1, arg2)
{
	ajaxStop();
}