jQuery(document).ready(function(){
	var maskHeight = jQuery(document).height();
	var maskWidth = jQuery(document).width();

	jQuery("#shadow").css({visibility:"hidden", background:"#222", position:"absolute", opacity:"0", height:maskHeight, width:maskWidth})
		.css("z-index", 999);
	
	jQuery("a[rel=shadowbox]").click(function(){
		jQuery("#shadow").css("visibility", "visible").animate({opacity:".7"}, 1000);
		var taghref = jQuery(this).attr("href");
		var href = taghref.split("#");
		var url = href[1];
		getContent(url);
	});
	
	jQuery("#shadow").click(function(){
		jQuery("#box").fadeOut(500, function(){
			jQuery.delay(500);
			jQuery(this).remove();
			jQuery("#shadow").animate({opacity:"0"}, 500).css('visibility', 'hidden');
		});
	});
});

function getContent(path)
{
	var userAgent = navigator.userAgent;
	var itemWidth = 360;
	var contentBox = jQuery("<div id=box class=clearfix></box>").insertAfter("#shadow");
	var msie = userAgent.search("MSIE");
	if(msie == -1)
	{
		var marginLeft = (itemWidth/2)*-1 + "px";
		jQuery("#box").css({"margin-left":marginLeft, background:"#FFB231", left:"50%"});
	}
	else
	{
		var marginLeft = (itemWidth/2)*-1 + "px";
		jQuery("#box").css({"margin-left":marginLeft, background:"#FFB231", left:"50%", width:"475px"});
	}
	path = "/wp-content/themes/obscure/library/scripts/" + path;
	
	jQuery("#box").load(path, function(response, status, xhr){
		if(status == "error")
		{
			var msg = "There was an error loading the document";
		}
		else
		{
			jQuery("#box").html(response);
		}
	});
}
