function showBox(that) {
	var n = that.id.split("_");
	$('#center ul.allVideos').each(function(index, element) {
		$(element).hide();
	});

	$("#box_"+n[1]).fadeIn(800);
	return false;
}

function leave(){
	$.cookie("bzCNetwk", null);
	window.parent.location.href = "http://www.google.com";
}

function enter(){
	$.cookie("bzCNetwk", "bzCNetwk", { expires: 90, path: '/' });
	$.fancybox.close();
}

function showDownloadPopup(that){
	var n = that.id.split("-");

	$.fancybox({
		'titleShow'			:	false,
		'padding'			:	0,
		'hideOnOverlayClick':	false,
		'showNavArrows'		:	false,
		'enableEscapeButton':	false,
		'href'				:	'/xhr.php',
		'ajax'				:	{
			type:'POST',
			data:'type=downloadBox&id='+n[1]
		}
	});

	return false;
}

function showSignupBox(that){
	var n = that.id.split("-");

	$.fancybox({
		'titleShow'			:	false,
		'padding'			:	0,
		'hideOnOverlayClick':	false,
		'showNavArrows'		:	false,
		'enableEscapeButton':	false,
		'href'				:	'/xhr.php',
		'ajax'				:	{
			type:'POST',
			data:'type=signupBox&id='+n[1]
		}
	});

	return false;
}

function showLoginBox(that){
	$.fancybox({
		'titleShow'			:	false,
		'padding'			:	0,
		'hideOnOverlayClick':	false,
		'showNavArrows'		:	false,
		'enableEscapeButton':	false,
		'href'				:	'/xhr.php',
		'ajax'				:	{
			type:'POST',
			data:'type=loginBox'
		}
	});

	return false;
}

function toggleLogin(that){

	return false;
}

$(document).ready(function() {
    // DISCLAIMER
	var d = new Date();
	var theTime = d.getTime();

	if($.cookie("bzCNetwk") == null){
		showDisclaimer();
	}

	function showDisclaimer(){
		$.fancybox({
			'titleShow'			:	false,
			'padding'			:	0,
			'autoDimensions'	:	false,
			'showCloseButton'	:	false,
			'hideOnOverlayClick':	false,
			'showNavArrows'		:	false,
			'enableEscapeButton':	false,
			'width'				:	742,
			'height'			:	430,
			'href'				:	'/xhr.php',
			'ajax'				:	{
				type	:	'POST',
				data	:	'type=disclaimer'
			}
		});
	}

    // ROUND ABOUT SLIDER FUNCTION
    $('ul#roundabout').roundabout(
    {
        easing: 'swing',
        duration: 500,
        startingChild: 0,
        shape: 'figure8',
        btnNext: '#nextRound',
        btnPrev: '#prevRound'
	});
    
    // ROUND ABOUT SLIDER AUTOPLAY FUNTION
    var interval;

    $('ul#roundabout').hover(
        function() {
            // oh no, it's the cops!
            clearInterval(interval);
        },
        function() {
            // false alarm: PARTY!
            interval = startAutoPlay();
        }
	);

    // let's get this party started
    interval = startAutoPlay();

    function startAutoPlay() {
    	return setInterval(function() {
    		$('ul#roundabout').roundabout('animateToPreviousChild', 500, 'swing');
    	},5000);
	};
	
    // VIDEOS SLIDER
    $(".latestVideos").carouFredSel({
    	width: "514",
        items: {
            visible: 3,
            minimum: 3
        },
        auto: {
            play: false
        },
        prev : {
            button	: "#prev",
            key		: "left"
        },
        next : {
            button	: "#next",
            key		: "right"
        }
    });
	
	//MENU
	function show() {
		var n = this.id.split("-");
		$('#submenu ul').each(function(index, element) {
			$(element).hide();
		});
		$("#submenu-"+n[1]).show();
	}
	
	function hide() { 
		null;
	}
	
	$(".hover-menu").hoverIntent({
		sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
		interval: 50,   // number = milliseconds for onMouseOver polling interval
		over: show,     // function = onMouseOver callback (required)
		timeout: 600,   // number = milliseconds delay before onMouseOut
		out: hide       // function = onMouseOut callback (required)
	});

	//BIG THUMB	
	$(".bigThumb").hover(
		function(){
			$(this).children().children('p').slideDown(200);
		},
		function(){
			$(this).children().children('p').slideUp(1000);
		}
	);
});
