var dbgString = "";
var _menusCreated = false;
var _level2open=false;
var ns = (navigator.appName=="Netscape")? true : false;
var ie = (navigator.appName!="Netscape")? true : false;
var IsFlashMode=true;
var currentFontColor = "";
 

function clearPreviewStatus(reload)
{
	var prOb=new ActiveXObject("Microsoft.XMLDOM");
	prOb.async=false;
	if(!prOb.load("/fibi/site/XML/clearPreviewStatus.hx.asp"))
	{
		alert("Error:"+prOb.parseError.reason);
		return;
	}
	
	var res="";
	try
	{
		res=prOb.documentElement.getAttribute("desc");
	}
	catch(e)
	{
		alert("Error:"+e.description);
		return;
	}
	if(res!="OK")
	{
		alert("Error:"+res);
		return;
	}
	if(reload)
		window.location.reload();
	else
		window.event.srcElement.style.display='none';
}
function goFibi(address)
{
	window.location=address;
}

function cleanCData(str)
{
	if(str.indexOf("<![CDATA[")==0)
	{
		return (str.substring(9,str.length-9-3));
	}
	return str;
}
function NavRollOver(obj,bgColor,fontColor)
{
	currentFontColor = obj.style.color;

	if(ie){obj.style.cursor='hand';}
	if(NavRollOver.arguments.length==1)
	{
		bgColor = "";
		fontColor = "";
	}
	else
	{
		if(NavRollOver.arguments.length==2)
		{
			bgColor = bgColor;
			fontColor = "";
		}
		else
		{
			if(NavRollOver.arguments.length==3)
			{
				bgColor = bgColor ;
				fontColor = fontColor;
			}
		}
	}		
	 obj.bgColor=bgColor;
	 obj.style.color = fontColor;
}
function NavRollOut(obj,bgColor,fontColor) 
{
	if(NavRollOut.arguments.length==1)
	{
		bgColor	 = '' ;
		fontColor = currentFontColor;
	}
	else
	{
		if(NavRollOut.arguments.length==2)
		{
			bgColor	 = bgColor ;
			fontColor = currentFontColor;
		}
		else
		{
			if(NavRollOut.arguments.length==3)
			{
				bgColor   = bgColor ;
				fontColor = fontColor;
			}
		}
	}		
	 obj.bgColor     = bgColor;
	 obj.style.color = fontColor;
	 status = "Done";
}
function hidemenus(i)
{
	status = "Done";
	document.all["divSubmenu"+i].style.visibility="hidden";
}

function openA(address)
{
	window.open(address);
}
function divOnOff(div,cancelBubble,on)
{
	if (cancelBubble) window.event.cancelBubble = true;
	var oDiv = document.all(div);
	if(isnull(oDiv)) return;
	if(on)
	{
		oDiv.style.display = "";
	}
	else
	{
		status = "Done";
		oDiv.style.display = "none";
	}
}
function isnull(arg) 
{
	arg = arg+'';
	return (arg == '' || arg == 'null' || arg == 'undefined');
}
function iif(q,truePart,falsePart)
{
	return (q) ? truePart : falsePart;
}
/// CHECK
function nz(param,val)
{
	return(
		isnull(param)
		? ((!isnull(val)) ? val : "") 
		: param
	);
}
function hasVScroll()
{
	return(screen.availHeight < document.body.scrollHeight);
}
function trim(str){
	try {
		return str.replace(/^\s+|\s+$/g,'');
	}
	catch (e) {
		return str;
	}
}
function changeClass(obj,clas){
	obj.className = clas;
}		
function fontChange(obj,fontColor) {
	obj.style.color = fontColor
}
function showHideDiv(obj,on)
{
	if(!_menusCreated)
		return;
	obj=docObj(obj);
	if (on)
	{
		obj.style.display = "";
	}
	else{
		obj.style.display = "none";
	}
}
function SHD(obj,on){
	
	if(!_menusCreated)
		return;
	obj=docObj(obj);
	var selects=document.getElementsByTagName("SELECT");
	if (on){
		obj.style.display = "";
		for(var i=0;i<selects.length;i++)
		{
			selects(i).style.visibility='hidden';
		}
	}
	else
	{
		obj.style.display = "none";
		for(var i=0;i<selects.length;i++)
		{
			selects(i).style.visibility='visible';
		}
	}
}
function SHDLev2(id,on)
{
	positionLevelTwo(id);
	SHD('m2L'+id,on);
}
function CCN(obj,clName)
{
	if(!document.getElementById(obj).className.match("S"))
		document.getElementById(obj).className=clName;
}
function CCN1(obj,clName){
	//alert(document.getElementById(obj).className)
	if(!document.getElementById(obj).className.match("S"))
		document.getElementById(obj).className=clName;
}
function CPC(id){
	if(document.getElementById('mL'+id).className.match("mBFS"))
	{
	   document.getElementById('mL'+id).className="mBFS";
		return;
	}
	if(document.getElementById('mL'+id).className.match("mBF"))
	{
	   document.getElementById('mL'+id).className="mBFH";
		return;
	}
	if(document.getElementById('mL'+id).className.match("mB"))
	   document.getElementById('mL'+id).className="mBH";
}
function CPH(id)
{
	if(!document.getElementById('mL'+id).className.match("S"))
	{
		if(document.getElementById('mL'+id).className.match("mBF"))
		   document.getElementById('mL'+id).className="mBF";
		else
		   document.getElementById('mL'+id).className="mB";
	}
}
function showHideTR(obj,on)
{
	if (on)
	{
		document.all[obj].style.top=event.y;
		document.all[obj].style.left=event.x-document.all[obj].offsetWidth;
		document.all[obj].style.display = "";
	}
	else
		document.all[obj].style.display = "none";
}
function docObj(obj)
{
	if(typeof(obj) != "object")
	{
		return(document.getElementById(obj));
	}
	return obj;
}



