/**
 * Escreve na página um objeto do tipo SWF
 *
 * @param swf arquivo para ser visualizado
 * @param width largura do clip
 * @param height altura do clip
 */
function print_swf(swf, width, height )
{
    //swf = 'fla/banner_top.swf';
    //width = 726;
    //height = 190;

    str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+ width +'" height="'+ height +'"><param name="movie" value="' + swf + '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed wmode="transparent" src="' + swf + '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'"></embed></object>';

    document.write(str);
}

var ban_arquivo = '';
var ban_width   = '';
var ban_height  = '';
var ban_destino = '';
var ban_url = '';
var target ='_blank';

function print_swf_load_action() {
    str = '<a href="' + ban_url + '" target="'+target+'" id="link_img" style="cursor:pointer;"><img src="' + ban_arquivo + '" width="'+ ban_width +'" height="'+ ban_height +'"/></a><br/><div class="clear"></div><a style="font-size:14px" class="floatRight bold marginRight20 marginTop" href="javascript:void(0);" onclick="esconde_light()">Fechar</a>';

    document.getElementById(ban_destino).innerHTML = str;
}

function print_swf_load(swf, width, height, destino, url,target_)
{
    if(destino != ""){
        ban_arquivo = swf;
        ban_width = width;
        ban_height = height;
        ban_destino = destino;
        ban_url = url;
        target=target_;
        addEvent(window,'load',print_swf_load_action);
    }
    else {
        print_swf(swf, width, height );
    }
}

function esconde_light() {
    Element.hide('lightbox');
    new Effect.Fade('overlay', {
        duration: 0.2
    });
    $("overlay").style.display = 'none';
    $("BannerFloat").style.display = 'none';
}
/**
 * Escreve na página um objeto do tipo SWF
 *
 * @param swf arquivo para ser visualizado
 * @param width largura do clip
 * @param height altura do clip

function print_swf(swf, width, height )
{
    //swf = 'fla/banner_top.swf';
    //width = 726;
    //height = 190;

    str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+ width +'" height="'+ height +'"><param name="movie" value="' + swf + '" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed wmode="transparent" src="' + swf + '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'"></embed></object>';

    document.write(str);
}
*/
/**
 * Escreve conteúdo diverso na página
 *
 * @param str conteúdo a ser impresso na página
 */
function print_conteudo(str)
{
    document.write(str);
}

/*
function estiloForm()
{

	arrLabel = document.getElementsByTagName("label");
	
	
	for(i=0; i<arrLabel.length; i++)
	{
		var ele = arrLabel[i];
		
		strClass = ele.className;
		
		alert(strClass);
		
		arrClass = strClass.split(" ");
		
		for ( j=0; j<arrClass.length; j++ ) {
		
			if (arrClass[j] == 'labelItalico')
			{
				label = ele.getAttribute('innerHTML');
				
				alert(ele.getAttribute('for'));
				
				document.getElementById(ele.getAttribute('for')).setAttribute('value',label);
			}		
		}
	}
	
}

//addEvent (window, "load", estiloForm);
*/

/**
 * ao setar o foco do elemento
 */
function input_blur(ele)
{
    if(ele.value =='')
    {
        ele.value= ele.defaultValue;
        ele.className = 'c_ml input_news';
        ele.s='';
    }
}
function input_focus(ele)
{
	
    if(ele.s!='t')
    {
        ele.value='';
        ele.className = 'DefaultFont';
        ele.s='t';
    }
}

function input_pass(ele, alvo)
{	
	
    ele.style.display = 'none';
	
    eleAlvo = document.getElementById(alvo);
    eleAlvo.style.display = 'inline';
	
    input_focus(eleAlvo);
	
    eleAlvo.focus();
}

function input_pass_blur(ele, alvo)
{
    if(ele.value === '')
    {
        ele.style.display = 'none';
		
        eleAlvo = document.getElementById(alvo);
        eleAlvo.style.display = 'inline';
		
        input_blur(eleAlvo);
    }
	
}

function setaEstilo(ele, valor)
{
    ele.style.backgroundColor = '#000';
    ele.style.opacity = valor/100;
    ele.style.filter= "Alpha(opacity="+ valor +")";
}

function alphaElementos()
{
    //arrEle = $('pagina').getElementsBySelector(".efeito");
    arrEle = document.getElementsByTagName('span');
	
    for(i=0; i<arrEle.length; i++)
    {
        if(arrEle[i].className == "efeito")
            setaEstilo(arrEle[i], 50);
    /*
		arrEle[i].setStyle({
			backgroundColor: '#000',
			opacity: 0.5
		});
		*/
    }
}

