/************************
* Author: Todd Langford
* Copyright 2011
************************/

/* Initialize Variables */
var popupStatus = 0;

function loadPopup(id) {  
	if(popupStatus==0) {  
		$("#backgroundPopup").css({ "opacity": "0.7" });  
		$("#backgroundPopup").fadeIn("slow");  
		$("#"+id).fadeIn("slow");  
		popupStatus = 1;  
	} 
}  

function disablePopup(id) {  
	if(popupStatus==1){  
		$("#backgroundPopup").fadeOut("slow");  
		$("#"+id).fadeOut("slow");  
		popupStatus = 0;  
	}  
}  

function centerPopup(id) {  
	var windowWidth = document.documentElement.clientWidth;  
	var windowHeight = document.documentElement.clientHeight; 
	var popupHeight = $("#"+id).height(); 
	var popupWidth = $("#"+id).width(); 
	$("#"+id).css({  
		"position": "fixed",  
		"top": windowHeight/2-popupHeight/2,  
		"left": windowWidth/2-popupWidth/2  
	});  
	$("#backgroundPopup").css({  
		"height": windowHeight  
	});  
}  

function openPopup(id) {
	centerPopup(id);
	loadPopup(id);
}

//Display innerHTML of id
function dspHTML(html,id) {
	document.getElementById(id).innerHTML = html;
}

//Hide or Show Divs
function switchit(divID) {
	
	var item = document.getElementById(divID);
	if (item) {
		item.style.display=(item.style.display=='none')?'block':'none';
	}
}

function hidediv(divID) {
	
	var item = document.getElementById(divID);
	item.style.display='none';

}

function showdiv(divID) {
	
	var item = document.getElementById(divID);
	item.style.display='block';

}

function fadediv(divID) {
	var fopacity = document.getElementById(divID).style.opacity;
	if (!fopacity) fopacity = 1;
	//alert('Opacity: '+fopacity);
	document.getElementById(divID).style.opacity = fopacity-0.1;
	document.getElementById(divID).style.filter = 'alpha(opacity='+(fopacity*100)+')';
	//alert('Opacity: '+document.getElementById(divID).style.opacity);
	if (fopacity > 0.1) {
		setTimeout('fadediv("'+divID+'")',100);
	} else {
		document.getElementById(divID).style.visibility = 'hidden';
		document.getElementById(divID).style.opacity = 1;
		document.getElementById(divID).style.filter = 'alpha(opacity=100)';
	}
}

