$(function() {


/*	
	var obgParent = $("body");
	var obgNav = $("body:not(#flash) ul.nav");
	
	var aCur= obgParent.attr("class");
   var aCurA=aCur.replace("navigate-","");
	var aNext="";
	var aNextOld="";


var str = document.location.href;
var pattern = /\//;
result = str.split(pattern)[4];

if(result == undefined || result.length < 1 || str.split(pattern)[3] != 'products'){
	result="navigate-main";	
}



$("body").attr("class","navigate-"+result);
var newimage="url(/images/nav/"+result+".index.png)";
var newid="#"+result+"";
//alert(newid);
//changeNav($("#ochistnye_sooruzheniya"));
//changeNav(($(newid)));
changeNav(($(newid)));



		
	$("a",obgNav).click(function(){
//		changeNav($("#ochistnye_sooruzheniya"));
		changeNav($(this));
//		return false;
	  return true;	
	});

*/
	
	$(".search input[type='image'],.login input[type='image']").hover(
      function () {
        $(this).attr("src","/images/buttons/search.h.png");
      },
      function () {
        $(this).attr("src","/images/buttons/search.png");
      }
    );
	
	$("#flash .enter img").hover(
      function () {
        $(this).attr("src","/images/enter.h.png");
      },
      function () {
        $(this).attr("src","/images/enter.png");
      }
    );
	
	$(".submit-button").hover(
      function () {
        $(this).addClass("submit-button-hover");
      },
      function () {
        $(this).removeClass("submit-button-hover");
      }
    );
	
	
	
	function calcHeight() {		
	
		$(".borders").css("height","auto");

		var heightNormal = parseInt ($(".borders").height());
		var heightCalck = $(window).height() - $(".head").height() - $(".footer").height();
		//alert (heightNormal +"..."+heightCalck)
		
		if ( heightNormal > heightCalck){
			if ( heightNormal > $(".nav").height()){
				$(".borders").css(heightNormal);
			}else{
				$(".borders").height($(".nav").height() - 5 );
			}
		}else{
			if ( heightCalck > $(".nav").height()){
				$(".borders").height(heightCalck);
			}else{
				$(".borders").height($(".nav").height() - 5 );
			}
		}
		/*
		if ( heightNormal < $(".nav").height()){

			if ( heightCalck > $(".nav").height()) ){
				$(".borders").height(heightCalck);
			}else{
				$(".borders").height($(".nav").height());
			}
		}else{
			if ( heightCalck > $(".nav").height()) ){
				$(".borders").height(heightCalck);
			}else{
				$(".borders").height($(".nav").height());
			}
			if ( heightCalck > 450 ){
				$(".borders").height(heightCalck);
			}else{
				//$(".borders").height("450px");
			}
		}*/
		
	}
	
	function changeNav(element) {
//	   alert(imOld);
		aNext = $(element).attr("rel");
		aNextA = $(element).attr("id");
		im="url(/images/nav/"+aNextA+".index.png)";
      $("#"+aNextA).css("background-image",im);

		obgParent.removeClass(aCur);
		obgParent.addClass(aNext);
      aCurA=aCur.replace("navigate-","");
		imOld="url(/images/nav/"+aCurA+".png)";
      $("#"+aCurA).css("background-image",imOld);
		aCur = aNext;
		aCurA = aNextA;

		
		calcHeight();
	}

	
	
	calcHeight();
	$(window).bind('resize', function() {
		calcHeight();
	});

	
});
