/*##################################################################
CREADO POR: BITWARE S.L.
EMAIL: BITWARE@BITWARE.ES
###################################################################-*/
// JavaScript Document


//funciones para mostrar y ocultar los combos
function mostrarSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='visible';
   }
}

function ocultarSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
   elements[i].style.visibility='hidden';
   }
}

//funcion para volver atrás

function back()
{
	history.back(-1);
}

//funcion para redirigir a pagina de avisos
function redirigirAviso(pagina) {
    document.location.href=pagina;
}

//funcion para redirigir a pagina con confirmacion
function redirigirAvisoConfirmacion(pagina) {

    if(confirm("Confirma que desea eliminar esta nonmina"))
    {
        document.location.href=pagina;
    }

}

//funcion para mostrar archivos en iframe oculto
function Navigate(url)
{
    //showModalDialog(url,"","dialogWidth:400px; dialogHeight:225px; status:no; center:yes");
    var navegador = navigator.appName
    try
    {
	    if (navegador == "Microsoft Internet Explorer") {
           document.all("IFPDF").src=url;
        }
        else{
           window.open(url);
	    }
    }catch(err)
    {} 
}    


//hide selects on page - copy code below
function hideSelects() {
//possible values for action are 'hidden' and 'visible'
	
	if (navigator.appName.indexOf("MSIE")) {
		for (var S = 0; S < document.forms.length; S++){
			for (var R = 0; R < document.forms[S].length; R++) {
				//if (document.forms[S].elements[R].options) {
					document.forms[S].elements[R].style.visibility = 'hidden';
				//}
			}
		}
	}
}

//funciones para mostrar/ocultar la imagen de cargando
function showDivAnimacion()
{
    try
    {
		ocultarSelects();
	    parent.document.getElementById('DIVANIMACION').style.display="block";
	    document.getElementById('DIVANIMACION').style.display="block";
	}catch(err)
    {} 
}

function hideDivAnimacion()
{
    try
    {
		mostrarSelects();
	    parent.document.getElementById('DIVANIMACION').style.display="none";
	    document.getElementById('DIVANIMACION').style.display="none";
	}catch(err)
    {} 
}

function ShowDIV(id)
{
    try
    {
	    if(document.getElementById(id).style.display=="block")
			document.getElementById(id).style.display="none";
		else
			document.getElementById(id).style.display="block";
	}catch(err)
    {} 
}

//
function redirigirInicio(){
    parent.location.href="default.aspx";
}

function abrirAviso() { 
		var x, y;
  		var ancho = 490;
  		var alto = 600;
  		x = (window.screen.width-ancho)/2;
  		y = (window.screen.height-alto)/2;
  		window.open('./Avisolegal.htm','Aviso','scrollbars=no,menu=no,width='+ancho+',height='+alto+ ',left='+x+ ',top='+y)
	}
	
function abrirDetalleOferta(idOferta) { 
		var x, y;
  		var ancho = 490;
  		var alto = 640;
  		x = (window.screen.width-ancho)/2;
  		y = (window.screen.height-alto)/2;
		
		var url1='./detalleOferta.aspx?cod='+idOferta;
		var url2='Bitware S.L - Oferta de Empleo';
		
		window.open(url1,'','scrollbars=no,menu=no,width='+ancho+',height='+alto+ ',left='+x+ ',top='+y)
		//window.open(url1,url2,'scrollbars=no,menu=no,width='+ancho+',height='+alto+ ',left='+x+ ',top='+y)
	}

function Resize(altoHijo){
    ResizeParent(altoHijo);
}

function ResizeParent(altoHijo){
    //hideDivAnimacion();
    var mainDivHeight;
    var heightDefault=400;

     mainDivHeight = altoHijo; //le damos el mismo alto que el contenido del iframe

    try
	{
		 if (mainDivHeight<heightDefault)
	        mainDivHeight=heightDefault;
	        
	     parent.document.getElementById('mainDiv').style.height = mainDivHeight + 'px';
	     parent.document.getElementById('mainIFRAME').style.height = mainDivHeight + 'px';
	}catch(err)
	{}
}

function RedimensionarPadre(){
    var navegador = navigator.appName
    try
	{
		if (navegador == "Microsoft Internet Explorer") {
	       // alert(document.getElementById('Form1').offsetHeight);

	       //ResizeParent(document.getElementById('Form1').offsetHeight);
	       ResizeParentancho(document.getElementById('Form1').offsetWidth);
	    }
	    else{
	       ResizeParent(this.theForm.clientHeight);
		}
	       //alert(this.theForm.clientHeight);
	       
    }catch(err)
	{}       
}
function RedimensionarCalendar(alto){
    var navegador = navigator.appName
    try
	{
		if (navegador == "Microsoft Internet Explorer") {
	       // alert(document.getElementById('Form1').offsetHeight);

	       //ResizeParent(document.getElementById('Form1').offsetHeight);
	       ResizeParentancho(alto);
	    }
	    else{
	       ResizeParent(this.theForm.clientHeight);
		}
	       //alert(this.theForm.clientHeight);
	       
    }catch(err)
	{}       
}






