Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}
var RGO = {	
	Popup: new function() {
    	/**
    	 * ���������� popup
    	 * @param string divId ID ���� � popup'��
    	 */
    	this.openPopup = function( divId, text ) {
    		if(typeof (pageTracker) != 'undefined') {
    			
    		if(text != '' && pageTracker != null) {
    			pageTracker._trackPageview(text);
    		}}
    		
    		divId = '#' + divId;
    		divObject = $(divId);
    		if( divObject.length > 0 ) {
	    		// ��������� ����� popup, ���� � ���������� ���� ��� �� ���
	    		if(! divObject.hasClass('popupDiv') ) {
	    			divObject.addClass('popupDiv');
	    		}
	    		divBgDivObj = this.isBgDivExist();
	    		// ���� ���� �� �� ��������...
	    		if( $(divId + ':hidden').length > 0 ) {
	    			divBgDivObj.css({  
	    				"opacity": "0.7",
	    				"filter": "alpha(opacity=70)",
	    				"width": "100%",
	    				"height": "100%"									
	    			});  
	    			// ���������� popup � ����������� ���
	    			this.centerBox( divObject );
	    			this.resizeWindow();
	    			$(window).bind('resize', function() {
	    				RGO.Popup.centerBox( divObject );
	    				RGO.Popup.resizeWindow();
	    			});
	    			$(window).bind('scroll', function() {
	    				RGO.Popup.centerBox( divObject );
	    				RGO.Popup.resizeWindow();
	    			});
	    			divObject.fadeIn("fast");  
	    			divBgDivObj.fadeIn("fast");  
	    		}
    		}
    	},
    	this.openBgDiv = function( ) {
    		$('body').append( '<div style="width:100%;height:100%;filter:alpha(opacity=70);opacity:0.7;display:none;" id="popupBgDiv" onclick="RGO.Popup.closeAllPopup()"></div>' );
    		$('#popupBgDiv').fadeIn("fast");
    	}
    	this.closeBgDiv = function( ) {
    		$('#popupBgDiv').fadeOut("fast");
    	}
    	/**
    	 * �������� popup
    	 * @param string divId ID ���� � popup'��
    	 */ 
    	this.closePopup = function( divId ) {
    		divId = '#' + divId;
    		divObject = $(divId);
    		if( divObject.length > 0 ) {
    			// ��������� ����� popup, ���� � ���������� ���� ��� �� ���
	    		if(! divObject.hasClass('popupDiv') ) {
	    			divObject.addClass('popupDiv');
	    		}
	    		divBgDivObj = this.isBgDivExist();
	    		// ���� ���� �� �� ��������...
	    		if( $(divId + ':hidden').length <= 0 ) {
	    			divObject.fadeOut("fast");  
	    			divBgDivObj.fadeOut("fast");  
	    		}
    		}
    	},
    	/**
    	 * ���������, ���������� �� ���� � �����. ���� ��� - ������ ��� � ��������� ��� �������
    	 * @return Object ���������� ������ �������� DIV'�
    	 */
    	this.isBgDivExist = function () {
    		// ��������� ���� �� DIV, ����������� ��������, ���� ��� - ������
    		if($('#popupBgDiv').length <= 0) {
    			$('body').append( '<div id="popupBgDiv" onclick="RGO.Popup.closeAllPopup()"></div>' );
    		}
    		return $('#popupBgDiv');
    	},
    	/**
    	 * ��������� ��� �������� popup'�
    	 */
    	this.closeAllPopup = function() {
    		$('.popupDiv').each(function (i) {
    			RGO.Popup.closePopup( this.id );
    		});
    	},
    	/**
    	 * ���������� popup
    	 */
    	this.centerBox = function( box ) {
    		box.css({  
	    		"position": "absolute",  
	    		"top": $(document).scrollTop() + ($(window).height() - box.height()) / 2,  
	    		"left": $(document).scrollLeft() + ($(window).width() - box.width()) / 2  
    		});  
    	},
    	/**
    	 * ��������� ������� ����
    	 */
    	this.resizeWindow = function() {
    		$('popupBgDiv').css({
    			"height": $(document).height(),
    			"width": '100%'
    		});
		}    	
    }
}

