$(document).ready(function () {
	
	$("#launch").click( function(){	
	    launchmusic();            
		return false;
	});

	$('a.return').click(function(){				
		$('html,body').animate({scrollTop: 0}, 1000);
		return false;		
	});
	
	$(".sideImgP").mouseover(function(){
		$("#sideLinks div").html("Get Preferred Seating")		
	});
	
	$(".sideImgX").mouseover(function(){
		$("#sideLinks div").html("The AIX Factor")
	});
	
	$(".sideImgM").mouseover(function(){
		$("#sideLinks div").html("Music Player")
	});
	
	$(".sideImgP, .sideImgX, .sideImgM").mouseout(function(){
		$("#sideLinks div").html("&nbsp;")		
	});	
	
	$("#secSBLawards a, #secSBLwine a").click(function(){
		$("#wrap").after('<div id="overlay">&nbsp;</div>');
		$("#overlay").after('<div id="slideshow"><div id="placeholder">&nbsp;</div></div>');		
		
		$("#overlay").css({"background-color":"#000","left":"0","opacity":".75","position":"absolute","top":"0","z-index":"100","width":"0","height":"0"});
		$("#slideshow").css({"background-color":"#000","position":"absolute","top":"50%","left":"50%","z-index":"125","width":"0px","height":"0px","marginLeft":"-310px","marginTop":"-240px","border":"10px solid white","opacity":"1"});
		
		$("#overlay").animate({width:$("body").width(),height:$("body").height()},250);
		$("#slideshow").animate({"width":"620px","height":"460px"},250,function(){
			swfobject.embedSWF("/themes/x1v2/objects/slideshow.swf?xmlfile=/themes/x1v2/objects/slideshow.xml", "placeholder", "620", "460","5.0.0", false, false,{quality:"high",wmode:"transparent"},false);
		});
		
		$("#overlay").click(function(){			
			$("#overlay").animate({"width":"0","height":"0","left":"0","top":"0"},500,function(){$("#overlay").remove()});
			$("#slideshow").animate({"width":"0px","height":"0px"},500,function(){$("#slideshow").remove()});			
		});		
		return false;
	});
	
	$("h2").each(function(){		
		$(this).next().hide();
		$(this).css({"cursor":"pointer"});
		$(this).click(function(){$(this).next().slideToggle();});
	})
});

function launchmusic(){
	var c = readCookie('player');
	if(c!="true"){
		var top = $(window).height()-156;
		var left = $(window).width()-341;
	    popup = window.open("/player/","musicplayer","width=341,height=156,top="+top+",left="+left+",status=no,toolbar=no,menubar=no,location=no",false);
	    if(!popup) alert("We noticed that you're utilizing a pop-up blocker.\nIf you'd like to hear music you may need to disable it.")
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}