/* CRISS ANGEL */
/* JAVASCRIPT
----------------------------------------------------------------------------- */


	var $j = jQuery.noConflict();


/* READY FUNCTION
----------------------------------------------------------------------------- */


	$j(document).ready(function() {
	
	/*
		$j('div.widget-advertising.overlay').wrap('<div id="overlay"></div>');
		$j('#overlay div.widget-advertising').append('<div id="text"><p>Don&#39;t miss the first LIVE episode in MINDFREAK history as Criss attempts to escape from an imploding building! Watch it LIVE on Wednesday, July 30 at 10 PM EST / 7 PM PST on A&amp;E, or <a class="mindfreak" href="http://www.crissangel.com/mindfreak">click here</a> to watch it live NOW!</p><a class="close" href="#">&times; Close</a></div>');
		$j('#overlay a.close').click(hideOverlay); 
	
 	*/
	
 
/* HIDDEN AUDIO PLAYER
----------------------------------------------------------------------------- */


		var myAudio = new mediaObject(asset_host + "/flash/audio_player.swf", "520", "467", "#000000", 'hidden','true'); 
		myAudio.setFeeds(site_host + "/playlists/audio.xml");


/* POPUP VIDEO PLAYER
----------------------------------------------------------------------------- */


		var videoPopup = new mediaObject(asset_host + "/flash/popup_video.swf", "500", "500", "#000000", 'popup');
		videoPopup.setFeeds(asset_host + "/xml/videos-all.xml");
		videoPopup.setPopupOptions("window_name", "toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=500, height=500", "/player-video");


/* FLASH: HEADER
----------------------------------------------------------------------------- */


		if (page == "can-site" || page == "can-profile") {
				
			// SMALL HEADER
			var so = new SWFObject(asset_host + "/flash/preloadNH.swf", "nheader", "100%", "255", "8", "#000000");
			so.addParam( "allowScriptAccess", "always" );
			so.addVariable("netPath", site_host);
			so.addVariable("path", asset_host + "/flash/network_header.swf");
			so.write("navigation");
		
		} else {
			
			// MAIN HEADER
			var plan; 
			
			if (plan_id == 45) {
			 
				plan = "45"; 
			 
			} else if (plan_id == 44) {
			 
				plan = "44"; 
			 
			} else if (plan_id == 56) {
			 
				plan = "56"; 
			 
			} else if (plan_id == 55) { 
			 
				plan = "55"; 
			 
			} else if (plan_id == 54) { 
			 
				plan = "43"; 
			 
			} else { 
			 
				plan = "43";
			
			}
			
			
			
			var loc = window.location;
			var so = new SWFObject(asset_host + "/flash/load.swf", "myswf", "100%", "365", "8", "#000000", true);
			so.useExpressInstall(asset_host + "/flash/expressinstall.swf");
			so.addVariable("plan", plan);
			so.addVariable("loc", loc);
			var _p = asset_host;
			so.addVariable("Path", _p);
			so.addParam("allowScriptAccess", "always");
	
			if (section == "home") so.addVariable("home", "1");
			if (section == "home") so.addVariable( "mute", "true" );
			if (section == "news") so.addVariable("page", "2");
			if (section == "mindfreak") so.addVariable("page", "3");
			if (section == "loyal") so.addVariable("page", "4");
			if (section == "criss") so.addVariable("page", "5");
			if (section == "merch") so.addVariable("page", "6");
			if (section == "legal") so.addVariable("page", "7");
			if (section == "members") so.addVariable("page", "7");
			if (section == "store") so.addVariable("page", "6");

			
			//muting
			if ( topic == "believe-23" ) {
				so.addVariable( "mute", "true" );
			}
			
			so.write("header");
		
		}
		
		
/* FLASH: CIRQUE COUNTDOWN
----------------------------------------------------------------------------- */


		if ($j('#cirque').length > 0) {

			var cirque_so = new SWFObject( asset_host + "/flash/cirque_countdown.swf", "cirqueSWF", "292", "362", "8", "#000000" );
			cirque_so.addParam( "allowScriptAccess", "always" );
			cirque_so.addParam( "wmode", "transparent" );
			cirque_so.addVariable( "xml_param", asset_host + "/xml/cirqueClock.xml" );
			cirque_so.write( "cirque" ); 

		}
		
		
/* FLASH: ROTATING BANNERS
----------------------------------------------------------------------------- */
		
		
		if ($j('#banners').length > 0) {
		
			var so = new SWFObject(asset_host + "/flash/banners.swf", "banners", "100%", "100%", "8", "#000000");
			so.addParam("scale", "noscale");
			so.addVariable( "xml", asset_host + "/xml/banners.xml" )
		
			if (page == "index") so.addVariable("placement", "Home");
			if (page == "loyal") so.addVariable("placement", "Home");
		
			so.write("banners");
		
		}
		
		
/* FLASH: VIDEO PLAYER (MINDFREAK PLAYER)
----------------------------------------------------------------------------- */
		
		
		if ($j('#mindfreak-player').length > 0) {

			var _cc;
			
			if (plan_id == 45 || plan_id == 44 || plan_id == 55 || plan_id == 56) {
			
				_cc = 'true';
				
			} else {
			
				_cc = 'false';
				
			}	
	
			var myVideo = new mediaObject(asset_host + "/flash/small_player.swf?logo=mftv&cc=" + _cc, "520", "484", "#000000", 'mindfreak-player','false'); 
	
			if (plan_id == 55 || plan_id == 56) {
			
				myVideo.setFeeds(site_host + "/playlists/mindfreak-exclusive.xml");
			
			} else {
			
				myVideo.setFeeds(site_host + "/playlists/mindfreak.xml");
			
			}
	
			myVideo.setLinks("mftv","mftv-video");
			myVideo.playMedia();

		} 
		
		
/* FLASH: VIDEO PLAYER (CATV)
----------------------------------------------------------------------------- */

		
		if ($j('#catv').length > 0) {

			var _cc;
			
			if (plan_id == 45 || plan_id == 44 || plan_id == 55 || plan_id == 56) {
			
				_cc = 'true';
				
			} else {
			
				_cc = 'false';
				
			}

			var myVideo = new mediaObject(asset_host + "/flash/small_player.swf?logo=catv&cc=" + _cc, "520", "484", "#000000", 'catv','false'); 

			if (plan_id == 55 || plan_id == 56) {
			
				myVideo.setFeeds(site_host + "/playlists/criss-exclusive.xml");
			
			} else {
			
				myVideo.setFeeds(site_host + "/playlists/criss.xml");
			
			}

			myVideo.setLinks("catv","catv-video");
			myVideo.playMedia();
			
		}
	
		
/* FLASH: ENLARGED VIDEO PLAYER
----------------------------------------------------------------------------- */

		
		if (page == "mftv-video") {
		
			if (plan_id == 54 || plan_id == 55 || plan_id == 56) {
			
				var myVideo = new mediaObject(asset_host + "/flash/large_player.swf?logo=mftv&cc=true", "793", "616", "#000000", "player","true"); 
	
			} else {
			
				var myVideo = new mediaObject(asset_host + "/flash/large_player.swf?logo=mftv&cc=false", "793", "616", "#000000", "player","true"); 
	
			}	
	
			myVideo.setFeeds(site_host + "/playlists/video.xml");
			myVideo.setLinks("videos","video");
			myVideo.playMedia(topic);

		}
		

/* END READY FUNCTION
----------------------------------------------------------------------------- */


	});


