function formSubmitAddInfoLinks(id, url)
{
  var container = document.getElementById(id).parentNode;
  
  var anchor = document.createElement('a');
  //anchor.setAttribute('href','#');
  anchor.setAttribute('class','js_link');
  anchor.setAttribute("onClick","openPopup('"+url+"', 350, 250)");
  
  var image = document.createElement('img');
  image.setAttribute('src','/images/help2.gif');
  image.setAttribute('alt','Info');
  
  anchor.appendChild(image);
  container.appendChild(anchor);
}


function showFlashLink(pageId)
{
  // if there is a flash page, change the link to visible
  if(pageId)
  {
    var div = document.getElementById("flash_link");
    div.className = "";
  }
}


function openPopup(url, x, y)
{
  var settings = "toolbar=no, location=no, status=yes, scrollbars=yes, resizable=1, width=" + x + ", height=" + y;
  var popup = window.open(url, 'popup', settings);
  popup.focus();
}



    function openWindow(url)
    {
      //url = url.replace(/filemanager\/productfiled/, "images");
      url = url.replace(/filemanager\/productfiled/, "productpics/521");
      url = url.replace(/file/, "picture");

      var settings = 'toolbar=no,location=no,status=yes,scrollbars=no,resizable=1,width=600,height=400';
      var imageWindow = window.open(url,'image',settings);
      imageWindow.focus();
      //http://leet.shop.wosbee.com/filemanager/productfiled/422file5Upload.jp
      //=>
      //http://leet.shop.wosbee.com/images/422file5Upload.jpg

    }
    function changeImage(url, link)
    {
      var mainImage = document.getElementById('main_image');
      var image = link.getElementsByTagName("img");
      var source = image[0].src;
      source = source.replace(/filed/, "pics");
      source = source.replace(/file/g, "picture");
      source = source.replace(/picturemanager/, "filemanager");
      mainImage.src = source;

      //http://leet.shop.wosbee.com/filemanager/productfiled/422file1Upload.jpg
      // =>
      //http://leet.shop.wosbee.com/filemanager/productpics/422picture1Upload.jpg

    }
    function hideDuplicate(elementId) { 

      var elementti = document.getElementById(elementId);

      // ie thinks <A> with name attribute is the element which is incorrect. remove that <A> and get element again.
      if(elementti.nodeName == "A") {
        elementti.parentNode.removeChild(elementti);
        elementti = document.getElementById(elementId);
      }
      
      var itemCode = document.getElementById("item_code").innerHTML;
      if(itemCode == elementId)
      {
        elementti.style.display = "none";
        elementti.parentNode.removeChild(elementti);
        return true;
      }
      else return false;
    }

    function formAsteriskCorrection() {
      // add space before asterisks so that they all look the same
      var fonts = document.getElementsByTagName("font");
      var x;
      for(x in fonts) 
      {
        if(fonts[x].innerHTML == "*") fonts[x].innerHTML = " *";
      }
    }
    function formSubmitAlignLeft(elementName, leftValue) {
      // change button's parent td align attribute to left
      var inputs = document.getElementsByTagName("input");
      for(var x in inputs) 
      {
        if(inputs[x].name == elementName)
        {
          var cell = inputs[x].parentNode;
          cell.align = "left";
          inputs[x].style.position = "relative";
          inputs[x].style.left = leftValue;
        }
      }
    }
