function submitWillVote() {
	var willVote = $('input[name=willvote]:checked').val();
	var userAnswer = 0;
	if (willVote === undefined) {
		alert("hm...nu vrei sa selectezi ceva totusi inainte sa apesi pe buton ?");
		return;
	}

	$('#left').html($('#responseaftervotelogo').html());

	
	if ('yes' == willVote) {
		userAnswer = "yes";
	}
	if ('no' == willVote) {
		userAnswer = "no"; 
	}
	
	if ('yes' == willVote) {
		$('#yesvote').fadeOut("slow", function() {
			$('#yesvote').html(parseInt($('#yesvote').html()) + 1);
		}).fadeIn("slow");

	}

	if ('no' == willVote) {
		$('#novote').fadeOut("slow", function() {
			$('#novote').html(parseInt($('#novote').html()) + 1);
		}).fadeIn("slow");
	}

	$.post("vote.php", {
		what : userAnswer
	}, function(data) {
	}, "text");

}

function submitVoteForPresident(presidentid) {
	
	$('#prez-left').css('display', 'none');
	$('#prez-right').css('display', 'none');
	$('#prez-comment-left').css('display', 'none');
	$('#prez-comment-right').css('display', 'none');
	$('#commentAfterVote').css('display', '');
	
	
	
	
	$.post("vote4us.php", {
		presidentid : presidentid
	}, function(data) {

	}, "text");

}

function submitEmail() {

	var email = $('#contactEmail').val();
	var subject = $('#contactSubject').val();
	var message = $('#contactMessage').val();

	if (email.length == 0) {
		$('#contactEmail').focus();
		return;
	}
	if (subject.length == 0) {
		$('#contactSubject').focus();
		return;
	}
	if (message.length == 0) {
		$('#contactMessage').focus();
		return;
	}

	$('#contactform').html($('#aftercontact').html());

	$.post("contactUs.php", {
		email : email,
		subject : subject,
		message : message
	}, function(data) {

	}, "text");
}

function updateChars() {
	var length = $("#comment").val().length;
	if (length > 140) {
		$("#comment").val($("#comment").val().substring(0, 140));
	} else {
		$("#charCount").html(140 - length);
	}
}

function sendComment() {

	var name = $("#name").val();
	var comment = $("#comment").val();
	var presidentId = $('#presidentId').html();

	if (name.length == 0) {
		$("#name").focus();
		return;
	}

	if (name == "cum te cheama ?") {
		$("#name").focus();
		return;
	}
	if (comment.length == 0) {
		$("#comment").focus();
		return;
	}

	// var htmlTemp = $('#submitVoteDiv').html();
	// $('#submitVoteDiv').html($('#another').html());
	// $('#commentinput').html(htmlTemp);

	$('#submitVoteDiv').html($('#another').html());
	

	$('#topCommentName').html(name);
	$('#topCommentMessage').html(comment);
	$('#commentinput').css('display', 'none');
	$.post("comment.php", {
		name : name,
		message : comment,
		presedinteID : presidentId
	}, function(data) {
		$('#comments').load('getcomments.php?presidentId=' + presidentId);
	}, "text");
	
}



function refreshComment() {
	var presidentId = $('#presidentId').html();

	$.get("presedinti/getonecomment.php", {
		presidentId : presidentId
	}, function(data) {
		var retArr = data.split("__#__#__");
		$('#topCommentName').html(retArr[0]);
		$('#topCommentMessage').html(retArr[1]);
	}, "text");
}

function showPage(page) {
	var presidentId = $('#presidentId').html();
	$('#comments').load(
			'getcomments.php?presidentId=' + presidentId + "&pageno=" + page);
}

function closeThankYouMessage() {
	//$('#left').html($('#voteresults').html());
	$('#closeme').css('display', 'none');
}

function submitComanda() {

	var email = $('#tricouEmail').val();
	var marime = $('#tricouMarime').val();
	var culoare = $('#tricouCuloare').val();
	var tipOm = $('#tricouTipOm').val();

	if (email.length == 0) {
		$('#tricouEmail').focus();
		return;
	}

	$('#comandaForm').html($('#aftercomanda').html());

	$.post("comandaTricouri.php", {
		email : email,
		marime : marime,
		culoare : culoare,
		tipOm : tipOm
	}, function(data) {

	}, "text");
}

function refreshCities() {
	var presidentId = $('#presidentId').html();
	var firstCity = $('#orase1').val();
	var secondCity = $('#orase2').val();
	$("#cities").load(
			"presedinti/httpgetcitynumbers.php?firstCity=" + firstCity
					+ "&secondCity=" + secondCity + "&presedinteId="
					+ presidentId);
}
