<!--
/****************************************************************/
/* Copyright © Cyiam (Pty) Limited, 2006                        */
/* All Rights Reserved                                          */
/*                                                              */
/* This code is protected by international patent and copyright */
/* laws. It may not be sold, used or distributed in any form    */
/* without prior written consent, signed by all the executive   */
/* members of Copyright © Cyiam (Pty) Limited.                  */
/*                                                              */
/* Contacts:                                                    */
/* André van Rensburg (andre@cyiam.com)                         */
/*                                                              */
/* Developers:                                                  */
/* André van Rensburg (andre@cyiam.com)                         */
/****************************************************************/
//--Globals
var navToCtl = "";

function IE60Browser()
{
  var fOK = true;
  var sUserAgent = navigator.userAgent;

  var nIndexBrowser = sUserAgent.indexOf("MSIE ");
  if (nIndexBrowser == -1)
    return false;  // not IE

  var sMSIETemp = sUserAgent.substr(nIndexBrowser);
  var nIndexSemiColon = sMSIETemp.indexOf(";");

  var sBrowserVer = sUserAgent.substr(nIndexBrowser + 5,nIndexSemiColon);
	
  if (parseFloat("6.0") > parseFloat(sBrowserVer))
    return false; // not IE 6.0 or higher

  return true;
}

// Sets the focus to the first text field on the current form
// Point the global navToCtlto point to a control to focus explicitly
function SetFocus()
{
	if ("" != navToCtl)
	{
		document.all(navToCtl).focus();
		document.all(navToCtl).select();
		return;
	}

	var elements = document.forms[0].getElementsByTagName("input");
	for(i = 0; i < elements.length; i++)
	{
		if (("text" == elements[i].type) || ("password" == elements[i].type))
		{
			if ((elements[i].disabled != true) && (elements[i].style.visibility == 'visible'))
			{
				elements[i].focus();
				elements[i].select();
				return;
			}
		}
	}
	elements = document.forms[0].getElementsByTagName("select");
	for(i = 0; i < elements.length; i++)
	{
		if ((elements[i].disabled != true) && (elements[i].style.visibility == 'visible'))
		{
			elements[i].focus();
			elements[i].select();
			return;
		}
	}
	elements = document.forms[0].getElementsByTagName("textarea");
	for(i = 0; i < elements.length; i++)
	{
		if ((elements[i].disabled != true) && (elements[i].style.visibility == 'visible'))
		{
			elements[i].focus();
			elements[i].select();
			return;
		}
	}
	elements = document.forms[0].getElementsByTagName("input");
	for(i = 0; i < elements.length; i++)
	{
		if (("checkbox" == elements[i].type) && (elements[i].disabled != true) && (elements[i].style.visibility == 'visible'))
		{
			elements[i].focus();
			elements[i].select();
			return;
		}
	}
	for(i = 0; i < elements.length; i++)
	{
		if (("radio" == elements[i].type) && (elements[i].disabled != true) && (elements[i].style.visibility == 'visible'))
		{
			elements[i].focus();
			elements[i].select();
			return;
		}
	}
	for(i = 0; i < elements.length; i++)
	{
		if (("button" == elements[i].type) || ("reset" == elements[i].type) || ("submit" == elements[i].type))
		{
			if ((elements[i].disabled != true) && (elements[i].style.visibility == 'visible'))
			{
				elements[i].focus();
				elements[i].select();
				return;
			}
		}
	}
}

function TextboxFocus()
{
	var item = window.event.srcElement;
	item.style.color = "#000000";
	item.value = "";
}

function TextboxUnfocus(text)
{
	var item = window.event.srcElement;
	if (item.value == "")
	{
		item.value = text;
		item.style.color = "gray";
	}
}

// id = The id of the div to open or close
// memid = The id of the hidden input to hold the postback value ("open" or "closed")
// skinRoot = The server root where the plus and minus images can be found.
function ToggleView(id, memid, skinRoot)
{
  var img = window.event.srcElement;
  var input = document.all.tags("input")(memid);
  var div = document.all.tags("div")(id);

  if ("none" == div.style.display)
  {
    div.style.display="inline";
    img.src = skinRoot + "images/minus.gif";
    img.alt = "Click to Collapse";
    input.value = "open";
  }
  else
  {
    div.style.display="none";
    img.src = skinRoot + "images/plus.gif";
    img.alt = "Click to Expand";
    input.value = "closed";
  }
}

function ShowView(id)
{
  var div = document.all.tags("div")(id);

   div.style.display="inline";
}

function HideView(id)
{
  var div = document.all.tags("div")(id);

  div.style.display="none";
}

function HideControl(id)
{
    var control = document.getElementById(id);
    control.style.display="none";
}
function ShowControl(id)
{
    var control = document.getElementById(id);
    control.style.visibility="visible";
}

function AssignValueToControl(control, textvalue)
{
    document.getElementById(control).value=textvalue;
}


function findElement(control, name)
                {
                    
                    var i = 0;
                    var j = 0;
                    
                    if (control.id != null && control.id.length > 0)
                    {
                        if (control.id.indexOf(name) >= 0)
                            return control;
                    }

                    if (control.hasChildNodes())
                    {
                        for (i=0; i < control.childNodes.length; i++)
                        {
                            var childControl = findElement(control.childNodes[i], name);
                            if (childControl != null)
                                return childControl;
                        }
                    }
                    
                    else if (control.rows != null)
                    {
                        for (i=0; i < control.rows.length; i++)
                        {
                            var row = control.rows[i];
                            for (j=0; j < row.cells.length; i++)
                            {
                                var cellControl = findElement(row.cells[j], name);
                                if (cellControl != null)
                                    return cellControl;
                            }
                        }
                    }
                    
                    return null;
                } 

