	function carregado(target) {
		var target = !target?'':target;
		try{
			if(target) {
				$(target).unblock();
			} else {
				$().unblock();
			}
		} catch(e) {
			
		}
	}
	function carregando(target,msg) {
		var target = !target?'':target;
		var msg = !msg?'':msg;
		
		if(target) {
			$(target).ready(function(){
				if(msg) {
					$(target).block({message:msg});
				} else {
					$(target).block();
				}
			});
		} else {
			if(msg) {
				$.blockUI({message:msg});
			} else {
				$.blockUI();
			}
		}	
	}
	$().ajaxStart(function(ev){
		
	});
	$().ajaxComplete(function(ev, xhr, s) { 
		carregado();
	});
	$().ajaxStop(function(ev){
		carregado();
	});
	$().ajaxError(function(ev){
		carregado();
	});
	$().ajaxSuccess(function(ev){
		carregado();
	});
	$().ajaxSend(function(request, settings){
		//carregando(Loading.msg);
	});


function replaceVars(htmlReplace) {
	var htmlTMP = htmlReplace;
	htmlTMP = replaceSubstring(htmlTMP,"{tplUrlFilesRoot}",tplUrlFilesRoot);
	htmlTMP = replaceSubstring(htmlTMP,"%7BtplUrlFilesRoot%7D",tplUrlFilesRoot);
	return htmlTMP;
}	
	
var htmlTemplate = new Array();
function callOnAppend (){
	monta__BNRTPL__PRODUTOS();
	monta__BNRTPL__FORMCONTATO();
}

function contaOcorrencias(frase,sub) {
	var frase = frase+'';
	var sub = sub+'';
	var cont = 0;
	
	for(i = 0; i < (frase.length - sub.length + 1); i++){
		var res = frase.substring(i, (i + sub.length));
		if(res+''==sub+''){
			cont++;
		}
	}

	return cont;
}

function onerrorimg(ob) {
	var strSrc = $(ob).attr('src')+'';
	var totalOcorr = contaOcorrencias(strSrc,'http');
	var pos = strSrc.indexOf('http',totalOcorr);
	if(pos>1) {
		var srcNew = strSrc.substring(pos,strSrc.length);
		$(ob).attr('src',srcNew);
		$(ob).removeAttr('onerror');
		$(ob).attr('onerror','$(this).remove()');
	}
}

var append = function(parent, child, onAppend) {
  //parent.appendChild(child);
  
  $(parent).append(child);
  $('img').each(function () {
	var img = $(this);
	$(this).attr('onerror','onerrorimg(this)');
  });
  
        // $('img').error(function () {
            // // notify the user that the image could not be loaded
			// alert('')
			// var strSrc = $(this).attr('src')+'';
			
			// var frase = "Programar em Java só é melhor que programar em Java e Java é bom demais";
			// var sub = "Java"; // ocorrências de "Java"
			// var cont = 0;
			// for(i = 0; i < (frase.length() - sub.length() + 1); i++){
				// var res = frase.substring(i, (i + sub.length()));
				// if(res.equals(sub)){
					// cont++;
				// }
			// }
    
			// alert("A frase contem " + cont + " ocorrencias de " + sub);

		// }).attr('src', '-');
		
  
  var htmlOriginal = $(parent).html();
  var htmlReplaced = replaceVars(htmlOriginal);
  $(parent).html(htmlReplaced);
  
  if (onAppend) onAppend(child);
  callOnAppend();
}

var after = function(parent, child, onAppend) {
  //parent.appendChild(child);
  $(parent).after(child);
  if (onAppend) onAppend(child);
  callOnAppend();
}


