$(document).ready(function(){	

var bars = "Септик для дачи и дома БАРС";
h1 = $("h1");
$.each(h1,function(){
	if ($(this).text() == bars){
		var barsNew = "Септики <span class='bars'>БАРС</span> <span class='barsSmall'>(B.A.R.S. - biological aqua refining systems)</span><br /><span class='barsLast'>На страже вашего комфорта!</span>";
		$(this).parent().append("<h2 style='font-size:30px'>"+barsNew+"</h2>").next();
		$(this).css("font-size","18px");
	}
});
$("h1").show();
$(".tableImgImg").css({
position: "absolute",
"z-index": "40"
});

var price = "Цены рассчитываются индивидуально";
priceValue = $(".shop_price_value");
$.each(priceValue,function(){
	if ($(this).text() == "1"){
		$(this).text(price);
		$(this).next().hide();
		$(this).prev().hide();
		$(this).css({
			"font-size":"110%",
			"text-align":"left"
		});
		$(this).parent(".price").css({
			height: "50px"
		});
	}
});

$('.goods ul li:even').css({
	clear: 'both',
	display: 'block'
});

if (window.external && (typeof window.XMLHttpRequest == "undefined")) {
  w = $(window).width();
  wWrap = $("#wrap").width();
  wLeft = ( w - wWrap ) / 2;
  $("#wrap").css({
	"margin-left": wLeft + "px"
  });
	
}

$(".tableImgImg table").css({
position: "absolute",
"z-index": "40"
});
$(".tableImgImg table img").css({
position: "absolute",
"z-index": "40",
display: "block"
});

$(".arrsIMG").css({
position: "absolute",
width: "100%",
height: "100%",
"z-index": "1000"
});

$(".notHover").hover(function(){
	$(this).css({
		background: "none",
		color: "#4F4F4F"
	});
});

$(".tdHover3").hover(function(){
	$(".tdHover3").css({
		background: "#8BA92E",
		color: "#FFFFFF"
	});
},function(){
	$(".tdHover3").css({
		background: "none",
		color: "#4F4F4F"
	});
});

$(".tdHover2").hover(function(){
	$(".tdHover2").css({
		background: "#8BA92E",
		color: "#FFFFFF"
	});
},function(){
	$(".tdHover2").css({
		background: "none",
		color: "#4F4F4F"
	});
});

$(".tdHover1").hover(function(){
	$(".tdHover1").css({
		background: "#8BA92E",
		color: "#FFFFFF"
	});
},function(){
	$(".tdHover1").css({
		background: "none",
		color: "#4F4F4F"
	});
});

$("#notPos tr").hover(function(){
	$(this).css({
		background: "none",
		color: "#4F4F4F"
	})
});

$('.calendaric')
.datePicker({inline:true})
.bind('dateSelected',function(e, selectedDate, $td)
{
alert(selectedDate.asString());
}
);

$(".wellleft").hover(function(){
	//$(".str-left:first").css({
		//"background-position": "-219px -50px"
	//});
	$(this).css({
		background: "url(../../../img/leftBut.png) left center no-repeat"
	});
},function(){
	//$(".str-left:first").css({
		//"background-position": "-264px -36px"
	//});
	$(this).css({
		background: "url(../../../img/none.png) right center no-repeat"
	});
});
/* $(".str-left:first").hover(function(){
	$(this).css({
		//"background-position": "-219px -50px"
	});
	$(".wellleft").css({
		background: "url(../../../img/leftBut.png) left center no-repeat"
	});
},function(){
	$(this).css({
		//"background-position": "-264px -36px"
	});
	$(".wellleft").css({
		background: "none"
	});
}); */



$(".wellright").hover(function(){
	//$(".str-right:first").css({
		//"background-position": "-264px -73px"
	//});
	$(this).css({
		background: "url(../../../img/rightBut.png) right center no-repeat"
	});
},function(){
	//$(".str-right:first").css({
		//"background-position": "-264px 0"
	//});
	$(this).css({
		background: "url(../../../img/none.png) right center no-repeat"
	});
});
/* $(".str-right:first").hover(function(){
	$(this).css({
		//"background-position": "-264px -73px"
	});
	$(".wellright").css({
		background: "url(../../../img/rightBut.png) right center no-repeat"
	});
},function(){
	$(this).css({
		//"background-position": "-264px 0"
	});
	$(".wellright").css({
		background: "none"
	});
}); */

$('#slide_block .strela_2').mousedown( function() { 
		$('#slide_block .strela_2').addClass('move');
		slider_move_left();												  
	  });
  $('#slide_block .strela_2').mouseup(function() {
     $('#slide_block .strela_2').removeClass('move');
    });
  $('#slide_block .strela_1').mousedown(function() {
		$('#slide_block .strela_1').addClass('move');
		slider_move_right();		
   });
  $('#slide_block .strela_1').mouseup(function() {
     $('#slide_block .strela_1').removeClass('move');
    });
    $('#gallery_block .close').click(function() {
     $('#gallery_block').animate({'opacity':'hide'});
    });
	$('#slide_block .slide_body a').click(function() {
	var num=$('#slide_block .slide_body a').index(this);
	num1=num-1;
	num2=num+1;
	$('#gallery_block .str-left').attr('id',num1);
	$('#gallery_block .str-right').attr('id',num2);
	gallery(num);
	 return false
    }); 
	$('#gallery_block .str-left').click(function() {
if ($(this).attr('id')==-1){}
else {
gallery($(this).attr('id'));	
var zz=$(this).attr('id')-0;
zz1=zz-1;
zz2=zz+1;
$('#gallery_block .str-left').attr('id',zz1);
$('#gallery_block .str-right').attr('id',zz2);
}
 });
 $('#gallery_block .str-right').click(function() {

if ($(this).attr('id')>$('#slide_block ul a').length-1){}
else {
gallery($(this).attr('id'));
var zz=$(this).attr('id')-0;
zz1=zz-1;
zz2=zz+1;
$('#gallery_block .str-left').attr('id',zz1);
$('#gallery_block .str-right').attr('id',zz2);
}
});

});

