﻿/// <reference path="jquery-1.3.2.min-vsdoc.js" />

function showOverlay() {
	//jQuery(document).ready(function() {
	var divTag = document.createElement("div");
	divTag.id = "overlayDiv";
	divTag.className = "overlayDiv";

	pageWidth = jQuery(document).width();
	pageHeight = jQuery(document).height();

	divTag.style.width = pageWidth + 'px';
	divTag.style.height = pageHeight + 'px';
	divTag.innerHTML = '&nbsp';
	document.body.appendChild(divTag);
	//$('.overlayDiv').show();
	//});
}

function hideOverlay() {
	$('.overlayDiv').remove();
}

function hideOverlayContent() {
	$('.overlayContent').hide();
}

function centerOverlayContent(idOverlayContent) {
	document.getElementById(idOverlayContent).style.display = "block";
	var div = document.getElementById(idOverlayContent);
	var w = parseInt(document.getElementById(idOverlayContent).offsetWidth);
	var h = parseInt(document.getElementById(idOverlayContent).offsetHeight);

	pageWidth = jQuery(window).width();
	pageHeight = jQuery(window).height();

	document.getElementById(idOverlayContent).style.top = (pageHeight - h) / 2 + "px";
	document.getElementById(idOverlayContent).style.left = (pageWidth - w) / 2 + "px";
}

function showModalInline(clientId) {
	hideOverlay();
	document.getElementById(clientId).style.display = "block";
	showOverlay();
}

function showModalCentered(idOverlayContent) {
	//jQuery(document).ready(function() {
	hideOverlay();
	centerOverlayContent(idOverlayContent);
	showOverlay();
	//});
}

function hideModal() {
	//jQuery(document).ready(function() {
	hideOverlayContent();
	hideOverlay();
	//});
}

// PANEL LOADING ANIMATION
function onUpdating(divId) {
	if (divId != '') {
		// get the update progress div
		var pnlPopup = $get('AjaxProgressPopUp');

		// get the gridview element
		var gridView = $get(divId);
		$('#' + divId).addClass("Opacity");
		// make it visible
		pnlPopup.style.display = '';

		// get the bounds of both the gridview and the progress div
		var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
		var pnlPopupBounds = Sys.UI.DomElement.getBounds(pnlPopup);

		//  center of gridview
		var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(pnlPopupBounds.width / 2);
		var y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(pnlPopupBounds.height / 2);

		//	set the progress element to this position
		Sys.UI.DomElement.setLocation(pnlPopup, x, y);
	}
}

function onUpdated(divId) {
	// get the update progress div
	var pnlPopup = $('#AjaxProgressPopUp');
	// make it invisible
	if(divId == "")
		$(".Opacity").removeClass("Opacity");
	else
		$('#' + divId).removeClass("Opacity");

	$(pnlPopup).hide();
}