jQuery(document).ready(function() {

$(function() {
        $(".frames-rotation").jCarouselLite({
            btnNext: ".next",
            btnPrev: ".prev",
            visible: 5,
            mouseWheel: true
        });
    });
    
    $(".postToggle").click(
        function() {
            var oldshow = $(".toggleDown").attr("show");
            var show = $(this).attr("show");

            $(".postToggle").removeClass("toggleDown");
            $(".postBox:visible").slideUp();

//alert( oldshow +" -- "+show);

        if(oldshow != show){
            $(this).addClass("toggleDown");
            $("#"+show).slideDown("slow");
            }
            }

         );


    /*
    var current_has_submenu = false;

    var attrmenu = $(".currentPage").attr("menu");
    //$(".currentPage").addClass("currentPage");
    var current_bg = $(".currentPage").css('background-color');

    if(attrmenu != '' && attrmenu != undefined ){
        current_has_submenu = true;
    }

    var item_width = 0;
    var ul_width = 0;

    $(".classNav:visible").each(function (i,n) {

    
        var id = $(n).attr("id");
        item_width = $("li[menu="+id+"]").width();
        var position = $("li[menu="+id+"]").position();
        var left = position.left;

      
        $("li",n).each(function (k,m) {
            ul_width += $(m).width();
        });

        if(ul_width > 0){
            //var leftpad = left - (ul_width - item_width);
            
            if(leftpad < left && leftpad > 0){
                //var padText = " "+leftpad+"px";
               // $("ul",this).css({"padding-left" : padText});
            }

        }
	//if( id == 'nav_calendar' ) { // hack by cxbyte // TODO
	//$('#' + id + ' div ul').css('padding-left', $('#top' + id).offset().left - $('#top' + id).width() - 134 + 'px'); }


    });
*/

$(function() {
if($(".entry table")){ // begin
    $(".entry table").each(function (num_t,obj_t) {
    var tab_id = $(obj_t).attr('id');
    if(!$(obj_t).hasClass('No-rgotable') && tab_id != "vkshare0"){
        // #
        $(obj_t).addClass("rgotable");
        $("tr",obj_t).each(function (k,m) {
            var classTd = "tdFirst"
                $("td:first",m).addClass(classTd);
            });
            if(!$("tr:first",obj_t).hasClass('No-coltop')){
                $("tr:first",obj_t).addClass("coltop");
            }
            else{
                $("tr:first",obj_t).addClass("trFirst");
            }
        $(".rgotable tr:nth-child(odd)").addClass("rowB");
    }
    });
} // end
});

if($("#catAll")){
    $("#catAll").addClass("current");
    $("#catNavi span").click(
        function() {
            var cat = $(this).attr("id");

            $("#catNavi span").removeClass("current");
            $(this).addClass("current");
            //alert(cat);
            if(cat == "catAll"){
                $(".galBox").show();
            }
            else{
                $(".galBox").hide();
                //$(".galBox").removeClass("r15");
                $("."+cat).show();
                $(".galBox:visible").each(function (a,b) {
                    //$(b).removeClass("r10");
                    });
            }
        });
}
// moved by JuliaHtml. 
// These strings block work of previous functions (foto rotation, for example).

	if ( $('#toSiteButton').length > 0 ) {
		clip = new ZeroClipboard.Client();
		clip.setText( $('#clipContainer').html() );
		clip.glue( 'toSiteButton' );
		clip.addEventListener('complete',function(){ RGO.Popup.openPopup('toSite'); });
	}
        
});

// --------------- Склонение существительных с числительными

function DeclensionForm($n, $form1, $form2, $form5) {
$n = Math.abs($n) % 100;
$n1 = $n % 10;
if ($n > 10 && $n < 20)
return $form5;
if ($n1 > 1 && $n1 < 5)
return $form2;
if ($n1 == 1)
return $form1;
return $form5;
}