// JavaScript Document
function $( name ){
	return document.getElementById( name );
}

function confirmAction(){
	if( confirm( "Are you sure you want to do this?" ) ) return true;
	else return false;
}

function delegate( that, thatMethod ){
    return function() { return thatMethod.call(that, arguments ); }
    //return function() { return thatMethod.apply(that, arguments ); }
}

function inptClearDefault( inpt, isfocus, txt ){
	if( isfocus ){
		if( inpt.value == txt ) inpt.value = "";
	}else{
		if( inpt.value == "" ) inpt.value = txt;
	}
}

function selectAll( field ){
	field.focus();
	field.select();
}

function publishSnapshot( publish, hash ){
	try{ $('prompt').className = 'hidden'; }catch( e ){};
	if( publish == false ){
		$('timetildelete').className = 'visible';
	}else{
		$('embedlinks').className = 'embedlinks';
		var aconn = new ajaxConnection( { processXMLResponse:function(){} }, '/api/processSnapshot' );
		aconn.addVariable( 'cmd', 'publish' );
		aconn.addVariable( 'publish', publish );
		aconn.addVariable( 'hash', hash );
		aconn.execute();
	}
}

