﻿function getRadWindow() {
	var oWindow = null;
	if (window.radWindow)
		oWindow = window.radWindow;
	else if (window.frameElement.radWindow)
		oWindow = window.frameElement.radWindow;
	return oWindow;
}
function closeRadWindow() {
	var me = getRadWindow();
	if (me != null) {
		me.close();
	}
}
function openRadWindow(url, winName) { 		
	var oWnd = radopen(url, winName);
	oWnd.center();
} 

// This function handles the menu expansion event
// for a RadMenu
function itemPopulating(sender, eventArgs)
{
	var item = eventArgs.get_item();
	var itemAttributes = item.get_attributes();
	var context = eventArgs.get_context();
			
	context["ProductLineId"] = itemAttributes.getAttribute("ProductLineId");
	context["ProductTypeId"] = itemAttributes.getAttribute("ProductTypeId");
	context["ProductId"] = itemAttributes.getAttribute("ProductId"); 
}
function itemPopulated(sender, eventArgs) {
	var $item = $(eventArgs.get_item()._childListElement);

	if($item.height() > 550)
	{
		$item.parent().css("top", "0");
		$item.css("max-height", "550px");
		$item.css("overflow-y", "scroll");
		$item.css("overflow-x", "hidden");
	}
}

// This function handles the treeview expansion event
// for a RadTreeView.
// This function must be repeated because
// this is handling nodes not items
function nodePopulating(sender, eventArgs)
{
	var node = eventArgs.get_node();
	var context = eventArgs.get_context();
	context["parentMenuID"] = node.get_value();
}

function openFeedbackWindow() {
	var oWnd = radopen('<%= ResolveClientUrl("~/Feedback/default.aspx") %>', "uxFeedbackWindow");
	oWnd.set_modal(true);			
}

$(document).ready(function() {
	$("a[href$='.pdf'], a[href$='.xls'], a[href$='.csv']").click(function() {
		pageTracker._trackPageview(this.href);
	});

	// Make the search icon perform a search
	$("td.gsc-search-button").live("click", function() { 
		$("input.gsc-search-button").click();
	});
	// Fix the navigation alignment
	$(".mainNav > ul > li:lt(4)").addClass("navAlign");
});
