    //hs.graphicsDir = '/files/graphics/';
    //hs.align = 'center';
	//hs.transitions = ['expand', 'crossfade'];
	///hs.outlineType = 'rounded-white';
	//hs.fadeInOut = true;
	///hs.dimmingOpacity = 0.45;
	//hs.dimmingDuration = 0,
	//hs.transitionDuration = 50;

	//hs.width = 800;
	//hs.height = 500;
	current = null;
$(document).ready(function(){
    var show = false;

	$ncat = $('#ncat div.ncat');
	$dsc = $('div.dsc');
	$samecat = $('#samecat');
	id = 0;
if (document.location.hash !='' && document.location.hash !='#')
	id = document.location.hash

if (id && $(id).length)
{   $ncat.hide();
   $dsc.hide();
   $(id).show();

   current = $(id.replace('item','scatimg'));
   current.addClass('current');
   //alert(current.html())
   $samecat.show();
}

             $('#slinks').remove();
             $("a.more").click(function() {


                href = $(this).attr('href').split('#')
                if (href[1])
                    $(this).attr('href','#'+href[1])

                id = $(this).attr('href');

                if (current)
					current.removeClass('current');
                current = $(id.replace('item','scatimg'));
                current.addClass('current');

                $ncat.hide();
                $dsc.hide();
                $(id).show();
                $samecat.show();
                    if ($('html,body').scrollTop() > 500)	                $('html,body').animate({ scrollTop: 300} );
	                return false;

                return true;
             })


             $("a.back").click(function(){             	$(id).hide();
             	$ncat.show();
             	$samecat.hide();
             	return false;             })

var Scrolling = {    size : 174,
    bsize : 610,
    left : 0,

	move : function(i){
		if (i > 0)
			{				if (this.left + this.size <= 0)
					{					$('#in').animate({ left: '+='+this.size} );
					this.left += this.size;
					}			}else{				//if (-1*(this.left - this.bsize) < $('#in').width() )
				//	{
					$('#in').animate({ left: '-='+this.size} );
					this.left -= this.size;


				//	}
				}
        //alert(this.left )
		return false;	}

}
            $('#scroll_left').click(function(){             	return Scrolling.move(1);            })
            $('#scroll_right').click(function(){            	return Scrolling.move(-1);
            })

            $('#in').mousewheel(function(event, delta) {
				return Scrolling.move(delta);
			})

             $("a[href$=jpeg],a[href$=jpg],a[href$=gif]").fancybox();




});



basket_confirm=function(){


    $.get("/basket.php",{order:1},

	       function(html)
	         {
	      		//$("body").append('<div id="order"></div>')
	      		$("#basketorder").remove();
		        $("#content").prepend(html);

		        //obj = document.getElementById('order_')
		        //hs.htmlExpand(obj, {contentId: 'order_' })
		        //alert($("#order").html(html))
	         });
}

del=function(id){

$.get("/basket.php",{del:id},

	       function(html)
	         {
	      		$("#basket").html(html);
	         });

}

var doBlink = function(obj,start,finish) { jQuery(obj).fadeOut(300).fadeIn(300); if(start!=finish) { start=start+1; doBlink(obj,start,finish); } }