function slider_move_left(){
if ($('#slide_block .strela_2').attr('class')=='strela_2 move'){
var ul=$('#slide_block .slide_body ul:first').width();	
var left=$('#slide_block .long').css('left');
var left=left.replace(/px/, "")-0;
if (ul<=615-left){}
else {
left-=10;
$('#slide_block .long').css({left:left});
setTimeout('slider_move_left()', 20)
}
}
else {}
}

function slider_move_right(){
	if ($('#slide_block .strela_1').attr('class')=='strela_1 move'){		
var left=$('#slide_block .long').css('left');
var left=left.replace(/px/, "")-0;
if (left>=0){}
else {
left=left+10;
$('#slide_block .long').css({left:left});
setTimeout('slider_move_right()', 20)
}
}
else {}
}

function gallery(num){

$('#gallery_block .foto img:first').remove();
	var i = new Image();
	if ($.browser.msie) {
            i.src = $('#slide_block .slide_body a').eq(num).attr('href')+ "?" + new Date().getTime();
			}
			else {
			 i.src = $('#slide_block .slide_body a').eq(num).attr('href');	
			}
		
	 $(i).load (function(){
		$('#gallery_block .foto').append(i);				 
	$('#gallery_block').animate({'opacity':'show'});
		if ($.browser.msie && $.browser.version == 6) {
	if ($('#gallery_block .foto img:first').width() > 476){$('#gallery_block .foto img:first').css({'width':'476px'})
	if ($('#gallery_block .foto img:first').height() > 276){$('#gallery_block .foto img:first').css({'height':'276px', 'width':'auto'})}
	}
	else if ($('#gallery_block .foto img:first').height() > 276){$('#gallery_block .foto img:first').css({'height':'276px'})}
	else {}
	}
	});					
}


