function getElementsByClass( searchClass, domNode, tagName) { 
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) { 
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1) 
			el[j++] = tags[i];
	} 
	return el;
} 
function OcultarDivImagenNoticia(){			
	var tabs = getElementsByClass('foto'); 
	tabs[0].style.display = 'none';
}

function OcultarImagen(){			
	window.event.srcElement.style.display = "None";
}

function comprobarCampos(campos){
	/*Extrae los campos de la cadena y los mete en un array*/	
	campos = campos.split(',');
	/*Para cada campo contenido en el array comprueba si su valor está vací­o
	 *si es así devuelve 0. */
	for(i = 0; i < campos.length; i++){
		if(document.getElementById(campos[i]).value.length == 0){
			return 0;
		}
	}
	/*Si no, devuelve 1*/
	return 1;
}

function cambiarUploadify(campo, idpagina){
	campo = document.getElementById(campo);
	
	//Lo enlaza a uploadify
	$("#"+campo.id).uploadify({
		'uploader'       : 'libs/uploadify/uploadify.swf',
		'script'         : 'libs/uploadify/uploadify.php',
		'cancelImg'      : 'libs/uploadify/cancel.png',
		'folder'         : 'temp',
		'queueID'        : 'cargador',
		'auto'           : true,
		'multi'          : false,
		'buttonText'	 : 'Examinar',
		'buttonImg'		 : 'fotos/btn_subirImagen.png',
		'width'			 : '179',
		'height'		 : '26',
		'sizeLimit'		 : 200000000,
		'fileExt'		 : '*.*',
		'fileDesc'		 : '*.*',
		'onComplete'	 : function(event, queueID, fileObj, response, data) {								
								subidaCompletada(fileObj.name, idpagina);
							}
	});
}

function antiCacheo(){
	var fecha = new Date(); 
	var ac = fecha.getHours().toString() + fecha.getMinutes().toString() + fecha.getSeconds().toString();
	return ac;
}

function esNumerico(objCampo, decimales){
	var divPopup = document.getElementById('popup');
	var valor = objCampo.value;
	valor = valor.replace(',', '.');
	if('undefined' == typeof(objCampo.previousValue)){
		objCampo.previousValue = objCampo.defaultValue;
	}
	if(isNaN(valor)){		
		objCampo.value = objCampo.previousValue;
		objCampo.focus();	
		divPopup.style.width = '350px';
		divPopup.style.height = '110px';
		divPopup.style.backgroundColor = '#FBD7E6';
		divPopup.innerHTML = '<div style="color:red; font-weight: bold; font-family: verdana; font-size: 14px;"><br />Solo se permiten valores numéricos sin separación de miles</div><br /><img src="images/btn_aceptar.png" style="cursor: pointer;" onclick="document.getElementById(\'' + objCampo.id + '\').focus(); popup(\'popup\');" />';
		popup('popup');	
	}else{
		var num = new Number(valor);
		objCampo.value = num.toFixed(decimales);		
	}	
}

function agregarPagador(){
	if(numpagadores < 5){
		document.getElementById('pagador'+numpagadores).style.display = 'inherit';
		numpagadores++;
		if(numpagadores == 5){
			document.getElementById('nuevopagador').style.display = 'none';
		}
		if(numpagadores > 0){
			document.getElementById('eliminarpagador').style.display = 'inherit';
		}
	}
}

function eliminarPagador(){
	if(numpagadores > 0){
		numpagadores--;
		document.getElementById('pagador'+numpagadores).style.display = 'none';
		document.getElementById('obtenerde'+numpagadores).selectedIndex = 0;
		document.getElementById('cif'+numpagadores).value = '';
		document.getElementById('razonsocial'+numpagadores).value = '';
		document.getElementById('direccion'+numpagadores).value = '';
		document.getElementById('cpostal'+numpagadores).value = '';		
		document.getElementById('porcentaje'+numpagadores).value = '';
		if(numpagadores < 5){
			document.getElementById('nuevopagador').style.display = 'inherit';
		}
		if(numpagadores == 1){
			document.getElementById('eliminarpagador').style.display = 'none';
		}
	}
}


