/* OLD CODE FOR SHOW / HIDE SEARCH *
DO NOT DELETE YET */
function ShowHide(element, image, a)
{
	var showhideElement = document.getElementById(element);
	var originImage = document.getElementById(image);		
	var text = document.all[a];		
	
	if (showhideElement==null || originImage==null || text==null)
	{
		return;
	}
	
	if (showhideElement.style.display == null || showhideElement.style.display == "none")
	{
		showhideElement.style.display = "inline";
		originImage.src = "./images/hide.gif";
		text.className  = "normalLinkBold";
	}
	else
	{
		showhideElement.style.display = "none";
		originImage.src = "./images/show.gif";
		text.className  = "normalLink";
	}
}

function ShowHideAdvancedSearch(showText, hideText)
{
	if(showText==null) showText = 'Show Advanced Search Options';
	if(hideText==null) hideText = 'Hide Advanced Search Options';
	
	var showhideElement = document.getElementById('tblAdvancedSearch');
	var text			= document.getElementById('lnkAdvancedSearch');
	var icon			= document.getElementById('imgAdvancedSearch');
	
	var txtHiddenSearch = document.getElementById('txtHiddenSearch');		
	
	if (showhideElement==null || text==null || icon==null || txtHiddenSearch==null)
	{
		return;
	}
	
	if (showhideElement.style.display == null || showhideElement.style.display == "none")
	{
		showhideElement.style.display	= "inline";
		text.innerText					= hideText;
		txtHiddenSearch.value			= "true";
		icon.src						= "./Images/magnifier_zoom_out.gif"
	}
	else
	{
		showhideElement.style.display	= "none";
		text.innerText					= showText;
		txtHiddenSearch.value			= "false";
		icon.src						= "./Images/magnifier_zoom_in.gif"
	}
}

function CheckAdvancedSearch()
{
	var txtHiddenSearch = document.getElementById('txtHiddenSearch');
	var showhideElement = document.getElementById('tblAdvancedSearch');
	
	if(txtHiddenSearch!=null && showhideElement!=null)
	{
		if (showhideElement.style.display == null || showhideElement.style.display == "none")		
		{
			if(txtHiddenSearch.value=="true")
			{
				ShowHideAdvancedSearch();
			}
		}
		else
		{
			if(txtHiddenSearch.value=="false")
			{
				ShowHideAdvancedSearch();
			}
		}
	}	
}

function OpenPopUp(url, title, width, height, centered, resize)
{
	var size	= "";
	var attribs = "";	
	
	if(width==null) width=500;
	if(height==null) height=500;
	if(centered==null) centered=true;
	if(resize==null) resize=false;
	
	if(resize) size = "yes"; else size = "no";
	
	if(centered)
	{	/*/ center the window /*/

		// if the screen is smaller than the window, override the resize setting
		if(screen.width <= width || screen.height <= height) size = "yes";

		WndTop  = (screen.height - height) / 2;
		WndLeft = (screen.width  - width)  / 2;

		// collect the attributes
		//attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
		//"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
		
		attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=yes," + 
		"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
	}
	else
	{
		/*/
		/ / There is still one last thing we can do for JavaScrpt 1.1
		/ / users in Netscape.  Using the AWT in Java we can pull the
		/ / information we need, provided it is enabled.
		/*/
		if(navigator.appName=="Netscape" && navigator.javaEnabled())
		{	/*/ center the window /*/

			var toolkit = java.awt.Toolkit.getDefaultToolkit();
			var screen_size = toolkit.getScreenSize();

			// if the screen is smaller than the window, override the resize setting
			if(screen_size.width <= width || screen_size.height <= height) size = "yes";

			WndTop  = (screen_size.height - height) / 2;
			WndLeft = (screen_size.width  - width)  / 2;

			// collect the attributes
			attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
			"status=no,toolbar=no,directories=no,menubar=no,location=no,top=" + WndTop + ",left=" + WndLeft;
		}
		else
		{	/*/ use the default window position /*/

			// override the resize setting
			size = "yes";

			// collect the attributes
			attribs = "width=" + width + ",height=" + height + ",resizable=" + size + ",scrollbars=" + size + "," + 
			"status=no,toolbar=no,directories=no,menubar=no,location=no";
		}
	}
		
	var win = window.open(url,null,attribs);		
	return;
}

function ShowModalDialog(url, title, width, height)
{
	if(width==null) width=500;
	if(height==null) height=500;
	
	var sFeatures="status:no;dialogHeight:"+height+"px;dialogWidth:"+width+"px";
		
	var win = window.showModalDialog(url,title,sFeatures);		
	return;
}

function AttachmentsPopUp(url)
{
	OpenPopUp(url, 'Attachments', 600, 400);	
}

function NotesPopUp(url, title)
{
	OpenPopUp(url, 'Notes', 800, 400, true, false);
}

function FavoritesPopUp(url, title)
{
	var sFeatures="dialogHeight:500px;dialogWidth:500px";	
	var win = window.showModalDialog(url,title,sFeatures);	
	return;
}

function noenter() 
{
  return !(window.event && window.event.keyCode == 13); 
}

// Event listeners

addEvent = function(o, e, f, s){
	//if(o!=null && e!=null && f!=null && s!=null)
	//{
		var r = o[r = "_" + (e = "on" + e)] = o[r] || (o[e] ? [[o[e], o]] : []), a, c, d;
		r[r.length] = [f, s || o], o[e] = function(e){
			try{
				(e = e || event).preventDefault || (e.preventDefault = function(){e.returnValue = false;});
				e.stopPropagation || (e.stopPropagation = function(){e.cancelBubble = true;});
				e.target || (e.target = e.srcElement || null);
				e.key = (e.which + 1 || e.keyCode + 1) - 1 || 0;
			}catch(f){}
			for(d = 1, f = r.length; f; r[--f] && (a = r[f][0], o = r[f][1], a.call ? c = a.call(o, e) : (o._ = a, c = o._(e), o._ = null), d &= c !== false));
			return e = null, !!d;
		}
   // }
};

removeEvent = function(o, e, f, s){
	//if(o!=null && e!=null && f!=null && s!=null)
	//{
	for(var i = (e = o["_on" + e] || []).length; i;)
		if(e[--i] && e[i][0] == f && (s || o) == e[i][1])
			return delete e[i];
	return false;
	//}
};