function obtenerID(e){
  var wd = window.document;
	if (wd.getElementById){
		return wd.getElementById(e);
	}else if (wd.all){
		return wd.all[e];
	}
}
 

function validarNumero(obj){
	obj.value=obj.value.replace(/[^\/\d]/g,'');
}


function mensajeError(frm,obj,campo,msg_error){

	$(obj).block(
		{	message: msg_error, 
			overlayCSS: { backgroundColor: '#ffffff', opacity: '0.7' },
			centerY: true, 
			centerX: true, 
			css: { 
				cursor: 'wait' ,
				width: 'auto',
				height : 'auto' ,
				padding : '20px 30px' ,
				border :'1px solid #c8cabb',
				color : '#70754D',
				font : 'bold 12px arial'
				}
		}); 
		setTimeout(function() {
			$(obj).unblock();
			if(campo!='contenido'){
				if(frm[campo].disabled!=true){
					frm[campo].focus();
				}
			}
		}
		, 2000); 
}

function mensajePregunta(obj,div_msg){
	$(obj).block(
		{	message: $('#'+div_msg), 
			overlayCSS: { backgroundColor: '#ffffff', opacity: '0.7' },
			centerY: true, 
			centerX: true, 
			css: { 
				cursor: 'wait' ,
				width: 'auto',
				height : 'auto' ,
				padding : '20px 30px' ,
				border :'1px solid #c8cabb',
				color : '#70754D',
				font : 'bold 12px arial'
				}
		}); 
}


function bloqueo(obj,msg){
	$(obj).block(
	{	message: msg, 
		overlayCSS: { backgroundColor: '#ffffff', opacity: '0.7' },
		centerY: true, 
		centerX: true, 
		css: { 
			cursor: 'wait' ,
			width: '260px',
			height : 'auto' ,
			padding : '30px 10px' ,
			border :'1px solid #c8cabb',
			color : '#70754D',
			font : 'bold 12px arial',
			top : '20px'
			}
	}); 
}

function desbloqueo1(obj,msg){
	$(obj).block(
	{	message: msg, 
		overlayCSS: { backgroundColor: '#ffffff', opacity: '0' },
		centerY: true, 
		centerX: true, 
		css: { 
			cursor: 'wait' ,
			width: '260px',
			height : 'auto' ,
			padding : '30px 10px' ,
			border :'1px solid #c8cabb',
			color : '#70754D',
			font : 'bold 12px arial',
			top : '20px'
			}
	}); 
	
	setTimeout(function() {
		$(obj).unblock();
	}
	, 2000);
}

function desbloqueo2(obj){
	$(obj).unblock();
}


function destinoEnlace(destino){
	document.location=destino;
}

function actualizaContador(obj) {
	longitud=obj.value.length;
	if (longitud>2048) obj.value=obj.value.substr(0,2048);
	obj.form.contador.value=obj.value.length;
}  


function ventanaPopup(pUrl, pWindowName, pWidth, pHeight, pAttrib, pCuadrante) 
{
    var anchoDisponibleVentana=window.screen.availWidth;
    var altoDisponibleVentana=window.screen.availHeight;
    // '1 si, 2 sd, 3 ii, 4 id, 5 c [pCuadrante]
    var lngX =0;
    var lngY =0;
    if (pCuadrante==1) {lngX =0;lngY=0;}
    else if (pCuadrante==2) {lngX=(anchoDisponibleVentana - pWidth -15);lngY=0;}
    else if (pCuadrante==3) {lngX=0;lngY=(altoDisponibleVentana -30 - pHeight);}
    else if (pCuadrante==4) {lngX=(anchoDisponibleVentana - pWidth -15);lngY=(altoDisponibleVentana -30 - pHeight);}
    else {lngX =((anchoDisponibleVentana - pWidth)/2);lngY = ((altoDisponibleVentana - pHeight)/2);}

    var attrib = 'left=' + lngX + ',top=' + (lngY-30) + ',';
	    attrib += 'screenX=' + lngX + ',screenY=' + lngY + ',width='+pWidth+',height='+pHeight;
			attrib += 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,maximize=no';
	attrib += pAttrib;
    window.open (pUrl, pWindowName, attrib);
}


function abrirExploradorArchivos(campo,destino,tipo){
	//ruta="../js/imgmanager/browser/default/browser.php?Type=File&Connector=php_connector/connector.php&return_id="+campo;
	ruta="/mfm.php?mode=standalone&field="+campo+"&target="+destino+"&type="+tipo;
	ventanaPopup(ruta,"FileManager",642,455,"",5);
}

function Validar(id){
	  	if (document.forms[id].txt_Nombre.value == "")
	  	{ alert("Por favor ingrese su nombre"); document.forms[id].txt_Nombre.focus(); return; }
	
	  	if (document.forms[id].txt_Telefono.value == "")
	  	{ alert("Por favor ingrese su número de teléfono"); document.forms[id].txt_Telefono.focus(); return; }	
		
	  	if (document.forms[id].txt_Email.value == "")
	  	{ alert("Por favor ingrese su dirección de e-mail"); document.forms[id].txt_Email.focus(); return; }
	
		if (document.forms[id].txt_Email.value.indexOf('@', 0) == -1 ||
		  document.forms[id].txt_Email.value.indexOf('.', 0) == -1)
	  	{ alert("Dirección de e-mail inválida"); document.forms[id].txt_Email.focus(); return; }
	
	  	if (document.forms[id].txt_Pais.value == "")
	  	{ alert("Por favor ingrese su pais de origen"); document.forms[id].txt_Pais.focus(); return; }
	
	  	if (document.forms[id].txt_Consulta.value == "")
	  	{ alert("Por favor ingrese su consulta"); document.forms[id].txt_Consulta.focus(); return; }
	
	  	document.forms[id].submit();
	}
