function cambiaColor(esto, accion, activo){
//activo = 1 - noactivo = 0 o cualquier cosa
	if(activo==1){
		if(accion=='entrar'){
			esto.style.color = '#FFFFFF'
			esto.style.cursor = 'hand'
			esto.style.backgroundColor = '#FF6600'
		}else{
			if(accion=='salir'){
				esto.style.color = '#4F9B1E'
				esto.style.cursor = 'default'
				esto.style.backgroundColor = '#FFFFFF'
			}
		}
	}
}

function cambiaColorPersonalizado(esto, accion, colorFore, colorBack){
//activo = 1 - noactivo = 0 o cualquier cosa
		if(accion=='entrar'){
			esto.style.color = colorFore;
			esto.style.cursor = 'hand';
			esto.style.backgroundColor = colorBack;
		}else{
			if(accion=='salir'){
				esto.style.color = colorFore;
				esto.style.cursor = 'default'
				esto.style.backgroundColor = colorBack;
			}
		}
}

function cambiaImg(esto, accion, activo, imagen){
//activo = 1 - noactivo = 0 o cualquier cosa
	if(activo==1){
		if(accion=='entrar'){
			esto.src = 'images/' + imagen + 'sel.jpg';
			esto.style.cursor = 'hand'
		}else{
			if(accion=='salir'){
				esto.style.cursor = 'default'
				esto.src = 'images/' + imagen + '.jpg';
			}
		}
	}
}

function irA(enlace){
	document.location.href = enlace;
}

function cambiarCursor(esto, tipo){
	esto.style.cursor = tipo;
}

function llenarTxt(obj, valor){
	document.getElementById(obj).value = "";
	document.getElementById(obj).value = valor;
}

function llenarTxtDesdeCombo(objTarget, objSource){
	indice = document.getElementById(objSource).options.selectedIndex;
	document.getElementById(objTarget).value = "";
	document.getElementById(objTarget).value = document.getElementById(objSource).options[indice].text;
}

function llenarTxtDesdeTxt(objTarget, objSource){
	document.getElementById(objTarget).value = "";
	document.getElementById(objTarget).value = document.getElementById(objSource).value;
}

function simularEnlace(esto, accion, color){
	if(accion=='entrar'){
		esto.style.color = color
		esto.style.cursor = 'hand'
		esto.style.textDecoration = 'underline'
	}else{
		if(accion=='salir'){
			esto.style.color = color
			esto.style.cursor = 'default'
			esto.style.textDecoration = 'none'
		}
	}
}

function simularEnlaceColumna(esto, accion, color){
	if(accion=='entrar'){
		esto.style.color = "#FFFFFF";
		esto.style.backgroundColor = color;
		esto.style.cursor = 'hand';
	}else{
		if(accion=='salir'){
			esto.style.color = "#000000";
			esto.style.backgroundColor = color;
			esto.style.cursor = 'default';
		}
	}
}

function simularEnlaceFoto(esto, accion){
	if(accion=='entrar'){
		esto.style.cursor = 'hand'
	}else{
		if(accion=='salir'){
			esto.style.cursor = 'default'
		}
	}
}

function imprimirVentana(ventana){
	ventana.print();
}

