// TodBox v.1.0
// Copywright Destinys Design (Aaron Laytom (indaGalaxy.co.uk) & Andrew Beniston (tryordie.co.uk)


function DisplayBox(pageURL, pageData, bWidth, bHeight){
	OpenBox(bWidth,bHeight);
	$('#windowBox').html("<center><img src='/images/icons/ajaxloading1.gif' style='margin-top:50%;></center>");
	var proccessPage = function(r){
		result = r;	
		$('#windowBox').html(result);
	}
	$.ajax({type: 'POST', url:pageURL, data:pageData,success:proccessPage, error: function(xhr, desc, exceptionobj){alert(xhr.responseText);CloseBox();}});
}

function OpenBox(bWidth,bHeight){
	var dWidth = $(document).width();
	$('#shadowBox').css('display', '');
	$('#shadowBox').animate({"opacity": 0.5, "width":(bWidth+22)+'px',"height":(bHeight+22)+'px',"left":((dWidth/2)-(bWidth/2)-10)+'px'},600);
	$('#windowBox').css('display', '');
	$('#windowBox').animate({"opacity": 1, "width":bWidth+'px',"height":bHeight+'px',"left":((dWidth/2)-(bWidth/2))+'px'},600);
	$('#windowClose').show();
	$('#windowClose').animate({"opacity": 1,"left":Math.round((dWidth/2)+(bWidth/2)-10)+'px'},600);
}

function CloseBox(){
	var tmp = $(document).width()
	$('#shadowBox').animate({"opacity": 0, "width":70+'px',"height":70+'px',"left":((tmp/2)-35)+'px'},600, "linear", function(){$('#shadowBox').hide();});
	$('#windowBox').animate({"opacity": 0, "width":50+'px',"height":50+'px',"left":((tmp/2)-25)+'px'},600, "linear", function(){$('#windowBox').hide();});
	$('#windowClose').animate({"opacity": 0,"left": ((tmp/2)+10)},600, "linear", function(){$('#windowClose').hide();});
}

$(window).load(function(){
	var tmp = $(document).width();
	$('#shadowBox').css({"left": ((tmp/2)-35)+'px'}).width(70).height(70);
	$('#windowBox').css({"left": ((tmp/2)-25)+'px'}).width(50).height(50);
	$('#windowClose').css({"left": ((tmp/2)+10)});
});