
this.overlayPreview = function(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.overlay").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='overlay'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("#overlay")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#overlay").remove();
    });	
	$("a.overlay").mousemove(function(e){
		$("#overlay")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	overlayPreview();
});

function show_registry(section,id) {
		$("input[name='product']").val(id);
		tb_show('Add To Gift Registry', '/ajax/store/' + section + '/registry_select/' + id + '/?height=240&width=300', 'false');
}

function add_to_gift_registry(id, product_id) {
	var p = $("input[name='product']").val();
	var qname = "input[name='cart_quan[" + product_id + "]']";
	var q = $(qname).val();
	$("input[name='store_action']").val('add_to_registry');
	$("input[name='registry']").val(id);
	$("input[name='quantity']").val(q);
	tb_remove();
	$('#product_form').submit();
}

function toggleDisplay(divId) {
	
	var obj;
	obj = document.getElementById(divId);
	
	if (obj.style.display=="none") {
		obj.style.display="inline";
	} else {
		obj.style.display="none";
	}	
}
