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");
            }
            }

         );

$(".slideBox").click(
function() {
    var show = $(this).attr("show");

    if($(this).hasClass("slideDown")){
        $("."+show).slideUp();
        $(this).removeClass("slideDown");
    }
    else{
        $("."+show).slideDown();
        $(this).addClass("slideDown");
        if($(this).attr("id")== "mapSlider"){
           google.maps.event.trigger(map, 'resize');
            map.fitBounds(bounds);
        }
    }
});

    

$(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'); });
	}

//-----------------------------------------------------------------------
$(".parts-switcher li span").click(
function() {

    if($(this).hasClass("current")){
        $(".meta-box").hide();
        $(".parts-switcher li span").removeClass("current");
    }
    else{

    $(".meta-box").hide();
    $(".parts-switcher li span").removeClass("current");
    var show = $(this).attr("id");

        $(this).addClass("current");
        $("."+show+":hidden").show();

    }

    return false;
});

  $(".parts-switcher li").hover(
  function () {
    $(this).addClass("li-hover");
  },
  function () {
    $(this).removeClass("li-hover");
  }

  );
//-----------------------------------------------------------------------


});

// --------------- Склонение существительных с числительными

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;
}
