/*CSS Browser Selector v0.3.2Rafael Lima (http://rafael.adm.br)http://rafael.adm.br/css_browser_selectorLicense: http://creativecommons.org/licenses/by/2.5/Contributors: http://rafael.adm.br/css_browser_selector#contributors*/function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',h=document.getElementsByTagName('html')[0],b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3')?g+' ff3':is('gecko/')?g:/opera(\s|\/)(\d+)/.test(ua)?'opera opera'+RegExp.$2:is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent); 

//funcao que carrega o conteudo da layer
function loadImageLayer(image){
	try{
		overlay();
		if (image){
			$('#overlayContent').load(rootUrl+"shared/image-modal.html", function(){
				$("#image-modal").append("<img src='"+image+"' alt='' />");
				$("#image-modal img").load(function(){
					var pageScroll = getPageScroll();
					var top = Math.ceil(-($('#overlayContent').height()/2));
					var left = Math.ceil(-($('#overlayContent').width()/2));

					if (pageScroll && pageScroll[1] > 0){
						top = top+pageScroll[1];
						$('#overlayContent').css({"margin-left":left+"px", "margin-top": top+"px"});
					}else{
						$('#overlayContent').css({"margin-left":left+"px", "margin-top": top+"px"});
					}
					$('#closeLayer').click(function(){
						removeOverlay();
					});
				});
			});
		}
	}catch(e){
		console.log(e);
	}
}
//funcao que carrega o conteudo da layer do detalhe do projeto
function loadProductLayer(images){
	try{
		overlay();
		if (images){
			$('#overlayContent').load(rootUrl+"shared/product-modal.html", function(){
				images.forEach(function(image){
					$("#product-modal ul").append("<li><img src='"+image+"' alt='' /></li>").css({"visibility":"hidden"});
				});
				$("#product-modal ul li img").load(function(){
					var pageScroll = getPageScroll();
					var top = Math.ceil(-($('#overlayContent').height()/2));
					var left = Math.ceil(-($('#overlayContent').width()/2));

					if (pageScroll && pageScroll[1] > 0){
						top = top+pageScroll[1];
						$('#overlayContent').css({"margin-left":left+"px", "margin-top": top+"px"});
					}else{
						$('#overlayContent').css({"margin-left":left+"px", "margin-top": top+"px"});
					}
					$("#product-modal ul").css({"visibility":"visible"});
					$("#product-modal ul li").hide();
					$("#product-modal ul li:first").show();
				
					$('#closeLayer').click(function(){
						removeOverlay();
					});
					
				});
				
			});
		}
	}catch(e){
		console.log(e);
	}
}
jQuery(document).ready( function() {
	advanced_search();
});


function advanced_search() {
	
	var tabs = jQuery(".advanced_search #tabs li a");
	var fieldsets = jQuery(".advanced_search .tab_content");
	
	tabs.eq(0).addClass('affected');
	fieldsets.hide();
	fieldsets.eq(0).show();
		
	tabs.bind('click', function() {
		tabs.removeClass('affected');
		jQuery(this).addClass('affected');
		var li = jQuery(this).parent().attr('class').replace('tab','').replace('over','');
		fieldsets.hide();
		fieldsets.eq(li-1).show();
	});
}

function loadImageLayerOnFlash(image){
	try{
		overlay();
		if (image){
			$('#overlayContent').load(rootUrl+"shared/image-modal.html", function(){
				$("#image-modal").append("<img src='"+image+"' alt='' />");
				$("#image-modal img").load(function(){
					var pageScroll = getPageScroll();
					var top = Math.ceil(-($('#overlayContent').height()/2));
					var left = Math.ceil(-($('#overlayContent').width()/2));

					if (pageScroll && pageScroll[1] > 0){
						top = top+pageScroll[1];
						$('#overlayContent').css({"margin-left":left+"px", "margin-top": top+"px"});
					}else{
						$('#overlayContent').css({"margin-left":left+"px", "margin-top": top+"px"});
					}
					$('#closeLayer').click(function(){
						removeOverlay();
					});
				});
			});
		}
	}catch(e){
		console.log(e);
	}
}

   function showmenu(elmnt)
{
if(document.getElementById(elmnt))
    document.getElementById(elmnt).style.display = "block";
}
        
function hidemenu(elmnt)
{
if(document.getElementById(elmnt)){
    document.getElementById(elmnt).style.display = "none";     	
    }
}

function fechar_floater()
    {
	document.getElementById('Floater').style.display = 'none';
	document.getElementById('Floater_fechar').style.display = 'none';
    } 
    
// Somente numeros
function onlynumber(myfield, e,tolerado)
{
    var tecla  = window.event?event.keyCode:event.which;
	if (tecla == 13 || tecla == 8 || tecla == 37 || tecla == 39 || tecla == 9)
        return true;
       
	else if (tecla>47 && tecla<58)
           return true;	
    else
           return false;
} 

// Formatando o Fone
function Formato_Fone(input, e)
{
    var keyCode;
    
	if (window.event)
		keyCode = window.event.keyCode;
	else if (e)
		keyCode = e.which;
	
    if (keyCode != 8)
	{ 
	    if(input.value.length == 4)
	        input.value = input.value+'-';		
	}
}