

//function toEnlarge(){
//	 document.getElementById("tablebarTarget").style.height = document.getElementById('tablebarmain').offsetHeight - document.getElementById('tablebar').offsetHeight +"px";
//}

// PRELOAD DE IMAGENES //

var toc = new Array();

function item(off, over)
{
	this.off = new Image(); this.off.src = off;
	this.over = new Image(); this.over.src = over;
}

function cache(id, off, over)
{
	item[id] = new item(off, over);
	toc[toc.length] = id;
}

function over(id)
{
	document.getElementById(id).src = item[id].over.src;
}

function out(id)
{
	document.getElementById(id).src = item[id].off.src;
}

// FIN DE PRELOAD DE IMAGENES //

function NewWindow(mypage,myname,w,h,scroll){
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;

	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

	settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable = no'

	win = window.open(mypage,myname,settings)
}


function runSWF( wmode, archivo, ancho, alto, version, bgcolor, id, menu, FlashVars, quality, allowScriptAccess) {
	if(version!=""){
		var version_data=version;
	}else{
		var version_data="6,0,0,0";
	}

	if(menu!=""){
		menu_data=menu;
	}else{
		menu_data=false;
	}

	if(bgcolor!=""){
		var bgcolor_data=bgcolor;
	}else{
		var bgcolor_data="#FFFFFF";
	}

	if(id!=""){
		id_data=id;
	}else{
		id_data="flashMovie";
	}

	if(quality!=""){
		quality_data=quality;
	}else{
		quality_data="high";
	}

	if(allowScriptAccess!=""){
		allowScriptAccess_data=allowScriptAccess;
	}else{
		allowScriptAccess_data="always";
	}

	var quality="high"; // calidad de visualización de la peli
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version= '+version_data+'" width='+ancho+' height='+alto+' id='+id_data+'>\n');
	document.write('<param name="movie" value='+archivo+'>\n');
	document.write('<param name= "allowScriptAccess" value= '+allowScriptAccess_data+'>\n');
	document.write('<param name="quality" value='+quality_data+'>\n');
	document.write('<param name="FlashVars" value='+FlashVars+'>\n');
	document.write('<param name="bgcolor" value='+bgcolor_data+'>\n');
	document.write('<param name="menu" value='+menu_data+' >\n');

	if( wmode )
		document.write('<param name="wmode" value="transparent">\n');

	document.write('<embed src='+archivo+' bgcolor='+bgcolor_data+' FlashVars='+FlashVars+' menu='+menu_data+' allowScriptAccess='+allowScriptAccess_data+' quality='+quality_data+' pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width='+ancho+' height='+alto+' swLiveConnect=true name='+id_data+ ( ( wmode ) ? ' wmode=transparent' : '' ) +'></embed>');
	document.write('</object>\n');
}


function movePage( frform, pagina ){
	var form = document.forms[frform];
	form.pagina.value = pagina;
	form.submit();
}

function funcOver( td ){
	var td = document.getElementById(td);
	td.style.cursor = 'pointer';

	if( td.style.backgroundColor == '' ){
		td.style.backgroundColor = '#e7eff7';
	}else{
		td.style.backgroundColor = '';
	}
}

function trim(valor){
  var re = /^(\s)*|(\s)*$/;
  var str = (valor ? valor : this);
  return str.replace(re,'');
}

