function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

$(document).ready(function(){ 
	$('.box_lojas').mouseover(function() {
		$(this).animate({ backgroundColor: "#ffffff" }, 150, function(){
			$(this).animate({ backgroundColor: "#262626" }, 150, function(){
				$(this).animate({ backgroundColor: "#666666" }, 150, function(){
					$(this).animate({ backgroundColor: "#262626" }, 150);
				});
			});
		});
		$(this).clearQueue();
	});
	
	$('.fotos').mouseover(function() {
		$(this).css('zIndex', 10);
		$(this).children('img').css({'width': '108px', 'height': '82px', 'borderWidth': '5px'});
		$(this).children('p').css('display','block');
	});

	$('.fotos').mouseout(function() {
		$(this).css('zIndex', 1);
		$(this).children('img').css({'width': '55px', 'height': '42px', 'borderWidth': '2px'});
		$(this).children('p').css('display','none');
	});
	
});

var duvidaAtual;
function mudaDuvida(proxima){
	if (duvidaAtual == proxima){ return; }
	$('#dv_'+duvidaAtual).css('display','none');
	$('#dv_'+proxima).css('display','block');
	duvidaAtual = proxima;
}

function criaPaginacao(tableName, itemsPerPage){
    this.tableName = tableName;
    this.itemsPerPage = itemsPerPage;
    this.currentPage = 1;
    this.pages = 0;

    this.init = function() {
        var rows = document.getElementById(tableName).rows;
        var records = rows.length;
        this.pages = Math.ceil(records / itemsPerPage);
        if (this.itemsPerPage>=this.pages)
           document.getElementById('pagingAll').style.display = 'none';
        else{
            document.getElementById('pagingAll').style.display = 'block';
            document.getElementById('pagingVolta').style.display = 'none';
            document.pagingForm.pagingAtual.value = this.currentPage;
            document.pagingForm.pagingAtual.size = document.pagingForm.pagingAtual.value.length;
            document.pagingForm.pagingTotal.value = this.pages;
            document.pagingForm.pagingTotal.size = document.pagingForm.pagingTotal.value.length;
            this.showPage(this.currentPage);
        }
    }
    
    this.showPage = function(pageNumber) {
        if (pageNumber==1)
            document.getElementById('pagingVolta').style.display = 'none';
        else
            document.getElementById('pagingVolta').style.display = 'block';
        if (pageNumber==this.pages)
            document.getElementById('pagingVai').style.display = 'none';
        else
            document.getElementById('pagingVai').style.display = 'block';

        var from = (pageNumber - 1) * itemsPerPage;
        var to = from + itemsPerPage - 1;
        var rows = document.getElementById(tableName).rows;
        // i starts from 1 to skip table header row
        for (var i = 0; i < rows.length; i++) {
            if (i < from || i > to)
                rows[i].style.display = 'none';
            else
                rows[i].style.display = '';
        }
        this.currentPage = pageNumber;
        document.pagingForm.pagingAtual.value = this.currentPage;
        document.pagingForm.pagingAtual.size = document.pagingForm.pagingAtual.value.length;
    }
    
    this.prev = function() {
        if (this.currentPage > 1)
            this.showPage(this.currentPage - 1);
    }
    
    this.next = function() {
        if (this.currentPage < this.pages) {
            this.showPage(this.currentPage + 1);
        }
    }
}

