function gE(myElement) {
	return document.getElementById(myElement);
}

function popUpNormal(url) {
	window.open(url, 'MultianunciosPopUp', 'width=620px,height=500px,scrollbars=0');
}

function popUpWithScroll(url) {
	window.open(url, 'MultianunciosPopUp', 'width=620px,height=500px,scrollbars=1');
}

function printItem(url) {
	window.open(url, 'MultianunciosPopUp', 'width=820px,height=700px,scrollbars=1');
}

function popImage(myimg) {
	var look='width=600,height=450,scrollbars=no,resizable=no'
	popwin = window.open('','',look)
	popwin.document.open()
	popwin.document.write('<html><body style="background:#000;margin:0px;padding:0px;"><img src="'+myimg+'" style="cursor:pointer;" alt="Haz clic para cerrar" onclick="window.close()"/></body></html>');
	popwin.document.close()
}

function showTabContent(type, id, tabs) {
	switch(type) {
		case 1:
			if(id == 'subastas' || id == 'profesionales_subastas') {
				gE('bgcat0').style.display='none'
				gE('bgcat1').style.display='block'
			} else {
				gE('bgcat0').style.display='block'
				gE('bgcat1').style.display='none'
			}
			break;
		case 0: default:
			var i = 0
			while (i < tabs) {
				gE('inicioTabContent'+i).style.display='none'
				gE('inicioTab'+i).className='inicioTabList'
				i++
			}
			gE('inicioTabContent'+id).style.display='block'
			gE('inicioTab'+id).className='inicioTabSelect'
			break;
	}
}

function enviarPuja() {
	if(document.getElementById('mipuja').value!=' ') {
		if(confirm('Tu puja es de '+document.getElementById('mipuja').value+' €.')) {
			document.getElementById('pujasform').submit();
		}	
	}
}

function date() {
	dows = new Array("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado");
	months = new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre");
	now = new Date();
	dow = now.getDay();
	d = now.getDate();
	m = now.getMonth();
	h = now.getTime();
	y = now.getYear();
	document.write(dows[dow]+", "+d+" de "+months[m]+" de "+y);
}

function resizeImage(idImg, w, h) {
	var img = idImg;
	var ancho = w;
	var hmax = h;
	var ratio = img.width / ancho;
	var alto = img.height / ratio;
	if(alto > hmax) {
		ancho2 = hmax*ancho/alto;
		alto = hmax;
		ancho = ancho2;
	}
	img.width = Math.round(ancho);
	img.height = Math.round(alto);
}

function ismaxlength(obj) {
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}

function validaTextoBBDD(str) {
	var RegExPattern = /[^'"\\]/;
	for(i=0; i<str.length; i++){
		if(!(str.charAt(i)).match(RegExPattern)) return false;
	}
	return true;
}