function abrirVentana(titulo, ancho, alto, imagen){

	var cuerpo; 

	v = window.open("", titulo, "toolbar=no, width=" + ancho + ", height=" + alto + ", location=no, directories=no, status=no, scrollbars=auto, resizable=no, titlebar=no, menubar=no, left=" + (screen.width-ancho)/2 + ", top=" + (screen.height-alto)/2);

	v.opener = self;	

	cuerpo = "\
	<html>\
	<head>\
	<title>:.: saganoble ˇ gran perro japonés :.:</title>\
	<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>\
	</head>\
	<LINK REL='stylesheet' TYPE='text/css' HREF='css/saga.css'>\
	<script src='js/general.js' language='javascript'>\
	</script>\
	<style type='text/css'>\
		body {font-family: Tahoma; font-size: 10; }\
	</style>\
	<body bottommargin='0' leftmargin='0' rightmargin='0' topmargin='0' bgcolor='#666666'>\
	<table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0' bgcolor='#666666' align='center' style='vertical-align: middle; '>\
	<tr><td height='15'></td></tr>\
	<tr>\
	<td align='center'><img src='images/logocab.jpg' border='0'></td>\
	</tr>\
	<tr><td align='center' height='15'><img src='images/linsep.jpg' border='0'></td></tr>\
	<tr>\
	<td align='center'><img src='images/" + imagen + ".jpg' border='1'></td>\
	</tr>\
	</table>\
	</body>\
	</html>\
	";
	v.document.write(cuerpo); 
	v.document.location.reload();
}

function abrirVentanaPedigri(titulo, ancho, alto, imagen){

	var cuerpo; 

	v = window.open("", titulo, "toolbar=no, width=" + ancho + ", height=" + alto + ", location=no, directories=no, status=no, scrollbars=yes, resizable=yes, titlebar=no, menubar=no, left=" + (screen.width-ancho)/2 + ", top=" + (screen.height-alto)/2);

	v.opener = self;	

	cuerpo = "\
	<html>\
	<head>\
	<title>:.: saganoble ˇ gran perro japonés :.:</title>\
	<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>\
	</head>\
	<LINK REL='stylesheet' TYPE='text/css' HREF='css/saga.css'>\
	<script src='js/general.js' language='javascript'>\
	</script>\
	<style type='text/css'>\
		body {font-family: Tahoma; font-size: 10; }\
	</style>\
	<body bottommargin='0' leftmargin='0' rightmargin='0' topmargin='0' bgcolor='#666666'>\
	<table width='100%' height='100%' cellpadding='0' cellspacing='0' border='0' bgcolor='#666666' align='center' style='vertical-align: middle; '>\
	<tr><td height='15'></td></tr>\
	<tr>\
	<td align='center'><img src='images/logocab.jpg' border='0'></td>\
	</tr>\
	<tr><td align='center' height='15'><img src='images/linsep.jpg' border='0'></td></tr>\
	<tr>\
	<td align='center'><img src='images/" + imagen + "_ped.jpg' border='1'></td>\
	</tr>\
	</table>\
	</body>\
	</html>\
	";
	v.document.write(cuerpo); 
	v.document.location.reload();
}

