$(document).ready(
	function(){
		
		//pikaruk blog vstavka photo block
		var number_photo_block=1;
		$("#link_add_photo").click(function () {
				number_photo_block++;
				var block_text = $("#blog_block_photo").html();
				var reg=/---/g;
				
				//alert();
				//$("<td></td>").html=block_text.replace(reg,number_photo_block)
			
				$("#tr_add_photo").before('<tr ><td>'+block_text.replace(reg,number_photo_block)+'</td></tr>');
				
				
				
				
												 
		});
		
		//pikaruk expert question block main page
		$("#questMinus").click(function () {


			$("#ul_quest/li:visible:last").hide();
		   });

		  $("#questPlus").click(function () {
			$("#ul_quest/li:hidden:first").show();

	  		 });

		 $("a[@id^=quest_a]").click(function () {

			var str =$(this).attr('id');
			var id= str.substr(7);

			  $("span[@id^=quest_span]").hide();
			  $("#quest_span"+id).show();
	  		 });
		
		
		
		//show gray div and autorization popup	   
	     $("#loginLinkToogle").click(function () {
			toogleAutunoficaton();							   
			   
	   });
		//hide gray div and autorization popup
	   $("#ui-gray").click(function () {
			toogleAutunoficaton();			
			});
		
		
		// Toggle Single Portlet
		$('a.toggle').click(function()
            {
                //$(this).parent('div').parent('div').parent('div').next('div').slideToggle('fast', function (){
                $(this).parent().parent().parent().next().slideToggle('fast', function (){
                    var img = $(this).prev('div').children('div').children('div').children('a').children('img');
                    
                    if(img.attr('src') == '/images/openClose.png')
                        img.attr('src', '/images/openClose2.png');
                    else
                        img.attr('src', '/images/openClose.png');
                
                }
                
                
                );
                return false;
            }
        );
        
        $('a.toggle2').click(function()
			{
                $(this).parent().parent().parent().next().slideToggle('fast');
				return false;
			}
		);
        
		// postovit acronym design
		$('#content acronym').each(function(i){
					var title=$(this).attr('title');
					$(this).attr('titleserega',title);
					$(this).attr('title','');
		});
		function acronim(){
		$('#content acronym').mouseover(
				function () 
				   {
					$(this).css("position","relative");
					$(this).append('<span><b class="b_top"></b><b class="b_center">'+$(this).attr('titleserega')+'</b><b class="b_bottom"></b></span>'); 
				   }
				).mouseout (
				function ()
					{
						$(this).css("position","inherit");
					 $(this).find('span').css('display','none');			
					}	   
				)
		}
		acronim();
		
	}
);
// banzalik functions box
function toogleAutunoficaton ()
{
	if ($.browser.msie)
	{ 
       	   with ($('div.ui-gray') ){
           height($(document.body).height()+7);
           width($(document.body).width());
           toggle();
       }
	  $('div.authoriz').toggle();
	}
	else
	{
	  $('div.authoriz').slideToggle('fast'); 
       	   with ($('div.ui-gray') ){
           height($(document.body).height()+7);
           width($(document.body).width());
           toggle();
       }
	}
}
