  var appName = navigator.appName.toLowerCase();
  var userAgent = navigator.userAgent.toLowerCase();
  var browser = ( appName )?( ( appName == "opera" || userAgent.indexOf("opera") >= 0 )? "opera" : ( ( appName.indexOf('netscape') >= 0 ) ? "ns" : ( ( userAgent.indexOf('msie') >= 0 ) ? "ie" : ( ( userAgent.indexOf( 'aol' ) >= 0 ) ? "aol" : null )))) : null;


function firstElemFocus() 
{
  if (document.forms.length == 0) return; 

  var focussed;
  var fi = 0;
  while ( fi < document.forms.length ) {
    var form = document.forms[fi++];
    
    if (!form) continue;

    if (form.getAttribute("donotfocus") != null) continue;
    
    if (form && form.elements.length > 0){
      focussed = false;

      var i = 0;
      while ( i < form.elements.length ) {
        elem = form.elements[i++];
        if (elem.getAttribute("donotfocus") != null) continue;
        try {
          elem.focus();
          focussed = true;
          break;
        } catch (e) {
        }
      }
      if (focussed) break;
    }
  }
  
}


 function selectTypeMini(type){

   var form = document.forms['form']; 
   var companyBillingInformation = document.getElementById("companyBillingInformation");

   var show = 'block';
   if ( browser == 'ns' || browser == "opera") {
    show = 'table-row';
   }
   
   var typeP = '{type}';
   var t1 = document.getElementById("t1");
   var t2 = document.getElementById("t2");

  if(type == 0){
   if(typeP == 'person' || typeP==''){
    type = 1;
   };

   if(typeP == 'company'){
    type = 2;
   };
  }

   if(type==2){
    companyBillingInformation.style.display = show;
   } else {
    companyBillingInformation.style.display = 'none';
   }  
   
 return false;

 }


function formatAsMoney(mnt) {
  var delimiter = "'";
  if (currentLanguage == "Arabic") {
    delimiter = ".";
  }
  mnt = mnt + "";
  var count = 3;
  var res = "";
  for(var i = mnt.length;i>=0; i--){
   if(count == 0 && i!=0) {
    count = 2;
    res = delimiter + mnt.charAt(i) + res;
   } else {
    res = mnt.charAt(i) + res;
    count--;
   }
  }
  return res;
}

function getForm(formName) {
  if( (typeof formName == 'undefined') || formName == null ){
    return null;
  }        
  return document.forms[formName];
}

function getObject(id){
  var object;
  
  if(document.getElementById){
    object = document.getElementById(id);
  }else if(document.all){
    object = document.all[id]; 
  }

  return object;
}

function getInput(inputName, formName) {  
  var form = getForm(formName);
  if (form == null){
    return null;
  }
  if( (typeof inputName == 'undefined') || inputName == null ){
    return null;
  }
  return form.elements[inputName];
}

function chooseOption(obj, value) {
  for ( var x=0; x < obj.options.length; x++ ) {
    var option = obj.options[x];
    if ( option.value == value ) {
      option.selected = true;
    }
  }
}

function chooseSelectOption(inputName, formName, value) {
  var input = getInput(inputName, formName);
  chooseOption(input, value);
}


function getInputValue(inputName, formName) {
  var input = getInput(inputName, formName);
  return (input == null) ? "" : input.value;
}