function ventanaMax(titulo, imagen){
	titulo = titulo + "Max"
	v=window.open("", "", "toolbar=no, location=no, directories=no, status=no, scrollbars=no, fullscreen=yes, resizable=no, titlebar=no, menubar=no");
	v.opener = self;

	v.document.write("<html>"); 
	v.document.write("<head>");
	v.document.write("</head>");

	v.document.write("<LINK REL='stylesheet' TYPE='text/css' HREF='css/ebmalena.css'>");

	v.document.write("<style type='text/css'>")
	v.document.write("	body {font-family: Tahoma;}");
	v.document.write("</style>");

	v.document.write("<script src='js/general.js' language='javascript'>");
	v.document.write("</script>");
	
	v.document.write("<body class='fondoazulc' bottomMargin='0' leftMargin='0' rightMargin='0' topMargin='0'>");
	v.document.write("<table border='0' cellpadding='0' cellspacing='0' height='100%' width='100%'>");
	v.document.write("  <tr>");
	v.document.write("<td class='letrablanca + fondogranate' align='right' width='47%' height='30'><font onclick='window.close(); return false; ' onmouseover='simularEnlace(this, \"entrar\", \"#ffffff\"); return false;' onmouseout='simularEnlace(this, \"salir\", \"#ffffff\"); return false;'>Cerrar Ventana</font>&nbsp;&nbsp;&nbsp;</td>");
	v.document.write("<td class='fondogranate' align='right' width='2%' height='30'><img onclick='window.close(); return false; ' onmouseover='cambiarCursor(this, \"hand\"); return false;' onmouseout='cambiarCursor(this, \"default\"); return false;' src='images/close.gif' width='22' height='22'></td>");
	v.document.write("<td class='fondogranate' align='center' width='2%' height='30'> | </td>");
	v.document.write("<td class='fondogranate' align='left' width='2%' height='30'><img onclick='window.print(); return false; ' onmouseover='cambiarCursor(this, \"hand\"); return false;' onmouseout='cambiarCursor(this, \"default\"); return false;' src='images/imprimir.gif' width='22' height='22'></td>");
	v.document.write("<td class='letrablanca + fondogranate' align='left' width='47%' height='30'>&nbsp;&nbsp;<font onclick='window.print(); return false; ' onmouseover='simularEnlace(this, \"entrar\", \"#ffffff\"); return false;' onmouseout='simularEnlace(this, \"salir\", \"#ffffff\"); return false;'>Imprimir Ventana</font>&nbsp;&nbsp;&nbsp;</td>");
	v.document.write("  </tr>");
	v.document.write("  <tr>");
	v.document.write("  	<td colspan='5' align='center'><img border='1' src='images/" + imagen + ".jpg'></td>");
	v.document.write("  </tr>");
	v.document.write("  <tr>");
	v.document.write("<td class='letrablanca + fondogranate' align='right' width='47%' height='30'><font onclick='window.close(); return false; ' onmouseover='simularEnlace(this, \"entrar\", \"#ffffff\"); return false;' onmouseout='simularEnlace(this, \"salir\", \"#ffffff\"); return false;'>Cerrar Ventana</font>&nbsp;&nbsp;&nbsp;</td>");
	v.document.write("<td class='fondogranate' align='right' width='2%' height='30'><img onclick='window.close(); return false; ' onmouseover='cambiarCursor(this, \"hand\"); return false;' onmouseout='cambiarCursor(this, \"default\"); return false;' src='images/close.gif' width='22' height='22'></td>");
	v.document.write("<td class='fondogranate' align='center' width='2%' height='30'> | </td>");
	v.document.write("<td class='fondogranate' align='left' width='2%' height='30'><img onclick='window.print(); return false; ' onmouseover='cambiarCursor(this, \"hand\"); return false;' onmouseout='cambiarCursor(this, \"default\"); return false;' src='images/imprimir.gif' width='22' height='22'></td>");
	v.document.write("<td class='letrablanca + fondogranate' align='left' width='47%' height='30'>&nbsp;&nbsp;<font onclick='window.print(); return false; ' onmouseover='simularEnlace(this, \"entrar\", \"#ffffff\"); return false;' onmouseout='simularEnlace(this, \"salir\", \"#ffffff\"); return false;'>Imprimir Ventana</font>&nbsp;&nbsp;&nbsp;</td>");
	v.document.write("  </tr>");
	v.document.write("</table>");
	v.document.write("</body>");
	v.document.write("</html>");
	v.document.location.reload();
}

function mostrarcapa(id){

	var capa = window.document.getElementById(id);

	capa.style.visibility = "visible";

	capa.style.left = event.x + document.body.scrollLeft;
	capa.style.top = event.y/2 - document.body.scrollTop;

}

function ocultarcapa(id){

	var capa = window.document.getElementById(id);	
	capa.style.visibility = "hidden";
	capa.style.left = 0;
	capa.style.top = 0;

}

function abrirEnlaceVentanaNuevaDimensionada(enlace, titulo, ancho, alto){
	v = window.open(enlace, titulo, "toolbar=no, width=" + ancho + ", height=" + alto + ", location=no, directories=no, status=no, scrollbars=yes, resizable=no, titlebar=no, menubar=no, left=" + (screen.width-ancho)/2 + ", top=" + (screen.height-alto)/2);
	v.resizeTo(ancho, alto);
	v.focus();
}

