// JavaScript Document
$(document).ready(function(){
	
	$('a[href*=#]').each(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
		&& location.hostname == this.hostname
		&& this.hash.replace(/#/,'') ) {
		var $targetId = $(this.hash), $targetAnchor = $('[name=' + this.hash.slice(1) +']');
		var $target = $targetId.length ? $targetId : $targetAnchor.length ? $targetAnchor : false;
		if ($target) {
			var targetOffset = $target.offset().top;
			$(this).click(function() {
				$('html, body').animate({scrollTop: targetOffset}, 2000);
				return false;
			});
		}
	}
	});	
	
	//$('.sg_img a').tipsy({gravity: 'sw', title: 'name', fade: true, offset: -20, });
//	$('#content_sobre_main_img a').tipsy({gravity: 'nw', title: 'name', fade: true, offset: -620, });
//	
	$('input').focus(function(){	
	var Bag = $(this).attr('id');
	var selfValue = Bag.substr(0);	
		if($(this).val() == selfValue){
			$(this).val('');
		}
	}).blur(function(){
	var Bag = $(this).attr('id');
	var selfValue = Bag.substr(0);
		if($(this).val() == ''){
			$(this).val(selfValue);
		}	
	});
	$('#Mensagem').focus(function(){
		if($(this).text() == 'Mensagem'){
			$(this).text('');
		}						  
	}).blur(function(){
		if($(this).text() == ''){
			$(this).text('Mensagem');
		}	
	});
	$('#bt_enviar').click(function(){
		if(($('#Email').val()=='') || ($('#Email').val()=='Email')){
			$('#logDiv_erro').fadeIn().text('Por favor digite seu Email');	
			$('#Email').focus();
		}
		else if(($('#Email').val().indexOf("@")<2) || ($('#Email').val().indexOf(".")<1)){
			$('#logDiv_erro').fadeIn().text('Por favor digite um Email válido');	
			$('#Email').focus();	
		}else{
			var vrf = $('#vrf').val();
			var nome = $('#Nome').val();
			var email = $('#Email').val();
			var tel = $('#Telefone').val();
			var msg = $('#Mensagem').val();

			$('#logDiv_erro').load('contact_resp.php',{verify:vrf,nome:nome,email:email,tel:tel,msg:msg}).fadeIn();	
			$('#frm_contato').fadeOut();
		}	
		$(this).val(' ');
		
	});
	
	//$("#Telefone").mask("(99) 9999-9999");
	$('#img-slider').cycle({
		fx: 'fade',
		speedIn:1000,  
   		speedOut:500,  
		timeout:9000,
		pager:'#nav',
		cleartype: true, 
		cleartypeNoBg: true,
		before: function(){
			$('#img-slider').append('<div id="nav">');	
		}
	});
	

		var settings = {
		autoReinitialise: true,
		horizontalDragMaxWidth: 67,
		horizontalGutter: 30
		};
		$('.scroll-content').jScrollPane(settings);

		//$('.jspPane').css({top:'41px'});
		$('#wrapScroller').appendTo('.jspContainer');
		$('.myTrack').appendTo('.jspContainer');
		
		$('.jspTrack').css({width:'870px'});
		
		if($('.myTrack').text() == ''){
			$('.myTrack').append('<span id="arr">arraste e veja mais deste projeto</span>');	
		}
		
		$('.jspDrag').live("mousemove",function(){
										//alert($('.jspDrag').offset().left);
		if($('.jspDrag').offset().left > 275){
			$('#arr').fadeOut(200);
		}else{
			$('#arr').fadeIn(200);	
		}
		});
	$('#slide-home').jcarousel({
    	wrap: 'circular',
		scroll:2,
		animation:500
    });
	$('.jb').click(function(){
		var str = $(this).attr('title');
		$('#show_job').html('<div style="position:absolute; top:340px; font-weight:bold; color:#fff; left:380px;"><img src="layout/ajaxLoader.gif" alt="Carregando"></div>').load('resp.php',{res:str},function(){
																																																							   		
		var settings = {
		autoReinitialise: true,
		horizontalDragMaxWidth: 67,
		horizontalGutter: 30
		};
		$('.scroll-content').jScrollPane(settings);

																																																						  	 	$('#wrapScroller').appendTo('.jspContainer');
		$('.myTrack').appendTo('.jspContainer');
		$('.jspTrack').css({width:'870px'});
		//$('.jspPane').css({top:'41px'});
		
		if($('.myTrack').text() == ''){
			$('.myTrack').append('<span id="arr">arraste e veja mais deste projeto</span>');	
		}
		$('.jspDrag').live("mousemove",function(){
										//alert($('.jspDrag').offset().left);
		if($('.jspDrag').offset().left > 275){
			$('#arr').fadeOut(200);
		}else{
			$('#arr').fadeIn(200);	
		}
		});
		
		
		
	});
		});
	
	setInterval(animaIsso,1);
	
	function animaIsso(){
		var n1 = Math.floor(Math.random()*91);
		var n2 = Math.floor(Math.random()*91);
		//var n2
		$('#content_sobre_main_img img').css({display:'block'}).animate({marginTop:n1,marginLeft:n2},2000);
		}
		//$('#loadDiv').fadeOut();
		
});
