$(document).ready(function(){
 if (jQuery.browser.msie){
	if($('.content').height() < 550){
		$('.content').css('height','550px');
	};
	var window_width = $('body').width();
	var window_height = $('body').height();
	fixPNG(document.getElementById('transparent_bg'));
	$('.transparent_bg').css('position','absolute');
	$('.transparent_bg').css('width',window_width+'px');
	$('.transparent_bg').css('height',window_height+'px');
	bg_left = (1019-window_width)/2;
	$('.transparent_bg').css('left',bg_left+'px');
 };
 $('div.search_submit').hover(function(){
	 	$(this).css('background-position','-50px 0');
	 },
	 function(){
		$(this).css('background-position','0px 0');
	 }
 );
 $('.person .big_photo a.close').click(function(){
		$(this).parent('.big_photo').hide();
		$('.transparent_bg').hide();
		return false;
	});
 $('.ask_price a.close').click(function(){
		$(this).parent().hide();
		$('.transparent_bg').hide();
		return false;
	});
 if (!jQuery.browser.msie){
   $('.transparent_bg').click(function(){
	 	$('div.ask_price').hide();
		$('.big_photo').hide();
		$('.transparent_bg').hide();
	});
 };
 $("a.lbox").click(function(){
		$(this).parent().find('.big_photo').show();
		if (/MSIE/.test(navigator.userAgent)){
			$(this).parent().find('.transparent_bg').show();
		}else{
			$('.transparent_bg').show();
		};
		return false;
	});
 $(".search_submit").click(function(){
		$(".search-form").submit();
	});
 $(".transparent_bg").each(function(){
		fixPNG(this);
	});
})

function AskPrice(sub){
 if (jQuery.browser.msie){
	 $('#ask_price').parent().show();
	 showdeadcenterdiv(600,300,'ask_price');
	 return false;
//	 return true;
 };
	$('div.ask_price').show();
	$('.transparent_bg').show();
	return false;
}
function fixPNG(element)
{
	if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
		var src;
		if (element.tagName=='IMG'){
			if (/\.png$/.test(element.src)){
				src = element.src;
				element.src = "/i/no.gif";
			}
		}
		else{
			src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
			if (src){
				src = src[1];
				element.runtimeStyle.backgroundImage="none";
			}
		}
		if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
};
function showdeadcenterdiv(Xwidth,Yheight,divid) { 
// First, determine how much the visitor has scrolled 

	var scrolledX, scrolledY; 
	if( self.pageYoffset ) { 
		scrolledX = self.pageXoffset; 
		scrolledY = self.pageYoffset; 
	} else if( document.documentElement && document.documentElement.scrollTop ) { 
		scrolledX = document.documentElement.scrollLeft; 
		scrolledY = document.documentElement.scrollTop; 
	} else if( document.body ) { 
		scrolledX = document.body.scrollLeft; 
		scrolledY = document.body.scrollTop; 
	} 

// Next, determine the coordinates of the center of browser's window 

	var centerX, centerY; 
	if( self.innerHeight ) { 
		centerX = self.innerWidth; 
		centerY = self.innerHeight; 
	} else if( document.documentElement && document.documentElement.clientHeight ) { 
		centerX = document.documentElement.clientWidth; 
		centerY = document.documentElement.clientHeight; 
	} else if( document.body ) { 
		centerX = document.body.clientWidth; 
		centerY = document.body.clientHeight; 
	} 

// Xwidth is the width of the div, Yheight is the height of the 
// div passed as arguments to the function: 
	var leftoffset = scrolledX + (centerX - Xwidth) / 2; 
	var topoffset = scrolledY + (centerY - Yheight) / 2; 
	leftoffset = -250;
// The initial width and height of the div can be set in the 
// style sheet with display:none; divid is passed as an argument to // the function 
	var o=document.getElementById(divid); 
	var r=o.style; 
	r.position='absolute'; 
	r.top = topoffset + 'px'; 
	r.left = leftoffset + 'px'; 
	r.right = 'auto'; 
	r.display = "block"; 
}
