   //variavel que indica qual scrolltop ira animar
    var scrollTop = {
        '#contato':691,
        '#servico':769,
        '#depoimentos':711,
        '#empresa':713,
        '#home':702
    };
    //milisegundos da animação do scrolltop
    var scrollTopSeconds = 1500;
    //milisegundos da animação dos clicks home empresa. ..
    var wrapperSeconds = 1000;
    
    
    function inspect( obj ) {
        if (typeof obj === "undefined") {
            return "undefined";
        }
        var _props = [];

        for ( var i in obj ) {
        if(i == 'innerHTML')
            continue;
        _props.push( i + " : " + obj[i] ); 
        }
        return " {" + _props.join( ",<br/\> " ) + "} ";
     }
	function getBody(){
		var B= document.body; //IE 'quirks'
		var D= document.documentElement; //IE with doctype
		D= (D.clientHeight)? D: B;
		return D;
	}
	function getOuterHeight(){
		if(typeof window.outerHeight!= 'undefined'){
			//most browsers
			return window.outerHeight;
		}
		else{
			var D = getBody();
			return D.outerHeight;
		}
	}
	function getScrollTop(){
        if(typeof pageYOffset!= 'undefined'){
            //most browsers
            return pageYOffset;
        }
        else{
            var D = getBody();
            return D.scrollTop;
        }
    }
	function getOuterWidth(){
		if(typeof window.outerWidth!= 'undefined'){
			//most browsers
			return window.outerWidth;
		}
		else{
			var D = getBody();
			return screen.availWidth;
		}
	}

	function getInnerHeight(){
		if(typeof window.innerHeight!= 'undefined'){
			//most browsers
			return window.innerHeight;
		}
		else{
			var D = getBody();
			return D.offsetHeight;
		}
	}

	function getInnerWidth(){
		if(typeof window.innerWidth!= 'undefined'){
			//most browsers
			return window.innerWidth;
		}
		else{
			var D = getBody();
			return D.offsetWidth;
			
		}
	}
	var minLeft = 188;
	var innerleft;
	if( screen.width > 1024){
		var widthWrapper = screen.width - 1 - ( parseInt(getOuterWidth()) - parseInt(getInnerWidth() ));
		innerleft = (( parseInt(screen.width) - 1024 ) / 2 ) - minLeft;
		$('#wrapper').css({'width':widthWrapper+'px'});
		$('#main').css({'left':innerleft+'px'});
	}else{
		$('#wrapper').css({'width':'1007px'});
		innerleft = (( parseInt(screen.width) - 1024 ) / 2 ) - minLeft;
		$('#main').css({'left':innerleft+'px'});
	}
    $(getBody()).css({'overflow-x':'hidden'});
	var divs = new Array(0, 1993, 3980, 5977, 7990);
	var qtdMovPainel = 93;
	var tempoMovPainel = 500;
	var qtdPainelImg = 3;
	var numPainelImg = $('#list-slide-business > li').length;
	var divLeftTest = ( numPainelImg > qtdPainelImg ) ?  -((numPainelImg - qtdPainelImg) * qtdMovPainel) : 0 ;
	$('#action-next').click(function(e){
		e.preventDefault();
		var divLeft = $('#list-slide-business').css('left');
		divLeft = parseInt(/-?\d+/.exec(divLeft));
		if (divLeft <= divLeftTest ){
			if ( numPainelImg > qtdPainelImg ){
			    divLeft += qtdMovPainel;
			    $('#list-slide-business').stop().css({'left':divLeft+'px'});
			    var firstChild = $('#list-slide-business > li').first()[0];
			    var lastChild = $('#list-slide-business > li').last()[0]
			    firstChild.parentNode.removeChild(firstChild);
			    lastChild.parentNode.appendChild(firstChild);			    
			    
				//$('#list-slide-business').stop().animate({'left':0+'px'}, tempoMovPainel,'easeOutCirc');
			}

		}
		divLeft = divLeft - qtdMovPainel;
		var newLeft = divLeft;
		$('#list-slide-business').stop().animate({'left':newLeft+'px'}, tempoMovPainel,'easeOutCirc');
	});

	$('#action-prev').click(function(e){
		e.preventDefault();
		e.stopPropagation();
		var divLeft = $('#list-slide-business').css('left');
		divLeft = parseInt(/-?\d+/.exec(divLeft));
		if (divLeft >= 0 ){
			if ( numPainelImg > qtdPainelImg ){
			    divLeft -=qtdMovPainel;
			    $('#list-slide-business').stop().css({'left':divLeft+'px'});
			    var firstChild = $('#list-slide-business > li').first()[0];
			    var lastChild = $('#list-slide-business > li').last()[0]
			    firstChild.parentNode.removeChild(lastChild);
			    firstChild.parentNode.insertBefore(lastChild, firstChild);
			}

		}
		divLeft = divLeft + qtdMovPainel;
		var newLeft = (divLeft > 0) ? 0 : divLeft ;
		$('#list-slide-business').stop().animate({'left':newLeft+'px'}, tempoMovPainel);
	});

	/*$('#nav-service').click(function(e){
		e.preventDefault();
		$('#wrapper').css({'height':'1350px'});
	});*/
	var listNum = {};
	$('.list-iten').each(function(index, value){
	    
	    listNum[$(value).children().attr('href')] = index;
		$(value).children().click(function(e){
		    var hash = $(this).attr('href');
		    if (!($.browser.msie)){
                e.stopPropagation();
    		    e.preventDefault();     
            if (Modernizr.history){
	       	        history.pushState(foo, '', hash);
	       	        }
	        $(window).trigger('hashchange');
	        }else{
                e.stopPropagation();
                e.preventDefault();
	                //$(window).trigger('hashchange');
	                animaParaMSIE7(hash); 
	        }
	        
	        /*if ($.browser.msie){
	            numList = listNum[hash];
			    if(hash == '#servico')
			        $('#wrapper').css({'height':'1350px'});
			    else
				    $('#wrapper').css({'height':'1000px'});        
        	    $('.list-iten').each(function(){
				    $(this).children('a').removeClass('active');
			    });
			    $($('.list-iten')[numList]).children('a').addClass('active');
			    newLeft = -(divs[numList]) + innerleft;
			    $('#main').animate({'left':newLeft+'px'});
	        
	        };*/
		});
	});
	function animaParaMSIE7(hash){
	    alteraTitulo(hash);
	    var numList = listNum[hash];
		if (hash == '#empresa'){
			    var newWdt = 0;
			    var minheight = 1000;
			    var heightAux = parseInt($('#article-business').css('height').replace('px',''));
			    newWdt += heightAux;
			    newWdt += 660;
			    newWdt = Math.max(minheight, newWdt);
			    $('#wrapper').css({'height':newWdt+'px'});
			}
			else if (hash == '#depoimentos'){
			    //var newWdt = parseInt($('#testimony-inner').css('height').replace(/px/,'')) - 330;
			    //o nome dessa variavel era pra ser newHdt de altura =x
			    var newWdt = 0;
			    var minheight = 1000;
			    var heightAux = parseInt($('#testimony .content').css('height').replace('px',''));

			    newWdt += heightAux;
			    newWdt += 640;
			    newWdt = Math.max(minheight, newWdt);
			    $('#wrapper').css({'height':newWdt+'px'});
			    }
                else if (hash == '#contato')
                    $('#wrapper').css({'height':'1071px'});
                else if (hash == '#servico'){
                    var newWdt = 0;
			        var minheight = 1000;
			        var heightAux = parseInt($('#services-inner .content').css('height').replace('px',''));

			        newWdt += heightAux;
			        newWdt += 640;
			        newWdt = Math.max(minheight, newWdt);
			        
			        $('#wrapper').css({'height':newWdt+'px'});
                    
                } else
			        $('#wrapper').stop().animate({'height':'1000px'});
	    $('.list-iten').each(function(){
			$(this).children('a').removeClass('active');
		});
		$($('.list-iten')[numList]).children('a').addClass('active');
		var newLeft = -(divs[numList]) + innerleft;
		$('#main').animate({'left':newLeft+'px'}, wrapperSeconds, function(){
                //tres linhas
			    var thisScrollTop = scrollTop[hash]
                if (hash != '#home')
			    $('html,body').stop().animate({scrollTop:thisScrollTop+'px'}, scrollTopSeconds);
			});
	}
	var foo = {'foo':'bar'}
	var listTitle={
	    '#home':'Combate Segurança - Aqui é seguro',
	    '#empresa':'Empresa - Combate Segurança',
	    '#depoimentos':'Depoimentos - Combate Segurança',
	    '#servico':'Serviços - Combate Segurança',
	    '#contato':'Contato - Combate Segurança'
	}
	function alteraTitulo(hash){
	        var title = listTitle[hash];
	        if (title == undefined)
	            document.title = listTitle['#home'];
	        else
    	        document.title = title;
	}
    $(window).bind({
	    hashchange: function(e){
	        //if (!($.browser.version == 7.0))
	        //    return false;
	        e.preventDefault();
	        //nao pega no moz
	        //alert(location.hash);
	        var hash = location.hash;
	        //alert(hash);
	        if (location.hash == '' || location.hash == undefined)
	            hash = '#home';
            alteraTitulo(hash);
	        var numList = listNum[hash];

			if (hash == '#empresa'){
			    var newWdt = 0;
			    var minheight = 1000;
			    var heightAux = parseInt($('#article-business').css('height').replace('px',''));
			    newWdt += heightAux;
			    newWdt += 660;
			    newWdt = Math.max(minheight, newWdt);
			    $('#wrapper').css({'height':newWdt+'px'});
			}
			else if (hash == '#depoimentos'){
			    //var newWdt = parseInt($('#testimony-inner').css('height').replace(/px/,'')) - 330;
			    //o nome dessa variavel era pra ser newHdt de altura =x
			    var newWdt = 0;
			    var minheight = 1000;
			    var heightAux = parseInt($('#testimony .content').css('height').replace('px',''));

			    newWdt += heightAux;
			    newWdt += 640;
			    newWdt = Math.max(minheight, newWdt);
			    $('#wrapper').css({'height':newWdt+'px'});
			    }
                else if (hash == '#contato')
                    $('#wrapper').css({'height':'1071px'});
                else if (hash == '#servico'){
                    var newWdt = 0;
			        var minheight = 1000;
			        var heightAux = parseInt($('#services-inner .content').css('height').replace('px',''));

			        newWdt += heightAux;
			        newWdt += 640;
			        newWdt = Math.max(minheight, newWdt);
			        
			        $('#wrapper').css({'height':newWdt+'px'});
                    
                } else
			        $('#wrapper').stop().animate({'height':'1000px'});
        	    $('.list-iten').each(function(){
				    $(this).children('a').removeClass('active');
			    });
			$($('.list-iten')[numList]).children('a').addClass('active');
			var newLeft = -(divs[numList]) + innerleft;
    			$('#main').animate({'left':newLeft+'px'}, wrapperSeconds, function(){
                //tres linhas
			    var thisScrollTop = scrollTop[hash]
                if (hash != '#home')
			    $('html,body').stop().animate({scrollTop:thisScrollTop+'px'}, scrollTopSeconds);
			});
			
			 
	    }
    });
    $(window).trigger('hashchange');

