var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
offsetX = 0;
offsetY = 20;
var toolTipSTYLE="";

function initToolTips()
{
	if(ns4||ns6||ie4)
	{
		if(ns4) toolTipSTYLE = document.toolTipLayer;
		else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
		else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
		if(ns4) document.captureEvents(Event.MOUSEMOVE);
		else
		{
		toolTipSTYLE.visibility = "visible";
		toolTipSTYLE.display = "none";
		}
		document.onmousemove = moveToMouseLoc;
	}
}

function quotereplace(param)
{
	var str = new String(param);
	str = str.replace('"', "&quot;").replace("'", "&prime;");
	return str;
}

function toolTip(msg, fg, bg, fsize, widt)
{
  if(toolTip.arguments.length < 1) // hide
  {
    if(ns4) toolTipSTYLE.visibility = "hidden";
    else toolTipSTYLE.display = "none";
  }
  else // show
  {
    if(!fg) fg = "#777777";
    if(!bg) bg = "#FFFFFF";
	if(!fsize) fsize = "-1";
	msg = quotereplace(msg);
 	if((!widt)||(widt=='')){
		var content =
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
    '<table border="0" cellspacing="0" cellpadding="4" bgcolor="' + bg + 
    '"><td><font color="' + fg +
    '" size="' + fsize + '">' + msg + '</font></td></table></td></table>';
	} else  {
	    var content =
    '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
    '<table border="0" width="' + widt + '" cellspacing="0" cellpadding="4" bgcolor="' + bg + 
    '"><td>' + msg + '</td></table></td></table>';
	}
    if(ns4) 
    {
      toolTipSTYLE.document.write(content);
      toolTipSTYLE.document.close();
      toolTipSTYLE.visibility = "visible";
    }
    if(ns6)
    {
      document.getElementById("toolTipLayer").innerHTML = content;
      toolTipSTYLE.display='block'
    }
    if(ie4)
    {
      document.all("toolTipLayer").innerHTML=content;
      toolTipSTYLE.display='block'
    }
  }
}
function moveToMouseLoc(e)
{
	if(ns4||ns6)
	{
		x = e.pageX;
		y = e.pageY;
	}
	else
	{
		x = event.x + document.body.scrollLeft;
		y = event.y + document.body.scrollTop;
	}
	toolTipSTYLE.left = x + offsetX;
	toolTipSTYLE.top = y + offsetY;
return true;
}

function winopn(urlful,widh,high){
	var winwidth = screen.availWidth; 
		winheight = screen.availHeight;
		wwidth = (winwidth-widh)/2;
		wheight = (winheight-high)/2;
		version = parseInt(navigator.appVersion);
	if (navigator.appName=="NetScape")
		{
			if (version <= 4)  {widh = widh + 150;} 
		}
	window.open(urlful,''+widh+'','left='+wwidth+',top='+wheight+',width='+widh+',height='+high+',scrollbars=0');
}

function winopnscrol(urlful,widh,high){
	var winwidth = screen.availWidth; 
		winheight = screen.availHeight;
		wwidth = (winwidth-widh)/2;
		wheight = (winheight-high)/2;
		version = parseInt(navigator.appVersion);
	if (navigator.appName=="NetScape")
		{
			if (version <= 4)  {widh = widh + 150;} 
		}
	window.open(urlful,''+widh+'','left='+wwidth+',top='+wheight+',width='+widh+',height='+high+',scrollbars=1');
}

function winopnscr(urlful,widh,high){
	var winwidth = screen.availWidth; 
		winheight = screen.availHeight;
		if ((!widh)&&(!high)) {
			widh = winwidth-100;
			high = winheight-200;
			wwidth = (winwidth-widh)/2;
			wheight = (winheight-high)/2;
		} else {
			wwidth = (winwidth-widh)/2;
			wheight = (winheight-high)/2;
		}
	    noww = new Date();
		rvd = noww.getTime();
		version = parseInt(navigator.appVersion);
	if (navigator.appName=="NetScape")
		{
			if (version <= 4)  {widh = widh + 150;} 
		}
	window.open(urlful,'win'+rvd+'','left='+wwidth+',top='+wheight+',width='+widh+',height='+high+',scrollbars=1,menubar=1,toolbar=1,resizable=1');
}

