$(document).ready(function(){
    $(".tableLojas .nomeLoja:even").addClass("contTras2");
    $(".detalhes01:even").addClass("contTras2");

    $('.scroll-by-demo').bind(
        'click',
        function()
        {
            $('#pane1')[0].scrollBy(parseInt($(this).attr('rel')));
            return false;
        }
    );

	$(".linkDestaqueBanner a:first").addClass("on")
	$(".linkDestaqueBanner a").click(function(){
		$(".linkDestaqueBanner a.on").removeClass("on")
		$(this).addClass("on")
	})	
    $(".cntGlossario ul il a:first").addClass("on")
    $(".cntGlossario ul li a").click(function(){
	    $(".cntGlossario ul li a.on").removeClass("on")
	    $(this).addClass("on")
    });	
		var url = "http://twitter.com/status/user_timeline/hwcollectorsbr.json?count=4&callback=?";
		$.getJSON(url,function(data){
			$(".cntTwitter h4").append("<a href='http://twitter.com/hwcollectorsbr' target='_blank'>@hwcollectorsbr</a>"); 
			$.each(data, function(i, item) {
				$("#tweets ul").append("<li class='cntTrans'>" + item.text.linkify() + "</span></li>");
			});
        });
		String.prototype.linkify = function() {
				return this.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
				return m.link(m);
			});		
		}; 
	 
        $("#thumbs a:first").addClass("ativo");
        
        var largePath = $("#thumbs a:first").attr('href');
        var largeAlt = $("#thumbs a:first").find('img').attr('alt');
        
        $("#largeImg").attr({src: largePath, alt: largeAlt});
    
        $("#largeImg").click(function(){  
            if ($("#thumbs a:last-child").is(".ativo")){
                $("#thumbs a:first").addClass("ativo");
                $("#thumbs a:last").removeClass("ativo");
                
                var largePath = $(".ativo").attr('href');
                var largeAlt = $(".ativo").find('img').attr('alt');
                $("#largeImg").attr({src: largePath, alt: largeAlt});
            }else{$(".ativo").toggleClass("ativo").next("#thumbs a").addClass("ativo");
            
            	var largePath = $(".ativo").attr('href');
                var largeAlt = $(".ativo").find('img').attr('alt');

                $("#largeImg").attr({src: largePath, alt: largeAlt});}
         });
        
        $('#thumbs a').click(function(){
            
            $(this).siblings(".ativo").removeClass("ativo");
            $(this).addClass("ativo");
            
            var largePath = $(this).attr('href');
            var largeAlt = $(this).find('img').attr('alt');
            
            $("#largeImg").attr({src: largePath, alt: largeAlt });
            return false;

    });     

});

function twitter_callback ()
{
	return true;
}
    function conhecaHw(){
        var urlconheca =location.search.split("?id=")
        var quebraconheca = urlconheca[0].split("#")
        //alert(urlconheca[1])
            if(quebraconheca == 1){
                $("#1").addClass("displayBlock")
            }else if(quebraconheca == 4){
                $("#4").addClass("displayBlock")
            }else{
                $("#6").addClass("displayBlock")
            }
    }


function layer(lay){
	for(i=1;i< 5;i++){
		if(i == lay){
			document.getElementById(i).style.display="block";
		}else{
			document.getElementById(i).style.display="none";
		}
	}	
}

function layer2(lay2){
    for(i=1;i<27;i++){
        if(i==lay2){
            document.getElementById(i).style.display = "block"
        }else{
            document.getElementById(i).style.display = "none"
        }
    }
}

				        
function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
    var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "counttxt";
    var countBody = opt_countBody ? opt_countBody : "countBody";
    var maxSize = opt_maxSize ? opt_maxSize : 300;
    var field = document.getElementById(countedTextBox);
    if (field && field.value.length >= maxSize) {
        field.value = field.value.substring(0, maxSize);
    }
    var txtField = document.getElementById(countBody);
    if (txtField) {
        txtField.innerHTML = maxSize - field.value.length;
    }
}
  
/*Home*/
function abreplano(id){
	//fechaplano();
	var plano = getById('plano'+id);
	plano.className = 'aberto';
}
function fechaplano(total){
    //Lojas ONLINE
    if(total == "9995"){
		var plano = getById('plano9995');
		plano.className = 'fechado';
    }else if(total == "9996"){
		var plano = getById('plano9996');
		plano.className = 'fechado';
    }else{
       for(var i=1; i <= total; i++){
		    var plano = getById('plano'+i);
		    plano.className = 'fechado';
        }
    
    }
}


function getById($id){
	if(document.getElementById){
		return document.getElementById($id);
	}else if(document.all){
		return document.all.$id;
	}else{
		return false;
	}
}

function mudaCampo(maxTam,idAtual,proxCampo){
	if (document.getElementById(idAtual).value.length >= maxTam){
	 document.getElementById(proxCampo).focus();
	}
}

    var _ptc="p";
    function showhide(bln) {
    var _div = document.getElementById('dvPDF');
	if(_div){
		if(bln)
			_div.style.display = "";
		else
			_div.style.display = "none";
	}
	
    }
   
   
    function windowOpener(url,width,height,name,scrolls) { 
		browserName = navigator.appName; 
        browserVer = navigator.appVersion.substring(0,1);
        if (scrolls==true) { 
                scrollsOption="yes"; 
        } else { 
                scrollsOption="no"; 
        } 
        var l = ( (window.screen.width - width) / 2 );
		var t = ( (window.screen.height - height) / 2 );
		if (browserName != "Netscape" || browserVer != 2) { 
                controlWindow=window.open( 
                url,name,"toolbar=no,height="+height+",width="+width+",location=no,directories=no,status=no,menubar=no,top="+t+",left="+l+",screenX="+l+",screenY="+t+",scrollbars="+scrollsOption+",resizable=no" 
                ); 
        } 
	} 
    function popupsaindosite(urlAbrir,tipo) {
	    windowOpener('pop_out.htm?url='+urlAbrir+'',549,380,'pop',false);
		//urchinTracker('/ondecomprar/popOut/'+tipo+'/'+urlAbrir+'');
    }
   
   function GetPDF(Titulo){
		var cep = document.getElementById('icep').value; 
		if(cep.length <5){
			 cep = ''; 
		}
		var elcidade = document.getElementById('ddl_cidade');
		var elestado = document.getElementById('ddl_estado');
		var elbairro = document.getElementById('ddl_bairro');
		var cidade = ''; 
		var estado = ''; 
		var bairro = ''; 
		if(elestado.selectedIndex > 0) {
			
			estado = elestado.options[elestado.selectedIndex].text; 
		}
		if(elcidade.selectedIndex > 0){
			cidade = elcidade.options[elcidade.selectedIndex].text;
		}
		if(elbairro.selectedIndex > 0) {
			 bairro = elbairro.options[elbairro.selectedIndex].text;
		}

		//alert(cidade + ' ' + estado + ' ' + bairro + ' ' + cep); 
	    windowOpener('criapdf_db.asp?cep=' + cep + '&cidade=' + cidade + '&estado=' + estado + '&bairro=' + bairro + '&titulo=' + Titulo,800,600,'pop',false); 

   
   }
   


