var selectedStack = null;

function openEditor()
{
	url = '/editor';
	popSettings = "width=1024,height=400,scrollbars=yes";
	popupWin = open( url, "popupWin", popSettings );
}

function highlightObject(obj)
{
	/*var offset = $(obj).offset();

	$('#highlighterTool').css('border', '3px solid #41a5ec');
	$('#highlighterTool').css('position', 'absolute');
	$('#highlighterTool').css('left', offset.left);
	$('#highlighterTool').css('top', offset.top-1 );
	$('#highlighterTool').css('width', $(obj).width()-6);
	$('#highlighterTool').css('height', $(obj ).height()-3);
	
	if( selectedObject != null )
		$(selectedObject).css('border',lastBorder);
		
	lastBorder = $(obj).css('border');
	if( lastBorder == null )
		lastBorder = '';
	
	selectedObject = obj;
	//$(obj).css('border', '3px solid #41a5ec');
	
	//alert(obj.id);
	*/
}

function getStack(eventObj)
{
	if( this.id != "" && this.id != 'highlighterTool' )
	{		
		//alert(this.id);
			
		selectedStack = Array();
		selectedStack.push(this.id);	
	
		eventObj.stopPropagation();	
		//highlightObject(this);
		
		$(this).parents().map
		(
			function() 
			{ 
				if( this.id != '' && this.id != null )
				selectedStack.push(this.id); 
			}
		);		
		
		if( window.popupWin && window.popupWin.setStack)
			popupWin.setStack(selectedStack);
	}
}

/*$(document).ready
(
	function() 
	{
		$('div,img,span').bind('mouseup', getStack);
		//$('body').prepend('<div id="highlighterTool"></div>');
	}
);*/

bind(document, 'keypress', keyPressed);

function keyPressed(e)
{
	if( document.all ) e = window.event;
	
	if(String.fromCharCode(e.charCode) == 'e' && e.ctrlKey)
	{
		openEditor();
	}
}
