function trim(s)
{
  return rtrim(ltrim(s));
}

function ltrim(s)
{
  return s.replace(/^\s+/, ''); 
}

function rtrim(s)
{
  return s.replace(/\s+$/, ''); 
}

$(document).ready(function()
    {
        var href = (document.location.href).split("/");
        
//Fancybox РґР»СЏ Р±РѕР»СЊС€РёС… РєР°СЂС‚РёРЅРѕРє РІ РёС‚РµРјРµ
        $("a.itemmainimage").fancybox({
            'zoomSpeedIn'        :    500,
            'zoomSpeedOut'        :    500,
            'titleShow'        : false,
            'transitionIn'    : 'elastic',
            'transitionOut'    : 'elastic'
        });
        
//РїРѕРїСЂР°РІРёР»Рё CSS РґР»СЏ РѕСЃРѕР±С‹С… СЃР»СѓС‡Р°РµРІ        
        $('.response .pics li:last-child').css('margin-right','0');    
        $('.pics .gal li:last-child').css('margin-right','0');  

	
	
        
//Р¤РѕС‚РѕРіР°Р»РµСЂРµСЏ РЅР° РіР»Р°РІРЅРѕР№ СЃС‚СЂР°РЅРёС†Рµ (РєР»РёРµРЅС‚С‹)
        $("#listS").html("<img src='/images/spinner.gif'>");
        $.ajax({
                    type: "POST",
                    url: "/photo/22/gallery/mainpage_clients",
                    cache: false,
                    async: true,
                    dataType: "html",
                    data: "ajax=true",
                    success: function(msg) {
                        $("#listS").html(msg);
                        $("#listS").jCarouselLite({
                            btnNext: "#nextS",
                            btnPrev: "#prevS",
                            visible: 5
                        });
                    }
        });

//РќР° РІСЃРµС… С€Р°РїРєР°С… РєРѕР»Р»РµРєС†РёРё        
        if($("#headerimgs").html()) {
            $.ajax({
                        type: "POST",
                        url: "/catalog/26/",
                        cache: false,
                        async: true,
                        dataType: "html",
                        data: "ajax=true&headers=true",
                        success: function(msg) {
                            $("#headerimgs").html(msg);
                            /*$('.listSlide').innerfade({
                                speed: 1000,
                                timeout: 5000,
                                type: 'sequence',
                                containerheight: '364px'
                            });*/
                            $('.slider').flexslider({
                                animation: "fade",
                                controlsContainer: ".flexslider-container",
                                pauseOnAction: false,
                                slideshow: true,
                                directionNav: false
                            });
                        }
            });
        }
        
        if($("#headerimgssm").html()) {
            $.ajax({
                        type: "POST",
                        url: "/catalog/26/",
                        cache: false,
                        async: true,
                        dataType: "html",
                        data: "ajax=true&headerssm=true",
                        success: function(msg) {
                            $("#headerimgssm").html(msg);
                            /*$('.listSlide').innerfade({
                                speed: 1000,
                                timeout: 5000,
                                type: 'sequence',
                                containerheight: '364px'
                            });*/
                            $('.slider_small').flexslider({
                                animation: "fade",
                                controlsContainer: ".flexslider_small-container",
                                pauseOnAction: false,
                                slideshow: true,
                                directionNav: false
                            });
                        }
            });
        }
        
        if($("div.slider").html()) {
            $('.slider').flexslider({
                                animation: "fade",
                                controlsContainer: ".flexslider-container",
                                pauseOnAction: false,
                                slideshow: true,
                                directionNav: false
            });
		
        }
		
		$(".carousellist").each(function() {
			var id = $(this).attr("id");
			var numElems = $(this).children("ul").children().size();
			id = id.split("_");
			var visible = 4;
			
			if(id[1] == "A") {
				visible = 3;
			}
			if((numElems < 3) && (id[1] == "A")) {
				visible = numElems;
			}
			
			if((numElems < 4) && (id[1] != "A")) {
				visible = numElems;
			}
			
			
			$("#list_" + id[1]).jCarouselLite({
				btnNext: "#next" + id[1],
				btnPrev: "#prev" + id[1],
				visible: visible
			});
			
			if((id[1] == "O") || (id[1] == "R")) {
				var heights_arr = Array();
				$('#list_' + id[1] + ' ul li .cat_inner').each(function() {  
					heights_arr.push($(this).outerHeight());
				});
			
				$('#list_' + id[1]).css('height', Math.max.apply(Math, heights_arr) + 'px');
				$('#list_' + id[1] + ' ul').css('height', Math.max.apply(Math, heights_arr) + 'px');
				$('#list_' + id[1] + ' ul li').css('height', Math.max.apply(Math, heights_arr) + 'px');
				$('#list_' + id[1] + ' ul li .cat_inner').css('height', Math.max.apply(Math, heights_arr) + 'px');

				$('#list_' + id[1] + ' ul li .cat_inner').css('display','block');
			}
		});
		
        
//РїСЂР°Р№СЃ-Р»РёСЃС‚ - РїСЂРѕРІРµСЂСЏРµРј РІРІРµРґРµРЅРЅС‹Р№ email
        $("#price_send").live("click", function() {
        
            $.ajax({
                    type: "POST",
                    url: "/" + $("#page").val() + "/" + $("#module").val() + "/checkemail",
                    cache: false,
                    async: true,
                    dataType: "json",
                    data: "ajax=true&email=" + $("#price_email").val(),
                    success: function(msg) {
                        if(msg[0] == 1) {
                            $.ajax({
                                            type: "POST",
                                            url: "/" + $("#page").val() + "/" + $("#module").val() + "/get",
                                            cache: false,
                                            async: false,
                                            dataType: "json",
                                            data: "ajax=true&email=" + $("#price_email").val(),
                                            success: function(msg) {
                                                if(msg[0] == 1) {
                                                    $("#price_form").html("<div style='text-align:center;'><p></p><p>Спасибо за ваш интерес.</p><p>В ближайшее время мы вышлем вам материалы на указанный email</p></div>");
                                                }
                                            }
                            });
                        }
                        else {
                            if($("#addinfo").hasClass("notshown")) {
                                $("#addinfo").removeClass("notshown");
                                $("#addinfo").slideDown(300);
                            }
                            else {
                                flag_mail = flag_name = flag_org = flag_city = flag_phone = 1;
                                var entered_value = $("#price_email").val();
                                entered_value = entered_value.replace("/^\S+/iu","");
                                re = /^([A-z0-9_\-]+\.)*[A-z0-9_\-]+@([A-z0-9][A-z0-9\-]*[A-z0-9]\.)+[A-z]{2,4}$/i;
                                if(re.test(entered_value)) {
                                    $("#price_email").css("background", "");
                                }
                                else {
                                    flag_mail = 0;
                                    $("#price_email").css("background", "red");
                                }    
                                
                                var re = /\S+/;
            
                                //Name
                                if(!$("#fio").val().match(re)) { 
                                    flag_name = 0;
                                    $("#fio").css("background", "red");
                                }
                                else {
                                    $("#fio").css("background", "");
                                }    

                                //Phone        
                                if(!$("#phone").val().match(re)) { 
                                    flag_phone = 0;
                                    $("#phone").css("background", "red");
                                }    
                                else {
                                    $("#phone").css("background", "");
                                }    
                                
                                //Organization
                                if(!$("#org").val().match(re)) { 
                                    flag_org = 0;
                                    $("#org").css("background", "red");
                                }    
                                else {
                                    $("#org").css("background", "");
                                }    
                                
                                //Р“РѕСЂРѕРґ
                                if(!$("#city").val().match(re)) { 
                                    flag_city = 0;
                                    $("#city").css("background", "red");
                                }    
                                else {
                                    $("#city").css("background", "");
                                }    
                                
                                if(flag_mail && flag_name && flag_org && flag_city && flag_phone) {
                                    $.ajax({
                                            type: "POST",
                                            url: "/" + $("#page").val() + "/" + $("#module").val() + "/get",
                                            cache: false,
                                            async: false,
                                            dataType: "json",
                                            data: "ajax=true&email=" + entered_value + "&fio=" + $("#fio").val() + "&org=" + $("#org").val() + "&phone=" + $("#phone").val() + "&city=" + $("#city").val() + "&zip=" + $("#index").val() + "&address=" + $("#address").val() + "&module=" + $("#module").val(),
                                            success: function(msg) {
                                                if(msg[0] == 1) {
                                                    $("#price_form").html("<div style='text-align:center;'><p></p><p>Спасибо за ваш интерес.</p><p>В ближайшее время мы вышлем вам материалы на указанный email</p></div>");
                                                }
                                            }
                                    });
                                }
                            }
                        }
                    }
            });
            
        });
        
        if(href[href.length - 1] !== 'cart') {
            $("#cart_small").html("<img src='/images/spinner.gif'>");
            $("#cart_small").html(getSmallCart());
        }
        
        if(href[href.length - 2] == 'admin') {
            $( ".date_request" ).live("click", function() {
                $(this).datepicker({"dateFormat": "yy-mm-dd",
                                    "defaultDate": "-3y",
                                    "changeYear": "true",
                                    "changeMonth": "true"});
                $(this).datepicker("show");
            });
        }
        
        $('a.close, #fade').live('click', function() { 
            $('#fade , .block_order').fadeOut(function() {
                $('#fade').remove();  
                $(".ordering").each(function() {
                    var id = $(this).attr("id");
                    id = id.split("_");
                    $(this).parent().html("<a href=\"javascript:;\" id=\"item_" + id[1] + "\" class=\"in_cart to_order\">Заказать</a>");
                });
            });
            return false;
        });    
        
        
        $(".to_order").live("click", function() {
            var id = $(this).attr("id");
            id = id.split("_");
            $(this).parent().html('<span class="text ordering" id="ordering_' + id[1] + '">Заказывается</span>');
            var popWidth = 300;
            
            $.ajax({
                        type: "POST",
                        url: "/cart/30/getorderform",
                        cache: false,
                        async: false,
                        dataType: "json",
                        data: "ajax=true&item_id=" + id[1],
                        success: function(msg) {
                            if(msg[0]) {
                                $("body").append(msg[0]);
                                $('#order').fadeIn().css({ 'width': Number( popWidth ) });
            
                                var popMargTop = ($('#order').height() + 80) / 2;
                                var popMargLeft = ($('#order').width() + 80) / 2;
                                 
                                $('#order').css({
                                    'margin-top' : -popMargTop,
                                    'margin-left' : -popMargLeft
                                });
                                 
                                $('body').append('<div id="fade"></div>'); 
                                $('#fade').css({'filter' : 'alpha(opacity=70)'}).fadeIn(); 
                                /*$("#fade").css({'z-index': '100'});*/
                            }
                        }
            });
         
            return false;
        });
            
        $("#order_send").live("click", function() {
                flag_mail = flag_name = flag_phone = 1;
                var entered_value = $("#shop_mail").val();
                entered_value = entered_value.replace("/^\S+/iu","");
                re = /^([A-z0-9_\-]+\.)*[A-z0-9_\-]+@([A-z0-9][A-z0-9\-]*[A-z0-9]\.)+[A-z]{2,4}$/i;
                if(re.test(entered_value)) {
                    $("#shop_mail").css("background", "");
                }
                else {
                    flag_mail = 0;
                    $("#shop_mail").css("background", "red");
                }    
                
                var re = /\S+/;
            
                //Name
                if(!$("#shop_name").val().match(re)) { 
                    flag_name = 0;
                    $("#shop_name").css("background", "red");
                }
                else {
                    $("#shop_name").css("background", "");
                }    

                //Phone        
                if(!$("#shop_phone").val().match(re)) { 
                    flag_phone = 0;
                    $("#shop_phone").css("background", "red");
                }    
                else {
                    $("#shop_phone").css("background", "");
                }    
                
                if(flag_mail && flag_name && flag_phone) {
                    var form = $(this).parent();
                    $.ajax({
                            type: "POST",
                            url: "/cart/30/orderne",
                            cache: false,
                            async: false,
                            dataType: "json",
                            data: "ajax=true&" + form.serialize(),
                            success: function(msg) {
                                if(msg[0] == 1) {
                                    $(".block_order").html("<div style='text-align:center;'><p></p><p>Спасибо за ваш заказ</p></div>");
                                    $(".block_order").fadeOut(2100, function() {
                                        $('#fade').remove();
                                        $('#order').remove();
                                        $(".ordering").each(function() {
                                            var id = $(this).attr("id");
                                            id = id.split("_");
                                            $(this).parent().html("<a href=\"javascript:;\" id=\"item_" + id[1] + "\" class=\"in_cart to_order\">Заказать</a>");
                                        });
                                    });
                                }
                            }
                    });
                }
        });

        
		$(".to_cart").live("click", function() {
            $(this).parent().html('<span class="text">отложен в корзину</span>');
            var id = $(this).attr("id");
            id = id.split("_");
            $("#cart_small").html("<img src='/images/spinner.gif'>");
            var cart = orderItem(id[1], 1, '', '');
            animateItem(id[1]);
            $("#cart_small").html(cart);
        });
        
        $(".deleteitems").live("click", function() {
            var id = $(this).attr("id");
            id = id.split("_");
            deleteItem(id[1], $("#count_" + id[1]).val(), '');
            animateRemoveItem(id[1]);
            if(!countCart()) {
                $(".card").remove();
                $("h1").after('<p class="error">Ваша корзина пуста</p>');
            }
        });
        
        $(".itemcounter").live("keyup", function() {
            var id = $(this).attr("id");
            id = id.split("_");
            var counter = parseInt($(this).val());
            if(!counter) {
                counter = 0;
            }
            var price = parseInt($("#itemprice_" + id[1]).text());
            var total = counter*price;
            $("#totalitemprice_" + id[1]).text(total);
            
            calculatePrices();
            setCart(id[1], counter);
        });
        
        $(".itemcounter").live("change", function() {
            var id = $(this).attr("id");
            id = id.split("_");
            var counter = parseInt($(this).val());
            if(!counter) {
                counter = 0;
            }
            var price = parseInt($("#itemprice_" + id[1]).text());
            var total = counter*price;
            $("#totalitemprice_" + id[1]).text(total);
            
            calculatePrices();
            setCart(id[1], counter);
        });
        
        $("#finalorder").live("click", function() {
            if(parseInt($("#totalitemsprice").text()) > 0) {
                $(this).parent().parent().parent().parent().children("h1").text("Спасибо за ваш заказ");
                $(this).remove();
                $("#orderform").slideDown(300);
                $('html,body').animate({ scrollTop: $("#orderform").offset().top}, 1000);
            }    
        });
        
        $("#shop_send").live("click", function() {
            var flag_mail = flag_name = flag_phone = flag_org = flag_city = 1;
            //Email
            var entered_value = $("#shop_mail").val();
            entered_value = entered_value.replace("/^\S+/iu","");
            re = /^([A-z0-9_\-]+\.)*[A-z0-9_\-]+@([A-z0-9][A-z0-9\-]*[A-z0-9]\.)+[A-z]{2,4}$/i;
            if(re.test(entered_value)) {
                $("#shop_mail").css("background", "");
            }
            else {
                flag_mail = 0;
                $("#shop_mail").css("background", "red");
            }    
            
            var re = /\S+/;
            
            //Name
            if(!$("#shop_name").val().match(re)) { 
                flag_name = 0;
                $("#shop_name").css("background", "red");
            }
            else {
                $("#shop_name").css("background", "");
            }    

            //Phone        
            if(!$("#shop_phone").val().match(re)) { 
                flag_phone = 0;
                $("#shop_phone").css("background", "red");
            }    
            else {
                $("#shop_phone").css("background", "");
            }    
            
            //City
            if(!$("#shop_city").val().match(re)) { 
                flag_city = 0;
                $("#shop_city").css("background", "red");
            }    
            else {
                $("#shop_city").css("background", "");
            }    
            
            //Org
            if(!$("#shop_org").val().match(re)) { 
                flag_org = 0;
                $("#shop_org").css("background", "red");
            }    
            else {
                $("#shop_org").css("background", "");
            }    
            
            if(flag_mail && flag_name && flag_phone && flag_org && flag_city) {
                var form = $(this).parent().parent("form");
                $.ajax({
                        type: "POST",
                        url: "/cart/30/order",
                        cache: false,
                        async: false,
                        dataType: "json",
                        data: "ajax=true&" + form.serialize(),
                        success: function(msg) {
                            if(msg[0] == 1) {
                                $("table.order_list").remove();
                                $("div.order").remove();
                                $("#orderform").html("<div style='text-align:center;'><p></p><p>Спасибо за ваш заказ</p></div>");
                                /*$("#orderform").fadeOut(2100, function() {
                                    
                                });*/
                            }
                        }
                });
            }
        });
        
        
        
        //Р¤РёР»СЊС‚СЂ РїРѕ СЃРѕСЃС‚Р°РІСѓ
        $(".niceCheck").live("click", function() {
            var id = $(this).children("input").attr("id");
            id = id.split("_");
            var tid = id[0] + "_" + id[1] + "_list";
            var uid = id[0] + "_" + id[1] + "_ready";
            if($(this).children("input").attr("checked")) {
                var content = $("#" + tid).text();
                $("#" + tid).html("<a href=\"javascript:;\" class=\"remove_check\"id=\"" + uid + "\">" + content + "</a>");
                filterItemsQuery();
            }
            else {
                var content = $("#" + tid).children("a").text();                
                $("#" + tid).html(content);
                filterItemsQuery();
            }
        });
        
        $(".remove_check").live("click", function() {
            var id = $(this).attr("id");
            id = id.split("_");
            var tid = id[0] + "_" + id[1] + "_list";
            var cid = id[0] + "_" + id[1] + "_check";        
            var content = $(this).text();
            $("#" + tid).html(content);
            $("#" + cid).attr("checked", false);
            $("#" + cid).parent().css("background-position","0 0");
            filterItemsQuery();
        });
        
        
        $("#data_search").click( function() {
            if($("#data_search").val() == "поиск по сайту")
                $("#data_search").val("");
        });
        
        $("#data_search").blur( function() {
            if($("#data_search").val() == "") {
                    $("#data_search").val("поиск по сайту");
            }
        });
                
        function setCart(id, num) {
            $.ajax({
                    type: "POST",
                    url: "/cart/30/setcart",
                    cache: false,
                    async: true,
                    dataType: "json",
                    data: "ajax=true&item_id=" + id + "&number=" + num
            });     
        }
        
        function calculatePrices() {
            var totalitems = 0;
            $(".itemcounter").each(function() {
                
                
                var id = $(this).attr("id");
                id = id.split("_");
                var counter = parseInt($(this).val());
                if(!counter) {
                    counter = 0;
                }
                var price = parseInt($("#itemprice_" + id[1]).text());
                var total = counter*price;
                totalitems += total;
            });
            $("#totalitemsprice").text(totalitems);
        }
        
        function countCart() {
            var ret = 0;
            $.ajax({
                    type: "POST",
                    url: "/cart/30/countcart",
                    cache: false,
                    async: false,
                    dataType: "json",
                    data: "ajax=true",
                    success:     function(msg){
                                    ret = msg[1];
                                }
            }); 
            
            return ret;            
        }
        
        function inCart(id) {
            var ret = false;
            $.ajax({
                    type: "POST",
                    url: "/cart/30/incart",
                    cache: false,
                    async: false,
                    dataType: "json",
                    data: "ajax=true&item_id=" + id,
                    success:     function(msg){
                                    if(msg[0] == 1) {
                                        ret = true;
                                    }
                                }
            }); 
            
            return ret;            
        }
        
        function animateItem(id) {
            $("#info_" + id).show();
            $("#info_" + id).animate({ backgroundColor: "yellow" }, 1300).animate({ opacity: "hide" }, 4000);
            return false;
        }
        
        function animateRemoveItem(id) {
            $("#cartcontainer_" + id).animate({ backgroundColor: "yellow" }, 500).animate({ opacity: "hide" }, 700);
            /*$("#cartcontainer_" + id).remove();*/
            return false;
        }
        
        function getSmallCart(){
            var cart = "";
            $.ajax({
                    type: "POST",
                    url: "/cart/30/showcart",
                    cache: false,
                    async: false,
                    dataType: "json",
                    data: "ajax=true",
                    success:     function(msg){
                                    cart = msg[1];
                                }
            }); 
            
            return cart;
        }
        
        function orderItem(id, number, element, new_element){
            var cart = "";
            $.ajax({
                    type: "POST",
                    url: "/cart/30/addtocart",
                    cache: false,
                    data: "ajax=true&item_id="+id+"&number="+number,
                    async: false,
                    dataType: "json",
                    success:     function(msg){
                                    cart = msg[1];
                                }
            }); 
            
            return cart;
        }

        function deleteItem(id, number, element) {
            var cart = "";
            $.ajax({
                    type: "POST",
                    url: "/cart/30/delete/" + id,
                    cache: false,
                    data: "ajax=true&number="+number,
                    async: false,
                    dataType: "json",
                    success:     function(msg){
                                    cart = msg[1];
                                }
            });
            
            return cart;
        }
        
        function filterItemsQuery()
        {
            var params = new Array();
            $(".niceCheck").each(function() {
                if($(this).children("input").attr("checked")) {
                    var id = $(this).children("input").attr("id");
                    id = id.split("_");
                    id = id[0] + "_" + id[1];
                    params[params.length] = id;
                }        
            });
            
            var min_pr = $("#min_pr").val();
            var max_pr = $("#max_pr").val();
            
                $("#filter_controls").hide();
                $("#filter_list").html("<table style='text-align:center;height:100%;width:100%;'><tr><td style='vertical-align:middle;width:100%;height:100%'><img src='/images/spinner.gif'></tr></td></table>");
            
            
            
                var url    = $("#url").val();
                
                $.ajax({
                    type: "POST",
                    url: "/catalog/26/" + url,
                    cache: false,
                    data: "ajax=true&filter=true&&min_pr=" + min_pr + "&max_pr=" + max_pr + "&params=" + params.join(","),
                    async: false,
                    success:        function(msg)
                                    {
                                        //location.hash = 'filter_sq';
                                        $("#filter_list").html(msg);
                                    }
                });
        }

        var href = document.location.href;
    }

);

