function format(input)
{
var num = input.value.replace(/\./g,'');
if(!isNaN(num)){
num = num.toString().split('').reverse().join('').replace(/(?=\d*\.?)(\d{3})/g,'$1.');
num = num.split('').reverse().join('').replace(/^[\.]/,'');
input.value = num;
}

else{ 
input.value = input.value.replace(/[^\d\.]*/g,'');
}
}
function formatNumeros(input)
{
var num = input.value.replace(/\./g,'');
if(!isNaN(num)){
input.value = num;
}
else input.value = input.value.replace(/[^\d\.]*/g,'');
}


function validarCotizacion(formulario) {

var error = false;
var cant = formulario.plan.length;
//alert(cant);
for(i=0;i<cant; i++){
if(formulario.plan[i].checked)
{
error = false; 
break;
}else{
mensaje=  "==> Selecione el plan de Hospedaje que desee.\n";
error=true;	
}
}


if(formulario.paislatin.value == "" &&  formulario.paisotro.value == "")
{

mensaje = mensaje +  "==> Seleccion su pais de residencia.\n";
error=true;	

}


if (error)
{
alert(mensaje);
return false;
}

else return true;
}





function validarPago(formulario) {
	
var error = false;
if(!formulario.tipo.checked)
{
mensaje=  "==> Selecione la forma de pago.\n";
error=true; 
}	


if (error)
{
alert(mensaje);
return false;
}
else return true;
}

function dimensionar(ancho, alto, centro) {
	if(centro==true) {
		derecha=(screen.width-ancho)/2;
		arriba=(screen.height-alto)/2;
		window.moveTo(derecha,arriba);
	}
	
	window.resizeTo(ancho,alto);
}

function darFoco(id) {
	id = document.getElementById(id);
	if(id)  {
		id.focus();
	} else {
		self.focus();
	}
}

function doPost(frm, params) {
	var frm = document.getElementById(frm);
	if(frm) {
		frm.action = params;
		frm.submit();
	}
}



/**/
function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	
	if (endstr == -1)
		endstr = document.cookie.length;
		
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	
	while (i < clen) {
		var j = i + alen;
		
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
			
		i = document.cookie.indexOf(" ", i) + 1;
		
		if (i == 0) 
			break; 
	}

	return null;
}

function setCookie (name, value) {
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	
	path="/";
	
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
}
/**/



function enviar()
 {
 var valor = document.form2.marcas.options[document.form2.marcas.selectedIndex].value; 
 //alert (valor);
 window.location = 'categorias.php?idcat='+valor;
}


function ocultar(num){
	if(num==2){
	document.form1.paislatin.options[0].selected="true"; 
	}
	if(num==1){
	document.form1.paisotro.options[0].selected="true"; 
	}	
}

function mostrarTablaFactura(){
var Select = document.getElementById("pais");
var valor = Select.options[Select.selectedIndex].value;
//var texto = Select.options[Select.selectedIndex].text;  
if(valor== 28){
	document.getElementById('tablafactura').style.display= "block"; 
}else{
	document.getElementById('tablafactura').style.display= "none"; 	
}
}