function winopnnew(urlful, widh, high, s){
	var winwidth = screen.availWidth; 
		winheight = screen.availHeight;
		wwidth = (winwidth-widh)/2;
		widh = widh+5;
		wheight = (winheight-high)/2;
		high = high+30;
		version = parseInt(navigator.appVersion);
		
	if (navigator.appName=="NetScape")
		{
			if (version <= 4)  {widh = widh + 150;} 
		}
	imagewin = window.open('',''+widh+'','left='+wwidth+',top='+wheight+',width='+widh+',height='+high+',scrollbars=1');
	imagewin.document.write("<html><head><title>"+urlful+"</title><link rel=\"stylesheet\" type=\"text/css\" href=\"../templates/default/style/mamtrix.css\"></head><body >"+s+"</body></html>");
	imagewin.document.close();
	//leftmargin=0 topmargin=0 marginwidth=0 marginheight=0
}

function Run(querystring)
{
	if (document.forms[0].hidStatus.value == 1){
		window.opener.location.replace(window.opener.location.href+"?"+querystring);
	}
}

function Func(indx)
{
var n1 = Array("themes/Default/images/btn_obj.gif","themes/Default/images/btn_desc.gif","themes/Default/images/btn_resour.gif","themes/Default/images/btn_progr.gif","themes/Default/images/btn_summ.gif");
var n2 = Array("themes/Default/images/btn_obj_b.gif","themes/Default/images/btn_desc_b.gif","themes/Default/images/btn_resour_b.gif","themes/Default/images/btn_progr_b.gif","themes/Default/images/btn_summ_b.gif");		
var ids = Array("btnObjective","btnDesc","btnResourc","btnProgres","btnSummary");		
	for (i = 0; i<=4; i++)
	{
		var x;
		if(document.getElementById && !document.all)
		{x = document.getElementById(ids[i]);}
		else if(document.all)
		{x = document.all[ids[i]];}	
		if (i == indx)
			x.src = n2[i];

		else
			x.src = n1[i];
	}
}
function SelectTextInControl(controlID)
{
	var x;
	if(document.getElementById && !document.all)
	{x = document.getElementById(controlID);}
	else if(document.all)
	{x = document.all[controlID];}	
//	alert(x.type);
	if (x.type == "text")
		x.select();
}

function gebi(id)
{
	var x;
	try
	{
		if(document.getElementById && !document.all)
			{x = document.getElementById(id);}
		else if(document.all)
			{x = document.all[id];}	
		
		if (x == null) throw "err"
		return x;
	}
	catch(er)
	{
		if(er == "err") alert("GEBI.Unknown_ID : "+id);
		return;
	}
}

function c_gebi(c_uid, id)
{
	if (c_uid != "")
	{
		prefix	= new String(c_uid);
		rExp	= /:/gi
		//		prefix	= (document.all ? prefix + "$" : prefix.replace(rExp, "_") + "_");
		prefix = prefix.replace(/\$/gi, "_");
		prefix	= prefix.replace(rExp, "_") + "_";
		id = prefix + id;
	}

	var x;
	try
	{
		if(document.getElementById && !document.all)
			{x = document.getElementById(id);}
		else if(document.all)
			{x = document.all[id];}	
		
		if (x == null) throw "err"
		return x;
	}
	catch(er)
	{
		if(er == "err") alert("GEBI.Unknown_ID : "+id);
		return;
	}
}

function gev(id)
{
	re = new RegExp("^\\s*$", "i")
	if(re.test(gebi(id).value)) 
		return 0;
	else
	{	
		re = new RegExp("^([0-9]+\\.{1}[0-9]+)$", "i")
		if(re.test(gebi(id).value)) 
			return parseFloat(gebi(id).value);
		else
			return parseInt(gebi(id).value);
	}
}

function ToDigital(val)
{
	re = new RegExp("^\\s*$", "i")
	if(re.test(val)) 
		return 0;
	else
	{	
		re = new RegExp("^([0-9]+\\.{1}[0-9]+)$", "i")
		if(re.test(val)) 
			return parseFloat(val);
		else
			return parseInt(val);
	}
}
