function historyBack()
{
	window.history.back(1);
	goToTop();
}

function goToTop()
{
	window.scrollTo(0,0);
}

var appHeight = 0;

function resizeApp(height)
{
	appHeight = height;
	
	if(height > 261)
	{
		if (window.innerHeight)
		{
			if(window.innerHeight < height)
			{
				document.getElementById('index').height = height;
			}
			else
			{
				document.getElementById('index').height = window.innerHeight;
			}
		}
		else if (document.documentElement && document.documentElement.clientHeight)
		{
			if(document.documentElement.clientHeight < height)
			{
				document.getElementById('index').height = height;
			}
			else
			{
				document.getElementById('index').height = document.documentElement.clientHeight;
			}
		}
		else if (document.body)
		{
			if(document.body.clientHeight < height)
			{
				document.getElementById('index').height = height;
			}
			else
			{
				document.getElementById('index').height = document.body.clientHeight;
			}
		}
		else
		{
			if(window.innerHeight < height)
			{
				document.getElementById('index').height = height;
			}
			else
			{
				document.getElementById('index').height = window.innerHeight;
			}
		}
	}
}

function resizeBrowser()
{
	if (typeof( window.innerWidth ) == 'number' )
	{
		if(window.innerHeight > appHeight)
		{
			document.getElementById('index').height = window.innerHeight;
		}
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		if(document.documentElement.clientHeight > appHeight)
		{
			document.getElementById('index').height = document.documentElement.clientHeight;
		}
	}
	else if (document.body)
	{
		if(document.body.clientHeight > appHeight)
		{
			document.getElementById('index').height = document.body.clientHeight;
		}
	}
	else
	{
		if(window.innerHeight > appHeight)
		{
			document.getElementById('index').height = window.innerHeight;
		}
	}
}

function showCert()
{
	var width = 480;
	var height = 525;
	var ww = screen.width;
	var hh = screen.height;
	var left = (ww - width) / 2;
	var top = (hh - height) / 2;
	window.open('https://www.digicert.com/custsupport/sspopup.php?order_id=00128377&hostname=','oo',"dependent=1,height="+height+",width="+width+",left="+left+",top="+top+",location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0");
}

function getBrowserHeight()
{
	var browserH = 0;
	
	if (window.innerHeight)
	{
		browserH = window.innerHeight;
	}
	else if(document.documentElement && document.documentElement.clientHeight)
	{
		browserH = document.documentElement.clientHeight;
	}
	else if(document.body)
	{
		browserH = document.body.clientHeight;
	}
	else
	{
		browserH = window.innerHeight;
	}
	return browserH;
}

function getScrollPos()
{
	if(navigator.appName == "Microsoft Internet Explorer")
	{
		return document.body.scrollTop;
	}
	else
	{
		return window.pageYOffset;
	}
}

function focusApp()
{
	if(document.getElementById('index') != undefined) document.getElementById('index').focus();
}


function popup(url)
{
	window.open(url, 'popup', config='width=368, height=241, toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, directories=no, statusbar=no');
}

//Google funnels and tracking
function updateGoogleFunnel(url)
{
	//alert(url);
	pageTracker._trackPageview(url); 
}

function addTransaction(orderid,total,tax,shipping,city,state,country,orderlines)
{
	pageTracker._addTrans(orderid, "Ultrashock Flex", total, tax, shipping, city, state, country);
	
	for(i=0;i<orderlines.length;i++)
	{
		pageTracker._addItem(orderid, orderlines[i]['productid'], orderlines[i]['title'], "Credits", orderlines[i]['price'], orderlines[i]['quantity']);
	}
	
	pageTracker._trackTrans();
}


//Event listeners
window.onresize = resizeBrowser;
window.onload = focusApp;
