function starbg(){
	var img = new Image();
	$(img)
		.load(function () {
			var img = new Image();
			$(img).load(function () {
				if(!$.browser.msie || ($.browser.msie && jQuery.browser.version - 7.0 > 0)) $("#starbg").show();
				jhmsani();
				$("#starbg").fadeOut("slow");
				$("#main").css({"background":"url(images/starbg.png) no-repeat center 80px"})
			}).attr('src', 'images/starbg.png');
	}).attr('src', 'images/starbgO.png');

}
function smad(x){
	x = x.toString();
	y = x.split(".");
	if(!y[1]) y[1] = "0";
	return y[0] + "<span style='font-size:14px;color:#cdcdcd;display:inline;'>." + y[1] + "</span>";
}
function online(x) { 
	$.ajax({
   		url: 'index.php',
		data: 'online='+x,
		type: 'POST',
		dataType: 'text',
		timeout: 10000,
 		error: function(){ return -1; },
		success: function(y){ $(".online").text(y); }
	});
	setTimeout("online(3);",10000);
};
$(window).unload(function(){ online(2); });

function nakedFIX(){
	if($('#painel center:first').css("display") != "none") $('div.naked').css({'marginTop':$('#painel center:first').outerHeight()+'px'}); 
	else $('div.naked').css({'marginTop': '1px'});
}
function jhmsani(){
	var img = new Image();
	$(img).load(function () {
		$('#title div:first img').animate({  borderSpacing: -360 }, {
		    step: function(now,fx) {
		      $(this).css('-webkit-transform','rotate('+now+'deg)');
		      $(this).css('-moz-transform','rotate('+now+'deg)'); 
		      $(this).css('-o-transform','rotate('+now+'deg)'); 
		      $(this).css('ms-transform','rotate('+now+'deg)'); 
		      $(this).css('transform','rotate('+now+'deg)');  
		    },
		    duration:1000,easing: "easeOutBack"
		},'linear');
		$("#title div:first").animate({"marginRight": "151px"},1000, function(){ setTimeout(function(){ $("#title div:first").fadeOut(); },150); } );
	}).attr('src', 'images/starbgt.png');
}
var o;
function menu(x,y){
	t = 500,tag="";
	clearTimeout(o);
	if(!y) { 
		x = $("#menu ul li span").index($(".active")) + 1;
		o = setTimeout(function() { menu(x,1); },500);
		return -1
	}else if(y < 0) tag = "o";

	switch(x){
		case 1:
			$("#menu ul li.tag"+tag).animate({"marginLeft":"2px"},{duration: t, easing: "easeOutBack",queue:false });
			break;
		case 2:
			$("#menu ul li.tag"+tag).animate({"marginLeft":"115px"},{duration: t, easing: "easeOutBack",queue:false });
			break;
		case 3:
			$("#menu ul li.tag"+tag).animate({"marginLeft":"225px"},{duration: t, easing: "easeOutBack",queue:false });
			break;
		case 4:
			$("#menu ul li.tag"+tag).animate({"marginLeft":"335px"},{duration: t, easing: "easeOutBack",queue:false });
			break;
	}
}
$(function(){
	var mydiv = "div.msn";
	var IE=document.all;
	var iXPos;
	var iYPos;

	online(3);

	$("#contato textarea").elastic();

	$("#menu ul li span").hover(function(){ $(this).not(".active").animate({color:"#efefef"},{duration:250,queue:false}); menu($("span").index(this),1); },function(){ menu($("span").index(this),0); $(this).not(".active").animate({color:"#cdcdcd"},{duration:250,queue:false}); }).click(function(){ $("#menu ul li span").not(this).animate({color:"#cdcdcd"},{duration:250,queue:false}); menu($("span").index(this),-1); });

	$(window).scroll(function(){
		p = $(window).scrollTop();
		q = $(document).height() - $(window).height();
			
		w = Math.ceil((100*p)/q);

		if(w >= 90) $("#footer div.footh").animate({"marginTop":"-20px"},{duration: 300,queue:false});
		else $("#footer div.footh").animate({"marginTop":"10px"},{duration:300,queue:false});

	});


	if($.browser.opera) $(".fixo").css({"height":"12px","marginTop":"4px"});
	if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1) $("#menu ul li.tag").css({"marginTop":"28px"});
	$("#painel input:eq(1)").nakedPassword({path: "images/naked/"});
	
	if($.browser.msie && jQuery.browser.version - 7.0 <= 0) {
		$("#title div:first").hide();
		$("#tempo img").css({"margin":"40 0 0 -135"});
	} else { 
		$("#tempo").hover(function(){ $(this).animate({"height":"75px"},{queue:false}).find("img:eq(1)").fadeOut();},function(){ $(this).animate({"height":"35px"},{queue:false}).find("img:eq(1)").fadeIn("fast"); })
		.append("<div style='position:absolute;z-index:10;margin:-18px 0 0 57px;'><img src='images/arrowdown.png' alt='down'></div>");
	}

	if (!IE){
		iXPos = (self.innerWidth  - $(mydiv).get(0).offsetWidth)/2 - 150 + "px";
		iYPos = document.documentElement.scrollTop + 20 + "px";
	} else	{
		iXPos = ((document.body.clientWidth) - $(mydiv).get(0).offsetWidth)/2 - 150 + "px";
		iYPos = document.documentElement.scrollTop + 20 + "px";
	}
	$(mydiv).css({"display":"none","top":"150px","left":iXPos});

	$("#msn").click(function() { 
		$(".msn iframe").attr("src","http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=877404e22477d7b@apps.messenger.live.com&mkt=pt-br&useTheme=true&themeName=green&foreColor=333333&backColor=DCF2E5&linkColor=333333&borderColor=8ED4AB&buttonForeColor=2C0034&buttonBackColor=CFE9D9&buttonBorderColor=8ED4AB&buttonDisabledColor=CFE9D9&headerForeColor=006629&headerBackColor=92D6AE&menuForeColor=006629&menuBackColor=FFFFFF&chatForeColor=333333&chatBackColor=F4FBF7&chatDisabledColor=F6F6F6&chatErrorColor=760502&chatLabelColor=6E6C6C").show();
		$("div.msn").fadeIn(); 
		} 
	);
	$("div.msn .close").click(function() { $("div.msn").hide("explode"); } );
	Drag.init($('div.msn div:first div:eq(0)')[0],$('div.msn')[0],0,screen.width-300,0,screen.height/2+15);

	$('#msn').hover(function(){$(this).css({'border':'1px solid #eeeeee','background':'#999999 url(../images/msn.png) no-repeat 120px center','cursor':'pointer','text-decoration':'underline'})},function(){$(this).css({'border':'1px solid #999999','background':'#777777 url(../images/msn.png) no-repeat 120px center','cursor':'default','text-decoration':'none'})})});
