jQuery.noConflict();
jQuery(document).ready(function() {
  var ixd = window.ixd || new frilunsj(null);
  if( ixd ) {
    ixd.init();
  }
});

function frilunsj(headerType) {
    var that = this;
    this.headerType = headerType;
    
    this.init = function() {
      tableClickability();
      initEmails();
      
      if( headerType ) {
        adjustWrapper(jQuery("#header"));
      }
    };
  
    var tableClickability = function() {
      jQuery("tr a").each(function(i) {
        var row = jQuery(this).parent().parent();
        if( ! row.is("tr") ) return;
        
        if( row.find("a").length == 1 )
          row.css({ cursor: 'pointer' });
      });
      
      jQuery("tr").click(function() {
        if ( jQuery(this).find("a").length == 1 ) {
          var destination = jQuery(this).find("a")[0].href;
          if ( destination )
            window.location = destination;
        }
      });
    };

  
    var initEmails = function() {
      if (!document.getElementById || !document.createElement)
    		return false;
    
    	var links = document.getElementsByTagName('a');
    	for (var i = 0, link = null, email = null, em = null; (link = links[i]); i++) {
    		if (link.rel == 'email') {
    			em = link.innerHTML.trim().split(' a ');
    			email = em[0] + '@' + em[1];
    			link.href = 'mailto:' + email;
    			link.innerHTML = email;
    		}
    	}
    };
    
    
}

String.prototype.trim = function() {
	return this.replace(/^\s*|\s*$/g, "");
}