// JavaScript Document
function chgImg(ImgClick) {
	ImgNum=ImgClick
	document.imagenppal.src = NewImg[ImgNum];
}


// mostrar foto grande para el detalle
function openwindow(txt) {
	window.open("ampliar.asp?foto="+txt,"my_new_window","width=500,height=500,top=0,left=0")
} 

function openpopup(popurl){
winpops=window.open(popurl,"","width=550,height=500,scrollbars=yes")
}


function openpopupOpcionales(popurl){
winpops=window.open(popurl,"","width=600,height=600,scrollbars=yes")
}

// 					Abre ventana default set


//////////////////////////////////////////////////////////////////////////////////////
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
// Ejemplo:
//	<a href="#" onclick="MM_openBrWindow('adfadf','kjhg','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes')"> jhgfkjhg</a>



function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// 					Abre ventana con el tamaño de una imagen 
//////////////////////////////////////////////////////////////////////////////////////

var win=null;
function mostrarimagen(url_imagen,titulo){
 	var img = new Image();
 	img.src = url_imagen;
	win=window.open('','','width='+img.width+',height='+img.height+',scrollbars=no,resizable=1,toolbar=0');
	win.document.write ('<html>\n');
	win.document.write (' <head>\n');
	win.document.write ('  <title>'+titulo+'</title>\n');
	win.document.write (' </head>\n');
	win.document.write (' <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">\n');
	win.document.write ('  <img src="' + url_imagen + '" height='+img.height+' width='+img.width+'>\n');
	win.document.write (' </body>\n');
	win.document.write ('</html>\n');	
}

//	Ejemplo:
//	<a href="javascript:mostrarimagen('imag1.jpg','Imagen1');">
//		<img src="imag1.jpg" border="0" width="200" height="118">
//	</a>

//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////



// 				Ventana emergente se adapta a la resolución
//////////////////////////////////////////////////////////////////////////////////////

{
var win= null;
	function NewWindow(url,name,scroll){
	  var w = (screen.width-12);
	  var h = (screen.height-55);
	  var settings  ='height='+h+','; 
		  settings +='width='+w+',';
		  settings +='top='+0+',';
		  settings +='left='+0+',';
		  settings +='scrollbars='+scroll+',';
		  settings +='resizable=yes';
	  win=window.open(url,name,settings);
	  if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
	}
}

//	Ejemplo
//	<a href="javascript:NewWindow('/','test','no');">
//		Pulsa aquí para abrir una nueva ventana que se adaptará a la resolución<
//	</a>



//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////


// 					Pantalla emergente centrada
//////////////////////////////////////////////////////////////////////////////////////


function NewWindow(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(); }
}

 
//	Ejemplo
//	<a href="http://www.yahoo.com/" onclick="NewWindow(this.href,'name','400','400','yes');return false;">
//		Popup Yahoo.com
//	</a>



// ***********************************************************************************
// **********************		Validacion de Formularios		**********************
// **************************************** in ***************************************

function MM_validateForm() { // Martín A. Garay 2001 info@mag-web.com.ar
	var i,p,q
	var nm
	var test
	var num
	var min, max
	var errors='',args=MM_validateForm.arguments;
	for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
	if (val) { nm=val.name; if ((val=val.value)!="")
		{
//----  si no esta vacio evalua:
//----  que contenga caracteres autorizados :
		var r
		var caract_extra = "#|-_·@()&$¿?,;.:!º\\/"
		var ubicacion 
		var enter = "\n"
		var caracteres = "abcdefghijklmnopqrstuvwxyzñ1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZÑáéíóúÁÉÍÓÚ,." + enter + caract_extra
		var contador = 0
		for (var r=0; r < val.length; r++) 
		{
		ubicacion = val.substring(r, r + 1)
			if (caracteres.indexOf(ubicacion) != -1) 
				{contador++} 
					else {errors+='- '+nm+' -- No esta permitido el caracter '+ ubicacion +'.\n';}
		}
//--- evalua los contenidos (mail, núm, rangos núm)
		if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');										//-- *Si es un email, que tenga '@'
			if (p<2 || p==(val.length-1)) errors+='- '+nm+' Debe ser una dirección de E-Mail.\n';	//  y 2 espacios antes y desp. de @
			} 
			else if (test!='R') { num = parseFloat(val);											//-- *Si se requieren núm
				if (isNaN(val)) errors+='- '+nm+' Debe contener solo números.\n';					//  ¿? si hay Nº
				if (test.indexOf('inRange') != -1) { p=test.indexOf(':');							//-- *Si se requiere un rango de ním
					min=test.substring(8,p); max=test.substring(p+1);
						if (num<min || max<num) errors+='- '+nm+' Debe tener numeros del '+min+' al '+max+'.\n';
						} 
				}
			} 
//----  si esta vacio y es requerido muestra la alerta
		else if (test.charAt(0) == 'R') errors += '- '+MM_Nombre(nm)+' debe estar completo.\n'; }
  	}
//----  Si hay algun error muestra la alerta
	if (errors) alert('Alguno(s) error(es) han ocurrido:\n'+errors);
		document.MM_returnValue = (errors == '');
}
//----  configura los nobres de los campos par a que el us. lo entienda mejor
//function MM_Nombre(Ncampo){
//	if (Ncampo == 'Nombre')(Ncampo = 'Nombre');				// campos de la default
//	if (Ncampo == 'Clave')(Ncampo = 'Clave');
//
//	if (Ncampo == 'mm_nombre')(Ncampo = 'Nombre');				// campos de registrarme y misdatos
//	if (Ncampo == 'mm_clave')(Ncampo = 'Clave');
//	if (Ncampo == 'mm_claveCH')(Ncampo = 'La verificacion de la clave');
//	if (Ncampo == 'mm_mail')(Ncampo = 'E-mial');
//	if (Ncampo == 'dia')(Ncampo = 'El Día de la fecha de naciomiento');
//	if (Ncampo == 'mes')(Ncampo = 'El Mes de la fecha de naciomiento');
//	if (Ncampo == 'ano')(Ncampo = 'El Año de la fecha de naciomiento');
//	if (Ncampo == 'mm_CategTKD')(Ncampo = 'Su categoria de Taekwon-do');
//	if (Ncampo == 'mm_sFederacion')(Ncampo = 'Nombre de la Federacion de Taekwon-do');
//	return Ncampo;
//}

// onSubmit="MM_validateForm('Nombre','','R');return document.MM_returnValue"
// tipo : combinacion de R + .... (RisNum)
// tipo : R - requerido
// tipo : isNum - Numeros
// tipo : isEmail - mail



// ***********************************************************************************
// **********************		Validacion de Formularios		**********************
// **************************************** Fin **************************************


// ***********************************************************************************
// **********************		Post It mensaj de help con **********************
// **************************************** IN **************************************

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="/app/abm/images/transparente.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

// Ejemplo: (Implementación:)
//-------------------------
//<a href="javascript:;"><img src="images/JOCampos.jpg" width="130" height="130" border="0" onMouseover="ddrivetip('<strong>Dr. Jorge O Campos</strong><br>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec ut eros vitae erat semper hendrerit. Proin leo nisl, aliquet nec, porttitor in, ultricies et, neque. Donec nisl dui, varius id, facilisis non, iaculis id, neque. Ut ultrices orci in erat. Nam ligula. Integer sed eros sit amet turpis suscipit luctus.', 200)";
//onMouseout="hideddrivetip()" /></a>