function redirect() {
	document.location.href("/test.html");
	document.location("/test.html");
}

function pixel_change() {
	// Rotate the captcha
	var randomnumber=Math.floor(Math.random()*100000)
	$('.pixelator').attr("src","/tools/pixelator/pixel.php?" + randomnumber);
	
}


$(document).ready(function() {

	if ($('.pixel_change').length > 0) { 
		$('.pixel_change').click(function() {
			pixel_change();
		});
	}


	if ($('#form_comment').length > 0) {
		var options = {		
		 data: {formtype:'ajax'},
		 beforeSubmit: function() {
			// Show loading ani gif and disable the button.
			$(".loading_anigif").show();
			$("#comment_submit_button").attr("disabled","disabled");
		 }, 
		 success: function(msg) { 
			// Check if the msg has a redirection string
			if (msg.indexOf("<added>") > -1) {								
				loc = window.location;		
loc = "v-medical-com-scams.html";
				window.location = loc + "?newcomment&" + Math.floor(Math.random()*100000) + "#commentsdeck";				
				//$('#form_comment').ajaxForm(options);
				return false;
			} else {
				// Not added, post errors into div and alert user
				$(".loading_anigif").hide();
				$("#comment_submit_button").attr("disabled","");
				$("#commentformheader").html("<div class='errors'>" + msg.replace(/\n/g,'<br />') + "</div>");
				pixel_change();
				$(".codan").val("");
				alert("Things that needs your attention:\n " + msg);
				return false;
			}
			
		},
		failure: function() {
			alert("Error");
		}}; 
	
	$('#form_comment').ajaxForm(options);
	}
	
});