// For new Prikbord

$(document).ready( function(){
	$("body").addClass("jsready");
	window.isIE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
	
	// hover/click on items
	$('.pb-item').each( function(){
		
		// click
		$(this).click(function(e){
			var perma = $('a[rel=bookmark]', $(this)).eq(0);
			var target = e.target;
			if(target.tagName.toUpperCase() == "A" || !perma.get(0)) return;
			document.location = perma.attr('href');
		});
	});
	
	// label on inputs
	$('input[title]').each( function(){		
		var input = $(this);
		input.val(input.attr('title'));
		input.addClass('labeled');
		input.focus( function() {
			if($(this).val() == $(this).attr('title')) {
				$(this).val('');
				$(this).removeClass('labeled');
			}
		});
		input.blur( function() {
			if($(this).val() == '') {
				$(this).addClass('labeled');
				$(this).val($(this).attr('title'));
			}			
		});
	});
	
	// scale embedded (video) content to available width
	$('#main-content object,#main-content embed').each(function() {
		var obj = $(this);
		var objWidth = obj.attr('width');
		var objHeight = obj.attr('height');
		obj.attr({ width:'100%' });
		var newHeight = Math.round((obj.get(0).offsetWidth / objWidth) * objHeight)
		if(newHeight > 0) obj.attr({ height:newHeight });
	});

});