$(document).ready(function(){
	links.setTarget();
});

links = {
	setTarget : function(){
		$("a[rel^='external']").attr('target','_blank');
	}
}

code = {
	init: function(){
		$('pre').each(function(){
			$(this).data('width',$(this).width());
			$(this).width(676).css({'overflow':'hidden','position':'static','top':0,'left':0});
			$(this).hover(
				function() {
					if($(this).data('width') > 670){
						$(this).stop().animate({'width':$(this).data('width') + 20},'fast');
					}
				},
				function() {
					$(this).stop().animate({'width':676},'fast');
				}
			)
		});
	}
}

tabs = {
	init : function(){
		hashPrefix = "#_";
		
		$('div.tabs').each(function(){
			$(this).find('.nav a').click(function(){
				$(this).parent().parent().find('li.selected').removeClass('selected');
				$(this).parent().addClass('selected');
				$(this).parents('div.tabs:first').find('div.content').hide();
				$(this).parents('div.tabs:first').find($(this).attr('href')).show();
				tempHash = $(this).attr('href');
				customHash = hashPrefix + tempHash.substr(1,tempHash.length);
				location.hash = customHash;
				return false;
			});
			
			$(this).find('div.content:gt(0)').hide();
		});
		if(location.hash) {
			currentHash = location.hash;
			currentHash = currentHash.substr(2,currentHash.length);
			$('a[href*='+currentHash+']').click();
			location.hash = currentHash;
		}
	}
}

function checkValues(which){
	if(which == 'checkboxDemo') {
		msg = "";
		$('#' + which + ' input[type=checkbox]').each(function(i){
			msg += 'Checkbox ' + (i+1) + ' is ' + $(this).attr('checked') + '\n';
		});
	}else{
		msg = "";
		$('#' + which + ' input[type=radio]').each(function(i){
			msg += 'Radio ' + (i+1) + ' is ' + $(this).attr('checked') + '\n';
		});
	}
	
	alert(msg);
}