// NS or IE?
NS = navigator.appName == "Netscape";
IE = navigator.appName == "Microsoft Internet Explorer";
Unknown = !(NS || IE);

// go to a specifc URL
function goto(URL)
{
	if(URL.length > 0)
		top.location.href = URL;
}

// open a new window
function OpenWindow(url, name)
{
	var win = window.open(url, name);
	win.focus();
}

// open a new [small] window
function OpenSmallWindow(url, name)
{
	var win = window.open(url, name, "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=550,height=350,left=25,top=25")
	win.focus();
}

//custom reference for window
var WinCustom = null;

// open a new custom window
function OpenCustomWindow(url, name, height, width)
{
	if(WinCustom == null || WinCustom.closed)
	{
		WinCustom = window.open(url, 'custom', "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=yes,directories=no,location=no,width=" + width + ",height=" + height + ",left=25,top=25")
	}
	else
	{
		WinCustom= window.open(url, 'custom');
		// = window.open(url, 'custom', "fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=no,resizable=yes,directories=no,location=no,width=" + width + ",height=" + height + ",left=25,top=25")
		WinCustom.resizeTo(parseInt(width)+2, parseInt(height)+50);
	}
    
	WinCustom.focus();
}

// close window
function closewin()
{
	self.close();
	window.close();
}

// generic show div and hide previous div 
var currentDiv = "";

function ShowDiv(divname)
{	
	if(currentDiv.length > 0)
	{
		var divToHide = document.getElementById(currentDiv)
		
		if(divToHide != null)
		    divToHide.style.display = 'none';
	}
	
	var myDiv = document.getElementById(divname);
			
	myDiv.style.display = 'block';
	
	currentDiv = divname;	
}


// generic show/hide element
function ShowHide(id)
{
	var div = document.getElementById(id);
	
	if(id != null)
	{
		if(div.style.display == 'none' || div.style.display == '')
			div.style.display = 'block';
		else
			div.style.display = 'none';
	}	
}


// change url by drop down selection
function gotoUrlFromDropDown(DropDownId)
{
	var ddl = document.getElementById(DropDownId);
	
	if(ddl.value != "#" && ddl.value != "" && ddl.value != null)
		document.location.href = ddl.value;
}


// event handler for the search button
function Search()
{
    var searchTerm = document.getElementById("ctl00_txtSearch").value;

    if(searchTerm.length > 0 && searchTerm != "")	
		top.location.href = "/search/default.aspx?q=" + encodeURIComponent(searchTerm);
}


// event handler for the search box
//function ClearSearch()
//{
//	var searchbox = document.getElementById("searchbox");
//	
//	if(searchbox.value == "Search")
//		searchbox.value = "";
//}


// capture the enter keypress event
function CaptureKey(e) 
{
	var keyCode;
	var searchTerm = document.getElementById("ctl00_txtSearch").value;
	var bSearch = false;
	
	if(NS)
	{
		keyCode = e.keyCode;
	}
		
	if(IE)
	{		
		keyCode = event.keyCode;
	}
	
	if(keyCode == 13) // enter key was pressed
	{
		if(searchTerm.length > 0 && searchTerm != "")
		{					
			// search	
			bSearch = true;
			Search();
		}
		
		// cancel event bubble
		if(bSearch)
			return false;
	}
}


// capture the keypress event
//document.onkeypress = CaptureKey;
