jQuery(document).ready(function(){initPesquisaTextoMain();initFakeCheckBox();initComercial();});function initFakeCheckBox()
{jQuery("input[type='checkbox']").each(function(){if(this.id!='')
{(this.checked)?jQuery("a[rel="+this.id+"]").addClass('fakechecked'):jQuery("a[rel="+this.id+"]").removeClass('fakechecked');}});jQuery(".fakecheck").click(function(){var checkrel=jQuery(this).attr("rel");(jQuery(this).hasClass('fakechecked'))?jQuery(this).removeClass('fakechecked'):jQuery(this).addClass('fakechecked');jQuery("#"+checkrel).click();return false;});}
if(typeof initVal=='undefined')
{var initVal='Digite aqui...';}
function initPesquisaTextoMain()
{var campoText=jQuery('#pesquisa_texto');campoText.val(initVal);campoText.focus(function(){if(campoText.val()==initVal)campoText.val('');});campoText.blur(function(){if(campoText.val()=='')campoText.val(initVal);});}
function limpaForm(form)
{var campoText=jQuery("#pesquisa_texto");if(campoText.val()==initVal)campoText.val('');form.submit();}
function initComercial()
{var width=screen.width;var boverlay=jQuery('<div>');var woverlay=jQuery('<div>');boverlay.attr('id','comercial_boverlay').addClass('comercial_boverlay');woverlay.attr('id','comercial_woverlay').addClass('comercial_woverlay');var comercial_div=jQuery('#comercial');if(width<=1024){comercial_div.load("/images/principal/comercial_pequeno/comercial.html");}else{comercial_div.load("/images/principal/comercial_grande/comercial.html");}
comercial_div.delegate("a[rel]","click",function(e){e.preventDefault();var clickedElem=jQuery(this);var comercialTable=comercial_div.find('table');var cTPos=comercialTable.position();var overlay_css={'width':comercialTable.width(),'height':comercialTable.height(),'left':cTPos.left,'top':cTPos.top}
if(typeof(clickedElem.attr('title'))!='undefined'){var winTitle=clickedElem.attr('title');}else if(typeof(clickedElem.attr('alt'))!='undefined'){var winTitle=clickedElem.attr('alt');}else{var winTitle='Demonstra&ccedil;&atilde;o';}
comercialTable.before(boverlay).before(woverlay);boverlay.css(overlay_css);woverlay.css(overlay_css);var win=woverlay.window({url:clickedElem.attr('rel'),checkBoundary:true,title:winTitle,draggable:false,resizable:false,maximizable:false,minimizable:false,showFooter:false,scrollable:true,bookmarkable:false,onClose:function(){boverlay.remove();woverlay.remove();if(jQuery('#mousefollow').size()){jQuery('#mousefollow').remove();}
jQuery('body').unbind("click.exitWindowClick");jQuery('body').unbind("mouseout");jQuery('body').unbind("mouseover");},onIframeEnd:function(wnd){var fl=jQuery('<div>');fl.css({padding:5,position:'absolute',border:'1px solid black','font-weight':'bold','background':'lightyellow','display':'block'});fl.html('Clique para fechar a demonstra&ccedil;&atilde;o!').attr('id','mousefollow');fl.appendTo(jQuery('body'));jQuery('body').mousemove(function(event){fl.show();fl.css({top:(event.pageY+15)+"px",left:(event.pageX+15)+"px"});}).mouseout(function(){fl.hide();});jQuery('body').bind("click.exitWindowClick",function(event){wnd.close(true);boverlay.remove();woverlay.remove();fl.remove();jQuery(this).unbind("click.exitWindowClick");});},width:(comercialTable.width())*0.9,height:(comercialTable.height())*0.9});});}