

/********************************************************************/
//** CROSS BROWSING MANAGER
//* Grupo de funciones globales dependientes del navegador/Sist.Op.
//*
//*
/********************************************************************/


function CBM_typeofNavigator()
{

	if ( navigator.appName.indexOf('Microsoft')!=-1)
	{
		if ( navigator.userAgent.indexOf('MSIE 4')!=-1 )
			return 'MSIE4';
		if ( navigator.userAgent.indexOf('MSIE 5')!=-1 )
			return 'MSIE5';
		if ( navigator.userAgent.indexOf('MSIE 6')!=-1 )
			return 'MSIE6';

		return 'MSIE6';

	}

	if ( navigator.appName.indexOf('Netscape')!=-1)
	{
		if ( navigator.userAgent.indexOf('Mozilla/4.')!=-1 )
			return 'NN4';
		if ( navigator.userAgent.indexOf('Netscape/6')!=-1 )
			return 'NN6';
		if ( navigator.userAgent.indexOf('Netscape/7')!=-1 )
			return 'NN7';
		if ( navigator.userAgent.indexOf('Firefox/2')!=-1 )
			return 'FRFX';
		if ( navigator.userAgent.indexOf('Mozilla/5')!=-1 )
			return 'Moz5';


		return 'NN4';


	}


	return 'UNKNOWN';

}







/********************************************************************/
// Obtiene el elemento con el id determinado
// Si el elemento no es unico puede dar un error o null (en Mozilla)
// y por eso hay que utilizar getDocumentCollection
function CBM_getDocumentElement(id)
{

	var OBJ;


 	switch (CBM_typeofNavigator())
 	{

		case 'NN4':

			OBJ = document[id];
		break;


		case 'MSIE4':
		case 'MSIE5':

			OBJ = document.all[id];
		break;


		case 'MSIE6':
		case 'NN6':
		case 'NN7':
		case 'Moz5':
		case 'FRFX':

			OBJ = document.getElementById(id);


		break;
	}


   return OBJ;

}



/********************************************************************/
// Obtiene el elemento con el id determinado
// Si el elemento no es unico puede dar un error o null (en Mozilla)
// y por eso hay que utilizar getDocumentCollection
function CBM_getDocumentCollection(id)
{

	var OBJ;


 	switch (CBM_typeofNavigator())
 	{

		case 'NN4':

			OBJ = document[id];
		break;


		case 'MSIE4':
		case 'MSIE5':

			OBJ = document.all[id];
		break;


		case 'MSIE6':
		case 'NN6':
		case 'NN7':
		case 'Moz5':
		case 'FRFX':

			OBJ = document.getElementsByName(id);


		break;
	}


   return OBJ;

}







/********************************************************************/

function CBM_showLabel (id)
{


	var objDiv = CBM_getDocumentElement(id);


 	switch (CBM_typeofNavigator())
 	{

		case 'NN4':
			if (typeof objDiv.visibility !='undefined')
				objDiv.visibility="show";
			return false;
		break;


		default:
			if (typeof objDiv.style !='undefined')
				objDiv.style.visibility="visible";


	}

	return true;




}


/********************************************************************/

function CBM_hideLabel (id)
{


	var objDiv = CBM_getDocumentElement(id);



 	switch (CBM_typeofNavigator())
 	{

		case 'NN4':
			if (typeof objDiv.visibility !='undefined')
				objDiv.visibility="hide";
			return false;
		break;


		default:
			if (typeof objDiv.style !='undefined')
				objDiv.style.visibility="hidden";


	}

	return true;




}



/********************************************************************/
function CBM_setLabel ( id, msghtml, x0, y0 )
{


	if ( typeof x0 != 'undefined' && typeof y0 != 'undefined')
	{
		xpos = x0;
		ypos = y0;
	}
	else
	{
		xpos = 0;
		ypos = 0;
	}


	var objDiv = CBM_getDocumentElement(id);


 	switch (CBM_typeofNavigator())
 	{

		case 'NN4':
			objDiv.top = ypos;
			objDiv.left = xpos;

			objDiv.document.open();
			objDiv.document.write ( msghtml );
			objDiv.document.close();
		break;


		default:
			objDiv.style.top = ypos;
			objDiv.style.left = xpos;

			objDiv.innerHTML = msghtml;
	}



}







/********************************************************************/
function CBM_refreshImages()
{
//alert("CBM_refreshImages");
//alert(navigator.userAgent);
 	switch (CBM_typeofNavigator())
 	{

		case 'NN6':
		case 'NN7':
		case 'Moz5':

			for (var i=0;i<document.images.length; i++){
				document.images.item(i).src = document.images.item(i).src;
				}



		break;


		case 'FRFX':
			for (var i=0;i<document.images.length; i++){
				imgsrc = document.images.item(i).src;
				if (imgsrc.toLowerCase().indexOf('javascript')!=-1)
				{
					eval (imgsrc.slice(11));
				}

			}
		break;

		default:
	}


return true;

}

/********************************************************************/


function CBM_moveLabelBy(id, ix, iy)
{


	var objDiv = CBM_getDocumentElement(id);

	objDiv.style.top =  objDiv.offsetTop + iy ;
	objDiv.style.left =  objDiv.offsetLeft + ix  ;



}

/********************************************************************/


function CBM_moveLabelTo(id, x, y)
{


	var objDiv = CBM_getDocumentElement(id);

	objDiv.style.top =  y ;
	objDiv.style.left =  x  ;
}