///////////////////////////////////////////////////////////////////////////////
function changeColor(color,bgcolor)
{
	event.srcElement.style.color=color;
	if(!isnull(bgcolor))
		event.srcElement.style.backgroundColor=bgcolor;
}
function cC(color,bgcolor)
{
	event.srcElement.style.color=color;
	if(!isnull(bgcolor))
		event.srcElement.style.backgroundColor=bgcolor;
}
function changeTextDecor(value,obj)
{
	if(obj==null)
		obj=event.srcElement;
	obj.style.textDecorationUnderline = value;
}
function imgOnOffChange()
{
	if(String(event.srcElement.src).indexOf("_off")>-1)
	{
		event.srcElement.src=String(event.srcElement.src).replace("_off","_on");
		return;
	}
	if(String(event.srcElement.src).indexOf("_on")>-1)
	{
		event.srcElement.src=String(event.srcElement.src).replace("_on","_off");
		return;
	}
}
function temp()
{
	alert("UNDER CONSTRUCTION");
}
function openWindow(winHref, winName, winWidth, winHeight,winLeft,winTop)
{
	if (winName==null) winName="";
	if (winWidth==null) winWidth=516;
	if (winHeight==null) winHeight=505;
	if (winLeft==null) winLeft=75;
	if (winTop==null) winTop=15;
	if (! window.focus)return true;
	var href;
	if (typeof(winHref) == 'string')
	   href=winHref;
	else
	   href=winHref.href;
	winStr="width=" + winWidth + ", height=" + winHeight + ", scrollbars=yes, left= " + winLeft + ", top= " + winTop
	window.open(href, winName, winStr);
	
}


// for search module 
function validWord(word){
	if ((word.indexOf("<")>-1) || (word.indexOf(">")>-1) || (word.indexOf("#")>-1))
		return false;
		
	if ((word.length<2) ||(word.indexOf("}")>-1) || (word.indexOf("{")>-1) || (word.indexOf("^")>-1)) 
		return false;
	
	if ((word.indexOf("!")>-1) || (word.indexOf("@")>-1) || (word.indexOf("~")>-1)|| (word.indexOf("|")>-1) ) 
		return false;
	
	if ((word.indexOf("&")>-1) || (word.indexOf("(")>-1) || (word.indexOf(")")>-1) || (word.indexOf("/")>-1)) 
		return false;
	
	if ((word.indexOf("$")>-1) ||  (word.indexOf(";")>-1)|| (word.indexOf("=")>-1) ) 
		return false;
	
	return true;
}	
function solution(url,w,h)
{
	var prop="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=" + w + ",height=" + h + ",screenX=75,screenY=15,left=75,top=15"
	window.open(url,"order",prop);
}
function openDictionary(winHref)
{
	winHref="/fibi/site/HTMLfiles/dictionary.asp?pi=1532#" + winHref;
	winName="Milon";
	var href;
	if (typeof(winHref) == 'string')
	   href=winHref;
	else
	   href=winHref.href;
	winStr="width=250, height=50, scrollbars=yes, left=500, top=230"
	window.open(href, winName, winStr);
}
function openTr(){document.write("<tr>");}
function closeTr(){document.write("</tr>");}
function openWind(addr,name,arguments)
{
	window.open(addr,name,arguments);
	return;
}

// Ben Kayam - 09/05/2003
function showMilonTerm(Word)
{
	var MilonUrl;
	MilonUrl  = "/milon/site/milon.asp?rdir=milon&word=";
	MilonUrl += Word;
	
	javascript:window.open(MilonUrl,'Milon','left=200,top=100,width=600,height=500,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0');
}

//// Ben Kayam 19/06/2003
// Display Div Options For MultiQA DataType.
function displayDiv(myOwnDiv,divToHide,offClass,onClass)
{
	if(document.all(""+divToHide).style.display == "")
	{
		document.all(""+divToHide).style.display = "none";
		document.all(""+myOwnDiv).className = offClass;			
	}
	else
	{
		document.all(""+divToHide).style.display = "";
		document.all(""+myOwnDiv).className = onClass;
	}
}
