

/*****************Fullscreen*************************************************************************************/

/**
 * toggles between fullscreen and normal modes.
 * 
 * fullscreen is included here becuase it is a custom class that manipulates the GMap layer
 */
var Fullscreen=new Class(
		{
			initialize:function(element,parent,onToggle)
			{
			this.parent=parent;
			this.element=element;
			this.onToggle=onToggle;
			this.root=document.getElementsByTagName("body")[0]; //only one body!
			this.toggle=Fullscreen.max;
			},

			execute:function(fullScreen){	
				fullScreen.toggle=fullScreen.toggle(fullScreen);
				fullScreen.onToggle();
				fullScreen.fireEvent('onResize');
			}
		});
Fullscreen.implement(new Events());

/**
 * Fullscreen static methods
 */
Fullscreen.max=function(fullScreen)
{	
	mm_debug("Event - Maximized");
	fullScreen.children=[];
	fullScreen.parent.removeChild(fullScreen.element);
	$each(fullScreen.root.childNodes, function(child){
		fullScreen.children.push(child);
	});	
	//separate remove loop because '$each method' is effected by the act of removing...
	$each(fullScreen.children, function(child){
		if($type(child)=='element'||child instanceof HTMLElement||child instanceof HTMLDivElement)
			fullScreen.root.removeChild(child);
		else
		{
			//alert((child)); //to see if any elements slipped by (during testing)
		}
	});		
	fullScreen.root.appendChild(fullScreen.element);
	$each(fullScreen.children, function(child){
		if(($type(child)=='element'||child instanceof HTMLElement||child instanceof HTMLDivElement)&&
				(child.getAttribute('class')=="media-tip"||child.getAttribute('id')=="sbox-overlay"||child.getAttribute('id')=="sbox-window"))
		{
			fullScreen.root.appendChild(child);
			child.style.top="0px";
			child.style.left="0px";
		}
	});	
	fullScreen.element.style.position="absolute";
	fullScreen.element.style.top="0px";
	fullScreen.element.style.left="0px";
	fullScreen.element.style.overflow="hidden";


	fullScreen.fireEvent("onMaximize");
	return Fullscreen.min;	//returns the undo function
};
Fullscreen.min=function(fullScreen){
	mm_debug("Event - Minimized");

	var children=[];
	$each(fullScreen.root.childNodes, function(child){
		children.push(child);
	});	
	$each(children, function(child){
		if(($type(child)=='element'||child instanceof HTMLElement||child instanceof HTMLDivElement))
			fullScreen.root.removeChild(child);
	});	
	$each(fullScreen.children,function(child){
		if(($type(child)=='element'||child instanceof HTMLElement||child instanceof HTMLDivElement))
			fullScreen.root.appendChild(child);
	});

	fullScreen.parent.appendChild(fullScreen.element);
	fullScreen.element.style.position="";
	fullScreen.element.style.top="";
	fullScreen.element.style.left="";
	fullScreen.element.style.overflow="";
	fullScreen.fireEvent("onMinimize");
	return Fullscreen.max;
};


