var isIE = navigator.userAgent.indexOf("MSIE")>-1;
var isFF = navigator.userAgent.indexOf("FireFox")>-1;
var curFile = null;
var curWnd = null;
var curContent = null;

function showHide(elemID)
{
	var obj = document.getElementById(elemID);
	if (!obj)
	{
		return;
	}
	obj.style.display = obj.style.display == 'none'?obj.style.display='':obj.style.display = 'none';
}


function modalEditorPopup(url,width,height,filename)
{
	if (isIE)
	{
		var result = showModalDialog(url,'','dialogWidth: 750px; dialogHeight: 700px; center: yes; status: no; unadorned: yes'); 
		if (result!='<J8979: html-edit-closed: no-save:2873323444>') 
		{ 
			document.getElementById('html_'+filename).value=result; 
			document.forms['form_'+filename].submit(); 
		};
	}
	else 
	{
		curFile = filename;
		window.open(url,"","width="+width+";height="+height+";center: yes; status: no; unadorned: yes;modal:yes;");
	}
}


function editorClose()
{
	if (curContent != '<J8979: html-edit-closed: no-save:2873323444>') 
	{ 
		document.getElementById('html_'+curFile).value=curContent; 
		document.forms['form_'+curFile].submit(); 
	};
	curFile = null;
	curContent = null;
}

/*
	Shows red border around editable block
*/
function editMouseOver(obj)
{
	obj.className='obuttonsover'; 
	if (isIE)
	{
		obj.parentElement.parentElement.className='odiv1';
	}
	else 
	{
		obj.parentNode.parentNode.className='odiv1';
	}
	
}

function editMouseOut(obj)
{

	obj.className='obuttonsout'; 
	if (isIE)
	{
		obj.parentElement.parentElement.className='odiv';
	}
	else
	{
		obj.parentNode.parentNode.className='odiv';
	}
}

function getParentByTag(node,tagName,className)
{
	var elem = null;

	if (isIE)
	{
		elem = node.parentElement;		
	}
	else
	{
		elem = node.parentNode;
	}
	if (elem.tagName == tagName && elem.className == className)
	{
		return elem;
	}
	return getParentByTag(elem,tagName,className);
}

function openPopup(url,width,height)
{
	window.open(url,'PlotLabPop','width='+width+'px, height='+height+'px, center=yes, status=no;');
	return false;
}
function LoginValidate()
{
	var frm = document.forms["login_form"];
	if (frm.user.value == '')
	{
		alert("Please enter login!");
		return false;
	}
	if (frm.pass.value == '')
	{
		alert("Please enter password!");
		return false;
	}
	return true;
}