var state=0;
$(document).ready(function(){
  	$('#pickerContent').hide();
  	$('#hidePaleta').click(function(){
  		  $('#showColors').click();
  	});
    $('#pickerContent').draggable();
    $('#picker').farbtastic('#contentImages');
    $('#showColors').click(function(){
        if (state){
        	$('#pickerContent').hide("normal");
        	$('#showColors').attr("value","Mostrar Colores");
        	state=0;
        }else{
        	$('#pickerContent').show("normal");
        	$('#showColors').attr("value","Ocultar Colores");
        	
        	state=1;
        }
     });
});

function appearItems()
{
    $("#contentGalery").animate({
        opacity:1
    }, 300);
}

function loadHTML(html){
	$("#contentGalery").attr("innerHTML",html);
}

function hideDiv()
{
	$("#contentGalery").hide(0);
}


function loadPicture(idArtist)
{
	$.post("ajax_image.php",{
             idArtist: idArtist,
             option  : "loadPicture"
           }, function(html) {
           	 $("#contentGalery").animate({
                       opacity:0
                     }, 300, function(){
    	                 $("#contentGalery").attr("innerHTML",html);
                      });
           	          setTimeout('appearItems()',305);
           	          appearItems();
     });
     
     $.post("ajax_image.php",{
             idArtist: idArtist,
             option  : "changeName"
           }, function(html) {
           	     //disappearItems();
           	     $("#titleArtist").attr("innerHTML",html);
           	     //appearItems()
     });
     
}

function changePicture(idArtist,idPicture){
	$.post("ajax_image.php",{
             idArtist: idArtist,
             idPicture:idPicture,
             option  : "changePicture"
           }, function(html) {
           	        $("#contentGalery").animate({
                       opacity:0
                     }, 300, function(){
    	                 $("#imageBig").attr("innerHTML",html);
                      });
           	          setTimeout('appearItems()',310);
           });
}