$(document).ready(function(){


 $(".top_butt div").hover(
      function () {
		$(this).css("background-image","url(img/butt_top2.gif)")
      }, 
      function () {
		$(this).css("background-image","url(img/butt_top.gif)")
      }
    );
    
$(".input").click(function(){
	$(this).val("");
	$(this).css("color","black");
	
})
    
$("a").click(function(){
	if($(this).hasClass("direct_link")){
		return true;
	}

hr = $(this).attr("href");
hr = hr.replace('http://' + location.host + '/','');
hr = hr.replace('index.php','');
hr = hr.replace('./?','');
	
	if($(this).hasClass("buy_link")){
		ret = add_to_cart(this,hr);
		if(ret == true){
			
		}else{
			return false;
		}
	}


get_html(hr);
$(".images_box").fancybox();
return false;
});



//-------------- grozs ---------------------------------------------------------------------
	//scroll the message box to the top offset of browser's scrool bar
	$(window).scroll(function()
	{
  		$('#message_box').animate({top:$(window).scrollTop()+"px" },{queue: false, duration: 350});  
	});
    //when the close button at right corner of the message box is clicked 
	$('#close_message').click(function()
	{
  		//the messagebox gets scrool down with top property and gets hidden with zero opacity 
		$('#message_box').animate({ top:"+=15px",opacity:0 }, "slow");
	});
//-------------------------------------------------------------------------------------------

})




function get_html(send){
//alert(send)
$("#loader").css("display","block");
//alert("sys/mod/body_mid.php?" + send)
$.ajax({
   type: "GET",
   url: "sys/mod/body_mid.php?" + send + "&InSess="+sess,
   dataType: "html",
   success: function(htmls){
     $("#loader").css("display","none");
     $("#main").html(htmls);
     $(".images_box").fancybox();
     $("#main a").click(function(){

if($(this).hasClass("direct_link")){
	return true;
}

hr = $(this).attr("href");
hr = hr.replace('http://' + location.host + '/','');
hr = hr.replace('index.php','');
hr = hr.replace('./?','');
hr = hr.replace('?','');
	if($(this).hasClass("buy_link")){
		ret = add_to_cart(this,hr);
		if(ret == true){
			
		}else{
			return false;
		}
	}
get_html(hr);
	return false;
	});
	$(".images_box").fancybox();
   }
 });

}

function login(){
user=$("#user").val();
pass=$("#pass").val();
get_html("login&user="+user+"&pass="+pass);

}


function change_price(element , id){
$("#price_"+id).html($(element).val());
$("#price_link_"+id).attr("href","./?id=order&ord_id="+id+"&count="+escape($(element).val()));

}

