function b_buscar_comb(este){	document.getElementById("fcomb").submit();}
function imagen_2(id, ancho , alto )
{
	alto	=	alto	;	//+20;
	ancho 	= 	ancho	;	//+10;
	var ventana = window.open("/Anuncios/Foto/?i="+id+"&param=1" , "" ,"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+ancho+",height="+alto+",left=50,top=50");
	ventana.resizeTo(alto,ancho);
	ventana.focus();
}

function nombre_s(	s1,  s2 )
{
var este = document.getElementById(s1).value ;
este=este.substr(este.lastIndexOf("\\")+1); 
document.getElementById(s2).value=este ;
}
		
function redondeo(number,X)		{	
X = (!X ? 0 : X);
return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}
		
function validar(thisform) 
{ 
	if (document.getElementById('email').value=="") 
	{ 
		alert("Debe introducir una dirección de correo."); 
		document.getElementById('email').focus();
		return false;
	}
	else
	{
		if (echeck(document.getElementById('email').value)==false)
		{
		document.getElementById('email').value="";
		document.getElementById('email').focus();
		return false;
		}
	}
	if (document.getElementById('comentario').value=="")
	{
		alert("Debe indicar algo en el texto."); 
		document.getElementById('comentario').focus();
		return false;
	}
	
	if(document.getElementById('precio').value!="")
	{
	
		myString = document.getElementById('precio').value 		;
		myString = myString.replace("." , "")	;
		myString = myString.substring(0 , myString.length-3)	;
	
	
		if( !validate_price (true) )
			{
			return false;
			}
		
	/*	
		myString  = redondeo(myString ,0);
//		myString = myString.parseInt(myString)	;
		if(myString > 10000000){			
			document.getElementById('precio').value=="";
			document.getElementById('precio').focus();
			return false; 
			
			}
		*/	
	}
//	return true; 

document.getElementById('f').submit();
}//
		
		
		
		
function echeck(str) {
var mensajedeerror ="Por favor, introduzca un formato correcto de email";
var at="@" 
var dot="." 
var lat=str.indexOf(at) 
var lstr=str.length 
var ldot=str.indexOf(dot) 
if (str.indexOf(at)==-1){ 
   alert(mensajedeerror) ;
   return false ;
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ 
   alert(mensajedeerror) ;
   return false ;
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
{
   alert(mensajedeerror) ;
   return false ;
}
 if (str.indexOf(at,(lat+1))!=-1){ 
   alert(mensajedeerror) ;
   return false ;
 } 
 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ 
   alert(mensajedeerror) ;
   return false ;
 }
 if (str.indexOf(dot,(lat+2))==-1){ 
   alert(mensajedeerror) ;
   return false ;
 }
 if (str.indexOf(" ")!=-1){
   alert(mensajedeerror) ;
   return false ;
 }
 return true;
}		
		
		
		
		
		
		
		
		
		
		
		
		
		
var f;
var reValidChars = /[0-9\.,]/;
var reKeyboardChars = /[\x00\x03\x08\x0D\x16\x18\x1A]/;
var reClipboardChars = /[cvxz]/i;													

function validate_price (formSubmit) {
	var i, ch, price_txt;
	var e = window.event;
	if (!f) f = document.getElementById('f');
        var bSkipPriceValidation = false;
        if (f.orig_price_type && f.orig_price_type.value==99)
		bSkipPriceValidation = true;

	if (!bSkipPriceValidation) {
        	price_txt = f.precio.value;
		if( price_txt == '' ) return true;

        	for (i=0;i<price_txt.length;i++) {
            		ch = price_txt.charAt(i);
	    		if (!reValidChars.test(ch)) {
alert('No puede usar letras o caracteres no numéricos\n en la casilla del precio.\nIndique el precio en euros.\n	Ejemplo: 1.200	');
document.getElementById('precio').value="";
document.getElementById('precio').focus();
				return false;
            		}
        	}

		if( price_txt.length > 2 && price_txt.indexOf(',') == -1 ) {
			if( price_txt.substr(price_txt.length - 2, 1) == '.' ) {
				var price_tmp = price_txt.substr(0, price_txt.length - 2) + ',' + price_txt.substr(price_txt.length - 1, 1) + '0';
				if( confirm("La cantidad no es correcta.\nQuería decir"+" "+price_tmp+" ?") )
					price_txt = price_tmp;
			}
			if( price_txt.substr(price_txt.length - 3, 1) == '.' ) {
				var price_tmp = price_txt.substr(0, price_txt.length - 3) + ',' + price_txt.substr(price_txt.length - 2, 2);
				if( confirm("La cantidad no es correcta.\nQuería decir"+" "+price_tmp+" ?") )
					price_txt = price_tmp;
			}
		}

		price_txt = price_txt.replace(/\./g, '');

		var tmp_array = price_txt.split(',');
		if( tmp_array.length > 2 ) {
			if( formSubmit ) {
alert('La cantidad no es correcta.\nIndique el precio en euros.\nEjemplo: 1.200');
document.getElementById('precio').value="";
document.getElementById('precio').focus();
				return false;
			}
			return;
		}

		var euros = tmp_array[0];
  		euros = parseInt(euros, 10);
  
		var price_tmp = '';
		if( !tmp_array[1] ) { var cents = '00'; } else { var cents = tmp_array[1]+'00'; cents = cents.substr(0,2); }
		if( isNaN(euros) || isNaN(cents) ) {
			if( formSubmit ) {
alert('La cantidad no es correcta.\nIndique el precio en euros. \nEjemplo: 1.200');
document.getElementById('precio').value="";
document.getElementById('precio').focus();
				return false;
			}
			return;
		}

		euros = euros.toString();
		cents = cents.toString();

		if( cents.length < 2 )
			{ cents = '00' + cents; cents = cents.substr(0,2); }

		var j = 0;
		for(var i=0; i<euros.length; i++) {
			j = euros.length - i - 1;
			if( i > 0 && i % 3 == 0 ) { price_tmp='.'+price_tmp; }
			price_tmp=euros.substr(j,1)+price_tmp;
		}
		price_tmp = price_tmp+','+cents;
        	var actValue = parseFloat(euros+"."+cents);
        	if (actValue > 10000000.00) 
			{
			alert('El precio es demasiado alto.\nEl precio máximo es 10.000.000,00 €');
//			f.precio.select();
document.getElementById('precio').value="";
document.getElementById('precio').focus();

			return false;
        	}
		f.precio.value = price_tmp;
	}
	return true;
}