function abrirenlaceventananueva(enlace){
	window.open(enlace, "", "");
}

function volver(){
	history.back();
}

function mandarNuevaVentana(formulario, pagina, ancho, alto){
	var izq = (screen.width - ancho) / 2;
	var arr = (screen.height - alto) / 2;
	var nVentana = parseInt(Math.random()*100); //para que no se repita el nombre de la ventana
	
	v=window.open("", nVentana, "width=" + ancho + ", height= " + alto + ", left =" + izq + ", top =" + arr + ", toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, titlebar=no, menubar=no");
	document.forms[formulario].target = nVentana;
	document.forms[formulario].action = pagina;
	document.forms[formulario].method = 'post';
	document.forms[formulario].submit();
//	v.resizeTo(ancho, alto);
//	v.moveTo(izq, arr);
	v.focus();
}

function mandar(formulario, pagina){
	document.forms[formulario].method = 'post';
	document.forms[formulario].target = '_self';
	document.forms[formulario].action = pagina;
	document.forms[formulario].submit();
}

function scroll(txt){
		document.getElementById(txt).value = document.body.scrollTop;
}

function moverScroll(txt){
		window.scrollTo(1,document.getElementById(txt).value);
}

function vaciarCombo(nombre){
	document.getElementById(nombre).clear();
}

function borrarCombo(nombre){
	document.getElementById(nombre).value = '';
}

function mostrarDist(objeto, objlinea){
	var ventana; 
	
	document.getElementById(objeto).value = objlinea.name;
	ventana = window.open("", "nueva", "toolbar=no, width=400, height=400, location=no, directories=no, status=no, scrollbars=auto, resizable=no, titlebar=no, menubar=no, left=" + (screen.width-400)/2 + ", top=" + (screen.height-350)/2);
	document.forms['distribuidor'].target = 'nueva';
	document.forms['distribuidor'].action = 'distribuidor.asp';
	document.forms['distribuidor'].method = 'post';
	document.forms['distribuidor'].submit();
	ventana.focus();

}

function cerrarVentana(){
	window.close();
}

function pasarFoco(tecla, elemento, obj){
	if(tecla==13){
		document.getElementById(elemento).focus();
		document.obj.focus();
	}
}

function pasarFoco_2(tecla, elemento){
	if(tecla==13){
		document.getElementById(elemento).focus();
	}
}

function pasarFormEnter(tecla, formulario, pagina){
	if(tecla==13){
		llenarAmpliacion(); 
		mandar(formulario, pagina);
	}
}

function pasarFormEnterSolo(tecla, formulario, pagina){
	if(tecla==13){
		mandar(formulario, pagina);
	}
}

function pasarFormEnterSoloNewPage(tecla, formulario, pagina, ancho, alto){
	if(tecla==13){
	    mandarNuevaVentana(formulario, pagina, ancho, alto)
	}
}

function pasarValorRadioTxt(txt, rad){
	if(document.getElementById(rad).checked){
		document.getElementById(txt).value = document.getElementById(rad).checked;
	}else{
		document.getElementById(txt).value = document.getElementById(rad).checked;
	}
}

function pasarValorTxtATxt(txtSource, txtTarget){
	document.getElementById(txtTarget).value = document.getElementById(txtSource).value;
}

function vaciarTxt(txt){
	document.getElementById(txt).value = "";
}

function llenarParametros(param1, param2, param3, param4, param5){
	llenarTxt("txtParam1", param1);
	llenarTxt("txtParam2", param2);
	llenarTxt("txtCampo1", param3);
	llenarTxt("txtCampo2", param4);	
	llenarTxt("txtTabla", param5);	
}

function recargarPadre(){
	window.opener.location.reload(false);
}

function CleanUp() {
        opener.focus();
        opener.location.href = opener.location;
        self.close();
}