// JavaScript Document

function Ventana(winName,theURL,ancho,alto,scrollb,resiza) { //v2.0
var features;
var x, y;

x=(screen.width - ancho) / 2;
y=(screen.height - alto) / 2;

features="status=no, toolbar=no, location=no, menubar=no, directories=no, resizable=" + resiza +", scrollbars=" + scrollb +", width= "+ ancho +", height=" + alto;

  ven=window.open(theURL,winName,features);
  ven.moveTo(x,y);
  ven.focus();

  return;
}

function Otro(lista, winName, pagina, ancho, alto, scrollb){
	if (lista.options[lista.selectedIndex].value==-1)
	{	lista.options[0].selected=true;
		Ventana(winName, pagina, ancho, alto, scrollb);
		}
return;
}

function Prohibido(lista){
	if (lista.options[lista.selectedIndex].value==-2)
	{lista.options[0].selected=true;}
return;
}

function Lista(lista, winName, pagina, ancho, alto, scrollb){

//alert(lista.value);
Otro(lista, winName, pagina, ancho, alto, scrollb);
Prohibido(lista);

return;
}

function ActualizaPadre(nuevo_objeto, valor){
	nuevo_objeto.value=valor;
	//window.opener.document.form1.MM_update.value="";
	
	if(window.opener.document.form1.MM_insert)
	{window.opener.document.form1.MM_insert.value="";}
	else
	{window.opener.document.form1.MM_update.value="";}
	
	window.opener.document.form1.submit();
	window.close();
}

function RedireccionaPadre(carpeta, direccion){
	//nuevo_objeto.value=valor;
	//window.opener.document.form1.MM_update.value="";
	window.opener.document.location.href=carpeta + "/" + direccion;	
	window.close();
}

function ActualizaPadreUpdate(nuevo_objeto, valor){
	nuevo_objeto.value=valor;
	window.opener.document.form1.MM_update.value="";
	window.opener.document.form1.submit();
	window.close();
	//window.opener.form2.tipos.value=elegidos;
	//window.close();
}

function Borra(pagina)
{var r;
	r=confirm("Estas a punto de eliminar este registro");
	
	if (r)
	{window.location=pagina;
	 return;}
	
return;
}

function Asignar(oculto, nuevo_objeto, valor){
	nuevo_objeto.value=valor;
	oculto.value="";
	window.document.form1.submit();
	
return;	
}

function RefreshParent(){
	
	window.opener.location.reload();
		
return	
}


function HH_jumpMenu(forma, id_tienda_obj){ //v3.0
  var parametros="";
	
	id_tienda = id_tienda_obj.value;
	if(forma.activos.checked==true) {parametros+="&activos=1";} else {parametros+="&activos=0";}
	if(forma.inactivos.checked==true) {parametros+="&inactivos=1";} else {parametros+="&inactivos=0";}
	if(forma.pendientes.checked==true) {parametros+="&pendientes=1";} else {parametros+="&pendientes=0";}
	
	if(forma.confoto.checked==true) {parametros+="&confoto=1";} else {parametros+="&confoto=0";}
		
	parametros += "&libre=" + forma.libre.value;
		
	window.location.href="search.php?id_tienda=" + id_tienda + parametros;	
}

function resizeOuterTo(w,h) {
 if (parseInt(navigator.appVersion)>3) {
   if (navigator.appName=="Netscape") {
    top.outerWidth=w;
    top.outerHeight=h;
   }
   else top.resizeTo(w,h);
 }
}

function MaximizarVentana(){
	
 //resizeOuterTo(screen.width,screen.height);
 resizeOuterTo(700,550);
 x=(screen.width - 700) / 2;
y=(screen.height - 500) / 2;
 parent.window.moveTo(x,y);
}

function AgregaElemento(nuevo_objeto, valor, forma){
	
	nuevo_objeto.value=valor;
	if(forma.MM_insert)
	{forma.MM_insert.value="";}
	else
	{forma.MM_update.value="";}
	
	forma.submit();
}
function CancelarTrabajo(alerta){
var r;
	r=confirm("Seguro que deseas cancelar el trabajo \n (" + alerta + ")");
	
	if(r){
	window.close();	
		}
return;
}

function ValidaLista(lista,msg,nuevo_objeto, valor, forma){
	
	if (lista.options[lista.selectedIndex].value < 1)
	{alert(msg);
	lista.focus();
	return;}
	
	nuevo_objeto.value=valor;
	if(forma.MM_insert)
	{forma.MM_insert.value="";}
	else
	{forma.MM_update.value="";}
	
	forma.submit();
}

function MarcoPadre(laurl){
	
 resizeOuterTo(400,200);
 top.document.location.href=laurl;	
 x=(screen.width - ancho) / 2;
y=(screen.height - alto) / 2;
 //window.close();
 parent.window.moveTo(x,y);
}

function CancelaAccion(direccion){
	document.location.href=direccion;
return;
}
