var maxH = 600;
var scrollWidth = 0;
var scrollHeight = 0;
var loaded = false;




function giveFocus()
{
	document.getElementById('altContent').focus();
}


function callFromFlash(var1)
{
	maxH = var1;
	moveScroll();
}


function talkToFlash()
{
	content.myFunctionId();	
}


function moveScroll()
{
	
	var winW = getWindowWidth();
	var winH = getWindowHeight();
	
	if(winW-scrollWidth >= 1035)	scrollWidth = 0;
	if(winH-scrollHeight >= maxH)	scrollHeight = 0;
	
	
	if(winH < maxH+scrollHeight)
	{
		scrollWidth = getScrollerWidth();
		document.getElementById('altContent').style.height = maxH+"px";
	}
	else
	{
		document.getElementById('altContent').style.height = "100%";
	}
	
	if(winW < 1035+scrollWidth)
	{
		scrollHeight = getScrollerWidth();
		document.getElementById('altContent').style.width = 1035+"px";
	}
	else
	{
		document.getElementById('altContent').style.width = "100%";
	}
}

function getWindowWidth()
{
	var winW;
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			winW = document.body.clientWidth;
		}
		else
		{
			winW = window.innerWidth;
		}
	}
	
	return winW;
}


function getWindowHeight()
{
	var winH;
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			winH = document.body.clientHeight;
		}
		else
		{
			winH = window.innerHeight;
		}
	}
	
	return winH;
}

function printPDF(path)
{
	
}

function getScrollerWidth() 
{

    var scr = null;

    var inn = null;

    var wNoScroll = 0;

    var wScroll = 0;



    // Outer scrolling div

    scr = document.createElement('div');

    scr.style.position = 'absolute';

    scr.style.top = '-1000px';

    scr.style.left = '-1000px';

    scr.style.width = '100px';

    scr.style.height = '50px';

    // Start with no scrollbar

    scr.style.overflow = 'hidden';



    // Inner content div

    inn = document.createElement('div');

    inn.style.width = '100%';

    inn.style.height = '200px';



    // Put the inner div in the scrolling div

    scr.appendChild(inn);

    // Append the scrolling div to the doc



    document.body.appendChild(scr);



    // Width of the inner div sans scrollbar

    wNoScroll = inn.offsetWidth;

    // Add the scrollbar

    scr.style.overflow = 'auto';

    // Width of the inner div width scrollbar

    wScroll = inn.offsetWidth;



    // Remove the scrolling div from the doc

    document.body.removeChild(

    document.body.lastChild);



    // Pixel width of the scroller

    return (wNoScroll - wScroll);

}


var myGoogleUtils = {
		
	setPageTracker: function (trackingNumber){
		
		//alert("setting page tracker code using number " +trackingNumber +". You should already see the SWF.");
		
		try{
		   var pageTracker = _gat._getTracker(trackingNumber);
		   pageTracker._trackPageview();
		} catch(err) {
			//Do nothing
		}    
	
	},
	
	appendAnalytics: function (trackingNumber){
	
		if(!trackingNumber){ return false; }
		
	
		var targetElement = document.getElementsByTagName("head")[0] || document.body;
		
		var gaJsHost = (("https:" === document.location.protocol) ? "https://ssl." : "http://www."),
			isIE = /*@cc_on!@*/false,
			script = document.createElement("script");
		
		script.type = "text/javascript";
		script.src = gaJsHost + "google-analytics.com/ga.js";
				
		//Internet Explorer requires some special love
		//see http://unixpapa.com/js/dyna.html for explanation
		if(isIE){
			
			var initInvoked = false;

			script.onreadystatechange = function () {
				
				var ready = this.readyState === "loaded" || this.readyState === "complete";
				
				if(!initInvoked && ready){ 
					initInvoked = true; //Prevent invoking multiple times
					myGoogleUtils.setPageTracker(trackingNumber);
				}
				
			};
			
		} else {
			
			script.onload = function (){
				myGoogleUtils.setPageTracker(trackingNumber);
			};
			
		}
		
		targetElement.appendChild(script);
		
	}
			
};