function imageSelect( id, imagesrc, caption, width )
{
    if( document.getElementById("caption") != null )
    {
        document.getElementById("caption").innerHTML = ( caption.length > 0 ) ? unescape( caption ) + '<br />' : ''; 
    }
    document.getElementById("pics").src = imagesrc;    
    document.getElementById("pics").className = "caption";
    var image_parts = imagesrc.split("/"); 
    var picname = image_parts[image_parts.length - 1];
    picname = picname.substring(2);
    image_parts[image_parts.length - 1] = picname;
    imagesrc = image_parts.join("/");
    document.getElementById("picsa").href = imagesrc;

    var lis = document.getElementsByTagName('li');
    for (var i=0;i<lis.length;i++)
    {
        if (lis[i].className.indexOf("currentImage") > -1)
        {
            lis[i].className = '';
        }
    }
    document.getElementById("pic"+id).className = "currentImage";
}

function killBlock(bid)
{
   document.getElementById(bid).style.display='none';
}

function hideBlock(id) {
        document.getElementById(id).style.display='none';
}

function viewBlock(id) {
        document.getElementById(id).style.display='inline';
}

function submitTheForm(form)
{
  d = document.getElementById(form);
  d.submit();
}

function submitTheFormAction(form, action, close)
{
  d = document.getElementById(form);
  d.action = action;
  d.submit();
  if(close)
    {
      setTimeout("closereload()", 200);
    }
}

