//BOOKMARK
function Bookmark(url) 
{
	title = "National Geographic Channel";

	if (window.sidebar)  // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, "");
	else if (window.external)  // IE Favorite
		window.external.AddFavorite(url, title);
}

//GOOGLE
function GoogleSearchMain() 
{
	document.getElementById("searchWord").value = document.getElementById("searchWordDummy").value;
	document.getElementById("cse-search-box").submit();
}

function GoogleSRespondOnEnter(evt, postbackId) 
{
	if (postbackId == 'searchWordDummy') {
		if (!evt) var evt = window.event;
		if (!evt) return;
		if (evt.keyCode == 13) {
			GoogleSearchMain();
			return false;
		}
	}
	else return true;
}

function GoogleSearch() {
	document.getElementById("searchWord").value = document.getElementById("Search").value;
	document.getElementById("cse-search-box").submit();
	return false;
}

function GoogleSearchRespondOnEnter(evt, postbackId) {
	if (postbackId == 'Search') {
		if (!evt) var evt = window.event;
		if (!evt) return;
		if (evt.keyCode == 13) {
			GoogleSearch();
			return false;
		}
	}
	else return true;
}
function setSearchText(text) {
	document.getElementById("Search").value = text;
}

function RespondOnEnter(evt, postbackId) 
{
	if (!evt) var evt = window.event;
	if (!evt) return;
	if (evt.keyCode == 13) {
		__doPostBack(postbackId, '');
		return false;
	}
}


//UPDATE BROWSER POPUP

function HidePopup(popupId) 
{
	document.getElementById(popupId).style.display = "none";
	try
	{
		Set_Cookie("HidePopupBar", "true", 30);
		return false;
	}
	catch (err)
	{
		return true;
	}
}

//UPDATE DK POPUP

function HideDKPopup(popupId) {
    document.getElementById(popupId).style.display = "none";
    try {
        Set_Cookie("HideDKTempMessage", "true", 0);
        return false;
    }
    catch (err) {
        return true;
    }
}


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';
}

function AddStyleRule(selector, style) {
	// IE won't accept real selectors...
	if (document.createStyleSheet) {
		if (!document.styleSheets.length) {
			var styleSheet = document.createStyleSheet();
		}
		else {
			var styleSheet = document.styleSheets[0];
		}
		styleSheet.addRule(selector, style);
	}
	else if (document.styleSheets) {
		if (!document.styleSheets.length) {
			(function() {
				// create a stylesheet if we need to
				var styleSheet = document.createElement('style');
				styleSheet.type = 'text/css';
				document.getElementsByTagName('head')[0].appendChild(styleSheet);
			})();
		};
		var styleSheet = document.styleSheets[0];
		styleSheet.insertRule(selector + "{" + style + "}", styleSheet.cssRules.length);
	}
}

function RemoveStyleRule() {
	var styleSheet = document.styleSheets[0];
	if (styleSheet.deleteRule) {
		if (styleSheet.cssRules.length - 1 >= 0) styleSheet.deleteRule(styleSheet.cssRules.length - 1);
	}
	else {
		var styleSheet = document.styleSheets[0];
		if (styleSheet.rules.length >= 1) {
			styleSheet.removeRule(styleSheet.rules.length - 1);
		}
	}
}