$(document).ready(function() {










    // add div
	$("#all").append('<div id="basket"></div>')
   	//get items
   	$.get("/basket.php",
	       function(html)
	         {
	         $("#basket").html(html);
	         $('#basket_sub').hide();
	         //$("#basket").blink(1,8);
	         doBlink("#bhd",1,5);
	         //alert();
	         });

    // change top menu
    $('#headr span a').each(function(){
    	//alert(location.href)
    	var h = 'http://'+location.host
    	var hr = this.href.replace(h,"")
    	//alert(h)
    	if (hr == '/')
    		this.innerHTML = 'Главная'
    	if (hr == '/cat/')
    		this.innerHTML = 'Прайс лист'
    })
     // change footer menu
    $('#footer a').each(function(){
    	//alert(location.href)
    	var h = 'http://'+location.host
    	var hr = this.href.replace(h,"")
    	//alert(h)
    	if (hr == '/')
    		this.innerHTML = 'Главная'
    	if (hr == '/cat/')
    		this.innerHTML = 'Прайс лист'
    })


	//add events
	$("a.basket").click(function(){
		$.get("/basket.php",
	       {add:this.id},
	       function(html)
	         {
	         $("#basket").html(html);
	         $('#basket_sub').hide();
	         //$("#basket").blink(1,8);
	         doBlink("#bhd",1,5);
	         $("#basket_items").css({maxHeight:'300px'});
	         });
   //alert(this.id)
   //doBlink(this,1,5)
   $(this).fadeTo("slow", 0.4);
   //$(this).click(function(){ return false})
   return false
	});


    //$('#basket_sub').hide();

    $('#basket').mouseover(function() {
        $('#basket_sub').show();
    });
    $('#basket').mouseout(function() {
        $('#basket_sub').hide();
    });

   if (location.pathname=='/price/') {
	$('.mmenu ul.dev3').show();
	$('.mmenu ul.dev2').show();
	$('.mmenu ul.dev1').show();
 	}


	/* FEEDBACK*/
	$("#feedback").ajaxForm({
	   	url:"/",
		method:"post",
		//beforeSubmit: function (){alert("start")} ,
		success: function (responseText, statusText){
			if (responseText == "-1")
				alert("Неизвестная ошибка. Попробуйте связаться с нами по телефону")
			if (responseText == "0")
				alert("Пожалуйста, заполните все поля, отмеченные *")
			if (responseText == "1")
				{				$("#feedback").prepend('<p style="color:red;font-weight:bold">Сообщение отправлено</p>')
				//alert("Сообщение отправлено")
				$("#feedback").resetForm();
				}
			//$.get("/basket.php",
		    //   function(html)
		    //     {
		    //     $("#basket").html(html);
		    //     $("#basket_sub").hide();
		    //     });
		}
   	});

	/* FLASH */

	// /files/news/im1_16_prev.swf

	   /* $("#flash").flash({
	        src: "/files/news/im1_16_prev.swf",
	        width:"260",
	        height:"195",
			});
       */








    /* HSLIDE */
    //$(".highslide").click(function(){    //	id = this.id    //	id = id.replace('img',"")
    //	id = id.replace('href',"")
    //	$("#item"+id).prepend('<a href="#" class="hsclose" onclick="return hs.close(this)" style="position:absolute; right:1px;">[X]</a>')
    //	return hs.htmlExpand(this, { contentId: "item"+id } )    //})
    /*********/

   $(".d").append('<p><br />* Количество товара указывается при оформлении заказа<br /> <span style="font-weight:bold;color:red;">** Оплата осуществляется по безналичному расчету. <br />Если вы желаете приобрести товар в розницу - обращайтесь в филиалы или фирменные салоны-магазины</span></p>');



tt=0;
sh=function (obj1,obj2,obj3){

	if (tt == 0)
	{
		tt=1
		$(obj2).height('auto')
		$(obj1).height($(obj2).height()+20)
		obj3.innerHTML='Свернуть [-]'
	}else{
		tt=0
		$(obj1).height(140)
		$(obj2).height(113)
		obj3.innerHTML='Подробнее [+]'
	}
	//alert($(obj1).height())
	return false;
}
    /* #fotoblock_items */
    if ($("#fcontent").height() > 145)
    	{    	//

    	//$("#top_text").height(100)
    	$("#fcontent").height(113)
    	$("#fotoblock_items").append('<a href="#" onclick=\'return sh("#fotoblock_items","#fcontent",this);\' style="float:right;margin-bottom:0px;">Подробнее [+]</a>')
    	//var content = $("#top_text").html()
    	//$("#top_text").css({"display":"none"})
    	//$("#fotoblock_items").append('<a href="#" onclick="return hs.htmlExpand(this, {contentId:\'top_text\'})" style="float:right;">Подробнее</a>')
    	//$("#fotoblock_items").append('<a href="#" onclick="return $("#top_text").css({"display":"auto"})" style="float:right;">Подробнее</a>')
    	 //$("#top_text").prepend('<a href="#" class="hsclose" onclick="return hs.close(this)" style="position:absolute; right:1px;">[X]</a>')
    	//$("#fcontent").prepend(content)
    	}

 });
var basket = null;


