




function showCurrency(s) {
	Element.hide('euro');
	Element.hide('pound');
	Element.hide('dollar');
	Element.show(s);
	
	setcookie('currency', s, 365 * 5, '/', '.' + document.domain);
	return false;
}

function setcookie(name, value, expires, path, domain, secure) 
{
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	
	var expires_date = new Date( today.getTime() + (expires) );
	
	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}


function uppercase(o) {
	s = new String(o.value); 
	o.value = s.toUpperCase();
}

function prevent(o, s) {
	if (!o.disabled) 
	{
		o.disabled = true;
		o.value = s;
		o.form.submit();
	}
}





function positionFooter() {

	if (document.body.offsetHeight && 
		document.documentElement.clientHeight)
	{
		bodyHeight = document.body.offsetHeight;
		viewHeight = document.documentElement.clientHeight;
		
		if (viewHeight > bodyHeight) 
		{
			done = false;
			
			tables = document.getElementsByTagName('TABLE');
			for (var i=0; i < tables.length; i++) {
				if (tables[i].className == 'contentTable') {
					tables[i].style.height = parseInt(tables[i].offsetHeight + (viewHeight - bodyHeight)) + 'px';
					done = true;
				}
			}
			
			if (done == false) {
				divs = document.getElementsByTagName('DIV');
				for (var i=0; i < divs.length; i++) {
					if (divs[i].className == 'matrix') {
						divs[i].style.height = parseInt(divs[i].offsetHeight + (viewHeight - bodyHeight)) + 'px';
					}
				}
			}
		}

		window.setTimeout('positionFooter()', 500);
	}
}


function checkPageOptions() {
  	var obj = document.getElementById("printpage");
	if (obj) {
		obj.onclick = function() {
			window.print();
			return false;
		};
	}
}

function checkDownloadOptions() {
  	var obj = document.getElementById("downloaddemo");
	if (obj) {
		obj.onclick = function() {
			urchinTracker ('/downloads/demo');
			__utmSetVar('DemoDownloaded');
			return true;
		};
	}

  	var obj = document.getElementById("downloadpromo");
	if (obj) {
		obj.onclick = function() {
			urchinTracker ('/downloads/demo');
			__utmSetVar('DemoDownloaded');
			return true;
		};
	}

  	var obj = document.getElementById("mac");
	if (obj) {
		obj.onclick = function() {
			Element.show("macinfo");
			return false;
		};
	}

  	var obj = document.getElementById("macclose");
	if (obj) {
		obj.onclick = function() {
			Element.hide("macinfo");
			return false;
		};
	}
	
	var obj = document.getElementById("discount");
	if (obj) {
		obj.onclick = function() {
			Element.show("discountinfo");
			return false;
		};
	}

  	var obj = document.getElementById("discountclose");
	if (obj) {
		obj.onclick = function() {
			Element.hide("discountinfo");
			return false;
		};
	}
}

function checkPricingOptions()
{
	$(document.body).select('div.pricingclose').each(function (e) {
		e.onclick = function () {
			$(e).up('div.pricinginfo').hide();
			return false;
		};
	});
	
	$(document.body).select('a.pricinginfo').each(function (e) {
		e.onclick = function () {
			$(document.body).select('div.pricinginfo').each(function (e) { e.hide() });

			$(e.id + 'info').show();
			return false;
		};
	});
}



// Initialize everything...
document.observe("contentloaded", function() {
	checkPageOptions();
	checkDownloadOptions();
	positionFooter();
	checkPricingOptions();
});