var Drag={obj:null,init:function(o,oRoot,minX,maxX,minY,maxY,bSwapHorzRef,bSwapVertRef,fXMapper,fYMapper){o.onmousedown=Drag.start;o.hmode=bSwapHorzRef?false:true;o.vmode=bSwapVertRef?false:true;o.root=oRoot&&oRoot!=null?oRoot:o;if(o.hmode&&isNaN(parseInt(o.root.style.left)))o.root.style.left="0px";if(o.vmode&&isNaN(parseInt(o.root.style.top)))o.root.style.top="0px";if(!o.hmode&&isNaN(parseInt(o.root.style.right)))o.root.style.right="0px";if(!o.vmode&&isNaN(parseInt(o.root.style.bottom)))o.root.style.bottom="0px";o.minX=typeof minX!='undefined'?minX:null;o.minY=typeof minY!='undefined'?minY:null;o.maxX=typeof maxX!='undefined'?maxX:null;o.maxY=typeof maxY!='undefined'?maxY:null;o.xMapper=fXMapper?fXMapper:null;o.yMapper=fYMapper?fYMapper:null;o.root.onDragStart=new Function();o.root.onDragEnd=new Function();o.root.onDrag=new Function();},start:function(e){var o=Drag.obj=this;e=Drag.fixE(e);var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);o.root.onDragStart(x,y);o.lastMouseX=e.clientX;o.lastMouseY=e.clientY;if(o.hmode){if(o.minX!=null)o.minMouseX=e.clientX-x+o.minX;if(o.maxX!=null)o.maxMouseX=o.minMouseX+o.maxX-o.minX;}else{if(o.minX!=null)o.maxMouseX= -o.minX+e.clientX+x;if(o.maxX!=null)o.minMouseX= -o.maxX+e.clientX+x;}if(o.vmode){if(o.minY!=null)o.minMouseY=e.clientY-y+o.minY;if(o.maxY!=null)o.maxMouseY=o.minMouseY+o.maxY-o.minY;}else{if(o.minY!=null)o.maxMouseY= -o.minY+e.clientY+y;if(o.maxY!=null)o.minMouseY= -o.maxY+e.clientY+y;}document.onmousemove=Drag.drag;document.onmouseup=Drag.end;return false;},drag:function(e){e=Drag.fixE(e);var o=Drag.obj;var ey=e.clientY;var ex=e.clientX;var y=parseInt(o.vmode?o.root.style.top:o.root.style.bottom);var x=parseInt(o.hmode?o.root.style.left:o.root.style.right);var nx,ny;if(o.minX!=null)ex=o.hmode?Math.max(ex,o.minMouseX):Math.min(ex,o.maxMouseX);if(o.maxX!=null)ex=o.hmode?Math.min(ex,o.maxMouseX):Math.max(ex,o.minMouseX);if(o.minY!=null)ey=o.vmode?Math.max(ey,o.minMouseY):Math.min(ey,o.maxMouseY);if(o.maxY!=null)ey=o.vmode?Math.min(ey,o.maxMouseY):Math.max(ey,o.minMouseY);nx=x+((ex-o.lastMouseX)*(o.hmode?1: -1));ny=y+((ey-o.lastMouseY)*(o.vmode?1: -1));if(o.xMapper)nx=o.xMapper(y);else if(o.yMapper)ny=o.yMapper(x);Drag.obj.root.style[o.hmode?"left":"right"]=nx+"px";Drag.obj.root.style[o.vmode?"top":"bottom"]=ny+"px";Drag.obj.lastMouseX=ex;Drag.obj.lastMouseY=ey;Drag.obj.root.onDrag(nx,ny);return false;},end:function(){document.onmousemove=null;document.onmouseup=null;Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode?"left":"right"]),parseInt(Drag.obj.root.style[Drag.obj.vmode?"top":"bottom"]));Drag.obj=null;},fixE:function(e){if(typeof e=='undefined')e=window.event;if(typeof e.layerX=='undefined')e.layerX=e.offsetX;if(typeof e.layerY=='undefined')e.layerY=e.offsetY;return e;}};function xalert(x,y,w,h,p){var IE=document.all;var iXPos;var iYPos;$('.xalert div:eq(3)').html("<img src='images/loading2.gif' alt='carregando'><br>Carregando");if(w){$('.xalert').css({"width":w});$('.xalert div:eq(1)').css({"width":w-33});}else{$('.xalert').css({"width":300});$('.xalert div:eq(1)').css({"width":270})}if(h)$('.xalert').css({"height":h});$('.xalert div:eq(1)').html(x);$.ajax({url:'/index.php',data:'load='+y+'&plano='+p,type:'POST',dataType:'text',timeout:10000,error:function(){alert('Algum erro ocorreu, tente mais tarde.');},success:function(x){$('.xalert div:eq(3)').html(x);}});$('.xalert').css({"display":"block","top":0,"left":0});if(!IE){iXPos=(self.innerWidth-document.getElementById('xalert').offsetWidth)/2+"px";iYPos=document.documentElement.scrollTop+20+"px";}else{iXPos=((document.body.clientWidth)-document.getElementById('xalert').offsetWidth)/2+"px";iYPos=document.documentElement.scrollTop+20+"px";}$('.xalert').css({"display":"none","top":iYPos,"left":iXPos});$('.xalert').fadeIn('slow');};jQuery.cookie=function(name,value,options){if(typeof value!='undefined'){options=options||{};if(value===null){value='';options.expires= -1;}var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}expires='; expires='+date.toUTCString();}var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=[name,'=',encodeURIComponent(value),expires,path,domain,secure].join('');}else{var cookieValue=null;if(document.cookie&&document.cookie!=''){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(cookie.substring(0,name.length+1)==(name+'=')){cookieValue=decodeURIComponent(cookie.substring(name.length+1));break;}}}return cookieValue;}};jQuery.fn.Shake=function(){this.each(function(init){var jqNode=$(this);jqNode.css({position:'relative'});for(var x=1;x<=3;x++){jqNode.animate({left: -25},10).animate({left:0},50).animate({left:25},10).animate({left:0},50);}});return this;};function querySt(ji){hu=window.location.search.substring(1);gy=hu.split("&");for(i=0;i<gy.length;i++){ft=gy[i].split("=");if(ft[0]==ji){return ft[1];}}};function loadtext(x){$("#text div").hide();$("#text div").html("<div style='text-align:center;padding-top:100px;'><img src='images/loading.gif'><br><b>Carregando</b></div>");$("#text div").fadeIn("slow");$.ajax({url:'/index.php',data:'loadtext='+x,type:'POST',dataType:'text',timeout:10000,error:function(){alert('Algum erro ocorreu, tente mais tarde.');},success:function(x){if(x){$("#text div").html(x);}else{$("#text div").html("<div style='text-align:center;padding-top:100px;'><img src='images/loading.gif'><br><b>Carregando</b></div>");}}});};function action(_type){$('#painel center:first').hide();nakedFIX();$('#contato center:first').hide();if(_type=="painel"){$("#image span").html("<img src='images/loading2.gif'><br><b>Verificando dados.</b>");$("#image span").fadeIn("slow");data="login=1&user="+$("#painel input:eq(0)").val()+"&password="+$("#painel input:eq(1)").val();$.ajax({url:'/index.php',data:data,type:'POST',dataType:'text',timeout:10000,error:function(){alert('Algum erro ocorreu, tente mais tarde.');},success:function(x){$("#image span").fadeOut("slow");if(x==23){$('#painel center:first').fadeIn('slow');$('#painel center:first').html("<font color='red'>Usuário/Senha INVÁLIDOS</font>");nakedFIX();}else{$.cookie('JHMSAUTH',x,{expires:1});setTimeout("window.location.reload()",2000);}}});}if(_type=="contato"){if($('#contato input:eq(1)').val().search('@')<0){$('#contato center:first').html("<font color='red'>por favor , coloque um email valido</font>");$('#contato center:first').fadeIn('slow');return 0;}if(!$('#contato input:eq(0)').val()){$('#contato center:first').html("<font color='red'>por favor,insira um nome</font>");$('#contato center:first').fadeIn('slow');return 0;}if(!$('#contato textarea').val()){$('#contato center:first').html("<font color='red'>por favor,insira uma mensagem</font>");$('#contato center:first').fadeIn('slow');return 0;}$('#contato input:eq(2)').val("Enviando");$('#contato input:eq(2)').attr("disabled","disabled");$("#image span").html("<img src='images/loading2.gif'><br><b>Enviando mensagem.</b>");$("#image span").fadeIn("slow");data="contato=1&nome="+$('#contato input:eq(0)').val()+"&email="+$('#contato input:eq(1)').val()+"&mensagem="+$('#contato textarea').val()+"&url="+window.location;$.ajax({url:'/index.php',data:data,type:'POST',dataType:'text',timeout:10000,error:function(){alert('Algum erro ocorreu, tente mais tarde.');},success:function(x){if(x==1){$('#contato center:first').html("<font color='red'>falha ao enviar a mensagem , tente mais tarde.</font>");$('#contato center:first').fadeIn('slow');$('#contatook').val("Enviar");$('#contatook').attr("disabled","");$("#image span").fadeOut("fast");}if(x==2){$('#contato center:first').html("<font color='#7bc24b'>Mensagem enviada com sucesso. Em breve entraremos em contato.</font>");$('#contato center:first').fadeIn('slow');$('#contatook').val("Obrigado.");$("#image span").fadeOut("fast");}}});}if(_type=="domain"){if(!$("#domain input:eq(0)").val())return 0;$("#image span").fadeIn("slow");$("#image span").html("<img src='images/loading2.gif'><br><b>Verificando domínio.</b>");$("#domain div:eq(1)").text("Verificando...");$.ajax({url:'/index.php',data:'checkdomain='+$("#domain input:eq(0)").val(),type:'POST',dataType:'text',timeout:10000,error:function(){alert('Algum erro ocorreu, tente mais tarde.');},success:function(x){if(x==1){$("#domain div:eq(1)").html("<span style='color:red;'>Domínio INDISPONÍVEL.</span>");}else if(x==2){$("#domain div:eq(1)").html("<span style='color:red;'>Não reconhecida extenção do domínio.</span>");}else if(x==3){$("#domain div:eq(1)").html("<span style='color:red;'>Dominio INVALIDO.</span>");}else if(x==4||x==5){$("#domain div:eq(1)").html("<span style='color:red;'>Não foi possível acessar a página.</span>");}else if(x==0||x==6){$("#domain div:eq(1)").html("<span style='color:#85e15f;'>Domínio DISPONÍVEL, entre em contato para reserva-lo.</span>");}$("#image span").fadeOut("slow");}});}};$(function(){Drag.init($('#xalert div:eq(0)')[0],$('#xalert')[0],0,screen.width-200,0,screen.height/2+15);$(".xalert div:eq(2)").click(function(){$(".xalert").hide("explode");});$("#menu").slideDown("slow");setTimeout(function(){$("#text").Shake();},1000);var img=new Image();$(img).load(function(){$("#content #image span img").fadeOut('fast');$('#content #image').css({"background":"url(images/mobo.png) no-repeat top center"});$("#content #image").hide().slideDown("slow");starbg();}).attr('src','images/mobo.png');$("#menu span").click(function(){$("#menu span").removeClass('active');$(this).addClass('active');loadtext($(this).attr("id"));});$("#painel input:eq(0)").focus(function(){if($(this).val()=="Login")$(this).val("");});$("#painel input:eq(1)").focus(function(){$(this).css({"background":"#777"});});$("#contato input:eq(0)").focus(function(){if($(this).val()=="Nome")$(this).val("");});$("#contato input:eq(1)").focus(function(){if($(this).val()=="Email para contato")$(this).val("");});$("#painel").keypress(function(e){if(e.which==13){action("painel");}});$("#painel input:eq(2)").click(function(){action("painel");});$("#contato input:eq(2)").click(function(){action("contato");});$("#contato input:eq(3)").click(function(){$("#contato input:eq(0)").val("");$("#contato input:eq(1)").val("");$("#contato textarea").val("");});$("#domain").keypress(function(e){if(e.which==13){action("domain");}});$("#domain input:eq(1)").click(function(){action("domain");});$("#painel input[type!='button'],#contato input[type!='button'],#domain input[type!='button'],#contato textarea").focus(function(){$(this).css({"background-color":"#999"});});$("#painel input[type!='button'],#domain input[type!='button'],#contato input[type!='button'],#contato textarea").blur(function(){$(this).css({"background-color":"#777"});});$("#main").css({"min-height":screen.height});});
function roundPHP ( val, precision ) { return parseFloat(parseFloat(val).toFixed(precision));  }
$(function(){$("#velocidade").click(function(){$("#image span").hide().html("<img src='images/loading2.gif'><br>Testando sua conexão.");$("#image span").fadeIn("slow");time=new Date();starttime=time.getTime();$.getScript("http://www.jhms.com.br/meter.js", function(){kbps=roundPHP(kbps,2);$("#image span").html("<div style='background:url(images/limit.png) no-repeat left top;width:90px;height:55px;margin:0 auto;font-size:19px;font-weight:bold;color:#000;font-family:arial;padding-top:35px;'>"+smad(parseInt(kbps)/10)+"</div>");});});$('#velocidade').hover(function(){$(this).css({'border':'1px solid #eeeeee','background':'#999999 url(../images/meter.png) no-repeat 120px center','cursor':'pointer','text-decoration':'underline'})},function(){$(this).css({'border':'1px solid #999999','background':'#777777 url(../images/meter.png) no-repeat 120px center','cursor':'default','text-decoration':'none'})})});