function searchProduct(){
	formulario = document.forms['search'];
//	alert(formulario.idAuthor.selectedIndex);
	if(( !formulario.strFind.value )&&(formulario.idAuthor.selectedIndex==0)){
		alert('Debe ingresar un parametro a buscar');
	}else{
		formulario.submit();
	}
}



	function Logout(){
		var formulario = document.forms['logout'];
		formulario.accion.value = 'logout';
		formulario.submit();
	}

	function Auth(){
		var formulario = document.forms['auth'];
		var strError = "";

		if( !formulario.user.value && !strError ){
			strError = 'Debe completar el campo Usuario';
			formulario.user.focus();
		}

		if( !formulario.pass.value && !strError ){
			strError = 'Debe completar el campo Contraseña';
			formulario.pass.focus();
		}

		if( strError ){
			alert( strError );
		}else{
			formulario.accion.value = 'ingresar';
			formulario.submit();
		}
	}

	function changeCatalogo( id ){
		window.location = 'catalogo.php?idArea='+id;
	}

	    // DETECTOR DE BROWSER //
	var dom = document.getElementById ? true:false;
	var nn4 = document.layers ? true:false;
	var ie4 = document.all ? true:false;

	var lastIdMenu = null;
	var lastMenuTimeout = 0;

	function mostrarMenu(oBtn, flag)
	{

		ocultarMenu();

		if( !flag ){
			var idMenu = oBtn.id.replace(/^btn/, 'mnu');
			var oMenu = null;

				if(ie4) { oMenu = document.all[idMenu].style; }
				else if(nn4) { oMenu = document.layers[idMenu]; }
				else if(dom) { oMenu = document.getElementById(idMenu).style; }

				if(oMenu !=null)
				{
					oMenu.visibility = "visible";
					lastIdMenu = idMenu;
				}
		}
	}

	function ocultarMenuClear()
	{
		if(lastMenuTimeout>0)
			clearTimeout(lastMenuTimeout);
	}

	function ocultarMenuAuto()
	{
		ocultarMenuClear();
		lastMenuTimeout = setTimeout('ocultarMenu()', 750);
	}

	function ocultarMenu()
	{

		ocultarMenuClear();
		if(lastIdMenu!=null)
		{
			var oMenu = null;
			if(ie4) { oMenu = document.all[lastIdMenu].style; }
			else if(nn4) { oMenu = document.layers[lastIdMenu]; }
			else if(dom) { oMenu = document.getElementById(lastIdMenu).style; }

			if (oMenu!=null)
			{
				oMenu.visibility="hidden";

				var objImg = 'btn'+lastIdMenu.substr(3);
				oImg = document.getElementById(objImg);
				oImg.src = pathMenu + objImg +'.gif';

				lastIdMenu = null;
				objImg		 = null;
			}

		}
	}

	function menuTdOver(o)
	{
		o.style.backgroundColor="#99172d";
		o.style.cursor="pointer";
	}
	function menuTdOut(o)
	{
		o.style.backgroundColor="";
		o.style.cursor=""
	}

	function goLink(linkhref)
	{
		//window.location = 'index.html';
		window.location = linkhref;
	}

	function resetForm( formName )
	{
		formulario = document.forms[formName];
		formulario.reset();
	}

	function submitForm( formName, accion )
	{
		formulario = document.forms[formName];
		formulario.accion.value = accion;
		formulario.submit();
	}

	function showbackframe( n, name ){
	  var formulario = document.getElementById( name );
	   if( n )
	    formulario.style.display = 'block';
	   else
	    formulario.style.display = 'none';
   }

  function TestBrowser()
	{
	  this.ver = navigator.appVersion;
	  this.agent = navigator.userAgent;
	  this.dom = document.getElementById?1:0;
	  this.opera6 = this.agent.indexOf("Opera 6")>-1;
	  this.opera5 = this.agent.indexOf("Opera 5")>-1;
	  this.opera = (this.opera6 || this.opera5);
	  this.ie5 = ((this.ver.indexOf("MSIE 5")>-1 || this.ver.indexOf("Internet Explorer 5")>-1) && this.dom && !this.opera)?1:0;
	  this.ie6 = ((this.ver.indexOf("MSIE 6")>-1 || this.ver.indexOf("Internet Explorer 6")>-1) && this.dom && !this.opera)?1:0;
	  this.ie4 = (document.all && !this.dom && !this.opera5)?1:0;
	  this.ie = this.ie4 || this.ie5 || this.ie6;
	  this.mac = this.agent.indexOf("Mac")>-1;
	  this.ns6 = (this.dom && parseInt(this.ver) >= 5)?1:0;
	  this.ns4 = (document.layers && !this.dom)?1:0;
	  this.supp = (this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 || this.opera6);
	  return this;
	}

	function addEventObject(o, evento, callbackFunction, bubble)
	{
		var objBrowser = new TestBrowser();
		if(!objBrowser.ie)
		{
			//o.attachEvent(evento, callbackFunction);
			o.addEventListener(evento, callbackFunction, bubble);
		}
		else
		{
			/*if(evento.indexOf('on')==0)
			{
				evento = evento.substr(2);
			}*/
			o.attachEvent(evento, callbackFunction);
			//o.addEventListener(evento, callbackFunction, bubble);
		}
	}

	function CambiarVisibility(obj) {
    var obj = document.getElementById(obj);
    if(obj.style.visibility == "hidden") {
      obj.style.visibility = "visible";
      obj.style.display = "";
    } else {
      obj.style.visibility = "hidden";
      obj.style.display = "none";
    }
  }

  //Enlarge the left bar
  //addEventObject(window, 'onload', toEnlarge, true);