var counter = 1;
var limit = 8;

function addInput(divName){
     if (counter == limit)  {
          alert("You have reached the limit of adding " + counter + " inputs");
     }
     else {
          var newP = document.createElement('p');
		  newP.setAttribute('id','file' + (counter + 1));
          newP.innerHTML = "<label>Image " + (counter + 1) + "</label><input type=\"file\"  name=\"mainimage" + (counter + 1) + "\" size=\"25\" style=\"margin-right:20px\" /><input type=\"file\"  name=\"largeimage" + (counter + 1) + "\" size=\"25\" style=\"margin-right:20px\" /><input type=\"button\" value=\"Remove\" onClick=\"removeElement('images', 'file" + (counter + 1) + "');\" \/>";
          document.getElementById(divName).appendChild(newP);
          counter++;
     }
}


function removeElement(parentDiv, childDiv){
     if (childDiv == parentDiv) {
          alert("The parent div cannot be removed.");
     }
     else if (document.getElementById(childDiv)) {     
          var child = document.getElementById(childDiv);
          var parent = document.getElementById(parentDiv);
          parent.removeChild(child);
     }
     else {
          alert("Child div has already been removed or does not exist.");
          return false;
     }
}


function popupConfirm(msg) { //v1.0
  document.MM_returnValue = confirm(msg);
}


function ee(name, domain, suffix, text)
{
   var address = name + "\u0040" + domain + "." + suffix;
   var url = "mai" + "lto:" + address;

   if( ! text )
   {
      text = address;
   }

   document.write("<a href=\"" + url + "\">" + text + "</a>");
}

