function showPic(Src,Text){
    if (Text==undefined) Text='';
    Gallery_ShowSimple(Src,Text);
}

function showPicGal(ObjName,ImgId){
    Gallery_Show(ObjName,ImgId);
}

jQuery.preloadImages = function(){
  for(var i = 0; i<arguments.length; i++)  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}


function HeadImgSlider() {
    $('#headimg2').fadeOut("slow", function() {
        headimgs.length++;
        var crt = (headimgs.length) % headimgscnt;
        var crt2 = (headimgs.length+1) % headimgscnt;
        $(this).parent().attr('href',headimgs[crt][0]);
        $(this).attr('src', headimgs[crt][1]).fadeIn("slow",function(){
            $('#headimg1').attr('src', headimgs[crt2][1]);
        });
    });
}

function AfisImgSlider() {
    $('#afisimg2').fadeOut("slow", function() {
        afisimgs.length++;
        var crt = (afisimgs.length) % afisimgscnt;
        var crt2 = (afisimgs.length+1) % afisimgscnt;
        
        $(this).unbind('click');
		$(this).click(function() {
		  showPicGal('Gallery_piese_afis_bal',crt);
		});        
        
        $(this).attr('src', afisimgs[crt][1]).fadeIn("slow",function(){
            $('#afisimg1').attr('src', afisimgs[crt2][1]);
        });
    });
}


function PortreImgSlider() {
    $('#portreimg2').fadeOut("slow", function() {
        portreimgs.length++;
        var crt = (portreimgs.length) % portreimgscnt;
        var crt2 = (portreimgs.length+1) % portreimgscnt;
        
        $(this).unbind('click');
		$(this).click(function() {
		  showPicGal('Gallery_cv_portre_bal',crt);
		});        

        $(this).attr('src', portreimgs[crt][1]).fadeIn("slow",function(){
            $('#portreimg1').attr('src', portreimgs[crt2][1]);
        });
    });
}

function PregImgSlider() {
    $('#pregimg2').fadeOut("slow", function() {
        pregimgs.length++;
        var crt = (pregimgs.length) % pregimgscnt;
        var crt2 = (pregimgs.length+1) % pregimgscnt;
        $(this).parent().attr('href',pregimgs[crt][0]);
        $(this).attr('src', pregimgs[crt][1]).fadeIn("slow",function(){
            $('#pregimg1').attr('src', pregimgs[crt2][1]);
        });
    });
}


var ttTimeOut = 0;
function tthover(obj, title){
	ttphover();
	var jobj = $(obj);

	//$("body").append("<p id='tooltip' OnMouserOver='javascript:ttphover();' OnMouserOut='javascript:ttpout();'>"+ title +"</p>");
	var position = jobj.position();

	$("#tooltip")
		.html(title)
		.css("top",(position.top + 20) + "px")
		.css("left",(position.left - 10) + "px")
		.fadeIn("fast");
}

function tthide(){
	$("#tooltip").fadeOut("fast");
}


function ttout(){
	ttpout();
}

function ttphover(){
	if (ttTimeOut) clearTimeout(ttTimeOut);
}

function ttpout(){
	ttTimeOut = setTimeout('tthide()', 1000);
}

