// seccion productos
// muestra capa seleccionada y esconde las demas
function ver_descp(visible, total_capas)
	{
	for (i=1; i<=total_capas; i++)
		{
		id_temp 	= "descp"+i;
		capa_temp 	= document.getElementById(id_temp);
		if (i == visible) 	{ capa_temp.style.display = "block"; }
		else			  	{ capa_temp.style.display = "none"; }
		}
	}

// Funciones POP
function popCentro(mypage, myname, w, h, scroll) {
			var winl = (screen.width - w) / 2;
			var wint = (screen.height - h) / 2;
			winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable';
			win = window.open(mypage, myname, winprops);
			if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
			}
function popTop(mypage, myname, w, h, scroll) {
			var winl = (screen.width - w) / 2;
			var wint = (screen.height - h) / 2;
			winprops = 'height='+h+',width='+w+',top=0,left='+winl+',scrollbars='+scroll+',resizable';
			win = window.open(mypage, myname, winprops);
			if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
			}

// Funciones de insercion de publicaciones
function valida_forma(){
	// adquisicion
	if(!valida_Nulos(document.form1.n_adquisicion,"No. de Adquisición")){return};
	if(!valida_Numeros(document.form1.n_adquisicion,"No. de Adquisición")){return};
	// Clasificacion
	if(!valida_Nulos(document.form1.n_clasificacion,"No. de Clasificación")){return};
	
	if(!valida_Nulos(document.form1.txtAutores,"Autores")){return};
	if(!valida_Nulos(document.form1.txtTitulo,"Título")){return};
	if(!valida_Nulos(document.form1.txtAnio,"Año de Publicación")){return};
	if(!valida_Numeros(document.form1.txtAnio,"Año de Publicación")){return};
	// edicion
	if(!valida_Numeros(document.form1.n_edicion,"No. Edición")){return};
	
	//alert (document.form1.txtSubtemas.value);
	document.form1.submit();
}

// VAlidacion para revista
function valida_forma_rev(){
	// alert('hola');
	// adquisicion
	if(!valida_Nulos(document.form1.n_adquisicion,"No. de Adquisición")){return};
	if(!valida_Numeros(document.form1.n_adquisicion,"No. de Adquisición")){return};
	// Clasificacion
	// if(!valida_Nulos(document.form1.n_clasificacion,"No. de Clasificación")){return};
	
	if(!valida_Nulos(document.form1.txtAutores,"Editor(es)")){return};
	if(!valida_Nulos(document.form1.txtTitulo,"Nombre")){return};
	if(!valida_Nulos(document.form1.txtAnio,"Año de Publicación")){return};
	if(!valida_Numeros(document.form1.txtAnio,"Año de Publicación")){return};
	
	//alert (document.form1.txtSubtemas.value);
	document.form1.submit();
}

function valida_Nulos(field,campo){
	with (field){
		if (field.value==null||field.value==""){
			alert("El campo " + campo + " no puede ir vacio.\nFavor de Verificar");
			field.focus();
			return false;
		}
		return true;
	}
}

function valida_Numeros(field,campo){
	var valid = "0123456789";
	var ok = "yes";
	var temp;
	for(var i=0; i<field.value.length; i++){
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if(ok == "no"){
		alert("El campo " + campo + " solo acepta números.\nFavor de Verificar");
		field.value = "";
		field.focus();
//		field.select();
		return false;
	}
	return true;
}

// Agragado de subtemas
function agrega(obj){
	var subtemas = "";

	for (var i=0; i<obj.elements.length;i++){
		if(obj.elements[i].type == "checkbox" && obj.elements[i].checked){
			subtemas += obj.elements[i].value + "-";
    	}
	}

	subtemas = subtemas.substr(0,subtemas.lastIndexOf("-"));
	window.opener.document.forms[0].txtSubtemas.value = subtemas;
	window.opener.document.forms[0].hidSubtemas.value = subtemas;
//	alert(window.opener.document.forms[0].txtSubtemas.value);
	//alert('cera');
	window.close();
}

/* Limit the number of characters per textarea / Dynamic V.: Nannette Thacker / Original:  Ronnie T. Moore */
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}


// SCROLLES (2) Copyright 2006 DevDude.com
// incia_carrusel(capa) y incia_carrusel2(capa) 
	
// scroll 1
var sheight=50;
var sspeed=2;

function incia_carrusel(capa) 
	{
	if (document.all)  					{ iemarquee(capa); }
	else if (document.getElementById) 	{ ns6marquee(document.getElementById(capa)); }
	}

function iemarquee(whichdiv){
	iediv=eval(whichdiv)
	sheight += 10;
	iediv.style.pixelTop=sheight
	// iediv.innerHTML=msg 
	sizeup=iediv.offsetHeight
	ieslide()
}

function ieslide(){
	if (iediv.style.pixelTop>=sizeup*(-1)){
		iediv.style.pixelTop-=sspeed
		setTimeout("ieslide()",100)
	}
	else{
		iediv.style.pixelTop=sheight
		ieslide()
	}
}

function ns6marquee(whichdiv){
	ns6div=eval(whichdiv)
	sheight += 10;
	ns6div.style.top=sheight + "px";
	// ns6div.innerHTML=msg
	sizeup=ns6div.offsetHeight
	ns6slide()
}
function ns6slide(){
	if (parseInt(ns6div.style.top)>=sizeup*(-1)){
		theTop = parseInt(ns6div.style.top)-sspeed
		ns6div.style.top = theTop + "px";
		setTimeout("ns6slide()",100)
	}
	else {
		ns6div.style.top = sheight + "px";
		ns6slide()
	}
}


// scroll 2
var sheight2=50;
var sspeed2=2;

function incia_carrusel2(capa) 
	{
	if (document.all)  					{ iemarquee2(capa); }
	else if (document.getElementById) 	{ ns6marquee2(document.getElementById(capa)); }
	}

function iemarquee2(whichdiv){
	iediv2=eval(whichdiv)
	sheight2 += 10;
	iediv2.style.pixelTop=sheight2
	// iediv.innerHTML=msg 
	sizeup2=iediv2.offsetHeight
	ieslide2()
}

function ieslide2(){
	if (iediv2.style.pixelTop>=sizeup2*(-1)){
		iediv2.style.pixelTop-=sspeed2
		setTimeout("ieslide2()",100)
	}
	else{
		iediv2.style.pixelTop=sheight2
		ieslide2()
	}
}

function ns6marquee2(whichdiv){
	ns6div2=eval(whichdiv)
	sheight2 += 10;
	ns6div2.style.top=sheight2 + "px";
	// ns6div.innerHTML=msg
	sizeup2=ns6div2.offsetHeight
	ns6slide2()
}
function ns6slide2(){
	if (parseInt(ns6div2.style.top)>=sizeup2*(-1)){
		theTop2 = parseInt(ns6div2.style.top)-sspeed2
		ns6div2.style.top = theTop2 + "px";
		setTimeout("ns6slide2()",100)
	}
	else {
		ns6div2.style.top = sheight2 + "px";
		ns6slide2()
	}
}