//ajax

var sel;
var url_last;
var fl =0;
/*
var settings1 = {
	  tl: { radius: 10 },
	  tr: { radius: 10 },
	  bl: { radius: 10 },
	  br: { radius: 10 },
	  antiAlias: true
}
*/

function formatTitle(title, currentArray, currentIndex, currentOpts) {
				//alert(currentIndex + ' --- ' +$("input#vote"+currentIndex).val());
				arr = title.split(" | ");
				//if(arr[1]!=''){arr[1]+='<br>';}
				if(arr[3]!=''){arr[3]='<br>'+arr[3];}
				rr = currentArray[currentIndex].rel;
				url = arr[0].replace(/ /g, "-");
				url = url.replace(".", "");
				if($("a[rel='"+rr+"'] input#voted-"+rr+"-"+currentIndex).val()==0){
					likes = '<div class="like-block"><a class="vote intext" onclick=\'vote("'+$("input#votedimg-"+rr+"-"+currentIndex).val()+'",'+currentIndex+',"'+rr+'","'+$("#fancybox-img").attr('src')+'"); return false;\'>Like&nbsp;<span>♥</span></a>&nbsp;<span id="vote-num" class="gold">'+$("a[rel='"+rr+"'] input#vote-"+rr+"-"+currentIndex).val()+'</span></div>';	
				}else{
					likes = '<div class="like-block"><span class="vote">Like&nbsp;<span>♥</span></span>&nbsp;<span id="vote-num" class="gold">'+$("a[rel='"+rr+"'] input#vote-"+rr+"-"+currentIndex).val()+'</span></div>';
				}
				
				return '<div class="descr-block">'+ likes +'<div class="name"><span style="color:#fff">'+  arr[1] +'</span></div><div class="copy"><strong><a href="/artists/'+url+'" class="intext">'+arr[0]+'</a></strong>; Copyright&nbsp;&copy;' + arr[2] + arr[3] + '</div><div class="clear"></div></div>';
				
}
function vote(name,nom,rel,img){
	//alert(name);
		$.ajax({
				type	: "POST",
				cache	: false,
				dataType: 'json',
				url		: "/ajax/ajax_vote.php",
				data	: {  'name':name, 'img':img },
				success: function(data) {
					
					  $("a.vote").replaceWith('<span class="vote">'+$('a.vote').html()+'</span>');
					  if(data.hits!=null) { 
						  $("#vote-num").text(data.hits); 
						  $("a[rel='"+ rel +"'] #vote-"+rel+"-"+nom).val(data.hits);
						  $(".w-voted-"+data.wid).val('1');
					  }

				}
		});
}

var did_you_know = function(nom){

		$.ajax({
				type	: "POST",
				cache	: false,
				dataType: 'json',
				url		: "/ajax/ajax_did_you_know.php",
				data	: {  'nom':nom },
				//$(this).serializeArray(),
				success: function(data) {
					
					$('.did-you-know-content').html(data.kod);
					$("a.did-you-know").attr('href', 'javascript: did_you_know(' + data.id + ')');

				}
		});
}

function artcube(id,fold,n,name,lg)
{
	kod = "";
	for (i=1; i<=16;i++)
	{
		kod += "<div class='load_img'>load</div>";
	}
	$('#_artcube').html(kod);

	$.ajax({
			type	: "POST",
			cache	: false,
			dataType: 'text',
			url		: "/ajax/ajax_load_img.php",
			data	: {
						   'fold':fold,
						   'id':id,
						   'n':n,
						   'name':name,
						   'lg':lg
					   },
			success: function(data) {
				
					$('#_artcube').html(data);
					$("#_artcube a.fncy").fancybox({
							'padding': 5,
							'titlePosition' 		: 'inside',
							'titleFormat'		: formatTitle,
							'onComplete': notallowsave
					});
					artcube_g();

			}
	});
}
function artist_pages(i,n,sp,lg, comma)
 {
	$.ajax({
			type	: "POST",
			cache	: false,
			dataType: 'text',
			url		: "/ajax/ajax_artist_page.php",
			data	: {
						    'i': i,
							'n': n,
							'lg': lg,
							'sp': sp,
							'comma': comma
					   },
			success: function(data) {
				
					$('#art_page_bl').html(data);
					hoverIO();
			}
	});
}

function notallowsave(){
	  $("#fancybox-inner img").mousedown(function(e) {
		  if( 1 == e.which || 3 == e.which) {
			  $(this).bind("contextmenu",function(e){
				  return false;
			  });
			  return false;
		  }
	  });
}