$('#basket').ready(function(){

	//menu1 = parseInt($(".right").css("top").substring(0,$(".right").css("top").indexOf("px")));
	//basket = $(window).height() - 96;

	$(window).scroll(function () {
		//offset1 = menu1 + $(document).scrollTop() + "px";
		//offset2 = basket - $('#basket').height() + $(document).scrollTop() + "px";
		offset2 = $(document).scrollTop() + "px";;

		//$('.right').animate({top:offset1},{duration:500,queue:false});
		$('#basket').animate({top:offset2},{duration:500,queue:false});
	});
	});


$('#mcat').ready(function(){

    //hide all
    $('.mmenu ul.dev3').hide();
	$('.mmenu ul.dev2').hide();
	//$('#current_line').parent().find('ul').each(function(){	//	this.show()	//});

	//$('.current_line').parent().find('ul.dev3').show()
	//$('#current_line').parent().find('ul.dev2').show()
	//$('#current_line').html("xxxxxxxxxxxxxxxx");
	//obj = $('#current_line').parent("li")
	//alert(obj.parent("ul").html())
    //document.write(printObjectTable(obj))
    $('#current_line').parent().show()
    $('#current_line').parent().parent().parent().show()
 	//$('.mmenu ul.dev1:has(li:has(ul.dev2:has(li:has(ul.dev3 li.current_line))))').show

	//show 1st
	if (window.location.pathname  == '/')
	    $('#fs').parent().find('ul.dev2').show()

	//document.write(printObjectTable(window.location))

	//add events
    $('.mmenu ul.dev1 li:has(ul.dev2) a').click(function() {
        $(this).parent().find('ul.dev2').slideToggle("normal");
        return false;
    });

    $('ul.dev2 li:has(ul.dev3) a').click(function() {
        $(this).parent().find('ul.dev3').slideToggle("normal");
        //return ;
    });

    $('ul.dev3 li a').click(function() {
		window.location.assign(this.href)
		//return true;
    });


	$('ul.dev1.price > li > ul').toggle()
	$('ul.dev1.price > li > strong').click(function(){		$('#content').height('auto')		$(this).parent().find('ul').toggle();
		//$(this).unbind('click');
		return false;
		})

        //alert(document.location.path)
    //if ($('#content').height() < 870)
    //	$('#content').height(870)
    //

	$("#div_mcat h3").html('Каталог товаров')

	$("a.g_link").click(function(){		$("#"+this.id+"_").slideToggle("normal");
		return false;	})

});





function printObjectTable(obj) {
    var table = '<table border="1" cellspacing="0" cellpadding="3">'
    for (i in obj) {
        table += '<tr>'
        table += '<td>' + i + ' &nbsp;</td>'
        val = obj[i]
        //if (obj[i] == '[object]') {
        if (obj[i] != null && obj[i].length > 0) {
        //if (obj[i] != null && obj[i].toString() == '[object Object]') {
            table += '<td><b>' + obj[i]
            for (j in val) {
                table += j + ' - ' + val[j] + '<br>'
            }
            table += '</b></td>'
        } else {
            table += '<td>' + obj[i] + ' &nbsp;</td>'
        }
        table += '</tr>'
    }
    table += '</table>'
    return table
}/**/



function number_format( number, decimals, dec_point, thousands_sep ) {    // Format a number with grouped thousands
    //
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://crestidg.com)

    var i, j, kw, kd, km;

    // input sanitation & defaults
    if( isNaN(decimals = Math.abs(decimals)) ){
        decimals = 2;
    }
    if( dec_point == undefined ){
        dec_point = ",";
    }
    if( thousands_sep == undefined ){
        thousands_sep = ".";
    }

    i = parseInt(number = (+number || 0).toFixed(decimals)) + "";

    if( (j = i.length) > 3 ){
        j = j % 3;
    } else{
        j = 0;
    }

    km = (j ? i.substr(0, j) + thousands_sep : "");
    kw = i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousands_sep);
    //kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).slice(2) : "");
    kd = (decimals ? dec_point + Math.abs(number - i).toFixed(decimals).replace(/-/, 0).slice(2) : "");


    return km + kw + kd;
}








            /*** FLASH ***/
			$(document).ready(function(){
				$('.flash').each(function(){				//
				//alert(this.id)
				  $(this).flash({
						src: this.id,
						wmode: 'opaque',
						width: 260,
						height: 195
					},
					{
						version: 8
					});
				//				})



					// MIN HEIGHT for CONTENT
					if ($("#content").height() < $("#bodyr").height())
						$("#content").height($("#bodyr").height()+130)
			});

