$(document).ready(function(){
	//ACTIONS FOR THE LOGIN POPUP WINDOW-------------------
	//load the login popup window when the button is clicked
	$("#formDeleteLink").click(function(){
		//center the window
		centerPopup("deletePopup", "deletePopupBkgd");
		//load the window
		loadPopup("deletePopup", "deletePopupBkgd");
		return false;

		
	});

	//closing the popup with the corner X button
	$("#cancelDeleteBtn").click(function(){
		disablePopup("deletePopup", "deletePopupBkgd");
	});

	//close popup when background is clicked
	$("#deletePopupBkgd").click(function(){
		disablePopup("deletePopup", "deletePopupBkgd");
	});


	$("#confirmDeleteBtn").click(function(){
			disablePopup("deletePopup", "deletePopupBkgd");
			return true;
		});
	
	//------------------------------------------------------
});



//setup popup
//0 means disabled; 1 means enabled
var popupStatus = 0;

//function to load popup
function loadPopup(popupID, backgroundID){
	//loads popup only if it is disabled
	if(popupStatus == 0){
		//change the backgroundPopup opacity to hide the site page elements and give the main popup window more focus
		$("#" + backgroundID).css({
			"opacity" : "0.7",
			"width" : "100%"
		});
		
		$("#" + popupID).css({
			"opacity" : "0.9"
		});

		//gives the backgroundPopup a fade in effect
		$("#" + backgroundID).fadeIn();

		//gives the main popup window a fade in effect
		$("#" + popupID).fadeIn();
		
		//change the popupStatus to 1(enabled)
		popupStatus = 1;
	}
}

//function to close/disable popup
function disablePopup(popUpID, bkgdID){
	//disables popup only if it is enabled
	if(popupStatus == 1){
		//fades the backgroundPopup out to give the full website main focus
		$("#" + bkgdID).fadeOut();

		//fades the main popup window out to give the full website focus
		$("#" + popUpID).fadeOut();

		//change the popupStatus to 0(disabled)
		popupStatus = 0;
	}
}

//function to center the main popup window in the browser window
function centerPopup(popupID, bkgdID) {
	if( typeof(window.innerWidth) == 'number' ){
		//non-IE
		var windowWidth = window.innerWidth;
		var windowHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in standards complaint mode
		//variables to hold browser window width/height
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight )){
		//IE 4 compatible
		var windowWidth = document.body.clientWidth;
		var windowHeight = document.body.clientHeight;
	}
	
	//variables to hold the popup window width/height
	var popupHeight = $("#" + popupID).height();
	var popupWidth = $("#" + popupID).width();

	//need to force the style for IE6
	$("#" + bkgdID).css({
		"height" : windowHeight,
		"width" : windowWidth
	});

	//centering
	$("#" + popupID).css({
		"top" : windowHeight/2-popupHeight/2,
		"left" : windowWidth/2-popupWidth/2
	});
}
