document.write = document.writeln = function(str){ /* Please do nothing. */ };



jQuery(function(){

  

  document.write = document.writeln = function(str){

     /* So, the DOM is ready but what to do with the string?

        > http://DennisHoppe.de

     */ 

  };

  

  // IE have to learn :focus

  jQuery('input, textarea')

    .focus(function(){

      jQuery(this).addClass('focus');

    })

    .blur(function(){

      jQuery(this).removeClass('focus');

    });

    

});

jQuery(document).ready(function() 
{
    var moduleColumns = new Array();
    // add sidebars
    jQuery('.sidebar').each(function(i) {
        moduleColumns[moduleColumns.length] = jQuery(this);
    });
    // add content
    jQuery('#contentbox').each(function(i) {
        moduleColumns[moduleColumns.length] = jQuery(this);
    });
    
    
    // determine max height
    var maxHeight = 0;
    // loop through each column
    for( var x = 0; x < moduleColumns.length; x++ ) {
        // get column height
        var colHeight = moduleColumns[x].height();
     	// if the column height is greater than the max height ...
        if(colHeight >= maxHeight) {
            // set new max height
            maxHeight = colHeight;
        }
    }
    
    // set heights
    // loop through each column
    for( var i = 0; i < moduleColumns.length; i++ )
    {
        // get height of column
        var colHeight = moduleColumns[i].height();
        // get the difference between max height and this column's height
        var diffHeight = maxHeight - colHeight;
        
        // if the column is smaller than max ...
        if( diffHeight > 0 )
        {
            /*
            // get the 
            var childModules = new Array();
            moduleColumns[i].children().children('.module-blue-body').each(function(i)
            {
                childModules[childModules.length] = $(this);
            });

            if ($.browser.msie) {
                    diffHeight += $(childModules[childModules.length-1]).outerHeight(true); // get height incl. margin
            } else {
                diffHeight += $(childModules[childModules.length-1]).height();
            }
            
            childModules[childModules.length-1].height( diffHeight );
            */
            
            //alert(moduleColumns[i].attr("id") + "|" + moduleColumns[i].children(".page").length);
            
            if(moduleColumns[i].attr("id") == "contentbox" && moduleColumns[i].children(".page").length == 1) {
                moduleColumns[i].children(".page").height (maxHeight-16);
            } else {
                moduleColumns[i].height (maxHeight);
            }
        }
    }
        
});


function evenWidthLabelTags() {
	// setup single column fields
	dojo.query(".fieldsContainer").forEach(function(node, index, arr) {
		var maxWidth = 0;
		var maxHeight = 0;
		
		// loop through to find the biggest fields
		dojo.query(".fieldSet label", node).forEach(function(node, index, arr) {
			var width = dojo.contentBox(node).w;
			var height = dojo.contentBox(node).h;
			
			if(width > maxWidth) {
				maxWidth = width;
			}
			if(height > maxHeight) {
				maxHeight = height;
			}
		});
		
		// loop through and set the fields
		dojo.query(".fieldSet label", node).forEach(function(node, index, arr) {
			var width = dojo.contentBox(node).w;
			dojo.contentBox(node, {w: maxWidth});
		});
		
	});
}
