﻿
function myLoad(){
    openPage(0);
    AjaxAppl._Default.vbGetCategorias(cbGetCategorias);
}

function openPage(nroPagina){
    sel('m'+nroPagina);
    if (nroPagina==0){
        document.getElementById("tdOferta").className = 'oculto';//setAttribute('class','oculto');
    }else{
        document.getElementById("tdOferta").className = '';
    }
    AjaxAppl._Default.vbOpenPage(nroPagina, cbCargarContenido);
}
function cbCargarContenido(res){
    document.body.scrollTop = 0;
    document.getElementById("colIzquierda").innerHTML = res.value;
}
function cbCargarContenidoMail(res){
    if (res.value=="ok"){
        alert("Gracias por contactarse con nosotros, su mensaje ha sido enviado");
        clean;
    }else{
    alert(res.value);
        //document.getElementById("colIzquierda").innerHTML = res.value;
    }
    
}

function cbGetHiddens(res){
    document.getElementById("oculto").innerHTML=res.value;
}
function cbGetCategorias(res){
    valor = res.value;
    valor2= res.value;
    var pos1 =0;
    var pos2 =0;
    pos1=valor.indexOf("#1");
    pos2=valor.indexOf("1#");
    if (pos1 > 0) {
     document.getElementById("hindReciclada").value = valor.substr(pos1+2,pos2-pos1-2);
     valor=valor.substr(0,pos1);
     valor= valor + valor2.substr(pos2+2,valor2.length-1)
    }
    
    document.getElementById("vertical_container").innerHTML=valor;
    loadAccordions();
    //loadSubAccordions();
}

// Cargando Acordeones
function loadAccordions() {
	var bottomAccordion = new accordion('vertical_container');
	bottomAccordion.activate($$('#vertical_container .accordion_toggle')[0]);
}

//function openPage(id){
//    sel('m'+id);
//    AjaxAppl._Default.vbOpenPage(id, cbCargarContenido);
//}

function abrir(id){
    recicladas =  document.getElementById("hindReciclada").value;
    document.getElementById("tdOferta").className = '';
    AjaxAppl._Default.vbOpenProduct(id, recicladas,  cbCargarContenido);
}

function dimencionar(ancho, alto, imagen, size){
	img = document.getElementById('geleGrafImgShow');
	img.height = size;
	img.width = size;
	img.src=imagen;
//	if (alto<ancho){
		img.height = alto * size / ancho;
		img.width = size;
/*	}else{
		if(alto>ancho){
			img.width = ancho * size / alto;
			img.height = size;
		}else{
			img.width = size;
			img.height = size;
		}
	}*/
	img.removeAttribute('style');
//	img.setAttribute('style','display:inline');
}
function dimencionar1(ancho, alto, imagen, size, id){
	img = document.getElementById('geleGrafImgShow' + id);
	img.height = size;
	img.width = size;
	img.src=imagen;
//	if (alto<ancho){
		img.height = alto * size / ancho;
		img.width = size;
/*	}else{
		if(alto>ancho){
			img.width = ancho * size / alto;
			img.height = size;
		}else{
			img.width = size;
			img.height = size;
		}
	}*/
	img.removeAttribute('style');
//	img.setAttribute('style','display:inline');
}

function plano() {
open("mapaGr.htm", "Sizewindow", "width=405,height=360,scrollbars=no,toolbar=no");
}
function clean(){
    var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
        x[i].value="";
    }
    var x = document.getElementsByTagName('textarea');
	for (var i=0;i<x.length;i++) {
        x[i].value="";
    }
}
function sendMail(){
    nom = document.getElementById('Text1').value;
    ape = document.getElementById('Text2').value;
    emp = document.getElementById('Text3').value;
    car = document.getElementById('Text4').value;
    ema  = document.getElementById('Text5').value;
    fon = document.getElementById('Text6').value;
    fax = document.getElementById('Text7').value;
    obs = document.getElementById('TextArea1').value;
    AjaxAppl._Default.vbSendMail(nom, ape, emp, car, ema, fon, fax, obs, cbCargarContenidoMail);
}
function sel(yo){
    document.getElementById('m0').className = 'norm';
    document.getElementById('m1').className = 'norm';
    document.getElementById('m2').className = 'norm';
    document.getElementById('m3').className = 'norm';
    document.getElementById('m4').className = 'norm';
    document.getElementById('m5').className = 'norm';
    document.getElementById(yo).className = 'oran';
}
function jsPaginar(pag){
    AjaxAppl._Default.getInicio(pag, cbCargarContenido);
}