addEvent(window,'load',alphaElementos);



function onFocusHandler_p(fld)
{
    fld.style.display = 'none';
    var fld2 = (document.getElementById) ? document.getElementById('password') : document.all['password'];
    fld2.style.display = 'inline';
    fld2.focus();
    return true;
}
function onBlurHandler_p(fld)
{
    if(fld.value === ''){
        fld.style.display = 'none';
        var fld2 = (document.getElementById) ? document.getElementById('fauxPassword') : document.all['fauxPassword'];
        fld2.style.display = 'inline';
    }
    return true;
}

function getOnChangeOrdenarProdutos()
{
    ele = document.getElementById('ordenar_produtos');
    ele.onchange = function()
    {
        document.getElementById("form_busca").submit();
    }
}

function getURL(url)
{
    window.location.href = url;
}

function display2(id)
{
    var ele;
    ele = document.getElementById(id);
    if(ele.style.display=='none'){
        ele.style.display='block';
    } else {
        hidden(id);
    }
}

function display_(id)
{
    var ele;
    var logo;
    ele = document.getElementById(id);
    logo = document.getElementById('logo_plano');
    if(ele.style.display=='none'){
        ele.style.display='block';
        logo.style.display='none';
    } else {
        hidden(id);
        logo.style.display='block';
    }
}

function hidden(id)
{
    document.getElementById(id).style.display='none';
}

function setaquantidade(check,idtext)
{
    if(check.checked == true)
        document.getElementById(idtext).value = "1";
    else
        document.getElementById(idtext).value = "";
}

function submit_form(form_id)
{				
    form = document.getElementById(form_id);
    form.action = site_url+"pedido/continuarComprando";
    form.submit();
}

function valida_form_cliente(nomeForm,nomeCampo1,nomeCampo2,nomeCampo3,nomeCampo4)
{

    elem1 = document.getElementById(nomeCampo1);
    elem2 = document.getElementById(nomeCampo2);
    elem3 = document.getElementById(nomeCampo3);
    elem4 = document.getElementById(nomeCampo4);
	
    if(elem1.value == "")
    {
        alert("Preencha o campo 'Nome/Raz�o'.");
    }
    else if(elem2.value == "")
    {
        alert("Preencha o campo 'Telefone'.");
    }
    else if(elem3.value == "")
    {
        alert("Preencha o campo 'Contato'.");
    }
    else if(elem4.value == "")
    {
        alert("Preencha o campo 'Email'.");
    }
    else
    {
        form = document.getElementById(nomeForm);
        form.submit();
    }
		
}

function valida_campo(nomeForm,idCampo)
{
    elem = document.getElementById(idCampo);
    if(elem.value == "")
        alert("Preencha o formul�rio corretamente.")
    else{
        form = document.getElementById(nomeForm);
        form.submit();
    }
}

function classDisplay(id) {

    var elem;

    elem = document.getElementById(id);
    
    var disp = elem.style.display;

    if(disp == 'none' || disp=="") {
        elem.style.display = "block";
    //Effect.toggle(id, 'appear');
    }
    else if(disp == 'block'){
        elem.style.display = "none";
    }

}

function mostraResultado(parm1,filial) {

    window.open(site_url+filial+"/enquete/mostraResultado/"+parm1, "_new","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=yes,width=210,height=280");
}

function hidden(id)
{
    document.getElementById(id).style.display='none';
}

function accordianInit ()
{
    accorianClients = document.getElementsByClassName('btnAcordion');
    for (i=0; i<accorianClients.length; i++) {
        accorianClients[i].setAttribute ('href', 'javascript:void(0);');
        accorianClients[i].onclick = function ()
        {
            Effect.toggle ('box_menu_'+this.getAttribute('id').substr(5), 'Blind', {
                duration:'0.4'
            });
        }
    }
}

addEvent (window, "load", accordianInit);


function openCurrent(id)
{    
    //Effect.toggle ('box_menu_' + id, 'Blind', {duration:'0.3'});
    $('box_menu_' + id).style.display = 'block';
}

function mostra_menu(at){
    var tags = document.getElementById(at).getElementsByTagName('li');
    for (var i=0; i<tags.length; i++){
        var tag = tags[i];
        var classe = tag.className;
        if (classe && classe == 'none'){
            tag.className = 'display';          
        } else if(classe && classe == 'display') {
            tag.className = 'none';            
        }
    }
}