/* LOAD FUNCTION
----------------------------------------------------------------------------- */


	$j(window).load(function() {
	
	
		addFlash();
		showOverlay();
		doMagic();
		slideshow();
		

/* POPUP EXTERNAL LINKS
----------------------------------------------------------------------------- */


		$j('a[rel=external]').click(function(){
		
			link = $j(this).attr('href');
			window.open(link);
			return false;
	
		});


/* CHAT FUNCTIONS
-----------------------------------------------------------------------------

	if (page == "loyalfest" || page == "chat-popup") {
		
		var embed = $j('div#chat table');
		
		$j('a.launchchat').click(function(){
		
			$j('div#chat').addClass('dim');
			$j('div#chat').prepend('<a class="reembed" href="#">Re-embed Chat Here</a>');
			$j('div#chat table').remove();

			window.open( site_host + '/chat-popup','Chat','width=600,height=440,resizable=0,scrollbars=0,toolbar=0,location=0,directories=0,status=0,menubar=0');
			
			$j('a.reembed').click(function(){

				$j('div#chat').append(embed);
				$j('a.reembed').remove();
				
				return false;
				
			});
			
			return false;
			
		});
		
		$j('a.closechat').click(function(){
	
			window.close();
			
		});
		
	} */

/* END LOAD FUNCTION
----------------------------------------------------------------------------- */


	});
	

/* OVERLAY TOGGLE FUNCTIONS
----------------------------------------------------------------------------- */


	function addFlash() {
	
		$j("#header").addClass("flash");
		$j("#cirque").addClass("flash");
		$j("#banners").addClass("flash");
	
	}
	
	function showOverlay() {
	
		// $j('#page-home div.flash').css('visibility','hidden');
		// $j('#dimmer').fadeIn('fast');
		// $j('#overlay').animate({top: 0}, 'slow');
		
	}

	function hideOverlay() {
	
		$j('#overlay').slideUp('fast');
		$j('#dimmer').fadeOut('fast');
		$j('#page-home div.flash').css('visibility','visible');
		return false;
	
	}
	
	function slideshow() {
		
		if ($('#page-login div.benefits div').length > 0) {

			$('div.benefits div').cycle({
		
				fade: true,
				speed: 400,
				timeout: 6000
			
			});

		}
		
	}
	