// Used for Linking
function setTarget(e, target)
{
	//Get source element...
	var eSrc;
     if( !e )
     {
         eSrc = window.event.srcElement;
     }
     else
     {
         eSrc = e.srcElement;
         if( !eSrc )
             eSrc = e.target;
     }
	
	//Walk up tree until we get to an A. 
	while(eSrc.tagName != "A" && String(eSrc) != "undefined" )
	{
		if(eSrc.parentElement)
			eSrc = eSrc.parentElement;
		else
			eSrc = eSrc.parentNode;
	}
	
	//Set the target.
	eSrc.target=target;
	
	return false;
}

function ShowImage(URL)
{
	// CHANGE SIZE OF WINDOW e.g. Width = 774, Height = 600
	pop_up(URL,'',774,600);
	return;
}

function ShowHelpNotes(URL)
{
    pop_up(URL,'',500,200);
}

function OpenInWindow(url, width, height)
{
	try
	{
		if(arguments.length>1)
		{
			window.open(url,"_blank","width=" + width + ",height=" + height + ";");
		}
		else
		{
			window.open(url,"_blank");
		}
	}
	catch(err)
	{
		alert(err.message);
	}
}

function pop_up(URL,PopUpName,Width,Height)
{
	try
	{
		if (Width =="" || Width == null) Width =486;
		if (Height == "" || Height == null) Height =500;

		var features =
		',directories=0'+
		',location=0'   +
		',menubar=0'   +
		',scrollbars=1'+
		',status=0'   +
		',toolbar=0'   +
		',resizable=1' +
		',width=' + Width +
		',height=' + Height +
		',screenX=15'
		',screenY=15'
		',top=15'+
		',left=15';
		URL = URL.replace(/\s/,'%20');
		wind=window.open (URL, PopUpName, features);
		wind.focus();
	}
	catch(err){}
}

// Used by the WebFire Content Editor Toolbar
function setAction(event, action, el)
{
	getElement("WebFireAction").value = action;
	event.cancelBubble = true;
	return false;
}

function setActionKey(event, action, el)
{
	event.cancelBubble = true;
	if(event.keyCode == 13 || event.keyCode == 32)
	{
		getElement("WebFireAction").value = action;
		return false;
	}
	else
		return true;
}

function getElement(eID)
{
	var ret = null;
	
	if( document.layers )	//NS method.
	{
		try
		{
			ret = document.layers(eID);
		}
		catch(e){}
	}
	else if( document.getElementById )			   //W3C method.
	{
		try
		{
			ret = document.getElementById(eID);
		}
		catch(e){}
	}
	else if( document.all )			   //IE method.
	{
		try
		{
			ret = document.all(eID);
		}
		catch(e){}
	}
	//else element not found.
	return ret;
}

function blankInput(n, t)
{
	var el = getElement(n);
	
	if(el.value == t)
		el.value = "";
}

function restoreDefault(n, t)
{
	var el = getElement(n);
	if(el.value == "")
		el.value = t;
}