
////////////////////////////////////////////////////////////////////////////////////
/* Dynamic Flash Sizing */

	var flashWidth = 0;
	var flashHeight = 0;
	var resizeRatio = 1;
	var dynamicSizing = false;
	var vertCentre = false;
	var maximize = false; 
	var flashID = ''; 
	var isMaximized;
	
	//Set up shared variables and determine the resizeRatio required to fill/fit the browser screen. 
	function initMovie(_flashWidth, _flashHeight, _flashID,  _vertCentre, _dynamicSizing, _maximize ){
		//Set Global Vars
		flashWidth = _flashWidth;
		flashHeight = _flashHeight;
		dynamicSizing = _dynamicSizing;
		vertCentre = _vertCentre;
		maximize = _maximize;
		isMaximized = maximize;
		flashID = _flashID;
		
		if(dynamicSizing == true){
			
			setResizeRatio();
			if(resizeRatio < 1 || maximize == true){ 
				resizeMovie(resizeRatio);
			}
			else
				resizeMovie(1);

			window.onresize = onWindowResize;
		}
	}
	
	function onWindowResize(){
		
		setResizeRatio();
		
		//Call flash function to show/hide mazimize button based on the current resizeRatio
		if(typeof document.getElementById("flashContent").toggleResize == 'function') /* Make sure flash function is accessible */
			document.getElementById("flashContent").toggleResize(resizeRatio);
		
		if(resizeRatio < 1 || (resizeRatio > 1 && isMaximized == true))
			resizeMovie(resizeRatio);
		else
			resizeMovie(1);
	}
	
	function setResizeRatio(){
	//Get Inner Browser Size
		var browserWidth = window.innerWidth*.95 || (window.document.documentElement.clientWidth || window.document.body.clientWidth)*.95 ;
		var browserHeight = window.innerHeight*.95 || (window.document.documentElement.clientHeight || window.document.body.clientHeight)*.95 ;
		
		//Get Resize Ratio
		heightRatio = roundNum(browserHeight/flashHeight, 4);
		widthRatio = roundNum(browserWidth/flashWidth, 4);
		//Whichever Ratio is lower is the one we need to stretch/shrink by
		if(widthRatio < heightRatio)
			resizeRatio = widthRatio;
		else
			resizeRatio = heightRatio;	
	}
	
	function resizeMovie(_ratio){
		
		obj = document.getElementById("flashContent");
		obj.style.width = roundNum(flashWidth*_ratio, 0);
		obj.style.height = roundNum(flashHeight*_ratio, 0);
		obj.style.marginLeft = (0-roundNum(flashWidth/2, 0))*_ratio + "px";
	
		if(vertCentre == true){
			obj.style.marginTop = (0-roundNum(flashHeight/2, 0))*_ratio-5 + "px";
			obj.style.top = "50%";
			
		}
		else{
			obj.style.marginTop = "0px";
			obj.style.top = "0px";
		}
		/* Custom Background with 100% width */
			obj = document.getElementById("flashBG");
			obj.style.height = flashHeight*_ratio;
			if(vertCentre == true){
				obj.style.marginTop = (0-roundNum(flashHeight/2, 0))*_ratio-5 + "px";
				obj.style.top = "50%";
				
			}
			else{
				obj.style.marginTop = "0px";
				obj.style.top = "0px";
			}
		/*End Background Code */
	
	}
	
	function maximizeMovie(_maximize){
		if(_maximize == true)
			resizeMovie(resizeRatio);
		else
			resizeMovie(1);
		
		isMaximized = _maximize;
	}
	
	function roundNum(nNumber, nDecimals){
		return Math.round(nNumber*Math.pow(10,nDecimals))/Math.pow(10,nDecimals);
	}

	function getMaxHeight(){
		return w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);	
	}
/* End Dynamic FLash Sizing */
////////////////////////////////////////////////////////////////////////////////////


function openWindow(url, target) {
	flashWindow = window.open(url, target, 'menubar=yes,status=yes,scrollbars=yes,toolbar=yes,location=yes,resizable=yes');
	flashWindow.focus();
	
	if(flashWindow.opener == null)
	{
		flashWindow.opener = window;
		flashWindow.opener.name = "opener";
	}
}

function openPrint(printContent, sectionTitle) {
	printWindow = window.open("printContent.php?sec="+sectionTitle, 'printWindow', 'width=800,height=600,menubar=no,status=yes,scrollbars=yes,toolbar=no,location=no,resizable=yes');
	printWindow.focus();
	
	if(printWindow.opener == null)
	{
		printWindow.opener = window;
		printWindow.opener.name = "opener";
	}
	printWindow.opener.printContent = printContent;
}


function getURL(url) {
	window.open(url, '_self');
}

//ANTISPAM EMAIL LINK
function antiSpam(id, domain, style) {
	document.write("<a href='mailto:" + id + "@" + domain + "' class='" + style + "'>" + id + "@" + domain + "</a>");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function show_drop_down_menu(menu_id, link_id) {
    if (document.getElementById(menu_id)) {
				var left = (getOffsetLeft(link_id) - 1) + 'px';
        var top = getOffsetTop(link_id) + document.getElementById(link_id).offsetHeight - 1 + 'px';
        document.getElementById(menu_id).style.left = left;
        document.getElementById(menu_id).style.top = top;
        document.getElementById(link_id).style.backgroundColor = '';
        document.getElementById(menu_id).style.visibility = 'visible';
				document.getElementById(menu_id).style.zindex = 100;
    }
}

function show_drop_down_menu_side(menu_id, link_id) {
    if (document.getElementById(menu_id)) {
				var left = getOffsetLeft(link_id) + document.getElementById(link_id).offsetWidth + 'px';
        var top = getOffsetTop(link_id) + 'px';
        document.getElementById(menu_id).style.left = left;
        document.getElementById(menu_id).style.top = top;
        document.getElementById(link_id).style.backgroundColor = '';
        document.getElementById(menu_id).style.visibility = 'visible';
				document.getElementById(menu_id).style.zindex = 100;
    }
}

function hide_drop_down_menu(menu_id, link_id) {
    if (document.getElementById(menu_id)) {
        document.getElementById(menu_id).style.visibility = 'hidden';
        document.getElementById(link_id).style.backgroundColor = '';
    }
}

function getOffsetTop(element) {
    el = document.getElementById(element);
    xPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getOffsetLeft(element) {
    el = document.getElementById(element);
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}
