document.write('<script type="text/javascript" src="./js/Tween.js"></script>');
document.write('<script type="text/javascript" src="./js/OpacityTween.js"></script>');
document.write('<script type="text/javascript" src="./js/Sequence.js"></script>');
document.write('<script type="text/javascript" src="./js/browser_detect.js"></script>');

$(document).ready(function(){
	init();
});

function mainmenu(){
	// MENU SECTION
	$(" #nav li a img ").hover(function() {
		var nav_id = $(this).attr("id");
		$(this).attr("src",currentPath+"images/topnav/"+nav_id+"-hover.jpg");
			}, function() {
		var nav_id = $(this).attr("id");
		$(this).attr("src",currentPath+"images/topnav/"+nav_id+".jpg");
	});
		
	$(" #nav ul ").css({display: "none"}); // Opera Fix
	$(" #nav li").hover(function(){
			$(this).find('ul:first:hidden').css({visibility: "visible",display: "none"}).show(400);
			},function(){
			$(this).find('ul:first').css({visibility: "hidden"});
			});
}

function init(){
	if(getcookie("splashtriggered") != "yes"){
		document.getElementById('masksplash').style.height = document.body.clientHeight+"px";
		splashAlign();
	}
	else{
		mainmenu();
		document.getElementById('masksplash').style.bottom = 10000+"px";
		document.getElementById('searchfield').value="Search";
		document.getElementById('masthead').innerHTML = "<object height='262' width='661' type='application/x-shockwave-flash' data='images/masthead_play_link.swf'><param name='movie' value='images/masthead_play_link.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='images/masthead_play_link.swf' width='661' height='262' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed></object>";
		
		$("div#pittcon2010").fadeIn(5000);
	}
}

function loadpage(value){
	if(getcookie("splashtriggered") != "yes"){
		var tg2 = document.getElementById('masksplash');
		
		t2 = new OpacityTween(tg2, Tween.regularEaseIn, 100, 0, 1);

		seq1 = new Sequence();
		
		seq1.addChild(t2);
		
		seq1.start();
		
		seq1.onMotionFinished = function(){
			document.cookie="splashtriggered=yes";
			document.getElementById('masksplash').style.bottom = 10000+"px";	
			document.getElementById('splash').style.bottom = 10000+"px";
			document.getElementById('searchfield').value="Search";
			
			document.getElementById('masthead').innerHTML = "<object height='262' width='661' type='application/x-shockwave-flash' data='images/masthead_play_link.swf'><param name='movie' value='images/masthead_play_link.swf'><param name='quality' value='high'><param name='wmode' value='transparent'><embed src='images/masthead_play_link.swf' width='661' height='262' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed></object>";
			
			$("div#pittcon2010").fadeIn(5000);
		};
		
		mainmenu();
	}
}


function getcookie ( cookiename )
{
  var results = document.cookie.match ( '(^|;) ?' + cookiename + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function splashAlign(){
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
	}
	
	if(BrowserDetect.browser == "Explorer")
		offset = 270;
	else if(BrowserDetect.browser == "Opera")
		offset = 270;
	else
		var offset=270;
	
	var myleft = (myWidth/2)-offset;
	
	if(myleft < 180)
		myleft = 180;
		
	var tg = document.getElementById('splash');
	
	tg.innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' id='splashvid' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='551' height='511' align='middle'><param name='movie' value='images/splash.swf'><param name='quality' value='high'><param name='wmode' value='transparent'> <embed src='images/splash.swf' width='551' height='511' align='middle' quality='high' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed></object>";	
	
	tg.style.marginLeft = myleft+"px";
}