jQuery(document).ready(function() {
    /*fixTopMenu();*/
    moveTitleImages();
    roundCorners();    
});

function roundCorners(){
    
  var cornerRadius = 7;
  
  jQuery.each( ['top', 'bottom','left', 'right', 'tl', 'tr', 'bl', 'br'], function(index, corner){
      jQuery('.rc'+corner).each(function(){	
	jQuery(this).corner('round '+corner+' '+cornerRadius);
      });
  });
  
  var lastLevel2Submenu = jQuery('#left_menu_container .level2 a').last();
  if (lastLevel2Submenu){ lastLevel2Submenu.corner('round bottom '+cornerRadius+'px');}
  
  jQuery('#main_body_container').corner('round '+cornerRadius+'px');
  jQuery('#main_content').corner('round '+Math.round(cornerRadius*1.3)+'px');
  
}

function moveTitleImages(){
  
  //do not do this in IE6
  if (jQuery.browser.msie && jQuery.browser.version.substr(0,1)<7) return;
    
  
  
  var first_div_in_header=jQuery('#main_content .csc-textpic').first();
  var first_div_in_header_clearer=jQuery('#main_content .csc-textpic-clear').first();
  if (first_div_in_header){    
    //if this is a title
    
    if (jQuery.trim(first_div_in_header.text()).length < 50){      
      first_div_in_header.clone().appendTo(jQuery("#header_container div"));
      first_div_in_header_clearer.clone().appendTo(jQuery("#header_container div"));      
      
      first_div_in_header.find('.csc-textpic-imagewrap').hide();
      first_div_in_header.html('<h1>'+first_div_in_header.text()+'</h1>'); // sorry this is brutal
    }
  }    
}

function fixTopMenu(){
  var first_top_menu_item=jQuery("#top_menu_container a").first();
  first_top_menu_item.html(first_top_menu_item.html().replace(" ","<br/>"))
}

