//função para abrir o hotsite
function hotSite(url){
    location.href=url;
}

function resizeModal(w, h) {
    document.getElementById('windowModal').style.width = w + "px";
    document.getElementById('windowModal').style.height = h + "px";

    document.getElementById('closeWindowModal').style.marginTop = "-" + h / 2 + "px";
    document.getElementById('closeWindowModal').style.marginLeft = w / 2 + 11 + "px";
    
    document.getElementById('windowModal').style.marginLeft = "-" + w / 2 + "px";
    document.getElementById('windowModal').style.marginTop = "-" + h / 2 + "px";

}

function resizeModalLesg(w, h) {
    document.getElementById('windowModalLesg').style.width = w + "px";
    document.getElementById('windowModalLesg').style.height = h + "px";

    document.getElementById('closeWindowModalLesg').style.marginTop = "-" + h / 2 + "px";
    document.getElementById('closeWindowModalLesg').style.marginLeft = w / 2 + 11 + "px";

    document.getElementById('windowModalLesg').style.marginLeft = "-" + w / 2 + "px";
    document.getElementById('windowModalLesg').style.marginTop = "-" + h / 2 + "px";

}

//função para exibir ou ocultar elementos
function setDisplay(e, typeDisplay) {
    document.getElementById(e).style.display = typeDisplay;
}

//função para contar caracteres de um elemento
function countChar(e) {
    return (document.getElementById(element).value.length);
}

//função para pegar altura total do documento
function getHeightSize() {
    var heightSize = document.body.offsetHeight;
    return heightSize;
}

//função para setar um elemento como modal
function setModal(e) {
    document.getElementById(e).style.height = getHeightSize() + "px";
}

//função para abrir um modal
function openModal() {
    document.getElementById('modal').style.display = 'block';
    document.getElementById('windowModal').style.display = 'block';
    document.getElementById('closeWindowModal').style.display = 'block';   
}

//função para fechar o modal e seus elementos
function closeModal() {
    document.getElementById('closeWindowModal').style.display = 'none';
    document.getElementById('windowModal').style.display = 'none';
    document.getElementById('modal').style.display = 'none';
}


//função para abrir um modal
function openModalLesg() {
    document.getElementById('modalLesg').style.display = 'block';
    document.getElementById('windowModalLesg').style.display = 'block';
    document.getElementById('closeWindowModalLesg').style.display = 'block';
}

//função para fechar o modal e seus elementos
function closeModalLesg() {
    document.getElementById('closeWindowModalLesg').style.display = 'none';
    document.getElementById('windowModalLesg').style.display = 'none';
    document.getElementById('modalLesg').style.display = 'none';
}

//função para iniciar a busca
function startSearch(){
	var palavra = document.getElementById('txtBusca');
	url = "http://www.yamaha-motor.com.br/cmi/Pagina.aspx?1511&palavraChaveBuscaPagina=" + palavra.value
	location.href = url;
}

//função para chamar uma url
function loadURL(url){	
	location.href = url;
}

//função para carregar uma imagem dentro de um elemento
function loadImg(e, img){
    document.getElementById(e).innerHTML = "<img src='" + img + "'>";
}

//função para carregar documento dentro de elemento via AJAX
function loadHTML(e,file) {
     loadAjax(e, file);    
}

function loadAjax(e, file) {
    
    var url = file;
    element = e ;
    xmlRequest.open("GET", url, true);
    xmlRequest.onreadystatechange = loadState;
    xmlRequest.send(null);

    if (xmlRequest.readyState == 1) {
        document.getElementById(element).innerHTML = "<div style='position:absolute; top:50%; left:50%; margin-top:-25px; margin-left:-25px;'><img src='img/gifLoad.gif' width='50' height='50'><p>Carregando</p></div>";
    }

    return url;

}

function loadState() {
    if (xmlRequest.readyState == 4) {
        document.getElementById(element).innerHTML = xmlRequest.responseText;
    }
} 

function loadIframe(iframeName, url) {
	
	/*if ( window.frames[iframeName] ) {
		window.frames[iframeName].location = url; 
		return false;
	}
	return true;
	*/
document.getElementById(iframeName).src = url
}

//função chamada em cada página de produto para definir o nome do modelo do produto
function setNomeModelo(modelo){
    document.getElementById('areaTextoModeloMoto').innerHTML = "<h2>" + modelo + "</h2>";
}


//função chamada em cada página de produto para definir o nome do modelo do produto
function setNomeModeloQuadriciclo(modelo){
    document.getElementById('areaTextoModeloQuadriciclo').innerHTML = "<h2>" + modelo + "</h2>";
}

function setSubModelo(markup){
    if(markup==''){document.getElementById('maisVersoes').style.display = 'none';}
    document.getElementById('areaTextoSubModeloMoto').innerHTML = markup;
}

//função para abrir popup
function abrePopup(ConteudoPopup)
{
janelaFoto = window.open
(ConteudoPopup, 'foto','width=599,height=382, menubar=no, tollbar=no, location=no,scrollbar=no, status=no, left=100, top=100')
}

//função para abrir popup página YAMALUBE
function abrePopupYAMALUBE(ConteudoPopupYAMALUBE)
{
janelaFoto = window.open
(ConteudoPopupYAMALUBE, 'foto','width=599,height=455, menubar=no, tollbar=no, location=no,scrollbar=no, status=no, left=100, top=100')
}
