$j(document).ready(function() { 

	//expandable subject heirarchy
	$j( "div#block409 .taggroup > ul > li:has(div)" ).addClass('hasChildren').not('.parent_tag').not('.active_tag').children('div').hide();
	
	// Add a toggler span
	$j( "div#block409 .hasChildren > h2 > a" ).append("<span class=\"expander\"></span>");
	
	$j( "div#block409 .hasChildren > h2 > a span.expander" ).bind( "click", function expandoList() {
		//alert("!!!");
		$j(this).parent().parent().parent().children('div').slideToggle("fast");
		return false; 
	});

	var active_color = '#000'; // Colour of user provided text
	var inactive_color = '#ccc'; // Colour of default text

  $j("input.default-value").css("color", inactive_color);
  var default_values = new Array();
  $j("input.default-value").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      this.style.color = active_color;
    }
    $j(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.value = default_values[this.id];
      }
    });
  });

	/* Move the first image up the top for the Detail Page */
	$j("#DetailPage #course_detail > div.img:first:not(.new_course_item)").addClass("course_title_image");
	
	// Front page slider 
	$j("#frontpage_subject_images").cycle({ 
	    speed:  'slow',
	    timeout: 10000 
	});
	
	/*$j('div.description').html($j('div.long_description > p:first-child').html());*/
	
	//$j('.new_course_item div.description').html($j('.new_course_item div.description + div.long_description > p:first-child').html());
	
	/*$j(".new_course_item .description > *:not(.img)").css({display: 'none'});
	$j(".new_course_item .description > p:first").css({display: 'block'});  */	

	jQuery('.long_description').each(function() { // For each .long_description element found
		var text = jQuery(this).children('p:not(:empty):first').text(); // Dump the contents of the first non-empty p tag into text
		
		if (jQuery(this).children('div.img:not(:empty):first').length) {
			text = jQuery(this).children('div.img:not(:empty):first').html()  + text;
		}
		
		/*if (text.length == 0) { 
			text = jQuery(this).children('div:first').html(); // 
			text = text + jQuery(this).text();
		}*/
		
		jQuery(this).prev().prepend(text);
	});	
});

jQuery(document).ready(function() {

});

