var arrInput = new Array(0);
  var arrInputValue = new Array(0);

function addInput() {
  arrInput.push(arrInput.length);
  arrInputValue.push("");
  display();
}

function display() {
  document.getElementById('parah').innerHTML="";
  for (intI=0;intI<arrInput.length;intI++) {
    document.getElementById('parah').innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
  }
}

function saveValue(intId,strValue) {
  arrInputValue[intId]=strValue;
}  

function createInput(id,value) {
  return "<input type='file' name='attachment[" + id + "]' id='attachment["+ id +"]' onChange='javascript:saveValue("+ id +",this.value)' value='"+ value +"'><br>";
}

function deleteInput() {
  if (arrInput.length > 0) { 
     arrInput.pop(); 
     arrInputValue.pop();
  }
  display(); 
}


function selectToggle(toggle, form) {
     var myForm = document.forms[form];
     for( var i=0; i < myForm.length; i++ ) { 
          if(toggle) {
               myForm.elements[i].checked = "checked";
          } 
          else {
               myForm.elements[i].checked = "";
          }
     }
}


function showLayer() {
   hiddenLayer = document.getElementById("t1");
   hiddenLayer.style.visibility = "visible";
   layerPosition = parseInt(hiddenLayer.style.height);
   if (layerPosition < 400) {
      hiddenLayer.style.height = (layerPosition + 5) + "px";
      setTimeout("showLayer()", 5);
  }
}
function addElement() {
  var ni = document.getElementById('contactLayer');
  ni.style.visibility = "visible";
}
function hideLayer() {
   hiddenLayer = document.getElementById("t1");
   layerPosition = parseInt(hiddenLayer.style.height);
   if (layerPosition > 25) {
      hiddenLayer.style.height = (layerPosition - 25) + "px";
      setTimeout("hideLayer()", 5);
  }
  if (layerPosition <= 25){
        hiddenLayer.style.visibility = "hidden";
  }

}


function appendEmailAddress(field,address){
        if (field == 'to'){
                if (document.EmailForm.to.value == ''){
                        document.EmailForm.to.value = address;
                }else{
                        document.EmailForm.to.value = document.EmailForm.to.value + ', ' + address;
                }
        }
        if (field == 'cc'){
                if (document.EmailForm.cc.value == ''){
                        document.EmailForm.cc.value = address;
                }else{
                        document.EmailForm.cc.value = document.EmailForm.cc.value + ', ' + address;
                }
        }
        if (field == 'bcc'){
                if (document.EmailForm.bcc.value == ''){
                        document.EmailForm.bcc.value = address;
                }else{
                        document.EmailForm.bcc.value = document.EmailForm.bcc.value + ', ' + address;
                }
        }

}


function validateSubject () {
  if(document.post.desc.value=='Enter a brief description of your topic') document.post.desc.value='';
  if(trim(document.getElementById('subject').value)=="") {
    alert("Please enter a subject");
    return false;
  }
  return true;
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

