$(document).ready(function() {
    //$('img[onclick]').css('cursor', 'hand');
});

$.ajaxSetup({
    headers: {X_EMERGE : "XMLHttpRequest"}
});

function jClosePopup() {
	$('#greyCont').fadeOut('slow', function() {
		$('#greyBox').toggle();
		$('#greyCont').css('border', '0px');
	});

}

function jImagePopup(url) {
	//$('#greyBox').css('visibility', 'visible');
	var dWidth = $(document).width();
	var dHeight = $(document).height();
	var wWidth = $(window).width();
	var wHeight = $(window).height();
	$('#greyBox').toggle();
	$('#greyCont').fadeIn('slow');
	$('#greyCont').html('<img id="p_img" src="'+url+'" class="onclick" onclick="jClosePopup()" />');
	$('#greyCont').css('border', '5px solid white');

	var left = $(window).scrollLeft();
	if($('#p_img').width() < wWidth) {
		left += ((wWidth-$('#p_img').width()) * 0.5);

	}
	var top = $(window).scrollTop();
	$('#greyCont').css('left', ''+left+'px');
	if($('#p_img').height() < wHeight) {
		top += ((wHeight-$('#p_img').height()) * 0.5);
	}
	$('#greyCont').css('top', ''+top+'px');


//	});


}

function jEqualizeValue(src, dest) {
	$('#'+dest).val($('#'+src).val());
}
