/*
	Copyright James Matteson 2011. All rights reserved.
*/
var utils = new function(){
   /* scripts */
   this.attachScriptSearch = function(url){
      var newScript = document.createElement('script');
      newScript.type = 'text/javascript';
      newScript.src = url;
      $('scriptSearch').appendChild(newScript);
   }
   this.attachScriptCallback = function(fnName, callbackName, index, section){
     var fn = 'function ' + fnName + '(root){ ' + callbackName + '(root, ' + index + ', "' + section + '") }';
     var newScript = document.createElement('script');
     
      newScript.type = 'text/javascript';
      
      if(Prototype.Browser.IE){
         newScript.text = fn;
      }else{
         newScript.innerHTML = fn;
      }
      
      $('scriptCallback').innerHTML = '';
      $('scriptCallback').appendChild(newScript);
   }
   
   /* dropdowns */
   this.addDDL = function(ddl, name, value){
      var option = new Element('option', { 'value': value });
      option.innerHTML = name;
      ddl.insert(option);
   }
   this.ddlValue = function(name){
      var ddl = $(name);
      if (ddl.options.length == 0) return '';
      return ddl.options[ddl.selectedIndex].value;
   }
   
   /* string */
   this.parseDomain = function(url){
      url = url.replace(/http:\/\//g, '');
      
      var i = url.indexOf('/');
      if (i > 0) url = url.substr(0, i);
      
      var temp = url.split('.');
      return (temp.length > 2) ? temp[temp.length - 2] + '.' + temp[temp.length - 1] : url;
   }
   
   /* other */
   this.noSelect = function(e) {
      e.onselectstart = function() { return false; };
      e.unselectable = "on";
      e.style.MozUserSelect = "none";
      e.style.cursor = "default";
   }
}
