// JavaScript Document
var popUpWin=0;

function popUpWindow(URLStr, name, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}  

function popUp(url, name, w, h) {
var opt = "scrollbars,resizable";
	win = window.open(url, name, "width=" + w + ",height=" + h + "," + opt);
}

var newwindow

function popitup(url , title) {
if (newwindow && !newwindow.closed)
{ newwindow.focus(); newwindow.document.clear() }
else
{ newwindow=window.open('','','width=404,height=316,resizable=1') }
newwindow.document.writeln('<> <head> <title>' + title + '<\/title> <\/head> <body bgcolor=\"black\"> <center>');
newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" >');
newwindow.document.writeln('<\/center> <\/body> <\/html>');
newwindow.document.close();
}

// Advanced popup image window
var wheight = 0, wwidth = 0;

function popitup5(url, title, iwidth, iheight, colour) {
var pwidth, pheight;

if ( !newwindow || newwindow.closed ) {
pwidth=iwidth+30;
pheight=iheight+30;
newwindow=window.open('','htmlname','width=' + pwidth +',height=' +pheight + ',resizable=1,top=50,left=10');
wheight=iheight;
wwidth=iwidth;
}

if (wheight!=iheight || wwidth!=iwidth ) {
pwidth=iwidth+30;
pheight=iheight+90;
newwindow.resizeTo(pwidth, pheight);
wheight=iheight;
wwidth=iwidth;
}

newwindow.document.clear();
newwindow.focus();
newwindow.document.writeln('<html> <head> <title>' + title + '<\/title> <\/head> <body bgcolor= \"' + colour + '\"> <center>');
newwindow.document.writeln('<img src=' + url + ' title=\"' + title + '\" alt=\"' + title + '\" id=\"img_popped\">');
newwindow.document.writeln('<\/center> <\/body> <\/html>');
newwindow.document.close();
newwindow.focus();
}

// Routines to tidy up popup windows when page is left
// Call with an onUnload="tidy5()" in body tag

function tidy5() {
if (newwindow && !newwindow.closed) { newwindow.close(); }
}

function show_hide_optional(label,onText,offText,chkbox)
{
	var linkContainer = document.getElementById(label);
	var label = findObj(label);
	var checkbox      = findObj(chkbox);
	var state 		  = checkbox.checked;
	
	var tmp = document.getElementsByTagName('div');
    var vis_state = label.style.visibility;
    var newState = "hidden";
    if (vis_state == "hidden")
        newState = "visible";
    label.style.visibility = newState;	
	for (var i=0;i<tmp.length;i++)
	{
		if(tmp[i].className == 'fm-optional')
		{
			//alert('state:' + state + ' display is:' + tmp[i].style.display);
			tmp[i].style.display = (state) ? 'block' : 'none';
		}
	}
	return false;
}

function show_form_onchange(form, field, trigger, classname)
{
    var result = false;
	if (document.forms.length > 0)
	{
	  	for (i=0;i<document.forms.length;i++)
	  	{
			if(document.forms[i].name == form)
			{				
                var list = document.forms[i].elements[field]; 
			}
		}
	}
	else
	{
		var list = document.form.field;
	}	
	var tmp = document.getElementsByTagName('div');
	var value = list.options[list.selectedIndex].value;
    classname += classname ? '|' : null;
 //   alert('classname: ' + classname);
    var arr_class = String(classname ? classname : '').split('|'); 

	for (var i=0;i<tmp.length;i++)
	{
        for (var j = 0; j < arr_class.length; j++)
        {     
            classname = arr_class[j];            
		    if( classname && tmp[i].className == classname)
		    {
          //      alert('found classname: ' + classname); 
			    if (value == trigger)
			    {
				    tmp[i].style.display = 'block';
                    result = true;
			    }
			    else
			    {
				    tmp[i].style.display = 'none';
			    }
		    }
	    }
    }
	return result;
}

function hide_all(form, field, str_classnames)
{
    var result = true;
    if (document.forms.length > 0)
    {
          for (i=0;i<document.forms.length;i++)
          {
            if(document.forms[i].name == form)
            {                
                var list = document.forms[i].elements[field]; 
            }
        }
    }
    else
    {
        var list = document.form.field;
    }    
    var tmp = document.getElementsByTagName('div');
    var arr_class = String(str_classnames ? str_classnames : '').split('|');
    for (var i=0;i<tmp.length;i++)
    {
      for (var j = 0; j < arr_class.length; j++)
      {      
        if( tmp[i].className == arr_class[j])
        {
            tmp[i].style.display = 'none';
        }
      }
    }
    return result;
}

var DHTML = (document.getElementById || document.all || document.layers);
function invi_obj(name,flag)
{
	if (!DHTML) return;
	//var x = new getObj(name);
	var x = findObj(name);
	x.style.visibility = (flag) ? 'hidden' : 'visible';
}

function invi_toggle(chkbox, target)
{
	if (!DHTML) return;
	var checkbox      = findObj(chkbox);
	var state 		  = checkbox.checked;
		
	checkbox.value = state ? 1 : 0;
	
	state = !state;
	invi_obj(target,state);
}

function append_link_text()
{ 
	var links = document.links || document.getElementsByTagName('a'); 
	var n = links.length; 
	for (var i = 0; i < n; i++) 
	{ 
		if (links[i].title && links[i].title != '') 
		{ // add the title to anchor innerhtml
			links[i].innerHTML += '<span>'+links[i].title+'</span>'; 
			links[i].title = ''; // remove the title 
		} 
	}
}

/*--- EndOfFile ---*/
