/**
* bookmark
*
* @param	url				The url to bookmark
* @param	description		Associate this description with the URL
*/
function addBookmark(url, description)
{
	if(url != null)
	{
		if(navigator.appName=='Microsoft Internet Explorer')
		{
			window.external.AddFavorite(url, description);
		}
		else if (navigator.appName=='Netscape')
		{
			alert("Please press CTRL+D to bookmark this page");
		}
	}
}

/**
* setHomePage
*
* @param	url		The url to use as the home page
*/
function setHomePage(ref, url)
{
	if(url != null)
	{
		if(navigator.appName=='Microsoft Internet Explorer')
		{
			ref.style.behavior='url(#default#homepage)'; 
			ref.setHomePage(window.location);
		}
		else if (navigator.appName=='Netscape')
		{
			alert("Click 'Edit->Preferences' and then choose the 'Navigator' tag and click 'Use Current Page'");
		}
	}
}

function showLayer(nr)
{
	if (document.layers)
	{
		vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'hide'
		document.layers[nr].visibility = vista;
	}
	else if (document.all)
	{
		vista = (document.all[nr].style.visibility == 'hidden') ? 'visible'	: 'hidden';
		document.all[nr].style.visibility = vista;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'hidden';
		document.getElementById(nr).style.visibility = vista;

	}
}

function blocking(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}

function openWindow(url)
{
	window.open(url, "window", "");
}

function printContent(src, layerName)
{
    target = window.open("", "", "");
    target.document.open();
    target.document.write("<html><head><" + "script language=\"javascript\" src=\"/scripts.js\"><" + "/script><link rel='stylesheet' type='text/css' href='/styles.css' /><title></title><" + "script language=JScript>function printAndClose() {idWBPrint.ExecWB(6, -1);idWBPrint.outerHTML = ''; self.close();}</script" + "></head><body onLoad='printAndClose();'><object id='idWBPrint' width=0 height=0 classid='clsid:8856F961-340A-11D0-A96B-00C04FD705A2'></object>" + src + "</body></html>");
    target.document.close();
}

function buildHTMLEditPopup(url, params)
{
	target = window.open(url, "", params);
}

/**
* setVisible
*
* @param	id		The id of the element to make visible
*/
function setVisibility(id, visible)
{
	if(id != null)
	{
		var obj = document.getElementById(id);
		if(obj != null)
		{
			if(visible == "visible")
			{
				obj.style.visibility = "visible";
				obj.style.display = "block";
			}
			else
			{
				obj.style.visibility = "hidden";
				obj.style.display = "none";
			}
		}
	}
}

/**
* setVisible
*
* @param	id		The id of the element to make visible
*/
function switchVisibility(id)
{
	if(id != null)
	{
		var obj = document.getElementById(id);
		if(obj != null)
		{
			if(obj.style.visibility == "visible")
			{
				obj.style.visibility = "hidden";
				obj.style.display = "none";
			}
			else
			{				
				obj.style.visibility = "visible";
				obj.style.display = "block";
			}
		}
	}
}

/**
* setVisible
*
* @param	id		The id of the element to make visible
*/
function clearTextField(id)
{
	if(id != null)
	{
		var obj = document.getElementById(id);
		if(obj != null)
		{
			obj.value = "";
		}
	}
}

/**
* formatText
*
*
*/
function formatText(fn, targetID)
{
	control = document.getElementById(targetID);
	source = "";

	if(document.selection && document.selection.createRange().text != '')
	{
		source = document.selection.createRange().text;
	}
	else
	{
		var startPos = control.selectionStart;
		var endPos = control.selectionEnd;
		source = control.value.substring(startPos, endPos)
	}

	if(fn == "strip")
	{
		source = source.replace(/\n|\r|\r\n/gi, " ");
	}

        if(document.selection && document.selection.createRange().text != '')
        {

        }
        else
        {
                var startPos = control.selectionStart;
                var endPos = control.selectionEnd;

		pre = control.value.substring(0, startPos);
		post = control.value.substring(endPos);

		control.value = pre + source + post;
        }
}

