﻿function regUpdatableScript(func)
{
	$(document).ready(function ()
	{
		var x = function (sender, args)
		{
			if (null != args)
				sessionStorage.setItem('TableFilter_Partial', 1);
			else
				sessionStorage.setItem('TableFilter_Partial', 0);
			func(sender, args);
			highlightSelected();
		}
		Sys.WebForms.PageRequestManager.getInstance().remove_endRequest(x);
		Sys.WebForms.PageRequestManager.getInstance().add_endRequest(x);
		x(null, null);
	});
}


function highlightSelected()
{
	var path = location.pathname.toLowerCase();
	if (path.indexOf('aspx') == -1)
		path += 'default.aspx';
	var q = '#nested-container-nav a[href|="' + path + '"]';
	var p = $(q);
	if (typeof p != 'undefined' && p != null && p.length == 1)
	{
		p[0].style.color = '#800000';
		p[0].style.fontWeight = 'bold';
	}
}

function formatImagePopupTitle(title, currentArray, currentIndex, currentOpts)
{
	//<img src="/fancybox/closelabel.gif" /></a>
	return '<div id="products-title"><span><a href="javascript:;" onclick="$.fancybox.close();">CLOSE X</a></span>' + (title && title.length ? '<b>' + title + '</b>' : '') + 'Image ' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
}


$('document').ready(function ()
{
	highlightSelected();
});
