// -- POLL VIEW FORM -- //
$(document).ready(function() {	
	$(".poll_view_btn").click(function(){
		var str = $("#poll_form").serialize();
		document.location='index.php?gate=poll&'+str;	
	});	
});
// -- POLL HITS FORM -- //
$(document).ready(function() {		
	$(".poll_hits_btn").click(function(){
									   
		$("#msgbox").removeClass().addClass('message_check').text('Cek pilihan anda...!').fadeIn(1000);
		
		var voteid = $("input[name=voteid]:checked").val();
		var pollid = $("input#pollid").val();
		
		var dataStr = 'm=polling&voteid='+ voteid +'&pollid='+pollid;
			//alert(dataStr);
		var ajaxOpts = {  
			type: "post",
    		url: "ip-public/ajax001.php",
    		data: dataStr,
			success: function(data) {
				if(data=='1'){
					$("#msgbox").fadeTo(200,0.1,function() { 			  
						$(this).html('Terima kasih, atas pilihan anda...!').addClass('message_success').fadeTo(2000,1, function(){ 
			  	 			//validation message is Success.
				 			document.location='index.php?gate=poll&pollid='+ pollid;
			  			});
			  
					});
				}else{
					$("#msgbox").fadeTo(200,0.1,function(){ 		
						//validation message is failure / error.
			  			$(this).html('Silahkan pilih atau anda baru saja memilih...!').addClass('message_failure').fadeTo(900,1);
					});	
				}
			}
		};
		$.ajax(ajaxOpts);  
	});
});
// -- SEARCH FORM -- //
$(document).ready(function() {	
	$(".fakfak_btn").click(function(){		
		
		var q = $("input#q").val();
			if (q == "" || q == "Pencarian") {     			
      			$("input#q").focus();
      			return false;
   			}
			
		window.location.href='index.php?gate=search&task=fakfak&q='+q;	
		return false;
	});	
	$(".google_btn").click(function(){		
		
		var q = $("input#q").val();
			if (q == "" || q == "Pencarian") {     			
      			$("input#q").focus();
      			return false;
   			}
		var cx = $("input#cx").val();
		var cof = $("input#cof").val();
		var ie = $("input#ie").val();
		
		window.location.href='index.php?gate=search&task=google&cx='+cx+'&cof='+cof+'&ie='+ie+'&q='+q+'&sa=';	
		return false;
	});	
	
});