/*
blog count:
type:
1).recommend
2).up
3).down
*/
function updateCount(checkDiv,div,type,id){ 
	
	
    $.get('/blog.php',{type:type,id:id},function(msg){
    	eval("var data=" + msg + "");
        if(data['type'] == 'recommend'){
            $('#'+div).html(data['count']);
            $('#'+checkDiv).html(data['html']);
        }else if(data['type'] == 'agree'){
            $('#'+div).html(data['count']);
            $('#'+checkDiv).html(data['html']);
        }else{
            $('#'+div).html(data['count']);
            $('#'+checkDiv).html(data['html']);
        }
    });

}

function memberBlogLogin(username,password,loginShowDiv,comments,submitComments){
	  var type = "member";
	  var username =  $('#'+username).val();
	  var password =  $('#'+password).val();
	  $.get('/blog.php',{type:type,username:username,password:password},function(msg){
	  	eval("var data=" + msg + "");
    	if(data['status'] == '0'){
    		 $('#login_error').html(data['html']);
    	}else{
    		tb_remove();
    		parent.allowBlogComments(loginShowDiv, comments, submitComments,data['html']);
    	}
    });
}

function allowBlogComments(loginShowDiv, comments, submitComments,html){
	 $('#'+loginShowDiv).html(html);
	 $('#'+submitComments).show();
}

function showBlogRecaptcha(element, submitButton, themeName) {

  Recaptcha.create("6LdBpAUAAAAAALQIhBmR9veAY_VuTz8qCQpi7zlW", element, {
        theme: themeName,
        tabindex: 0
        //callback: Recaptcha.focus_response_field
  });

  document.getElementById(submitButton).style.visibility = "visible";
}

function getBlogRecapcha(tableName,recaptchaError){
	

	var recaptcha_challenge_field   = $('#recaptcha_challenge_field').val();
	var recaptcha_response_field =  $('#recaptcha_response_field').val();

    
    $.get('/recapchaBlog.php',{recaptcha_challenge_field:recaptcha_challenge_field, recaptcha_response_field:recaptcha_response_field},function(msg){
		 if(parseInt(msg) == 1){
			$('#'+recaptchaError).html("");
			$('#'+tableName).submit();
		 }else{
			$('#'+recaptchaError).html("Incorrect Code. Please Refresh the code and Try again.");
			return false;
		 }
     });


}