function closereload()
{
  window.opener.location.reload();
  window.close();
}

function onloadPageFormsBlocks(menu_ids, shorts)
{
  menu_ids = menu_ids.split(",");
  shorts   = shorts.split(",");

  for(i=0;i<menu_ids.length;i++)
  {
    for(j=0; j<shorts.length; j++)
      {
        d = document.getElementById('menuid'+shorts[j]+'_'+menu_ids[i]);
        if(d)
          {
            d1 = document.getElementById('menufile_'+shorts[j]+'_'+menu_ids[i]);

            if(d.checked)
              {
                d1.style.display = '';
              }
            else
              {
                d1.style.display = 'none';
              }
          }
      }
  }
}

function chechInquiry(source)
{
  d = document.getElementById(source);
  d.checked = true;
}

function checkboxes(do_check, elem)
{
  var elts = document.forms['search'].elements[elem];
  if(elts[0])
    {
      for(var i = 0; i < elts.length; i++)
        elts[i].checked = do_check;
    }
  else
      elts.checked = do_check;
}

function checkstring(form, string, boxes)
{
  d  = document.getElementById(form);
  s  = document.getElementById(string);

  var cond1 = '';

  var elts = document.forms[form].elements[boxes];
  if(elts[0])
    {
      for(var i = 0; i < elts.length; i++)
        {
          if(elts[i].checked)
            cond1 = true;
        }
    }
  else
    {
      if(elts.checked)
        cond1 = true;
    }

  if(!(s.value))
    alert("Р’С‹ РЅРµ РІРІРµР»Рё СЃС‚СЂРѕРєСѓ РґР»СЏ РїРѕРёСЃРєР°");
  else if(!cond1)
    alert("Р’С‹ РЅРµ РІС‹Р±СЂР°Р»Рё РЅР°РїСЂР°РІР»РµРЅРёРµ РїРѕРёСЃРєР°");
  else
    d.submit();
}