$(function(){
	var objTPage = $('#tpl_page');
	var attrID = $(objTPage).attr('id')+'';
	var html = $(objTPage).text();
	
	
	
	
	var jTemplate = $(objTPage);
	try {
		var jElement = jTemplate.template(
								eval( "(" + jValues + ")" )
							);
		
		$(objTPage).before(jElement);
		$(objTPage).remove();
	} catch(e) {
		
	}
	

	
	
	
	$('.box_tplVARS').each(function(){
		$(this).find('.tpl').each(function(){
			var attrID = $(this).attr('id')+'';
			var html = $(this).text();

			
			
			var jTemplate = $(this);
			var boOk = $('.'+attrID).size();
			//if(jTemplate.is('div')) {
			if(boOk) {
				//alert(attrID + ' = ' + html)
				var jElement = jTemplate.template(
										eval( "(" + jValues + ")" )
									);
				
				var className = attrID;
				
				$('.'+className).before(jElement);
				$('.'+className).remove();
			}
			
			//htmlTemplate[attrID] = html;
		});
		
		$('.box_tplVARS').remove();
		

	});
	
	
		
	$('.logo a').focus(function(){
		$(this).blur();
	});
	
	$('a[param=home],a[param=destaques],a[param=lancamentos],a[param=promocoes],a[param=produtos_todos],a[param=contato],a[param=faq],a[param=pedidos],a[param=cadastro]').each(function(){
		var param = $(this).attr('param');
		switch(param) {
			case 'home' :
					$(this).attr('href','');
				break;
			case 'destaques' :
					$(this).attr('href','produtos/lista/destaques/1');
				break;
			case 'lancamentos' :
					$(this).attr('href','produtos/lista/lancamentos/1');
				break;
			case 'promocoes' :
					$(this).attr('href','produtos/lista/promocoes/1');
				break;
			case 'produtos_todos' :
					$(this).attr('href','produtos/');
				break;
			case 'contato' :
					$(this).attr('href','contato/');
				break;
			case 'faq' :
					$(this).attr('href','paginas/faq');
				break;
			case 'pedidos' :
					$(this).attr('href','pedidos');
				break;
			case 'cadastro' :
					$(this).attr('href','cadastro');
				break;
		}
	});
	
	$('.__BNRTPL__NAVIGATION').each(function(){

	});	

	
	

	//populaCombo(obj_sel_secoes,globals_arrDadosDB['secoes'],'idSecao','Nom_Secao');
	
	
	if(!$('#column_right + .sidebar:not(:has(*))').size()) {
		//$('#column_right').remove();
	}
	
	

	
	$('.__BNRTPL__SECOES').each(function(){
		if($(this).is('[class*=mcdropdown]')) {
			var obj_searchFilter = $('.mcdropdown');
			//populaCombo(obj_sel_secoes,globals_arrDadosDB['secoes'],'idSecao','Nom_Secao');
			dropDownCategorias(this);
		} else if($(this).is('[class*=menubar]')) {
			var strHTML = display_secoes_sidebar(globals_arrDadosDB['secoes']);
			$(this).append(strHTML);
			// var objDIV = document.createElement('div');
			// var objUL = document.createElement('ul');
			
			// $(objUL).attr('id','manubar');
			
			// $(objDIV).append(strHTML);
			// $(objUL).append($(objDIV).find('ul:eq(0)').html());
			
			// $(this).append(objUL);
	
			//loadMenuBar(this,globals_arrDadosDB['secoes']);
		} else {
			
		}
	});
			function pageselectCallback(page_index, jq){
                // Get number of elements per pagionation page from form
                // var items_per_page = $('#items_per_page').val();
                // var max_elem = Math.min((page_index+1) * items_per_page, members.length);
                // var newcontent = '';

                
                // Prevent click eventpropagation
                return false;
            }

	
	
	monta__BNRTPL__PRODUTOS ();
	monta__BNRTPL__VIDEOS ();
	


	
	$('.__BNRTPL__FABRICANTES').each(function(){
		if($(this).is('select')) {
			populaCombo(this,globals_arrDadosDB['fabricantes'],'idFabricante','Nom_Fabricante');
			$(this).bind('change',function(){
				var id = $(this).val();
				if(id+''!='') {
					txtOption = $($(this).find('option').get(this.selectedIndex)).html();
					document.location.href = 'produtos/lista/idfabricante/'+id+'/nomefabricante/'+txtOption;
					//document.location.href = 'produtos/lista/nomefabricante/'+txtOption;
				}
			});
		} else {
			
		}
	});
	
	$('.__BNRTPL__PAGINAS').each(function(){
		var objArr = globals_arrDadosDB['paginas'];
		var html = '<ul style="margin: 0; padding: 0; list-style-type: none;">'; 
		for(i in objArr) {
			html+='<li><a href="paginas/index/idpagina/'+objArr[i]['idPagina']+'">'+objArr[i]['Nom_Pagina']+'</a></li>'
		}
		html+='</ul>';
		$(this).append(html);
	});
	
	
	
});

	function sizeof(arg) { var total=0;for(i in arg){total++;} return total; }
	function array(arg) { return new Array(); }
	function is_array(arg) { return (typeof arg == 'array' || typeof arg == 'object' ||  arg.constructor == Array); }
	function is_object(arg) { return ( typeof arg == 'object' ); }

	function isFunction(arg) { return (typeof arg == 'function'); }
	function unset(arg) { arg = null; }
	function str_repeat(str, i) { if (isNaN(i) || i <= 0) return ""; return str + str_repeat(str, i-1); }
	function strlen(arg) { var arg = arg+''; return arg.length; }
	function isset(arg) { return arg?true:false; }
	function explode(str,arg) { var arg = arg+''; return arg.split(str); }
	function isVisible(arg) { return ( !$(arg).is(':visible') || $(arg).is(':hidden') || $(arg).parents(':hidden').length); }
	function strtoupper(arg) { var arg = arg+''; return (arg.toUpperCase()); }
	
	function number_format(number,decimals,dec_point,thousands_sep){var n=number,prec=decimals;n=!isFinite(+n)?0:+n;prec=!isFinite(+prec)?0:Math.abs(prec);var sep=(typeof thousands_sep=="undefined")?',':thousands_sep;var dec=(typeof dec_point=="undefined")?'.':dec_point;var s=(prec>0)?n.toFixed(prec):Math.round(n).toFixed(prec);var abs=Math.abs(n).toFixed(prec);var _,i;if(abs>=1000){_=abs.split(/\D/);i=_[0].length%3||3;_[0]=s.slice(0,i+(n<0))+_[0].slice(i).replace(/(\d{3})/g,sep+'$1');s=_.join(dec);}else{s=s.replace('.',dec);}return s;}
	function strip_tags(str,allowed_tags){var key='',allowed=false;var matches=[];var allowed_array=[];var allowed_tag='';var i=0;var k='';var html='';var replacer=function(search,replace,str){return str.split(search).join(replace);};if(allowed_tags){allowed_array=allowed_tags.match(/([a-zA-Z]+)/gi);}str+='';matches=str.match(/(<\/?[\S][^>]*>)/gi);for(key in matches){if(isNaN(key)){continue;}html=matches[key].toString();allowed=false;for(k in allowed_array){allowed_tag=allowed_array[k];i=-1;if(i!=0){i=html.toLowerCase().indexOf('<'+allowed_tag+'>');}if(i!=0){i=html.toLowerCase().indexOf('<'+allowed_tag+' ');}if(i!=0){i=html.toLowerCase().indexOf('</'+allowed_tag);}if(i==0){allowed=true;break;}}if(!allowed){str=replacer(html,"",str);}}return str;}
	
	function get_html_translation_table(table,quote_style){var entities={},histogram={},decimal=0,symbol='';var constMappingTable={},constMappingQuoteStyle={};var useTable={},useQuoteStyle={};useTable=(table?table.toUpperCase():'HTML_SPECIALCHARS');useQuoteStyle=(quote_style?quote_style.toUpperCase():'ENT_COMPAT');constMappingTable[0]='HTML_SPECIALCHARS';constMappingTable[1]='HTML_ENTITIES';constMappingQuoteStyle[0]='ENT_NOQUOTES';constMappingQuoteStyle[2]='ENT_COMPAT';constMappingQuoteStyle[3]='ENT_QUOTES';if(!isNaN(useTable)){useTable=constMappingTable[useTable];}if(!isNaN(useQuoteStyle)){useQuoteStyle=constMappingQuoteStyle[useQuoteStyle];}if(useTable=='HTML_SPECIALCHARS'){entities['38']='&amp;';if(useQuoteStyle!='ENT_NOQUOTES'){entities['34']='&quot;';}if(useQuoteStyle=='ENT_QUOTES'){entities['39']='&#039;';}entities['60']='&lt;';entities['62']='&gt;';}else if(useTable=='HTML_ENTITIES'){entities['38']='&amp;';if(useQuoteStyle!='ENT_NOQUOTES'){entities['34']='&quot;';}if(useQuoteStyle=='ENT_QUOTES'){entities['39']='&#039;';}entities['60']='&lt;';entities['62']='&gt;';entities['160']='&nbsp;';entities['161']='&iexcl;';entities['162']='&cent;';entities['163']='&pound;';entities['164']='&curren;';entities['165']='&yen;';entities['166']='&brvbar;';entities['167']='&sect;';entities['168']='&uml;';entities['169']='&copy;';entities['170']='&ordf;';entities['171']='&laquo;';entities['172']='&not;';entities['173']='&shy;';entities['174']='&reg;';entities['175']='&macr;';entities['176']='&deg;';entities['177']='&plusmn;';entities['178']='&sup2;';entities['179']='&sup3;';entities['180']='&acute;';entities['181']='&micro;';entities['182']='&para;';entities['183']='&middot;';entities['184']='&cedil;';entities['185']='&sup1;';entities['186']='&ordm;';entities['187']='&raquo;';entities['188']='&frac14;';entities['189']='&frac12;';entities['190']='&frac34;';entities['191']='&iquest;';entities['192']='&Agrave;';entities['193']='&Aacute;';entities['194']='&Acirc;';entities['195']='&Atilde;';entities['196']='&Auml;';entities['197']='&Aring;';entities['198']='&AElig;';entities['199']='&Ccedil;';entities['200']='&Egrave;';entities['201']='&Eacute;';entities['202']='&Ecirc;';entities['203']='&Euml;';entities['204']='&Igrave;';entities['205']='&Iacute;';entities['206']='&Icirc;';entities['207']='&Iuml;';entities['208']='&ETH;';entities['209']='&Ntilde;';entities['210']='&Ograve;';entities['211']='&Oacute;';entities['212']='&Ocirc;';entities['213']='&Otilde;';entities['214']='&Ouml;';entities['215']='&times;';entities['216']='&Oslash;';entities['217']='&Ugrave;';entities['218']='&Uacute;';entities['219']='&Ucirc;';entities['220']='&Uuml;';entities['221']='&Yacute;';entities['222']='&THORN;';entities['223']='&szlig;';entities['224']='&agrave;';entities['225']='&aacute;';entities['226']='&acirc;';entities['227']='&atilde;';entities['228']='&auml;';entities['229']='&aring;';entities['230']='&aelig;';entities['231']='&ccedil;';entities['232']='&egrave;';entities['233']='&eacute;';entities['234']='&ecirc;';entities['235']='&euml;';entities['236']='&igrave;';entities['237']='&iacute;';entities['238']='&icirc;';entities['239']='&iuml;';entities['240']='&eth;';entities['241']='&ntilde;';entities['242']='&ograve;';entities['243']='&oacute;';entities['244']='&ocirc;';entities['245']='&otilde;';entities['246']='&ouml;';entities['247']='&divide;';entities['248']='&oslash;';entities['249']='&ugrave;';entities['250']='&uacute;';entities['251']='&ucirc;';entities['252']='&uuml;';entities['253']='&yacute;';entities['254']='&thorn;';entities['255']='&yuml;';}else{throw Error("Table: "+useTable+' not supported');return false;}for(decimal in entities){symbol=String.fromCharCode(decimal);histogram[symbol]=entities[decimal];}return histogram;}
	function htmlspecialchars(string,quote_style){ if(string==null) return '';var histogram={},symbol='',tmp_str='',entity='';tmp_str=string.toString();if(false===(histogram=get_html_translation_table('HTML_SPECIALCHARS',quote_style))){return false;}for(symbol in histogram){entity=histogram[symbol];tmp_str=tmp_str.split(symbol).join(entity);}return tmp_str;}
	
	function trataString(arg) { return replaceSubstring(arg,"\n",' ') }
	function ceil(value){return Math.ceil(value);}
	
	
	var AbstractVideo = function() {
		this.id = '';
		this.nome;
		this.foto = new Array();
		this.chamada;
		this.resumo;
		this.descricao;
		this.urlFoto;
		this.urlVideo;
		this.link_detalhe;
		
		this.arrDados = new Array();
		this.pub_arrParams = new Array();
		this.__construct = function() {
			this.foto['min'] = '';
			this.foto['pqn'] = '';
			this.foto['gnd'] = '';
			this.foto['big'] = '';
			
			this.pub_arrParams['bo_ativo'] = true;
			this.pub_arrParams['bo_imagemprincipal'] = false; 
		}
		
		this.setID = function($id) { this.id = $id; }
		this.GetID = function() { return this.id; }
			
		this.setNome = function($nome) { var $nome = !$nome?'':$nome; this.nome = $nome; }
		this.GetNome = function () { return this.nome; }

		this.setLinkDetalhe = function () { this.link_detalhe = 'videos/detalhe/idvideo/'+this.GetID(); }
		this.GetLinkDetalhe = function () { return this.link_detalhe; }
		
		
		
		this.setFoto = function () {
			this.pub_arrParams['bo_imagemprincipal'] = false; 
			if(this.arrDados['Dsc_ImagemPrincipalExtensao']+''!='') {
				this.pub_arrParams['bo_imagemprincipal'] = true; 
				
				$idAUX = str_repeat('0',9-strlen(this.id))+this.id;
				$urlFOLDER = ARQ_URL_PRODUTOS + "/"+$idAUX+"/"+$idAUX+"";
				
				this.foto['min'] = $urlFOLDER + '_0.jpg';
				this.foto['pqn'] = $urlFOLDER + '_1.jpg';
				this.foto['gnd'] = $urlFOLDER + '_2.jpg';
				this.foto['big'] = $urlFOLDER + '_3.jpg';
			}
		}
		
		this.GetFoto = function ($cs) {
			var $cs = !$cs?'':$cs;
			return this.foto[$cs];
		}
		
		this.setChamada = function ($chamada) { var $chamada = !$chamada?'':$chamada; this.chamada = $chamada; }
		this.GetChamada = function () { return this.chamada; }
		
		this.setDescricao = function ($descricao) { var $descricao = !$descricao?'':$descricao; this.descricao = $descricao; }
		this.GetDescricao = function () { return this.descricao; }
		
		this.setUrlVideo = function ($url) { var $url = !$url?'':$url; this.urlVideo = $url; }
		this.GetUrlVideo = function () { return this.urlVideo; }
		
		this.setUrlFoto = function ($url) { var $url = !$url?'':$url; this.urlFoto = $url; }
		this.GetUrlFoto = function () { return this.urlFoto; }
		
		this.setResumo = function ($resumo) { 
			var $resumo = !$resumo?'':$resumo;
			$resumo = $resumo+''=='' || $resumo+''=='null'?'':$resumo;
			if($resumo+''=='') {
				$resumo = this.arrDados['Dsc_Descricao']+'';
				$resumo = strlen($resumo)>500?substr(strip_tags($resumo),0,500)+'...':$resumo;
			}
			this.resumo = $resumo=='null'?'':$resumo;
			this.resumo = trataString(this.resumo);
		}
		this.GetResumo = function () { return this.resumo; }
		
		this.setFromArray = function ($arr) {
			this.arrDados = $arr;
			this.setID(this.arrDados['idVideo']);
			// this.setFoto();
			this.setNome(this.arrDados['Nom_Video']);
			this.setChamada(this.arrDados['Dsc_Chamada']);
			this.setResumo(this.arrDados['Dsc_Resumo']);
			this.setDescricao(this.arrDados['Dsc_Descricao']);
			this.setUrlFoto(this.arrDados['Dsc_UrlFoto']);
			this.setUrlVideo(this.arrDados['Dsc_UrlVideo']);
			this.setLinkDetalhe();
		}
		this.GetDados = function () { this.arrDados = $arr; }
		
		this.__construct();
	}
	
	var AbstractProduto = function() {
		this.id = '';
		this.nome;
		this.preco;
		this.ind_inativo;
		this.preco_min;
		this.preco_max;
		this.preco_pessoa;
		this.total_dominios;
		this.mode;
		this.foto = new Array();
		this.descricao;
		this.id_fabricante;
		this.nome_fabricante;

		this.arrDados = new Array();

		this.pub_arrParams = new Array();

		this.__construct = function() {
			this.foto['min'] = '';
			this.foto['pqn'] = '';
			this.foto['gnd'] = '';
			this.foto['big'] = '';
			
			this.pub_arrParams['bo_ativo'] = true;
			this.pub_arrParams['bo_comprar'] = true; 
			this.pub_arrParams['bo_imagemprincipal'] = false; 
		}
		
		this.setMode = function($mode){
			this.mode = !$mode?'':$mode;
		}

		this.setID = function($id) { this.id = $id; }
		this.GetID = function() { return this.id; }
		
		this.setIdFabricante = function ($id) { this.id_fabricante = $id; }
		this.GetIdFabricante = function () { var $idfabricante = !this.id_fabricante?'':this.id_fabricante; return $idfabricante; }
		
		this.setNomeFabricante = function ($nome) { this.nome_fabricante = htmlspecialchars($nome); }
		this.GetNomeFabricante = function () { return this.nome_fabricante; }
			
		this.setNome = function($nome) { var $nome = !$nome?'':$nome; this.nome = $nome; }
		this.GetNome = function () { return this.nome; }
		
		this.setProdutoInativo = function ($ind_inativo) { var $ind_inativo = !$ind_inativo?'0':$ind_inativo; this.ind_inativo = $ind_inativo; }
		this.setPreco = function ($preco) { var $preco = !$preco?'':$preco; this.preco = $preco; }
		this.setPrecoMin = function ($preco) { var $preco = !$preco?'':$preco; this.preco_min = $preco; }
		this.setPrecoMax = function ($preco) { var $preco = !$preco?'':$preco; this.preco_max = $preco; }
		this.setPrecoPessoa = function ($preco) { var $preco = !$preco?'':$preco; this.preco_pessoa = $preco; }
		
		this.setTotalDominios = function ($total) { var $total = !$total?'':$total; this.total_dominios = $total; }
		
		this.GetPodutoInativo = function () { return this.ind_inativo; }
		this.GetProdutoInativoFormated = function () { 
			if(this.ind_inativo+''=='1') {
				return '<font color="red">Sim</font>';
			} else {
				return '<font color="green">Não</font>';
			} 
		}
		
		this.GetPreco = function () { return this.preco; }
		this.GetPrecoFormated = function ($moeda,$cs) { 
			var $moeda = !$moeda?'':$moeda;
			var $cs = !$cs?'':$cs;
			switch($cs) {
				case 'min' :
						$preco = parseFloat(this.preco_min)>0?this.preco_min:'';
					break;
				case 'max' :
						$preco = parseFloat(this.preco_max)>0?this.preco_max:'';
					break;
				case 'pessoa' :
						$preco = parseFloat(this.preco_pessoa)>0?this.preco_pessoa:'';
					break;
				default :
						$preco = parseFloat(this.preco)>0?this.preco:'';
					break;
			}
			
			
			switch(this.mode) {
				case 'edit':
						if($preco+''=='') {
							return '';
						}
						if(!$preco) {
							return '0';
						}
						return number_format($preco,2,',','.');
					break;
				default :
						if(!$preco) {
							this.pub_arrParams['bo_comprar'] = false; 
							return 'sob consulta';
						} else {
							switch(strtoupper($moeda)+'') {
								case 'R$':
								default:
										return 'R$ ' + number_format($preco,2,',','.');
									break;
								case '$':
										return '$ ' + number_format($preco,2,'.',',');
									break;
							}		
						}
					break;
			}

		}		
		this.GetPrecoMinFormated = function ($moeda) { 
			return this.GetPrecoFormated($moeda,'min');
		}
		this.GetPrecoMaxFormated = function ($moeda) { 
			return this.GetPrecoFormated($moeda,'max');
		}
		this.GetPrecoPessoaFormated = function ($moeda) { 
			return this.GetPrecoFormated($moeda,'pessoa');
		}
		this.GetPrecoMaxFormatedLabel = function ($moeda) { 
			if(this.preco_max+''=='' || this.preco_max+''==this.preco_min+'') return '';
			return '<small>até: </small>' + this.GetPrecoFormated($moeda,'max');
		}
		this.GetTotalDominios = function () { 
			return this.total_dominios;
		}
		this.setLinkDetalhe = function () { this.link_detalhe = 'produtos/detalhe/idproduto/'+this.GetID(); }
		this.GetLinkDetalhe = function () { return this.link_detalhe; }
		
		
		
		this.setFoto = function () {
			this.pub_arrParams['bo_imagemprincipal'] = false; 
			if(this.arrDados['Dsc_ImagemPrincipalExtensao']+''!='') {
				this.pub_arrParams['bo_imagemprincipal'] = true; 
				
				$idAUX = str_repeat('0',9-strlen(this.id))+this.id;
				try{
					$urlFOLDER = ARQ_URL_PRODUTOS + "/"+$idAUX+"/"+$idAUX+"";
				} catch(e){
					$urlFOLDER = $idAUX+"/"+$idAUX+"";
				}
				
				this.foto['min'] = $urlFOLDER + '_0.jpg';
				this.foto['pqn'] = $urlFOLDER + '_1.jpg';
				this.foto['gnd'] = $urlFOLDER + '_2.jpg';
				this.foto['big'] = $urlFOLDER + '_3.jpg';
			}
		}
		
		this.GetFoto = function ($cs) {
			var $cs = !$cs?'':$cs;
			return this.foto[$cs];
		}
		
		this.setDescricao = function ($descricao) { var $descricao = !$descricao?'':$descricao; this.descricao = $descricao; }
		this.GetDescricao = function () { return this.descricao; }
		
		this.GetVendedoresDados = function () {
			if(!globals_arrDadosDB['pessoas']) return '';
			var result = '';
			var arrDadosPessoas = globals_arrDadosDB['pessoas'];
			var arrDadosProdutosXPessoas = globals_arrDadosDB['produtos_pessoas'];
			
			var arrProdPes = arrDadosProdutosXPessoas[this.GetID()];
						
			var strResult = '';
			strResult += '<table>';
			for(idPessoa in arrProdPes) {
				var Num_Preco = arrProdPes[idPessoa]['Num_Preco'];
				
				var arrPessoas = arrDadosPessoas[idPessoa];
				var Nom_Pessoa = arrPessoas['Nom_Pessoa'];
				var Dsc_Site = arrPessoas['Dsc_Site'];
				
				strResult += ' <tr>';
				strResult += '  <td>'+ Nom_Pessoa +'</td>';
				strResult += '  <td><a href="'+Dsc_Site+'" target=_blank"">'+ Dsc_Site +'</a></td>';
				strResult += '  <td>R$ '+ Num_Preco +'</td>';
				strResult += '</tr>';
			}
			strResult += '</table>';
			return strResult; 
		}
		
		this.setResumo = function ($resumo) { 
			var $resumo = !$resumo?'':$resumo;
			$resumo = $resumo+''=='' || $resumo+''=='null'?'':$resumo;
			if($resumo+''=='') {
				$resumo = this.arrDados['Dsc_Descricao']+'';
				$resumo = strlen($resumo)>500?substr(strip_tags($resumo),0,500)+'...':$resumo;
			}
			this.resumo = $resumo=='null'?'':$resumo;
			this.resumo = trataString(this.resumo);
		}
		
		this.GetResumo = function () { return this.resumo; }
		
		
		this.setFromArray = function ($arr) {
			this.arrDados = $arr;
			if(this.arrDados) {
				this.setID(this.arrDados['idProduto']);
				this.setFoto();
				this.setNome(this.arrDados['Nom_Produto']);
				this.setPreco(this.arrDados['Num_Preco']);
				this.setPrecoMin(this.arrDados['minPreco']);
				this.setPrecoMax(this.arrDados['maxPreco']);
				this.setProdutoInativo(this.arrDados['Ind_Inativo']);
				this.setPrecoPessoa(this.arrDados['Num_PrecoPessoa']);
				this.setTotalDominios(this.arrDados['totalDominios']);
				this.setDescricao(this.arrDados['Dsc_Descricao']);
				this.setResumo(this.arrDados['Dsc_Resumo']);
				this.setIdFabricante(this.arrDados['idFabricante']);
				this.setNomeFabricante(this.arrDados['Nom_Fabricante']);
				this.setLinkDetalhe();
			}
			
		}
		this.GetDados = function () { this.arrDados = $arr; }
		
		this.__construct();
	}

	var arrInstance = new Array();
	pagingArrayData = function(objContainerPag,$arrPag) {
		this.paginaAtual = 1;
		this.arrDATA = $arrPag;
		this.idPaging = '';
		this.objAncora = '';
		this.bopaginationtop = true;
		this.bopaginationbottom = true;
		
		this.dataType = 'produtos';
		
		this.pagination = new Array();
		this.optInit = new Array();
		this.offset = 0;
		this.rowsPerPage = 15;
		this.maxPages = 10;
		
		this.init = function() {
			var rnd = (new Date()).getTime();
			this.idPaging = "jqpaging_"+rnd;
		}
		
		this.setDataType = function($t) {
			this.dataType = $t;
		}		
		this.setVars = function() {
			this.maxPages = sizeof(this.arrDATA['dados'])/this.rowsPerPage;
			this.maxPages = this.maxPages<1?1:this.maxPages;
			this.getPagination();
		}
		
		this.paginador = function(page_index, jq, opts) {
				var page = parseInt(page_index) + 1;
				var str = '';
				for(i in arrInstance) {
					str+=i+' = '+arrInstance[i] + "\n";
				}
				//$(objContainerPag).fadeTo("quick", 0);
				//$(objContainerPag).toggle();

				var idPaging = opts['idpaging']+'';
				
				var objInstance = arrInstance[idPaging];
				//$(objInstance.objAncora).focus();
				objInstance.paginaAtual = page;
				objInstance.pagination['currentPage'] = page;
				
				objInstance.printPagination();
				
				
				var objTbEdit = $('#'+idPaging).find('.tbEdit');
				
				$(objTbEdit).removeClass('loaded');
				$(objTbEdit).find('.th_actions').remove();
				$(objTbEdit).find('.td_actions').remove();
				// $(objTbEdit).find('#formSave').remove();
				
				
				
				objInstance.showData();

			return false;
		}
		
		this.create = function() {
			this.setVars();
			$(objContainerPag).after('<div id="'+this.idPaging+'" class="box_all_paging"><div class="content" param="'+this.idPaging+'"></div></div>');
			//$(objContainerPag).remove();
			
			//$('.boxListProd').appendTo('#'+this.idPaging);
			//$('#'+this.idPaging).find('.content').append(html);
			$(objContainerPag).appendTo($('#'+this.idPaging).find('.content'));
			
			//$(objContainerPag).append('<div class="content" param="'+this.idPaging+'"></div>');
			$(objContainerPag).append('<div class="maincontent" param="'+this.idPaging+'"></div>');
			
			if(this.bopaginationtop) $('#'+this.idPaging).find('.content').before('<div class="boxpag"><div class="paginationtop pagination"></div></div>');
			if(this.bopaginationbottom) {
				$('#'+this.idPaging).find('.content').after('<div class="boxpag"><div class="paginationbottom pagination"></div></div>');
			} else {
				$('#'+this.idPaging).find('.content').after('<div class="boxpag" style="display: none;"><div class="paginationbottom pagination"></div></div>');
			}
			
			//$(objContainerPag).find('.content').before('<div class="boxpag"><div class="paginationtop pagination"></div></div>');
			//$(objContainerPag).find('.content').after('<div class="boxpag"><div class="paginationbottom pagination"></div></div>');
			
			
			var parentBox = $('#'+this.idPaging);
			
			$(parentBox).before('<a name="'+this.idPaging+'" style="width:1px;height:1px;position:absolute;left:-10000px;margin-top:-100px;"><input type="text"></a>');

			this.objAncora = $('a[name='+this.idPaging+'] input');
			arrInstance[this.idPaging] = this;
			
			
			
			//if(this.pagination['rowCount']>this.rowsPerPage) {
				//optInit["callback"]=pageselectCallback;
				this.optInit["callback"]=this.paginador;
				this.optInit["idpaging"]=this.idPaging;
				
				this.optInit["items_per_page"]=this.rowsPerPage;
				this.optInit["num_display_entries"]=10;
				this.optInit["num_edge_entries"]=3;
				this.optInit["prev_text"]='&laquo;';
				this.optInit["next_text"]='&raquo';
				//$('#'+this.idPaging).find('.paginationtop').pagination(sizeof(this.arrDATA['dados']), optInit);
				$('#'+this.idPaging).find('.paginationbottom').pagination(sizeof(this.arrDATA['dados']), this.optInit);
				
				
				$('#'+this.idPaging).find('.pagination a').each(function(){
					//$(this).attr('onClick',"");
				});
			//}
			
			//this.showData();
			$(parentBox).before('<a name="'+this.idPaging+'2" style="width:1px;height:1px;position:absolute;left:-10000px;top:0px;"><input type="text"></a>');
			$('a[name='+this.idPaging+'2] input').focus().remove();
			
		}
		this.filterData = function(arrFilter) {			
			this.arrDATA['dados'] = arrFilter;
			//alert(arrFilter)
			this.setVars();
			var objDivPagBottom = $('#'+this.idPaging).find('.paginationbottom').get(0);
			if(objDivPagBottom) {
				$(objDivPagBottom).html('');
				$(objDivPagBottom).pagination(sizeof(this.arrDATA['dados']), this.optInit);
				this.paginador(0,'',this.optInit);
			}
			this.showData();
			
			var objTbEdit = $('#'+this.idPaging).find('.tbEdit');
			$(objTbEdit).removeClass('loaded');
			$(objTbEdit).find('.th_actions').remove();
			$(objTbEdit).find('.td_actions').remove();
		}
		this.preparaArrayData = function(arrDATA) {
			var arrDATA_NEW = new Array();
			var count = 0;
			if(arrDATA) {
				if(!arrDATA[0] && $(arrDATA).size()) {
					for(iLoop in arrDATA) {
						arrDATA_NEW[count] = arrDATA[iLoop];
						count++;
					}
				} else {
					arrDATA_NEW = arrDATA;
				}
			}
			return arrDATA_NEW;
		}
		this.showData = function() {
			//alert(this.paginaAtual);
			//alert(this.rowsPerPage);
			$(this.objAncora).focus();
			//$(objContainerPag).fadeTo("slow", 1);
			$(objContainerPag).find('.maincontent').html('');
			var item = 1;
			var startPage = 0;
			$limit = (this.rowsPerPage+''=='')?this.pagination['rowCount']:this.rowsPerPage;
			$start = ($limit*this.pagination['currentPage']) - $limit; // do not put $limit*(this.page - 1)
			
			this.arrDATA['dados'] = this.preparaArrayData(this.arrDATA['dados']); 
			
			if(this.pagination['rowCount']) {
					for($i=$start;$i<this.pagination['rowCount'];$i++) {
						var row = this.arrDATA['dados'][$i];
						this.arrDATA['dados']['loaded'] = true;
						
						
						if(this.arrDATA['dados'][$i]) {
								if(!this.arrDATA['dados'][$i]['loaded']) {
									var html = this.arrDATA['tpl'];
									if(isFunction(html)) {
										var arrArg = new Array();
										arrArg.push(item);
										arrArg.push(row);
										func = html;
										html = func.apply(null, arrArg);
									} else {
											html = replaceSubstring(html,"{tplUrlFilesRoot}",tplUrlFilesRoot);
											
											
											switch(this.dataType+'') {
												case 'video' :
														var clsVideo = new AbstractVideo();	
														clsVideo.setFromArray(row);
														
														html = replaceSubstring(html,"{clsVideo->GetID()}",clsVideo.GetID());
														html = replaceSubstring(html,"{clsVideo->GetNome()}",clsVideo.GetNome());
														html = replaceSubstring(html,"{clsVideo->GetFoto('pqn')}",clsVideo.GetFoto('pqn'));
														html = replaceSubstring(html,"{clsVideo->GetFoto('min')}",clsVideo.GetFoto('min'));
														html = replaceSubstring(html,"{clsVideo->GetFoto('gnd')}",clsVideo.GetFoto('gnd'));
														html = replaceSubstring(html,"{clsVideo->GetFoto('big')}",clsVideo.GetFoto('big'));
														html = replaceSubstring(html,"{clsVideo->GetChamada()}",clsVideo.GetChamada());
														html = replaceSubstring(html,"{clsVideo->GetResumo()}",clsVideo.GetResumo());
														html = replaceSubstring(html,"{clsVideo->GetLinkDetalhe()}",clsVideo.GetLinkDetalhe());
														html = replaceSubstring(html,"{clsVideo->GetDescricao()}",clsVideo.GetDescricao());
														html = replaceSubstring(html,"{clsVideo->GetUrlFoto()}",clsVideo.GetUrlFoto());
														html = replaceSubstring(html,"{clsVideo->GetUrlVideo()}",clsVideo.GetUrlVideo());
														
													break;
												default :
														var clsProduto = new AbstractProduto();	
														clsProduto.setFromArray(row);
														
														html = replaceSubstring(html,"{clsProduto->GetID()}",clsProduto.GetID());
														html = replaceSubstring(html,"{clsProduto->GetNome()}",clsProduto.GetNome());
														html = replaceSubstring(html,"{clsProduto->GetFoto('pqn')}",clsProduto.GetFoto('pqn'));
														html = replaceSubstring(html,"{clsProduto->GetFoto('min')}",clsProduto.GetFoto('min'));
														html = replaceSubstring(html,"{clsProduto->GetFoto('gnd')}",clsProduto.GetFoto('gnd'));
														html = replaceSubstring(html,"{clsProduto->GetFoto('big')}",clsProduto.GetFoto('big'));
														html = replaceSubstring(html,"{clsProduto->GetResumo()}",clsProduto.GetResumo());
														html = replaceSubstring(html,"{clsProduto->GetIdFabricante()}",clsProduto.GetIdFabricante());
														html = replaceSubstring(html,"{clsProduto->GetNomeFabricante()}",clsProduto.GetNomeFabricante());
														html = replaceSubstring(html,"{clsProduto->GetProdutoInativoFormated()}",clsProduto.GetProdutoInativoFormated());
														html = replaceSubstring(html,"{clsProduto->GetPrecoFormated()}",clsProduto.GetPrecoFormated());
														html = replaceSubstring(html,"{clsProduto->GetPrecoMinFormated()}",clsProduto.GetPrecoMinFormated());
														html = replaceSubstring(html,"{clsProduto->GetPrecoPessoaFormated()}",clsProduto.GetPrecoPessoaFormated());
														html = replaceSubstring(html,"{clsProduto->GetPrecoMaxFormated()}",clsProduto.GetPrecoMaxFormated());
														html = replaceSubstring(html,"{clsProduto->GetPrecoMaxFormatedLabel()}",clsProduto.GetPrecoMaxFormatedLabel());
														html = replaceSubstring(html,"{clsProduto->GetTotalDominios()}",clsProduto.GetTotalDominios());
														html = replaceSubstring(html,"{clsProduto->GetLinkDetalhe()}",clsProduto.GetLinkDetalhe());
														html = replaceSubstring(html,"{clsProduto->GetDescricao()}",clsProduto.GetDescricao());
														html = replaceSubstring(html,"{clsProduto->GetVendedoresDados()}",clsProduto.GetVendedoresDados());
														
														//html = replaceSubstring(html,"{clsProduto->GetDescricao()}",clsProduto.GetDescricao());
														
														//alert(html);
													break;
											}
											$(objContainerPag).find('.maincontent').append(html);
											this.arrDATA['dados'][$i]['loaded'] = html;
									}
										
								} else {
									$(objContainerPag).find('.maincontent').append(this.arrDATA['dados'][$i]['loaded']);
								}
						}
						
						if(item>=this.rowsPerPage) break;
						item++;
					}
			} else {
						var html = this.arrDATA['tpl'];
						if(isFunction(html)) {
							var arrArg = new Array();
							arrArg.push(item);
							arrArg.push(row);
							func = html;
							html = func.apply(null, arrArg);
						} else {
							$(objContainerPag).find('.content').append('');
						}
			}
			loadSettings();
			
		}
		
		this.printPagination = function() {
			
			$startPage = 0;
			if(this.pagination['currentPage']>1) {
				$startPage = (this.pagination['currentPage']-1) * this.rowsPerPage;
			}
			/*
			$maxPagesHalf = ceil(this.maxPages / 2);
			if(this.pagination['numPages'] <= this.maxPages) {
				$startPage = 0;
				$endPage = this.pagination['numPages'];
			} else if (this.pagination['currentPage'] <= $maxPagesHalf) {
				$startPage = 0;
				$endPage = this.maxPages;
			} else if ((this.pagination['currentPage'] + $maxPagesHalf) > this.pagination['numPages']) {
				$endPage = this.pagination['numPages'];
				$startPage = $endPage - this.maxPages;
			} else {
				$startPage = this.pagination['currentPage'] - $maxPagesHalf - 1;
				$endPage = this.pagination['currentPage'] + $maxPagesHalf;
			}
			*/
			
			var result = '';
			
			//if(this.pagination['rowCount']>this.rowsPerPage) {
				var totalShow = (this.rowsPerPage*this.pagination['currentPage']);
				totalShow = totalShow>this.pagination['rowCount']?this.pagination['rowCount']:totalShow;
				
				if(this.pagination['rowCount']) {
					if(this.pagination['rowCount']<=this.rowsPerPage) {
						result += '<div class="pageListInfo">Mostrando <span>'+($startPage+1)+' - '+totalShow+'</span> de <span>'+this.pagination['rowCount']+'</span> distribuído(s) em <span>'+this.pagination['numPages']+' página</span></div>';
					} else {
						result += '<div class="pageListInfo">Mostrando <span>'+($startPage+1)+' - '+totalShow+'</span> de <span>'+this.pagination['rowCount']+'</span> distribuído(s) em <span>'+this.pagination['numPages']+' páginas</span></div>';
					}
				} else {
					result += '<div class="pageListInfo">Nenhum registro encontrado</div>';
				}
				
				var parentBox = $('#'+this.idPaging);
				$(parentBox).find('.pageListInfo').remove();

				$(parentBox).find('.paginationtop').before(result);
				$(parentBox).find('.paginationbottom').before(result);
			//}
			

			

		}
		
		this.getRowCount = function () {
			this.pagination['rowCount'] = sizeof(this.arrDATA['dados']);
		}
		
		this.getPagination = function () {
			this.getRowCount();
			this.pagination['numPages'] = ceil(this.pagination['rowCount'] / this.rowsPerPage);
			this.pagination['currentPage'] = ceil(this.offset / this.rowsPerPage) + 1;
			if(this.offset == 0) {this.pagination['currentPage'] = 1;}
			this.pagination['firstRowOnPage'] = this.offset + 1;
			this.pagination['lastRowOnPage'] = (this.pagination['currentPage'] == this.pagination['numPages']) ? this.pagination['rowCount'] : this.offset + this.rowsPerPage;
			if(this.pagination['rowCount'] == 0) {
				this.pagination['firstRowOnPage'] = 0;
				this.pagination['lastRowOnPage'] = 0;
			}
		}
		
		
		this.init();
	}


	loadSettings = function() {
		if($('.media').size()){
			$('.media').each(function(){
					$(this).removeClass('media');
					$(this).media();
					
			})
			
		}
		
		if($('a.highslide').size() || $('a.highslide-gallery').size()){
			hs.anchors = null;
			//$.include([LIB_DIR + '/jquery/plugins/highslide/files/highslide-with-gallery.packed.js',LIB_DIR + '/jquery/plugins/highslide/files/highslide.css']);
			
			$('a.highslide:not(.loaded),a.highslide-gallery:not(.loaded)').each(function(){
				var objA = $(this);
				var objIMG = $(this).find('img:eq(0)');
				var src = $(objIMG).attr('src')+'';
				src = src.replace('_0.','_2.');
				src = src.replace('_1.','_2.');
				
				
				
				
				var objNewImg = new Image();
				objNewImg.src = src;
				objNewImg.onerror = function(){
					$(objA).removeClass('highslide');
					$(this).remove();
				}
				
					
				var title = $(objIMG).attr('title')+'';
				//alert($(this).attr('href'))
				//$(this).attr('href',src);
				//$(this).attr('onclick','return hs.expand(this)');
				
				if(!$(this).attr('onclick')) {
					//$(this).attr('onclick',"return hs.expand(this,{ align: 'center', outlineType: 'rounded-white', captionOverlay: { position: 'rightpanel'} })");
					this.onclick = function() {
						return hs.expand(this,{ align: 'center', outlineType: 'rounded-white', captionOverlay: { position: 'rightpanel'}});
					};
					//$(this).attr('onclick',"alert('')");
				}
				
				/*
				
				//$(this).after('<div class="highslide-caption"><div class="boxcaption"><div style="padding: 2px 10px 5px 10px;"><h4>'+title+'</h4>You can open more than one image at a time, and arrange them on your screen by dragging them around. The captions can be positioned anywhere relative to the image.</div></div></div>');
				
				//return hs.expand(this, 			{wrapperClassName: 'wide-border', captionOverlay: { position: 'rightpanel'}})
				
				
				$(this).removeClass('highslide');
				$(this).removeClass('highslide-gallery');
				*/
				$(this).addClass('loaded');
				
				
				
			});
			
			
		}
		
		
		$('.prodcat:not(.loaded)').each(function(){
			$(this).addClass('loaded');
				var att_idProduto = $(this).attr('param');
				
				// var tree_secoes = new Tree(globals_arrDadosDB['secoes'],"idSecao,Nom_Secao,idSecaoPai");
				//tree_secoes.url = "";
				// tree_secoes.getTree();
				// var strLink = '';
				var html = '';
				var arrSecoes = globals_arrDadosDB['produtos_secoes'][att_idProduto];
				if(arrSecoes) {
					html += '<ul>';
					for(i in arrSecoes) {
						var idSecao = arrSecoes[i];
						var arrSecoesTree = tree_secoes.get_pais(idSecao);
						var strSep = '';
						html += '<li>';
						
						for(i2 in arrSecoesTree) {
							var idSecao = arrSecoesTree[i2];
							var nom_secao = tree_secoes.arrTreeResult[idSecao+""]['Nom_Secao'];
							var idSecaoPai = tree_secoes.arrTreeResult[idSecao+""]['idSecaoPai'];
							var Link = baseUrlModule + "produtos/lista/idsecao/" + idSecao;
							if(idSecaoPai+""!="") {
								Link = Link + '/idsecaop/' + idSecaoPai;
							}
							html += strSep + '<a href="'+Link+'">'+nom_secao+'</a>';
							strSep = ' <span class="sep">:</span> ';
							//alert(nom_secao)
							// //alert(idSecao);
						}
						html += '</li>';
					}
					html += '</ul>';
				}
				$(this).append(html);
				$(this).removeClass('prodcat');
				$(this).addClass('prodcatloaded');
			
		});
		
	$('.__BNR_FOTOS:not(.loaded)').each(function(){
		$(this).addClass('loaded');
		$(this).addClass('images_list');
		
		var strParam = $(this).attr('param');
		eval('var objParam = '+strParam+';');
		
		var porpag = 3;
		if(objParam) {
			porpag = objParam.porpag;
		}
		
		var images_list = globals_arrFotos['images_list'];
		var images_group = globals_arrFotos['images_group'];
		var html = '';
		if(images_group) {
			$('.images_list').append('<ul></ul>');
			for(idx in images_group) {
				var row = images_group[idx];
				
				var pathP = row[0]['path'];
				var pathG = row[1]['path'];
				
				html += '<li class="images_list_dnone"><a href="'+pathG+'" class="highslide"><img src="'+pathP+'" alt="" title=" Click para ampliar " border="0" /></a></li>';
				
									
			}
		} else {
			$('.images_list').append('<ul></ul>');
			for(idx in images_list) {
				var row = images_list[idx];
				var path = globals_arrFotos['url'] + idx;
				
				html += '<li class="images_list_dnone"><img src="'+path+'" /></li>';
			}
		}
			
		$($('.images_list').find('ul').get(0)).append(html);
		$('.images_list').prepend('<div style="width:1px;height:1px;overflow:hidden;"><input type="text" id="focusimg"  /></div>');
		
		
		var total = $('.images_list ul:eq(0) li').size();
		if(total<=porpag) { $('.images_list_dnone').removeClass('images_list_dnone'); }
		var strPaging = '';
		var totalpag = Math.round(total/porpag);
		for(i=1;i<=totalpag;i++) {
			strPaging +='<a href="#'+i+'" param="'+i+'">'+i+'</a>';
		}
		$('.images_list ul:eq(0)').after('<div class="pagination">' + strPaging + '</div>');
		
		$('.pagination a').click(function(){
			var objFocus = $("#focusimg");
			objFocus.focus();
			$('.pagination a').removeClass('current');
			$(this).addClass('current');
			var pag = $(this).attr('param');
			var start = (porpag*(pag-1));
			
			var end = (porpag*pag)-1;
			$('.images_list ul:eq(0) li').addClass('images_list_dnone');
			//alert(start + ' = ' + end)
			for(i=start;i<=end;i++) {
				if(i>total)break;
				$('.images_list ul:eq(0) li:eq('+i+')').removeClass('images_list_dnone');
			}
			
			
			return false;
		});
		$('.pagination a:eq(0)').click();
	});
		
	}
	


	function monta__BNRTPL__VIDEOS() {
		$('.__BNRTPL__VIDEOS').each(function(){
			$(this).removeClass('__BNRTPL__VIDEOS');
			
			$(this).removeClass('__BNRTPL__VIDEOS_LOADED');
			$(this).addClass('__BNRTPL__VIDEOS_LOADED');
			
			$strClass = $(this).attr('class')+'';
			eval('var param = '+$(this).attr('param')+';');
			var param = !param?'':param;
			
			
			$arrClass = $strClass.split(' ');
			
			var idxLayout = 'padrao';
			for(idx in $arrClass) {
				var strClass = $arrClass[idx];
				if(arrLayouts['videos'][strClass]) {
					idxLayout = strClass;
					break;
				}
			}
			
			var arrDATA = new Array();
			arrDATA['dados'] = new Array();
			if(param.data) {
				arrDATA['dados'] = arrDados[param.data];
			} else {
				switch(idxLayout+'') {
					default :
							arrDATA['dados'] = globals_arrDadosDB['videos'];
						break;
				}
			}
			
			

			arrDATA['tpl'] = arrLayouts['videos'][idxLayout];
			
			var arrDATA_NEW = new Array();
			arrDATA_NEW['tpl'] = arrDATA['tpl'];
			arrDATA_NEW['dados'] = new Array();
			var count=0;
			

			
			if(!arrDATA['dados'][0] && $(arrDATA['dados']).size()) {
				for(iLoop in arrDATA['dados']) {
					arrDATA_NEW['dados'][count] = arrDATA['dados'][iLoop];
					count++;
				}
				var objV = new pagingArrayData(this,arrDATA_NEW);
			} else {
				var objV = new pagingArrayData(this,arrDATA);
			}
			
			objV.setDataType('video');
			objV.create();
			
		});
	}
	function monta__BNRTPL__FORMCONTATO() {
		$('.__BNRTPL__FORMCONTATO').each(function(){
			var objFormContent = $(this);
			
			var html = '';
			html+='						<form class="form_contato">';
			html+='							<div class="wrap-input">';
			html+='								<label>Nome:</label>';
			html+='								<input type="text" name="nome" title="Nome" class="input-text" />';
			html+='							</div>';
			html+='							<div class="wrap-input">';
			html+='								<label>E-mail:</label>';
			html+='								<input type="text" name="email" title="E-mail" class="input-text" />';
			html+='							</div>';
			html+='							<div class="wrap-input">';
			html+='								<label>Telefone:</label>';
			html+='								<input type="text" name="telefone" title="Telefone" class="input-text" />';
			html+='							</div>';
			html+='							<div class="wrap-input">';
			html+='								<label>Mensagem:</label>';
			html+='								<textarea name="mensagem" title="Mensagem"></textarea>';
			html+='							</div>';
			html+='							<div class="wrap-input">';
			html+='								<label>&nbsp;</label>';
			html+='								<input type="submit" value="enviar" />';
			html+='							</div>';
			html+='						</div>';
			html+='';
			
			$(objFormContent).append(html);
			
			$($(objFormContent).find('.form_contato').get(0)).submit(function(){
					var html = '';
					var boOk = true;
					$(this).find('input,select,textarea').each(function(){
						if(!$(this).is('type="button"') && !$(this).is('type="submit"')) {
							var label = $(this).attr('title');
							var valor = $(this).val();
							var required = $(this).attr('required');
							if(!required) {
								if(valor+''=='') {
									alert('O campo "' + label + '" é obrigatório e deve ser preenchido!');
									boOk = false;
									return false;
								}
							}
							html+='<p><b>'+label+'</b>: ' + valor + '</p>';
						}
					});
					if(boOk) {
						alert(html);
					}
					
				return false;
			});
			
			
			$(this).removeClass('__BNRTPL__FORMCONTATO');
			$(this).removeClass('__BNRTPL__FORMCONTATO_LOADED');
			$(this).addClass('__BNRTPL__FORMCONTATO_LOADED');
		});
	}
	function monta__BNRTPL__PRODUTOS() {
		$('.__BNRTPL__PRODUTOS').each(function(){
			
			$(this).removeClass('__BNRTPL__PRODUTOS');
			
			$(this).removeClass('__BNRTPL__PRODUTOS_LOADED');
			$(this).addClass('__BNRTPL__PRODUTOS_LOADED');
			
			
			$strClass = $(this).attr('class')+'';
			eval('var param = '+$(this).attr('param')+';');
			var param = !param?'':param;
			
			
			$arrClass = $strClass.split(' ');
			
			var idxLayout = 'padrao';
			for(idx in $arrClass) {
				var strClass = $arrClass[idx];
				if(arrLayouts['produtos'][strClass]) {
					idxLayout = strClass;
					break;
				}
			}
			
			
			$strSeparator = '';
			var arrDATA = new Array();
			if($(this).is('[class*=lancamentos]')) {
				// arrDATA['dados'] = globals_arrDadosDB['produtos_lancamentos'];
				// arrDATA['tpl'] = arrLayouts['tplProdutoSidebarLancamento'];
			} else {
				//arrDATA['tpl'] = arrLayouts['tplProduto'];
			}
			
			arrDATA['dados'] = new Array();
			if(param.data) {
				arrDATA['dados'] = arrDados[param.data];
			} else {
				switch(idxLayout+'') {
					case 'sidebarlancamento' :
							arrDATA['dados'] = arrDados['produtos_lancamentos'];
						break;
					case 'detalhe' :
							arrDATA['dados'] = arrDados['produtos'];
						break;
					default :
							arrDATA['dados'] = arrDados['produtos'];
						break;
				}
			}
			
			

			arrDATA['tpl'] = arrLayouts['produtos'][idxLayout];
			
			
			
			var arrDATA_NEW = new Array();
			arrDATA_NEW['tpl'] = arrDATA['tpl'];
			arrDATA_NEW['dados'] = new Array();
			var count=0;
			
			
			if(!arrDATA['dados'][0] && $(arrDATA['dados']).size()) {
				for(iLoop in arrDATA['dados']) {
					arrDATA_NEW['dados'][count] = arrDATA['dados'][iLoop];
					count++;
				}
				var objP = new pagingArrayData(this,arrDATA_NEW);
			} else {
				var objP = new pagingArrayData(this,arrDATA);
				
			}
			
			if(param.rowsPerPage) objP.rowsPerPage = param.rowsPerPage;
			objP.create();
			objP.showData();
			objP.printPagination();
			// $(this).removeClass('__BNRTPL__PRODUTOS');
		});
	}
	
	
	function callTimeoutFN() {
		loadSettings();
	}
	setInterval('callTimeoutFN()',700);