 	$('html').addClass('js'); // flash of unloaded content

function equalNavMenus() {
	$("#topics-1").height($("#topics-0").height());
}

function startPlayer(options) {
	$("#flash_container").html(
					'<embed width="460" height="360" flashvars="docId=' + options.doc_id +':'+ options.clip_start + ':'+ options.clip_length + '&amp;preRollPath='+ options.pre_roll_path +'" quality="high" '+ 
					'bgcolor="#000000" ' +  
					'src="'+ options.player_src+'" ' + 
					'wmode="transparent" ' + 
					'type="application/x-shockwave-flash"/>'
				);
}

function doShare(site, options) {
	// console.debug("entered doShare with site %s", site);
	var t;
	switch (site) {
		case 'facebook':  t = 'http://www.facebook.com/sharer.php?u=#{url}&t=#{title}'; width=600; height=500; break;
		case 'digg':      t = 'http://digg.com/remote-submit?phase=2&url=#{url}&title=#{title}&bodytext=#{description}'; width=625; height=500; break;
		case 'delicious': t = 'http://del.icio.us/post?v=4&jump=close&url=#{url}&title=#{title}&bodytext=#{description}'; width=880; height=600; break;
		default: throw("Unknown host");	
	}
	var url = $.tmpl(t, options);
	// console.debug("doShare got this for a url: %s", url);
	$.jqURL.loc(url, {wintype:'_blank',w:width,h:height});
}

/**
 * things to do after an AJAX window has been loaded.
 */
function postAjaxLoad() {
    decorateCollectionMedallions();
}

$(document).ready(function(){
	
 	$('html').removeClass('js'); // flash of unloaded content

	
	$("#schedule #rota").cycle({ 
	    fx:    'scrollUp', 
	    speed:  2000,
	    timeout:5000 
	 });
		
	/* Search field value set */
	$("#q").blur(function () {
		if($(this).val() == ""){
			$(this).val("search");
		}
	});
	
	$("#q").click(function () {
		if($(this).val() == "search"){
			$(this).val("");
		}
	});
	
	// share overlay
	$('#share-overlay').hide();
	
	$('dd#v-share a').toggle(
	    function (){
		    $('#share-overlay').slideDown('100');
		    return false
		},
		function (){
		    $('#share-overlay').slideUp('200');
		    $('#success_notification').empty();
		    return false
		});
	$('a#share-close').click(function (){
		$('#share-overlay').slideUp('200');
		$('#success_notification').empty();
		return false
		});
		
	$('#share-overlay').css ({position: "absolute", bottom: "0px", left: "10px"});
		
	$('#share-links li').each(function(i, el) {
		$(this).children("a:first").click(function() {
			doShare($(this).parent().attr("class"), share_options);
		});
	});
	
	// initialise plugins
	jQuery(function(){
		jQuery('ul.sf-menu').superfish({
			onShow: equalNavMenus
		});
	});
	
//	jQuery('ol.medallion').equalHeights(); 
	jQuery('#container[class*="search"], #container[class*="collection"]').equalHeightsContent(); 

    decorateCollectionMedallions();
});


