// JavaScript Document
var hash;
var currentPage;
var centralPromoSize;
var specsheetSize;

function googleMapsKey()
{
	return 'ABQIAAAAj-sHgjP9YrnsZIuUKXijrRSNHVMCivTB52jpoe8Zyo7M6-LPKxSmuZLuqAvY6IhaRL70PmUBqVg1sg';
}

function pageLoaded(centralSize, specSize, miniPromosFiles1, miniPromoFiles2)
{
	centralPromoSize	= centralSize;
	specsheetSize			= specSize;

  var fl = document.getElementById('SplashFlash'); 

	hash 		= window.location.hash;
	switch(hash)
	{
		/*case '#signup':
			openRegistration();
		break;*/
		
		case '#specs':
			openSpecs();
		break;
		
		case '#contact':
				openContact();
			break;
		
		case '#terms':
				openTerms();
			break;
	
		default:
			openPromo();
	}	
	setInterval(hashWatcher, 400);
}

function hashWatcher()
{
	if (window.location.hash != hash)
	{
		hash = window.location.hash;
	
		switch(hash)
		{	
			case '#specs':
				openSpecs();
			break;
			
			case '#contact':
				openContact();
			break;
			
			case '#terms':
				openTerms();
			break;
			
			default:
				openPromo();
		}
	}
}

function openContact()
{
	try
	{
		pauseClouds();
	} catch( err)
	{
	}
	removeCurrentPage();
	var div			= document.getElementById('centerDiv'); 
		div.style.height	= '490px';
	//var promo		= document.getElementById( 'miniPromosTable' );
	//	promo.style.marginTop	= div.style.height;	
	var newPage = currentPage = document.createElement('div');
		newPage.setAttribute('id', 'contactPanel');
	div.appendChild(newPage);
	currentPage = swfobject.embedSWF("splash/Contact.swf", "contactPanel", "900", "490", "9.0.45", "splash/scripts/expressInstall.swf", false, {wmode:'transparent'}, {id:'currentPage'});
	window.location.hash = hash = '#contact';
}

function openSpecs()
{
	try
	{
		pauseClouds();
	} catch( err)
	{
	}		
	removeCurrentPage();
	var div			= document.getElementById('centerDiv'); 
		div.style.height	= '690px';
	//var promo		= document.getElementById( 'miniPromosTable' );
	//	promo.style.marginTop	= div.style.height;
	var imgElement	= currentPage = document.createElement('img');
		imgElement.setAttribute('src', 'splash/images/specs.png');
		imgElement.setAttribute('id', 'currentPage');
		imgElement.style.width = specsheetSize[0]+'px';
		imgElement.style.height = specsheetSize[1]+'px';
	div.appendChild(imgElement);
	window.location.hash = hash = '#specs';
}

function openTerms()
{
	try
	{
		pauseClouds();
	} catch( err)
	{
	}		
	removeCurrentPage();
	var div			= document.getElementById('centerDiv'); 
		div.style.height	= '690px';
	//var promo		= document.getElementById( 'miniPromosTable' );
	//	promo.style.marginTop	= div.style.height;
	var el	= currentPage = document.createElement('div');
		el.setAttribute('id', 'currentPage');
	div.appendChild(el);
	
	$('#currentPage').load('terms.html');
	window.location.hash = hash = '#terms';
}

function openPromo()
{
	removeCurrentPage();
	var div			= document.getElementById('centerDiv'); 
	if(hash.substring(1))
	{
		if(hash.substring(1) != 'promo')
		{
			window.location.hash = hash = '#';
		}
	}
	try
	{
		resumeClouds();
	} catch( err)
	{
	}
	var specialPromotion = document.getElementById('in-front-of-the-music');	
	if(specialPromotion)
	{
		specialPromotion.style.height = '490px';
	}
	else
	{
	var imgElement	= currentPage = document.createElement('a');
		imgElement.setAttribute('id', 'currentPage');
		imgElement.setAttribute('href', 'http://reelworld.com');
		imgElement.setAttribute('style', 'display:block;height:490px;');
	div.appendChild(imgElement);
	}
}

function openTwitter(evt)
{
	window.open( 'http://reelworld.com/twitter' );	
}

function removeCurrentPage()
{
	var specialPromotion = document.getElementById('in-front-of-the-music');	
	if(specialPromotion)
	{
		specialPromotion.style.height = '0px';
	}
	
	var currentPage = document.getElementById('currentPage');	
	if(currentPage)
	{
		var div	= document.getElementById('centerDiv');
			div.removeChild(currentPage);
	}
}