function showhide(what,what2)
{
  if (what.style.display=='none')
    {
      what.style.display='';
    }
  else
    {
      what.style.display='none'
    }
}













var myWidth=0;
function init_gallery() {
        setInterval('startLine()', 1);
}

function startLine() {
        if (document.body.clientWidth != myWidth) {
                myWidth = document.body.clientWidth;
                inLine();
        }
}
function inLine() {
        var td = document.getElementById('photo-parent').getElementsByTagName('td');
        var table = document.getElementById('photo-parent').getElementsByTagName('table');
        var count = 0;
        var row = false;

        for (var i = 1; (table.item(i)); i++) {
                if ((row == false) && (table.item(i).offsetTop == table.item(i-1).offsetTop)) count++; else row = true;
                td.item(i).style.height = 'auto';
        }
        td.item(0).style.height = 'auto';
        count++;

        for (var i = 0; (td.item(i)); i=i+count) {
                myHeight = 0;
                for (var o = 0; (td.item(i+o) && o < count); o++) if (td.item(i+o).offsetHeight > myHeight) myHeight = td.item(i+o).offsetHeight;
                for (var o = 0; (td.item(i+o) && o < count); o++) td.item(i+o).style.height = myHeight + 'px';
        }
        document.getElementById('photo-parent').style.visibility = 'visible';
}

function submitTheForm(form)
{
  d = document.getElementById(form);
  d.submit();
}

function submitTheFormAction(form, action, close)
{
  d = document.getElementById(form);
  d.action = action;
  d.submit();
  if(close)
    {
      setTimeout("closereload()", 200);
    }
}

function closereload()
{
  window.opener.location.reload();
  window.close();
}

function onloadPageFormsBlocks(menu_ids, shorts)
{
  menu_ids = menu_ids.split(",");
  shorts   = shorts.split(",");

  for(i=0;i<menu_ids.length;i++)
  {
    for(j=0; j<shorts.length; j++)
      {
        d = document.getElementById('menuid'+shorts[j]+'_'+menu_ids[i]);
        if(d)
          {
            d1 = document.getElementById('menufile_'+shorts[j]+'_'+menu_ids[i]);

            if(d.checked)
              {
                d1.style.display = '';
              }
            else
              {
                d1.style.display = 'none';
              }
          }
      }
  }
}



function setMenuOver(elem) {
   elem.className = 'over';
}

function setMenuOut(elem) {
   elem.className = 'default';
}

