// JavaScript Document
	// set up ftk and register components
	ftk.setComponentPath('js');
	ftk.registerComponent('ftk.window');
	ftk.registerComponent('ftk.mask');
	
	var maskObj;
	var allWindows;

	//  Use these two variables to play with the position of the close button //
	var xOffset = 40; // increasing this moves it LEFT
	var yOffset = 10; // increasing this moves it UP
	
	// Need More
	var demographics;
	var closeButton;
	
	// Initialize //
	function init()
	{
		// check if component is loaded and ready to use
		if(!ftk.areAllComponentsLoaded())
		{
			setTimeout(init, 5); // try again in 5 ms
			return;
		}
				
		maskObj = new ftk.mask('#000000',60);
		
		// Need More
		demographics = new ftk.window('demographics');
		closeButton = new ftk.window('closeButton');
		
	
		allWindows = new Array();
	
		// Need More
		allWindows.push(demographics);

	}
	
	function hideAllWindows(obj)
	{
		for(var i = 0 ; i < allWindows.length ; i++)
			if(allWindows[i] != obj)
				allWindows[i].fadeOut(500);
		
		if(obj == null)
		{
			maskObj.unmask(500);
			closeButton.fadeOut(500);
		}
	}
	
	function showWindow(obj)
	{
		hideAllWindows(obj);
		//resetErrors();
	
		obj.show();
		obj.setOpacity(0);
		obj.fadeToOpacity(90, 500);
		obj.center();

		closeButton.show();
		closeButton.setOpacity(0);
		closeButton.fadeIn(500);
		closeButton.setPosition(obj.getX() + obj.getWidth() - xOffset, obj.getY() - yOffset);
		closeButton.setZIndex(500);
		
		maskObj.mask(500);
	}

	// setup onload
	if (window.addEventListener)
		window.addEventListener('load', init, false);
	else if (window.attachEvent)
		window.attachEvent('onload', init);
	else
		window.onload = init;