/**
 * @author bao.nguyen
 */
// Shows the containing div

var originalTopLocation = null;
var originalLeftLocation = null;
function grapeTipGrow(){
	// calculate top location for the grape-tip containing div...current = current - 140
	if (originalTopLocation == null) {
  	originalTopLocation = document.getElementById('grape-tip-container').style.top;
  }
	var topLocation = originalTopLocation.split('px');
	var topLocation = parseInt(topLocation[0]) - 165;
	document.getElementById('grape-tip-container').style.top = topLocation + 'px';
	//check if grape announces to the left
	if (document.getElementById('grape-tip-container').className == 'grape-tip-left'){
		//calulate left movement
		if (originalLeftLocation == null) {
		  originalLeftLocation = document.getElementById('grape-tip-container').style.left;
	  }
		var leftLocation = originalLeftLocation.split('px');
		var leftLocation = parseInt(leftLocation[0]) - 243;
		document.getElementById('grape-tip-container').style.left = leftLocation + 'px';
		document.getElementById('grape-tip').style.left = '243px';
	}
	// set the size of the containing div
	document.getElementById('grape-tip-container').style.width = '300px';
	document.getElementById('grape-tip-container').style.height = '235px';	
	document.getElementById('grape-tip').style.top = '165px';
}

function grapeTipShrink(){
	// calculate top location for the grape-tip containing div...current = current + 140

	document.getElementById('grape-tip-container').style.top = originalTopLocation;
	
	//check if grape announces to the left
	if (document.getElementById('grape-tip-container').className == 'grape-tip-left'){
		//calulate left movement
		document.getElementById('grape-tip-container').style.left = originalLeftLocation;
		document.getElementById('grape-tip').style.left = '0px';
	}
	// reset the size of the containing div
	document.getElementById('grape-tip').style.top = '0px';	
	document.getElementById('grape-tip-container').style.width = '50px';
	document.getElementById('grape-tip-container').style.height = '50px';	
}

function autoInstallFlashPlayer(){
	var version = deconcept.SWFObjectUtil.getPlayerVersion();
	// if version[major] == 0 - no flash player installed
	if (version["major"] == 0) {
    // use run ActiveContent
		  AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','name','empty-swf','width','1','height','1','src','media/swf/empty','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','media/swf/empty' ); //end AC code
		}
		// elseif version major < 0
		else if (version["major"] < 9) {			
			// do express install
			var htmlToWrite = '<div id="express-install" style="position:absolute;z-index: 600000; margin: 0 0;top:0; width: 100%; height: 100%;"></div>';			
			document.write(htmlToWrite);
			var fo = new SWFObject("/media/swf/empty.swf", "empty-swf", "100%", "100%", "9", "#ffffff", "high");
			fo.useExpressInstall("/media/swf/expressinstall.swf");
			fo.addParam("wmode", "transparent");
			fo.write("express-install");			
			}
}

function toggleTreeMenu(toggleElement){
	// (check to see if menu is opened or closed (get class name))
	// get class name for anchor tag
	// if opened (menu-collapse)

	if(Element.hasClassName(toggleElement,'menu-collapse')){
		// (close)
		// get ul tag (sibling?) or get parent li, and get ul, set display to none
		toggleElement.up('li').down('ul').hide();
		
		// set anchor class to collapsed
		Element.removeClassName(toggleElement,'menu-collapse');
		Element.addClassName(toggleElement,'menu-expand');
	}
	// else closed (menu-expand)
	else if(Element.hasClassName(toggleElement,'menu-expand')){
		// (open)
		// get ul tag (sibling?) or get parent li, and get ul, set display to block
		toggleElement.up('li').down('ul').show();		
		
		// set anchor class to expanded
		Element.removeClassName(toggleElement,'menu-expand');
		Element.addClassName(toggleElement,'menu-collapse');	
	}

}