//function CheckAllBoxes()
//{
//  var inputs, first;
//  inputs = document.all.tags("input");
//  first = document.all("selAll").checked;
//  for (i = 0; i < inputs.length; i++)
//  {
//    if (("checkbox" == inputs[i].type) && ("selAll" != inputs[i].id) && (!inputs[i].disabled))
//      inputs[i].checked = first;
//  }
//}

//function SetButtons()
//{
//  var inputs;
//  inputs = document.all.tags("input");
//  for (i = 0; i < inputs.length; i++)
//  {
//    if (("checkbox" == inputs[i].type) && ("selAll" != inputs[i].id) && (inputs[i].checked))
//    {
//      frmFolders.btnSubmit.disabled = false;
//      return;
//    }
//  }
//  frmFolders.btnSubmit.disabled = true;
//}

function NavToNewWindow(url, windowName)
{
	var w = window.open(url, windowName, 'location=0,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1', true);
	w.moveBy(15, 15);
	w.focus();
	//document.body.removeAttribute("onload", 0);
	//document.onClick = "";
}

function NavToNewForm(topic, windowName)
{
  var w = window.open(topic, windowName, 'location=0,menubar=0,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=0,width=800,height=635', true);
	//w.moveBy(15, 15);
	//w.focus();
	//document.body.attributes.removeNamedItem("onload");
	//document.body.removeAttribute("onload", 0);
	//document.onClick = "";
}

function Navigate(topic, windowName)
{
  var w = window.open(topic, windowName, 'location=0,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,top=10,left=10,width=800,height=600',true);
  w.focus();
  return;
}

function NavigateMinimal(topic, windowName)
{
  var w = window.open(topic, windowName, 'location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0,top=10,left=10,width=800,height=600',true);
  w.focus();
  return;
}

function NavigateWithIDQuery(topic, windowName, idName)
{
  var url = topic + "?" + idName + "=" + window.event.srcElement.id;
  var w = window.open(url, windowName, 'location=0,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1,top=10,left=10,width=700,height=600',true);
  w.focus();
  return;
}

function NavigateWithIDQueryMinimal(topic, windowName, idName)
{
  var url = topic + "?" + idName + "=" + window.event.srcElement.id;
  var w = window.open(url, windowName, 'location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0,top=10,left=10,width=700,height=600',true);
  w.focus();
  return;
}

function ConvertCaps()
{
  var txt = window.event.srcElement.value;
  txt = txt.toLowerCase();
  var ret = txt.split(" ");

  var newStr = "";
  for (i = 0; i < ret.length; i++)
  {
    if (("van" != ret[i]) && ("von" != ret[i]) && ("de" != ret[i]) && ("der" != ret[i]) && ("le" != ret[i]) && ("du" != ret[i]))
      ret[i] = ret[i].charAt(0).toString().toUpperCase() + ret[i].substr(1, ret[i].length - 1);
    if (0 == i) newStr = newStr + ret[i];
    else newStr = newStr + " " + ret[i];
  }
  window.event.srcElement.value = newStr;
}

function left(strVal, iEnd, iNumChars)
{
  var k;
  var iStart;
  var sTmp = "";
  
  sTmp = strVal;
  if (iEnd < 0) iEnd = 0;
  if (iEnd >= sTmp.length) iEnd = sTmp.length-1;
  
  iStart = iEnd - iNumChars;
  if (iStart < 0) iStart = 0;
  if (iStart > iEnd) iStart = iEnd;
  
  sTmp = "";
  for (k = iStart; k <= iEnd; k++)
    sTmp += strVal.charAt(k);
      
  return(sTmp);
}

function right(strVal, iStart, iNumChars)
{
  var k;
  var iEnd;
  var sTmp = "";
  
  sTmp = strVal;
  if (iStart < 0) iStart = sTmp.length-1;    // Start at end if negative
  if (iStart >= sTmp.length) iStart = sTmp.length-1;
  
  iEnd = iStart + iNumChars;
  if (iEnd >= sTmp.length) iEnd = sTmp.length-1;
  if (iEnd < iStart) iEnd = iStart;
  
  sTmp = "";
  for (k = iStart; k <= iEnd; k++)
    sTmp += strVal.charAt(k);
      
  return(sTmp);
}

function cint(chrVal)
{
  if (chrVal == '0') return(0);
  if (chrVal == '1') return(1);
  if (chrVal == '2') return(2);
  if (chrVal == '3') return(3);
  if (chrVal == '4') return(4);
  if (chrVal == '5') return(5);
  if (chrVal == '6') return(6);
  if (chrVal == '7') return(7);
  if (chrVal == '8') return(8);
  if (chrVal == '9') return(9);
  // Should never get here, but oh well
  return(0);
}

function stripSpaces(s)
{
  var k;
  
  k = s.indexOf(" ");
  while (k >= 0) {
    s = s.substr(0, k) + s.substr(k+1);   
    k = s.indexOf(" ");
  }
  return(s);
}
-->
