
/********************************************************
* Flash 
* Detects and returns flash version
*
* Methods:
* 	control() returns boolean- has flash obj == true
* 	version() returns integer- flash version 
*	embed() writes out basic embed tag for swf
*
* Example:
* CHE.flash.version() >= 7;
********************************************************/
Flash = {
	//has flash
	control: function()
	{
		var oF = navigator.plugins["Shockwave Flash"] || new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
		
		return (oF) ? 1 : 0;
	
	},
	
	version: function()
	{
		var oF;
		var v = null;
		if (navigator.plugins && navigator.mimeTypes.length)
		{
			oF = navigator.plugins["Shockwave Flash"];
			
			if (oF && oF.description)
			{
				v = oF.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")[0];
			}
		} 
		else if (window.ActiveXObject)
		{
			var vb = '<scr' + 'ipt language=vbscript type=text/vbscript\> \n';
				vb += 'Function VBGetSwfVer(i) \n';
				vb += 'on error resume next \n';
				vb += 'Dim swControl, swVersion \n';
				vb += 'swVersion = 0 \n';
				  
				vb += 'set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i)) \n';
				vb += 'if (IsObject(swControl)) then \n';
				vb += 'swVersion = swControl.GetVariable("$version") \n';
				vb += 'end if \n';
				vb += 'VBGetSwfVer = swVersion \n';
				vb += 'End Function \n';
				vb += '<\/scr' + 'ipt\>';
	
			document.write(vb);

		for (i=25;i>0;i--)  v =	VBGetSwfVer(i);

		if(v != 0 && v!= null ) v = v.split(",")[0].split(" ")[1];
		
		}
		return parseInt(v);
	},
	
	
	//url,id,w,h
	embed: function(o)
	{
		var d = document;
		d.write('<object id="' + o.fid + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + o.fwidth + '" height="' + o.fheight + '">');
		d.write('<param name="movie" value="' + o.furl + '" />');
		d.write('<param name="quality" value="high" />');
		d.write('<param name="allowScriptAccess" value="always" />');
		d.write('<param name="wmode" value="opaque" />');
		d.write('<param name="loop" value="false" />');
		d.write('<embed src="' + o.furl + '" type="application/x-shockwave-flash" quality="high" loop="false" width="' + o.fwidth +'" height="' + o.fheight + '" pluginspage="http://www.macromedia.com/go/getflashplayer" id="' + o.fid + '" border="0" wmode="opaque"></embed>');
		d.write('</object>');
	
	}
	
};



Navigation = {

	items: ['nav-gas', 'nav-iso', 'nav-virtualbooth', 'nav-markets', 'nav-resources', 'nav-technology', 'nav-about'],
	dynitems: ['dyn-nav-gas', 'dyn-nav-iso', 'dyn-nav-virtualbooth', 'dyn-nav-markets', 'dyn-nav-resources', 'dyn-nav-technology', 'dyn-nav-about'],

	doMouseOver: function(el) {
		var dynId = 'dyn-' + el.id;
		var xy = [Dom.getRegion(el).left -1, Dom.getRegion(el).bottom];
		
		//left align about nav so its not off browser window
		if (dynId == 'dyn-nav-about') {
			xy[0] = Dom.getRegion(el).right - parseInt(Dom.getStyle(dynId, 'width')) + 5;
	}
			
		//show highlight
		Dom.addClass(el, 'roll');
		
		//show menu
		Dom.setStyle(dynId, 'display', 'block');
		Dom.addClass(dynId, 'menu');
		Dom.setXY(dynId, xy);
	},
	
	doMouseOut: function(el) {
		var dynId = 'dyn-' + el.id;
		this.clearPreviousMenu();
		
	},
	
	clearPreviousMenu: function() {
		var previousMenu = Dom.getElementsByClassName('menu', 'ul');
		var previousItem = Dom.getElementsByClassName('roll', 'a', 'nav');
		if (previousMenu.length > 0) {
			Dom.removeClass(previousMenu[0], 'menu');
			Dom.setStyle(previousMenu[0], 'display', 'none');
		}
		if (previousItem.length > 0) {
			Dom.removeClass(previousItem[0], 'roll');
		}
	},

	addClasss: function() {
		var self = this;
		
		Event.on(this.items, 'mouseover', function(e) {
			var el = Event.getTarget(e);
			self.clearPreviousMenu();
			if (!Dom.hasClass(el, 'on')) {
				self.doMouseOver(el);
			}
		});
		
		Event.on(document.body, 'mouseover', function(e) {
			var el = Event.getTarget(e);
				var getAncestorByTagName = function(element, tagName) {
				while (element.tagName != tagName && element.tagName != 'BODY') {
					element = element.parentNode;
				}
				return element;
			};
			var ancestor = getAncestorByTagName(el, 'UL');

			if (ancestor.tagName != 'UL') {
				self.clearPreviousMenu();
			}
		});
	}
	
		
};

// Non YUI JS code for Opening Windows
var popWin;

function openWin(props,width,height) {
	if (!popWin || popWin.closed) {	
		popWin = window.open('/popups.php?img='+props.href,'popup','width='+width+',height='+height+',resizable=yes,scrollbars=no,location=no,toolbar=no,status=no,menubar=no'); 
	}
	else {
		
		if (width != "470") {
			popWin.resizeTo(width,height)
		}
		popWin.focus();
		popWin.location = '/popups.php?img='+props.href;
	}
	return false;
}
