// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
function getPageScroll() {
    var xScroll, yScroll;
    if (self.pageYOffset) {
        yScroll = self.pageYOffset;
        xScroll = self.pageXOffset;
    } else if (document.documentElement && document.documentElement.scrollTop) {
        yScroll = document.documentElement.scrollTop;
        xScroll = document.documentElement.scrollLeft;
    } else if (document.body) {
        yScroll = document.body.scrollTop;
        xScroll = document.body.scrollLeft;
    }
    arrayPageScroll = new Array(xScroll, yScroll);
    return arrayPageScroll;
}

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function SpotLight(contentType, contentSrc, contentWidth, contentHeight, contentFlashvars, contentParams) {
	
	//Get page and window dimensions, determine placement of spotlight window
	var documentHeight = $(document).height();
	var documentWidth = $(document).width();
	var arrayPageScroll = getPageScroll();
	var arrayPageSize = getPageSize();
	var topPosition = arrayPageScroll[1] + 50;
	var leftPosition = ((arrayPageSize[0] - 20 - contentWidth) / 2);
	
	//Set the URL for the donate page
	var donateUrl = baseUrl+"Donate/Donate.html";
	
	if (contentType == 'iframe') {
		$("body").append("<div id='overlay'></div><div class='spotlight'><a href='#' class='spotLightClose'>Close</a><br /><div id='spotlightContent'></div></div>");	
		$("#overlay").css({height:documentHeight, width:documentWidth, "display":"block"});
		$("div.spotlight").css({"display":"block","position":"absolute","top":topPosition,"left":leftPosition,"width":contentWidth});
		contentHeight = contentHeight+20;
		$("#spotlightContent").append("<iframe src="+contentSrc+" marginheight='0' marginwidth='0' frameborder='0' height="+contentHeight+" width="+contentWidth+" scrolling='auto' allowtransparency='true'></iframe>");
	}	
	
	if (contentType == 'flash') {
		$("body").append("<div id='overlay'></div><div class='spotlight'><a href="+donateUrl+" class='spotLightDonate'></a><a href='#' class='spotLightClose'>Close</a><br /><div id='spotlightContent'></div></div>");	
		$("#overlay").css({height:documentHeight, width:documentWidth, "display":"block"});
		$("div.spotlight").css({"display":"block","position":"absolute","top":topPosition,"left":leftPosition,"width":contentWidth});
		swfobject.embedSWF(contentSrc,"spotlightContent",contentWidth,contentHeight,"9.0.0","js/expressInstall.swf",contentFlashvars, contentParams);
	}	
	
	$("a.spotLightClose").bind("click", function() {
		$("#overlay").remove();
		$("div.spotlight").remove();
		return false;
		});
}