function writeFlash(swfName, width, height, wmode, flashvars) 
{
	AC_FL_RunContent(
		'id', swfName,
		'name',swfName,
		'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
		'width', width,
		'height', height,
		'src', swfName,
		'quality', 'high',
		'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
		'align', 'middle',
		'play', 'true',
		'loop', 'true',
		'scale', 'showall',
		'wmode', wmode,
		'devicefont', 'false',
		'bgcolor', '#ffffff',
		'allowScriptAccess','sameDomain',
		'movie', 'swf/'+swfName,
		'flashvars', flashvars,
		'salign', ''
		); //end AC code
};

//Function called by the flash animation to open thickbox
function ShowFeature(id)
{
	var pseudoLinkId = "feature" + id
	var el = document.getElementById(pseudoLinkId);
	var loader = document.getElementById("flashLoader");
	loader.innerHTML = "";
	
	if(el != null) {
		var strOverlay = "<div onclick=\"closeFeature();\" class=\"div_overlay\" style=\"display:block;\" id=\"divOverlay\"></div><div class=\"overlay_msg_box\" style=\"display:block;\" id=\"msgBox\"></div>";
		var container = document.createElement("div");
		container.innerHTML = strOverlay;
		loader.appendChild(container);

		var pagesize = formatFlashSize(985, 765);
		var imageWidth = pagesize[0];
		var imageHeight = pagesize[1];
	
		var msgbox = document.getElementById("msgBox");
		if(msgbox != null) {
			msgbox.style.height = imageHeight+"px";
			msgbox.innerHTML = "<a onclick=\"closeFeature();\" class=\"btn_close\" href=\"javascript:void(0);\"></a><iframe id='frmFlash' src='so_flash.aspx?configUrl="+el.href+"&w="+imageWidth+"&h="+imageHeight+"' width='"+imageWidth+"' height='"+imageHeight+"' border='0' scrolling='no' style='margin:0; padding:0; border:0px none; ' frameborder='0'></iframe>";
			openOverLayPanel('divOverlay', 'msgBox', 1);
			positionFlash("msgBox", imageWidth, imageHeight);
//			var ifrm = document.getElementById("frmFlash");
//			if(ifrm != null)
//			{
//				if ((jQuery.browser.msie && jQuery.browser.version > 6 && jQuery.browser.version < 8))
//				ifrm.style.zoom = "100%";
//				//ifrm.src="so_flash.aspx?configUrl="+el.href+"&w="+imageWidth+"&h="+imageHeight;
//			}
		}
	}
}

//Formats the flash to fit in the window
function formatFlashSize (w, h)
{
	var pagesize = tb_getPageSize();
	var x = pagesize[0] - 20;
	var y = pagesize[1] - 20;

	var imageWidth = w;
	var imageHeight = h;
	if (imageWidth > x) {
		imageHeight = imageHeight * (x / imageWidth); 
		imageWidth = x; 
		if (imageHeight > y) { 
			imageWidth = imageWidth * (y / imageHeight); 
			imageHeight = y; 
		}
	} else if (imageHeight > y) { 
		imageWidth = imageWidth * (y / imageHeight); 
		imageHeight = y; 
		if (imageWidth > x) { 
			imageHeight = imageHeight * (x / imageWidth); 
			imageWidth = x;
		}
	}
	
	arrayPageSize = [Math.round(imageWidth), Math.round(imageHeight)];
	return arrayPageSize;
}

//Position the flash centered
function positionFlash(id, w, h) 
{
	j$("div.overlay_msg_box").css({marginLeft: '-' + parseInt((w / 2), 10)-5 + 'px', width: w + 'px'});
	if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6 
		j$("div.overlay_msg_box").css({marginTop: '-' + parseInt((h / 2), 10)-2 + 'px'});
	} else { // IE6
		var winInHt = document.documentElement.clientHeight;
		var scrollPos = document.documentElement.scrollTop;
		var free_height = ((winInHt - h)/ 2) + scrollPos;
		
		with ((document.all? document.all[id] : document.getElementById(id)).style) {
			position='absolute';
			top=free_height + 'px';
		}
	}
}

//Close the feature
function closeFeature()
{
	var parentWindowFlashLoader = parent.document.getElementById("flashLoader");
	if( parentWindowFlashLoader != null) {
		parentWindowFlashLoader.innerHTML = "";
	}
}

function showText(id)
{
	var obj = document.getElementById(id);
	if(obj != null) {
		obj.style.display = 'block';
	}
}
function hideText(id)
{
	var obj = document.getElementById(id);
	if(obj != null) {
		obj.style.display = 'none';
	}
}
function setObjAttr(objId, attr, val)
{
	var obj = document.getElementById(objId);
	if(obj != null) {
			eval("obj."+attr+"='"+val+"';")
	}
}

function revertImgState(imgId, hidId)
{
	var img = document.getElementById(imgId);
	var hid = document.getElementById(hidId);
	if(img != null && hid != null) {
		setObjAttr(imgId, 'src', hid.value);
	} else {
		setObjAttr(imgId, 'src', 'img/buy_map_inac.jpg');
	}
}

function simulateLinkClick(elementId) {
	var el = document.getElementById(elementId); 
	if(el != null) {
		try { eval(el.href.replace(/%20/g, ' ')); } catch(e1){} //FF
		try { var str = el.href.replace(/%20/g, ' ').replace(/%22/g, '\'');  eval(str); } catch(e2){} //Safari, IE 
		try { eval(el.click()); } catch(e3){} //IE
	}
}

function writeHomeAnim(lang) {
	var animName = "home_anim_" + lang;
	var parms = "";
	var innovCookie = getCookie('innovAnim');
	if(innovCookie != null) {
		parms = "skipintro=true";
		document.write("<img src='swf/"+animName+".jpg' alt='InnovMetric' />");
	} else {
		setCookie('innovAnim', "1", 1);
		writeFlash(animName, 630, 420, 'opaque', parms);
	}
}