﻿function onUpdating(divId) {
	// get the update progress div
	var pnlPopup = $get('AjaxProgressPopUp');

	// get the gridview element
	var gridView = $get(divId);

	// make it visible
	pnlPopup.style.display = '';

	// get the bounds of both the gridview and the progress div
	var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
	var pnlPopupBounds = Sys.UI.DomElement.getBounds(pnlPopup);

	//  center of gridview
	var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(pnlPopupBounds.width / 2);
	var y = gridViewBounds.y + Math.round(gridViewBounds.height / 2) - Math.round(pnlPopupBounds.height / 2);

	//	set the progress element to this position
	Sys.UI.DomElement.setLocation(pnlPopup, x, y);
}

function onUpdated() {
	// get the update progress div
	var pnlPopup = $get('AjaxProgressPopUp');
	// make it invisible
	pnlPopup.style.display = 'none';
}

// WEBISODES WIDGET

function showDefaultView() {
    $('.WebisodesContent').hide();
    $('.ViewButtons .selected').removeClass('selected');
    $('.DefaultBtn').addClass('selected');
    $('.WebisodesLoading').show();
    $('.WebisodesLoading').removeClass('NoBackground');
    $('.WebisodesLoading').height(169);
}

function showThumbView() {
    $('.WebisodesContent').hide();
    $('.ViewButtons .selected').removeClass('selected');
    $('.ThumbBtn').addClass('selected');
    $('.WebisodesThumbnailLoading').show();
}

function pagerThumbView() {
    $('.ThumbList').css('visibility', 'hidden');
    $('.ThumbPager .selected').removeClass('selected'); 
    $('.WebisodesThumbnailLoading').show();
}

function showListView() {
    $('.WebisodesLoading').height(288);
    $('.WebisodesLoading').addClass('NoBackground');
    $('.WebisodesContent').hide();
    $('.ViewButtons .selected').removeClass('selected');
    $('.ListBtn').addClass('selected');
    $('.WebisodesLoading').show();
}

function playVideoView() {
    $('.ViewButtons .selected').removeClass('selected');
    $('.DefaultBtn').addClass('selected');
    $('.WebisodesLoading').show();
    $('.WebisodesModule .image').css('visibility', 'hidden');
    $('.WebisodesLoading').height(169);
}

function hideWebisodesLoading() {
    $(document).ready(function () {
        $('.WebisodesLoading').fadeOut("fast");
        $('.WebisodesThumbnailLoading').fadeOut("fast");
        $('.WebisodesLoading').removeClass('NoBackground');
    });
}

//DROP DOWN EFFECT WITH JQUERY
//$(document).ready(function() {
	//	$('.VideosDivButton').click(function() {
	//		$('.ShowsLinks').hide();
	//		$('.ShowsDiv').removeClass("MasterButtonBackground");
	//		$('.VideoLinks').show("slide", { direction: "up" }, 500);
	//		$('.VideosDiv').addClass("MasterButtonBackground");
	//		$('.VideosDivButton').css({ opacity: null });
	//		$('.ShowsDivButton').css({ opacity: '0.4' });
	//		$('.ListingsDivButton').css({ opacity: '0.4' });
	//	});

	//	$('.ShowsDivButton').click(function() {
	//		$('.VideoLinks').hide();
	//		$('.VideosDiv').removeClass("MasterButtonBackground");
	//		$('.ShowsLinks').show("slide", { direction: "up" }, 500);
	//		$('.ShowsDiv').addClass("MasterButtonBackground");
	//		$('.ShowsDivButton').css({ opacity: null });
	//		$('.VideosDivButton').css({ opacity: '0.4' });
	//		$('.ListingsDivButton').css({ opacity: '0.4' });
	//	});

//	$('.CloseVideos').click(function() {
//		$('.VideoLinks').css('display', 'none');
//		
//		$('.VideosDiv').removeClass("MasterButtonBackground");
		//		$('.ShowsDivButton').css({ opacity: null });
		//		$('.ListingsDivButton').css({ opacity: null });
//	});

//	$('.CloseShows').click(function() {
//		$('.ShowsLinks').css('display', 'none');
		//$('.ShowsLinks').attr('style', '')
//		$('.ShowsDiv').removeClass("MasterButtonBackground");
		//		$('.VideosDivButton').css({ opacity: null });
		//		$('.ListingsDivButton').css({ opacity: null });
//	});
//});

//FADE EFFECT
//$(document).ready(function() {
//	$('.VideosDivButton').hover(function() {
//		$('.ShowsDivButton').css({ opacity: '0.4' });
//		$('.ListingsDivButton').css({ opacity: '0.4' });
//	}, function() {
//		$('.ShowsDivButton').css({ opacity: null });
//		$('.ListingsDivButton').css({ opacity: null });
//	});

//	$('.ShowsDivButton').hover(function() {
//		$('.VideosDivButton').css({ opacity: '0.4' });
//		$('.ListingsDivButton').css({ opacity: '0.4' });
//	}, function() {
//		$('.VideosDivButton').css({ opacity: null });
//		$('.ListingsDivButton').css({ opacity: null });
//	});
//});

//COOKIES

function Set_Cookie(name, value, expires, path) {
	var today = new Date();
	today.setTime(today.getTime());

	if (expires) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date(today.getTime() + (expires));

	document.cookie = name + "=" + encodeURIComponent(value) +
		((path) ? ";path=" + path : ";path=/") +
		((expires) ? ";expires=" + expires_date.toGMTString() : "")
		;
}

function Get_Cookie(name) {

	var start = document.cookie.indexOf(name + "=");
	var len = start + name.length + 1;
	if ((!start) &&
			(name != document.cookie.substring(0, name.length))) {
		return null;
	}
	if (start == -1) return null;
	var end = document.cookie.indexOf(";", len);
	if (end == -1) end = document.cookie.length;
	return unescape(document.cookie.substring(len, end));
}

function Delete_Cookie(name, path) {
	if (Get_Cookie(name)) document.cookie = name + "=" +
			((path) ? ";path=" + path : ";path=/") +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}