function ResizeParentancho(altoHijo) {
    hideDivAnimacion();
    var mainDivWidth;
    var widthDefault;    
    mainDivWidth = altoHijo; //le damos el mismo alto que el contenido del iframe

    try {
        parent.document.getElementById('mainDiv').style.width = "100%";
        parent.document.getElementById('mainIFRAME').style.width = "100%";
        parent.document.getElementById('mainDiv').style.height = document.getElementById('Form1').offsetHeight +'px';
        //parent.document.getElementById('mainDiv').style.vertical-align = "Top";
        //parent.document.getElementById('mainIFRAME').style.height = "100%";
        parent.document.getElementById('mainIFRAME').style.height = document.getElementById('Form1').offsetHeight +'px';
        //parent.document.getElementById('mainDiv').style.height = document.getElementById('Form1').offsetHeight +'px';
    } catch (err)
	{ }
    //alert(parent.document.getElementById('mainDiv').style.height);
}


function recargarPagina()
    {
     parent.location.href="admIndex.aspx?ifr=16";
    }



//FUNCIONES DE VALIDACIÓN
//#####################################################################
function isEmailAddress(theElement, nombre_del_elemento )
{
    var s = theElement.value;
    var filter=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
    if (s.length == 0 ) return true;
    if (filter.test(s))
    return true;
    else
    alert("Ingrese una dirección de correo válida");
    theElement.focus();
    return false;
}


function IsNumber(e) 
{
    tecla = (document.all) ? e.keyCode : e.which;
    if (tecla==8) return true;
    patron = /\d/; // Solo acepta números
    te = String.fromCharCode(tecla);
    return patron.test(te);
} 


//FUNCIONES DE FORMATEO DE NUMEROS
//#################################################################
function oNumero(numero)
{
	//Propiedades
	this.valor = numero || 0
	this.dec = -1;
	//Métodos
	this.formato = numFormat;
	this.ponValor = ponValor;
	//Definición de los métodos
	function ponValor(cad)
	{
		if (cad =='-' || cad=='+') return
		if (cad.length ==0) return
		if (cad.indexOf('.') >=0)
		    this.valor = parseFloat(cad);
		else
		    this.valor = parseInt(cad);
		}
	function numFormat(dec, miles)
	{
	var num = this.valor, signo=3, expr;
	var cad = ""+this.valor;
	var ceros = "", pos, pdec, i;
	for (i=0; i < dec; i++)
	ceros += '0';
	pos = cad.indexOf('.')
	if (pos < 0)
	    cad = cad+"."+ceros;
	else
	    {
	    pdec = cad.length - pos -1;
	    if (pdec <= dec)
	        {
	        for (i=0; i< (dec-pdec); i++)
	            cad += '0';
	        }
	    else
	        {
	        num = num*Math.pow(10, dec);
	        num = Math.round(num);
	        num = num/Math.pow(10, dec);
	        cad = new String(num);
	        }
	    }
	pos = cad.indexOf('.')
	if (pos < 0) pos = cad.lentgh
	if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+')
	       signo = 4;
	if (miles && pos > signo)
	    do{
	        expr = /([+-]?\d)(\d{3}[\.\,]\d*)/
	        cad.match(expr)
	        cad=cad.replace(expr, RegExp.$1+','+RegExp.$2)
	        }
	while (cad.indexOf(',') > signo)
	    if (dec<0) cad = cad.replace(/\./,'')
	        return cad;
	}
}//Fin del objeto oNumero:

function puntitos(donde,caracter,campo)
{
	var decimales = false;
	campo = eval("donde.form." + campo);
		decimales = true;




	pat = /[\*,\+,\(,\),\?,\\,\$,\[,\],\^]/
	valor = donde.value
	largo = valor.length
	crtr = true
	if(isNaN(caracter) || pat.test(caracter) == true)
		{
		if (pat.test(caracter)==true) 
			{caracter = "\\" + caracter}
		carcter = new RegExp(caracter,"g")
		valor = valor.replace(carcter,"")
		donde.value = valor
		crtr = false
		}
	else
		{
		var nums = new Array()
		cont = 0
		for(m=0;m<largo;m++)
			{
			if(valor.charAt(m) == "." || valor.charAt(m) == " " || valor.charAt(m) == ",")
				{continue;}
			else{
				nums[cont] = valor.charAt(m)
				cont++
				}
			
			}
		}

	if(decimales == true) {
		ctdd = eval(1 + dec);
		nmrs = 1
		}
	else {
		ctdd = 1; nmrs = 3
		}
	var cad1="",cad2="",cad3="",tres=0
	if(largo > nmrs && crtr == true)
		{
		for (k=nums.length-ctdd;k>=0;k--){
			cad1 = nums[k]
			cad2 = cad1 + cad2
			tres++
			if((tres%3) == 0){
				if(k!=0){
					cad2 = "." + cad2
					}
				}
			}
			
		for (dd = dec; dd > 0; dd--)	
		{cad3 += nums[nums.length-dd] }
		if(decimales == true)
		{cad2 += "," + cad3}
		 donde.value = cad2
		}
	donde.focus()
}	


