var js_script = 'http://'+document.location.hostname+'/lib/js';
var abs_path = 'http://'+document.location.hostname;
var rel_path = document.location.hostname;



$(document).ready(function() {

	
	//cabos e terminais
	$(".subs").hide();
	$(".opensub").live('mouseover',function(event){
		
		if(event.type == 'mouseover')
		{	
			$(".subs").show();
		}		
	});
	
	$(function(){
	
		$("#price").maskMoney({symbol:"",decimal:",",thousands:"."})
	})
	
	
	$('#nav').droppy();	
	$("#cpf").mask("999.999.999-99");
	$("#cnpj").mask("99.999.999/9999-99");
	$("#postalcode").mask("99999-999");
	$("#phone").mask("(99)9999-9999");
	$("#Telefone").mask("(99)9999-9999");
	$("#cell").mask("(99)9999-9999");
	$("#DataInsp").mask("99/99/9999");
	
	
	
	$('#uf').change(function() {
		
		
		$('#cities').html('<option value="sda">Carregando ...</option>');
		$.get(abs_path + '/process.php', { uf : $('#uf').val(), action: 'listcities' }, 
		function(resposta){
			
			$("#cities").empty().html(resposta);
		});
	});
	

	
	$("#readterms").hide();

	
	$("#readterms-close span").click(function(){
		$("#readterms").hide();
	})
	
	
	
	$("#lkreadterms").click(function(){
		$("#readterms").slideToggle();
	})
	
	$("#readterms").draggable({ cancel: "#readterms-content"});

	
	
	
	//checkbox termos
	//$('#btncad').attr("disabled", true);
	$("#terms").click(function() {
		
	if(this.checked == true){
	
		$('#btncad').removeAttr("disabled"); 
		
		}else{
		
		$('#btncad').attr("disabled", true);
		}
	});

	
//-----------------------------------------------------------------------------
//	CHECKBOX
//-----------------------------------------------------------------------------
$('#checkAll').click(function(){$(':checkbox').attr('checked',this.checked)});

	
});


/*ABRE POPUP*/
function openw(url, title, width, height) {

   var w = window.screen.availWidth;
   var h = window.screen.availHeight;

   var leftPos = (w-width)/2, topPos = (h-height)/2;

   
   var NewWindows = window.open(url, title,'scrollbars=yes, width=' + width + ', height=' + height + ', top=' + topPos + ', left=' + leftPos);
   NewWindows.focus();

}

