function slideSwitch() {
    var $active = $('#slide DIV.active');

    if ( $active.length == 0 ) $active = $('#slide DIV:last');

    // use this to pull the divs in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#slide DIV:first');

    // uncomment below to pull the divs randomly
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});



// ===================================================================================



function insereCart(formcart,produto,estoque)

	{

	if (estoque == "0" || estoque == "0.00")

		{

		if (!confirm("Esse item está sujeito a disponibilidade de estoque e pode ser comprado por encomenda sendo que seu prazo de entrega será superior ao prazo normal.\nConfirma a inclusão desse item em seu pedido?"))

			{

			return false;

			}

		}



	with (document.forms["formcart"+formcart])

		{

		prod.value=produto;

		submit();

		}

	}



// ===================================================================================



function ChecaEndereco()

	{

	with (document.forms["formend"])

		{

		if (cep.value!='')

			{

			frames['cepajusta'].location.href = 'loja_cep.php?cepdestino='+cep.value;

			c = document.getElementById('dadosendereco');

			if (c.style.display=='') { c.style.display='none'; }

			d = document.getElementById('dadosaguarde');

			if (d.style.display=='none') { d.style.display=''; }

			}

		}

	}



// ===================================================================================



function textCounter(field,countfield,maxlimit)

	{

	if (field.value.length > maxlimit)

		{

		field.value = field.value.substring( 0, maxlimit );

		alert('O texto só pode conter até '+maxlimit+' caracteres.');

		return false;

		}

	else

		{

		countfield.value=maxlimit-field.value.length;

		}

	}



// ===================================================================================



function ChecaPresente()

	{

	with (document.forms["formend"])

		{

		if (presente.value=="1")

			{

			document.getElementById('present').style.display='';

			}

		else

			{

			document.getElementById('present').style.display='none';

			}

		}

	}



// ===================================================================================



function TipoPessoa()

	{

	with (document.forms["formend"])

		{

		if (tp.value=="2")

			{

			razaosocial.disabled=false;

			cnpj.disabled=false;

			ie.disabled=false;

			razaosocial.value="";

			cnpj.value="";

			ie.value="";

			document.getElementById('pessjur1').style.display='';

			document.getElementById('pessjur2').style.display='';

			document.getElementById('pessjur3').style.display='';

			document.getElementById('pessfisi1').style.display='none';

			document.getElementById('pessfisi2').style.display='none';

			}

		if (tp.value=="1")

			{

			razaosocial.disabled=true;

			cnpj.disabled=true;

			ie.disabled=true;

			razaosocial.value="----";

			cnpj.value="----";

			ie.value="----";

			document.getElementById('pessjur1').style.display='none';

			document.getElementById('pessjur2').style.display='none';

			document.getElementById('pessjur3').style.display='none';

			document.getElementById('pessfisi1').style.display='';

			document.getElementById('pessfisi2').style.display='';

			}

		}

	}



// ===================================================================================



function showHide(id)

	{

	var obj = document.getElementById(id);

	if(obj.style.display == "")

		{

		obj.style.display = "none";

		}

	else

		{

		obj.style.display = "";

		 }

	}



// ===================================================================================



function TrocaConteudo(id,conteudo)

	{

	var obj = document.getElementById(id);

	obj.innerHTML = conteudo;

	}



function TrocaDIV(id1,id2)

	{

	var obj1 = document.getElementById(id1);

	var obj2 = document.getElementById(id2);

	obj1.innerHTML = obj2.innerHTML;

	}



objPRODIMG = 1;



function TrocaIMGPROD(id)

	{

	var obj = document.getElementById(id);

	showHide("imagem"+objPRODIMG);

	showHide("imagem"+id);

	objPRODIMG = id;

	}



// ===================================================================================














