dojo.require("dojo.html.*");
dojo.require("dojo.math.*");
dojo.require("dojo.animation.*");
dojo.require("dojo.event.*");

function openBarebonesWindow( url, width, height ){
		
	window.open( 
		url, 
		'_blank',
		'directories=no, location=no, menubar=no, resizable=no, scrollbars=no,' + 
		'status=no, titlebar=no, toolbar=no, width=' + width + ', height=' + height 
	);
	return false;
}

function openBareScrollWindow( url, width, height ){
		
	window.open( 
		url, 
		'_blank',
		'directories=no, location=no, menubar=no, resizable=no, scrollbars=yes,' + 
		'status=no, titlebar=no, toolbar=no, width=' + width + ', height=' + height 
	);
	return false;
}

function openBasicWindow( url, width, height ){
		
	window.open( 
		url, 
		'_blank',
		'directories=no, location=no, menubar=yes, resizable=no, scrollbars=yes,' + 
		'status=no, titlebar=no, toolbar=no, width=' + width + ', height=' + height 
	);
	return false;
}

/*	
		common setup functionality for all mixin pages
		@param customSetupFunc another user defined function to call after this
*/
function setupPage( customSetupFunc ){
	setupButtons();
	setupFormalMenu();
	if( customSetupFunc ) customSetupFunc();
}

/*
	look for buttons on a page to give them default rollover functionality
*/
function setupButtons(  ){
	
	var buttons = dojo.html.getElementsByClass('button');
	var buttonsOver = dojo.html.getElementsByClass('buttonOver');
	
	for( var i in buttons )
		dojo.event.connect( buttons[i], 'onmouseover', buttonOver );
	
	for( var i in buttonsOver )		
		dojo.event.connect( buttonsOver[i], 'onmouseout', buttonOut );
	
}

// handles what happens then the mouse enters a button
// this presumes that the over img is the first sibling tag after the normal state 
function buttonOver( event ){
	var target = dojo.html.getEventTarget(event);
	target.style.display = 'none';	
	dojo.dom.nextElement(target).style.display = 'inline';	
}

// handles what happens then the mouse leaves a button
function buttonOut( event ){
	var target = dojo.html.getEventTarget( event );
	target.style.display = 'none';	
	dojo.dom.prevElement(target).style.display = 'inline';
}

/* */
function setupFormalMenu(){
	
	var aboutPanel = dojo.byId('aboutPanel');
	
	if( aboutPanel ){
	
		var aboutButtonOver = dojo.html.getElementsByClass('buttonOver', aboutPanel )[0];
		
		dojo.event.connect( aboutButtonOver, 'onclick', function( event )
		{
			var aboutPanel = dojo.byId('aboutPanel');	
			var left 		= dojo.style.totalOffsetLeft( aboutPanel );
			var top 		= dojo.style.totalOffsetTop( aboutPanel );
			var height 	= dojo.style.getPixelValue( aboutPanel, 'height');
			
			var end = ( top < 0 ) ? [ left, 0 ] : [ left, -height]; 
			
			var curve = new dojo.math.curves.Line( [ left, top ], end);
			var anim = new dojo.animation.Animation( curve, 500 );
			
			dojo.event.connect(anim, "onAnimate", function(e) {
					aboutPanel.style.top = e.y + 'px';
			});
			
			anim.play();
			
		});
		
	}// end aboutPanel existance if
	
}// end function setupFormalMenu