/*



Dynamic Application of Functions to DOM
*/
var debug = false;


/*



This is the function that applies the functions to the DOM
Defined just before </body> in the markup.
This occurs before initAfterImages();
*/
function init(){

  /*



  Embed Flash
  Flash.EmbedFlash(EF_object, EF_width, EF_height, EF_filename, true);
  */

  /*
  
  
  Add "Drop Shadow" to Logo
  */
  var dropShadow = new String('<h3 id="company2"><span>Deep South <span>Crane Rentals, Inc.</span></span></h3>');
  new Insertion.After("company", dropShadow);
  /*



  Forms
  */
  $$("input", "select", "textarea").each(c.addFocus);
  
  
  $$('table.DataTable tbody tr').each(function(node, i){
    if (i%2==0){
      node.addClassName('alt');
    }
    node.observe('mouseover', function(e){
     node.addClassName('hover'); 
    });
    node.observe('mouseout', function(e){
     node.removeClassName('hover'); 
    });
  });

}




/*



Library of Custom Functions
*/
var Flash = $H({
  /*
  
  
  Returns the Flash object existing on the DOM,
  allowing you to use methods and functions from within the ActionScript itself
  */
  $Flash: function(movieName){
    if (!navigator.appName.include("Microsoft")){
      return window[movieName];
    } else {
      return document[movieName];
    }
  },
  /*
  
  
  
  This function is used to embed the Flash into the page
  
  Variables:
  
    Variable Name   : Laman        : Data Type
    
    EF_object       : id of object : String
    EF_width        : width        : String
    EF_height       : height       : String
    EF_filename     : filename     : String
    EF_transparency : transparency : Boolean
  
  */
  EmbedFlash: function(EF_object, EF_name, EF_width, EF_height, EF_filename, EF_transparency){
    if($(EF_object)){
      $(EF_object).update(IEHacks.FlashHTML(EF_object, EF_name, EF_width, EF_height, EF_filename, EF_transparency));
    }
  },
  FlashHTML: function (EF_object, EF_name, EF_width, EF_height, EF_filename, EF_transparency){
    if (EF_transparency){
      var EF_transparency_ParamMarkup = new String('<param name="wmode" value="transparent" />');
      var EF_transparency_EmbedMarkup = new String('wmode="transparent"');
    } else {
      var EF_transparency_ParamMarkup = new String('');
      var EF_transparency_EmbedMarkup = new String('');
    }
    var markup = [
      '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="', EF_width, '" height="', EF_height, '" id="', EF_name, '" align="middle" style="height: ', EF_height, '; width: ', EF_width, ';">',
      '<param name="allowScriptAccess" value="sameDomain" />',
      EF_transparency_ParamMarkup,
      '<param name="movie" value="', EF_filename, '" />',
      '<param name="quality" value="high" />',
      '<embed src="', EF_filename, '" ', EF_transparency_EmbedMarkup, ' quality="high" width="', EF_width, '" height="', EF_height, '" name="', EF_name, '" align="middle" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />',
      '</object>'].join("");
    return markup;
  }
});
/*

Aliasing $Flash
*/
var $Flash = Flash.$Flash;





/*


The start of the custom functions object
*/
var c = $H({
  /*


  Drop Down show's the first ul child
  */
  addDropDown: function(node, i){
    node.observe("mouseover", function(){node.addClassName("hover");});
    node.observe("mouseout", function(){node.removeClassName("hover");});
    if (node.down("ul")){
      var ul = node.down("ul");
      node.observe("mouseover", function(){ul.show();});
      node.observe("mouseout", function(){ul.hide();});
    }
  },
  addFocus: function(node, i){
    node.observe("focus", c.toggleFocus.bindAsEventListener(node));
    node.observe("blur", c.toggleFocus.bindAsEventListener(node));
  },
  toggleFocus: function(e){
    this.toggleClassName("focus");
  },
  addHover: function(node, i){
    node.observe("mousover", c.toggleHover.bindAsEventListener(node));
    node.observe("mouseout", c.toggleHover.bindAsEventListener(node));
  },
  toggleHover: function(e){
    this.toggleClassName("hover");
  }
});

function cl(str){if(debug){
  Try.these(
    function(){console.log(str);},
    function(){alert(str)}
  );
}}
