function ApplicationManager() {

	this.enquete = {
		
		votar:function(container,votar) {
			
			this.checkIfChecked();
			
			$('#formenquete').ajaxSubmit({				
				type:"POST",				
				success: function(response) {					
					eval(response);										
				}
			}); 	
		
		},
		confirm : function() {
		
			if (!this.checkIfChecked()) { return false;}
			
			window.open('/enquete_validator.php','janEnquete','width=280,height=280,scrollbars=no,top=50,left=50,status=no,resizable=no');		
		
		},
		checkIfChecked : function() {
			
			var checks = false;
		
			jQuery('#formenquete input[@type=radio]').each(function(i) {
			
				if (jQuery(this)[0].checked) {
					
					checks = true;
				
				}
			
			});
			
			if (!checks) {
			
				alert("Por favor! Selecione uma das alternativas na qual deseja votar!");return false;
				
			}
			
			return true;
		
		}
	
	}
	
	this.postComent = function() {
	
		jQuery('#comentform').ajaxSubmit({
			url:"/ajax/ajaxRequest.php",				
			type:"POST",				
			success: function(response) {	
				
				eval(response);
				
			}
		}); 	
		
	}
		
	this.execVoto = function(idnews,value) {
	
		jQuery.ajax({
			url:"/ajax/ajaxRequest.php",
			type:"GET",
			data:"page=voto&id=" + idnews + "&value="+value,				
			dataType:"script",
			success:function(response) {
													
			}
			
		});
		
	}
	
	this.postContato = function() {
	
		jQuery('#contatoform').ajaxSubmit({
			url:"/ajax/ajaxRequest.php",				
			type:"POST",				
			success: function(response) {	
				
				try {
					eval(response);
				} catch(e) {
					
					alert(response);
				
				}
				
			}
		}); 	
		
	}
	
	this.getMoreNews = function(item,type) {
	
		jQuery('#aba-more-news a').removeClass("selected");
		jQuery(item).addClass("selected");
		
		if (type == "recentes") {
			
			jQuery("#news-comentadas").hide();
			jQuery("#news-votadas").hide();
			
		}
		
		if (type == "comentadas") {
			
			jQuery("#news-recentes").hide();
			jQuery("#news-votadas").hide();
			
		}
		
		if (type == "votadas") {
			
			jQuery("#news-recentes").hide();
			jQuery("#news-comentadas").hide();
			
		}
		
		jQuery("#news-"+type).show();			
	
	}
	
	this.loadCidades = function(objSource,objTarget,selectedItem,setDisabled) {		
		parans = "";
		uf = objSource.options[objSource.selectedIndex].value;	
			
		if (uf!="") {
			jQuery("#"+objTarget)[0].options[0].text = "Carregando...";
			jQuery("#"+objTarget)[0].disabled = true;	
			
			jQuery.ajax({
				url:"/ajax/ajaxRequest.php",
				type:"GET",
				data:"uf=" + uf + "&page=cidades&objTgt="+objTarget,				
				dataType:"html",
				success:function(response) {
					
					jQuery("#container_"+objTarget).html(response);
					
					if (selectedItem!=undefined) {
						jQuery("#"+objTarget).val(selectedItem);
					}
					
					if (setDisabled) {
					
						jQuery("#"+objTarget).attr("disabled","disabled");
					
					} else {
					
						jQuery("#"+objTarget).focus();
						
					}
										
				}
				
			});
					
		}	
	}
	
	this.reloadCaptcha = function(instance) {
													
		jQuery("#catpcha").val("");
		jQuery("#" + instance).attr("src",jQuery("#" + instance).attr("src") + "?nocache="+Math.round(Math.random() * (6 - 1)) + 1);
		jQuery("#catpcha").focus();
	
	}
	
	this.textSize = function(obj,type) {txt = jQuery("#"+obj)[0];size = parseInt((txt.style.fontSize!="") ? txt.style.fontSize:"14px");txt.style.fontSize = (type=="+" && size<18) ? (++size)+"px": ((size>10 && type=="-") ? (--size)+"px":size+"px");}

}

var App = new ApplicationManager();
