/**
 * Javascript di utilita' per login e logout.
 */

/**
 * b, element to make desapear
 * a, element id to display
 * divIdB, div element that contains b element. This will desapear.
 * divIdA, div element that contains element with id a. This will apear.
 */
function txt2pwd(/**Object*/b,/**String*/a,/**String*/divIdB,/**String*/divIdA) {
	findElementById(divIdB).style.display="none";
	b.style.display="none";
	findElementById(divIdA).style.display="";
	findElementById(a).style.display="";
	findElementById(a).focus();
}

/**
 * b, element to make desapear
 * a, element id to display
 * divIdB, div element that contains b element. This will desapear.
 * divIdA, div element that contains element with id a. This will apear.
 */
function pwd2txt(/**Object*/b,/**String*/a,/**String*/divIdB,/**String*/divIdA) {
	if(b.value.length==0){
		findElementById(divIdB).style.display="none";
		b.style.display="none";
		findElementById(divIdA).style.display="";
		findElementById(a).style.display="";
	}
}

/**
 * a, element to reset
 * b, string which makes empty the object element.
 */
function resetField(/**Object*/a,/**String*/b) {
	if(a.value.length==0) {
		a.value=b;return;
	} 
	if(a.value==b) {
		a.value="";
	}
}

function findElementById(a) {
	return(document.all+""!="undefined"?document.all[a]:document.getElementById(a));
}

function Get_Cookie( name ) {

	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring	( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function Delete_Cookie( name, path, domain ) {
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
	( ( path ) ? ";path=" + path : "") +
	( ( domain ) ? ";domain=" + domain : "" ) +
	";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
