function SetFocus(TargetFormName) {
  var target = 0;
  if (TargetFormName != "")
    for (i=0; i<document.forms.length; i++) {
      if (document.forms[i].name == TargetFormName) {
        target=i;
        break;
      }
    }
  var TargetForm = document.forms[target];

  for (i=0; i<TargetForm.length; i++) {
    if ( (TargetForm.elements[i].type != "image") &&
         (TargetForm.elements[i].type != "hidden") &&
         (TargetForm.elements[i].type != "reset") &&
         (TargetForm.elements[i].type != "submit") ) {
      TargetForm.elements[i].focus();
      if ( (TargetForm.elements[i].type == "text") ||
           (TargetForm.elements[i].type == "password") )
        TargetForm.elements[i].select();

      break;
    }
  }
}

function NewWindow(mypage, myname, w, h, top, left, scroll, resize, status, menubar, toolbar, resizable, address) {
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  winops = 'height='+h+',width='+w+',top='+top+',left='+left+',scrollbars='+scroll+',resize='+resize+',status='+status+',toolbar='+toolbar+',resizable='+resizable+',location='+address+''
  win = window.open(mypage, myname, winops)
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

function verifyDelete(){
  msg = "Are you sure you wish to DELETE this record?";
  return confirm(msg);
}

function replace(string,text,by) {
  // Replaces text with by in string
  var strLength = string.length, txtLength = text.length;
  if ((strLength == 0) || (txtLength == 0)) return string;
  var i = string.indexOf(text);
  if ((!i) && (text != string.substring(0,txtLength))) return string;
  if (i == -1) return string;
  var newstr = string.substring(0,i) + by;
  if (i+txtLength < strLength)
      newstr += replace(string.substring(i+txtLength,strLength),text,by);
  return newstr;
}

function doLogin(){
  var objTemp = new Object();
  objTemp['si_email'] = document.getElementById('si_email').value;

  var objCallback = { validate: function() {} };

  var objLogin = new login(objCallback);
  objLogin.validate(objTemp);
}

function setElementById(strElement, setValue){
  document.getElementById(strElement).value = setValue;
}

function setLocationByName(setValue){
  for (i=0;i<document.forms.payment.si_location.length;i++){
	if (document.forms.payment.si_location[i].value == setValue){
	  document.forms.payment.si_location[i].checked = true;
	}
  }
}

function setInvestorByName(setValue){
  for (i=0;i<document.forms.payment.si_type_of_investor.length;i++){
	if (document.forms.payment.si_type_of_investor[i].value == setValue){
	  document.forms.payment.si_type_of_investor[i].checked = true;
	}
  }
}

function toggleElement(strElement, blnVisible){
  var objStyle = document.getElementById(strElement).style;
  if (objStyle){
	objStyle.display = (blnVisible == 1) ? 'block' : 'none';
  }
}
