﻿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';
}

//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').hide("slide", { direction: "up" }, 100);
		$('.VideosDiv').removeClass("MasterButtonBackground");
		$('.ShowsDivButton').css({ opacity: null });
		$('.ListingsDivButton').css({ opacity: null });
	});

	$('.CloseShows').click(function() {
		$('.ShowsLinks').hide("slide", { direction: "up" }, 100);
		$('.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";
}



