// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

attachmentUpload = {
  addFile: function(effects) {
    var newNode = $('file_select').cloneNode(true)
    newNode.id = ''
    newNode.firstChild.innerHTML = $('attachments').childNodes.length
    effects ? new Effect.Appear(newNode) : newNode.show()
    $('attachments').appendChild(newNode)
  },

  setDefaultTitle: function(uploadElement) {
    var matches = uploadElement.value.match(/([^\\|\/]+)(\.[^\.]+)$/)
    if(matches) {
      var textField = uploadElement.parentNode.nextSibling.childNodes[1]
      if(textField.value == '') {
        textField.value = matches[1]
      }      
    }
    this.addFile(true)
  },
  
}

var anchorPosition = window.location.href.indexOf('#') + 1;
if (anchorPosition > 1) {
  anchor = window.location.href.substring(anchorPosition);
  if (anchor.length == 40) {
    new Ajax.Request('/in/tracking', {
      method: 'post',
      asynchronous:true, 
      evalScripts:true,
      onSuccess: function(response) {

      }
    });
  }
}

callUrl = function(url) {
  $$('body').first().innerHTML += "<iframe src='"+url+"' width='1' height='1'></iframe>";
}
