

/**
 * Shared scripts.
 * Creates a shortcut to go to the admin interface.
 *
 */
var ROOT_PATH = '/';

function ucfirst( str )
{
    var f = str.charAt(0).toUpperCase();
    return f + str.substr(1, str.length-1);
}

function addToFavorites( name )
{
	var site_url = 'http://' + window.location.host;
	var site_name = 
		name || ucfirst( window.location.host.substring( window.location.host.indexOf('.')+1, window.location.host.lastIndexOf('.') ) );
	
	if ( navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 ) // Gecko
		window.sidebar.addPanel( site_name, site_url, "" );
	else if ( !!(window.attachEvent && !window.opera) ) // IE
		window.external.AddFavorite( site_url, site_name );
}

function gotoAdmin()
{
	window.open("/manager/");
}


Element.addMethods({
	setWidth: function(element,w) {
	   	element = $(element);
	   	if ( !Object.isString(w) ) w += "px";
    	element.setStyle({ width: w });
    	return element;
	},
	setHeight: function(element,h) {
   		element = $(element);
	   	if ( !Object.isString(h) ) h += "px";
    	element.setStyle({ height: h });
    	return element;
	}
});

// Debugging ----------------------------//
if ( typeof(console) == 'undefined' ) {
	var console = {log: function() {}};
}

shortcut.add( 'Shift+w', gotoAdmin, {'disable_in_input': true} );