/*
Some useful wrappers
*/
function GID(id){
	return document.getElementById(id);
}

function show(id){
	GID(id).style.display="block";
}

function hide(id){
	GID(id).style.display="none";
}

function toggle(id){
	if( GID(id).style.display=="block" )
		GID(id).style.display="none";
	else
		GID(id).style.display="block";
}


/*
It reads the button name and it shows its name on a div
*/
function readButtonName(name){
	if( name=='' ){
		GID('info').innerHTML='';
		hide('backdiv');
	}
	else{
		GID('info').innerHTML=name;
		show('backdiv');
	}
}

/*
Do the submit after showing icon and text of the updating process
*/
function confirmAndLink(idform,idbutton,confirm_text,wait_text,url){
	if( confirm(confirm_text) ){
		if( GID('loading') )
			show('loading');
		if( GID(idbutton) )
			//the button is a <input>
			if( GID(idbutton).value )
				GID(idbutton).value=wait_text;
			//the button is a <div> or a <span>
			else
				GID(idbutton).innerHTML=wait_text;
		location.href=url;
	}
}

/*
Do the submit after showing icon and text of the updating process
*/
function confirmAndSubmit(idform,idbutton,confirm_text,wait_text){
	if( confirm(confirm_text) ){
		if( GID('loading') )
			show('loading');
		if( GID(idbutton) )
			if( GID(idbutton).value )
				GID(idbutton).value=wait_text;
			else
				GID(idbutton).innerHTML=wait_text;
		GID(idform).submit();
	}
}

/*
Do the submit after showing icon and text of the updating process
*/
function confirmAndundo(idform,idbutton,confirm_text,wait_text,url){
	location.href=url;
}

/*
Do the submit after showing icon and text of the updating process
*/
function confirmAndSubmitx(idform,idbutton,confirm_text,wait_text){
			GID(idform).submit();
	}
