function print_r(obj,pre,child){
	if(pre === undefined)   pre   = false;
	if(child === undefined) child = 0;

	var n  = "\n";
	var t  = "&nbsp;&nbsp;&nbsp;&nbsp;";
	var ts = "";

	if(pre) for(var i = 0; i <= child; i++) ts += t;

	if(obj.constructor == Array || obj.constructor == Object)
	{
		if(pre && child == 0)
		{
			document.write('<pre>'+n);
			document.write('Array'+n);
			document.write('('+n);
		}
		else if(pre && child > 0)
		{
			document.write(ts+'('+n);
		}
		else
		{
			document.write('Array (');
		}

		for(var value in obj)
		{
			if(obj[value].constructor == Array|| obj[value].constructor == Object)
			{
				var newChild = child + 1;

				if(pre && child == 0)
				{
					document.write(ts+'['+value+'] => Array'+n);
				}
				else if(pre && child > 0)
				{
					document.write(ts+t+'['+value+'] => Array'+n);
					newChild++;
				}
				else
				{
					document.write(" ["+value+"] => ");
				}

				print_r(obj[value],pre,newChild);
			}
			else
			{
				if(pre && child == 0)
				{
					document.write(t+'['+value+'] => '+obj[value]+n);
				}
				else if(pre && child > 0)
				{
					document.write(ts+t+'['+value+'] => '+obj[value]+n);
				}
				else
				{
					document.write(' ['+value+'] => '+obj[value]+' ');
				}
			}
		}

		if(pre && child == 0)
		{
			document.write(') ');
			document.write('</pre>');
		}
		else if(pre && child > 0)
		{
			document.write(ts+') '+n);
		}
		else
		{
			document.write(') ');
		}
	}
}




function mycarousel_initCallback(carousel) {
	car1 = carousel;
	/*$('.jcarousel-control a').bind('click', function() {
		carousel.scroll($.jcarousel.intval($(this).text()));
		return false;
	});*/
};

  
(function($) {
	var userAgent = navigator.userAgent.toLowerCase();
	$.browser = {  
		version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1],
		safari: /webkit/.test( userAgent ),
		opera: /opera/.test( userAgent ),
		msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
		mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
	};
})(jQuery);
  
     
$(document).ready(function() {
	
    $('#mycarousel').jcarousel({
        initCallback: mycarousel_initCallback
    });
	
	
	$('img.thumb_img').css('opacity','0.5');
	$("img.thumb_img").mouseover(
		function(){
			$(this).animate({ opacity: 1 }, 500 );
		}
	);
	$("img.thumb_img").mouseout(
		function(){
			$(this).animate({ opacity: 0.5 }, 500 );
		}
	);
	$('img.curr_img').css('opacity','1');
	$('img.curr_img').unbind("mouseover");
	$('img.curr_img').unbind("mouseout");

});


function ajaxRequest(urli,datai) {
	var aj = $.ajax({
		  type: "get",
		  url: urli,
		  data: datai,
		  dataType: "json",
		  success: getResponse,
		  beforeSend: showLoad
	});
}



function getResponse(oReq) {
	var json = oReq;
	if (json.status=="1"){
		id_curr=json.curr;
		id_prev=json.prev;
		id_next=json.next;
		
		car_set = id_curr-1;
		car1.scroll(car_set);
		
		
		
		if (!isNaN(parseInt(json.id_autor))){
		
			objImagePreloader.onload = function() {
				$('#big_img').attr('src',objImagePreloader.src);
				h = $('#big_img').height();
				if (h<345){
					margin = (345-h)/2;
				}else{
					margin = 0;
				}
				$('#pr_main_img').css('margin-top',margin+'px');
			
				objImagePreloader.onload=function(){};
				$('#ico-loading').hide();
				$('#big_img').show();
			
				$('#enlarge').show();
				//xx = $('a.work_box').lightBox();
			

			}

			$('#big_img').attr('src',json.photo);
			objImagePreloader.src = json.photo;
		
		
			$('#pr_main_img').attr('href','/artists/'+json.id_autor+'/');
			$('#br_title').html(json.title);
			$('#pr_main_img').attr('title','<i>'+json.title+'</i> '+json.descr1);
		}else{
			$('#ico-loading').hide();
			
			h = $('#size_'+id_curr).attr('rel');
			//alert(h);
			if (h<345){
				margin = (345-h)/2;
			}else{
				margin = 0;
			}
			$('#b_img_'+id_curr).css('margin-top',margin+'px').css('display','block');
			//$('#b_img_'+id_curr).show();
			//$('#pr_main_img').attr('href',json.photo_big);
			$('#br_title').html('<i>'+json.title+'</i> '+json.descr1);
		}
		
		
		
		
				
		if (id_prev==0&&id_curr==0) $('a.pr-prev').addClass('pr-prev-disabled');
		else $('a.pr-prev').removeClass('pr-prev-disabled');
		
		if (id_next==0) $('a.pr-next').addClass('pr-next-disabled'); 
		else $('a.pr-next').removeClass('pr-next-disabled');
		
		
		
	
		
	}else{

	}
}


function showLoad () {
	$('#big_img').hide();
	$('#big_img').attr('src','');
	$('.work_box').hide();
	$('#enlarge').hide();
	$('#ico-loading').show();
	
}


function getPrev(){
	getImage(id_prev);
}

function getNext(){
	getImage(id_next);
}

function getImage(id){
	$('img.curr_img').css('opacity','0.5');
	$("img.curr_img").mouseover(
		function(){
			$(this).animate({ opacity: 1 }, 500 );
		}
	);
	$("img.curr_img").mouseout(
		function(){
			$(this).animate({ opacity: 0.5 }, 500 );
		}
	);
	$('.thumb_img').removeClass('curr_img');
	$('#img_'+id).addClass('curr_img');
	$('img.curr_img').css('opacity','1');
	$('img.curr_img').unbind("mouseover");
	$('img.curr_img').unbind("mouseout");
	
	
	
	
	
	ajaxRequest('/'+ajax_link+'/'+id_link+'/'+id+'/', '');
	
	
}

function changeImage(id){
	$('.im_'+id).hide();
	$('.im_h_'+id).show();

}

function restoreImage(id){
	$('.im_h_'+id).hide();
	$('.im_'+id).show();
}





