$(document).ready(function(e){
	
	if (v_counter_enable=="T"){
		$.ajax({		
			method: "get",
			url: "../video_counter_api.php?vid="+video_id+"&cat="+category+"&int=t",
			cache: false,
			timeout: v_timeout, //ms
			beforeSend: function(){			
				$("#video_counter").html("<img valign='absbottom' src='"+loading_path+"' width='13px' height='13px'/>");
			},		
			success: function(html){ //so, if data is retrieved, store it in html
				//alert(html);
				var value;
				if (html=="-"){
					if (error_msg==""){
						value = db_v_count;
					}else{
						value = error_msg;
					}
				}else{
					if (parseInt(html) >= parseInt(db_v_count)){
						value = html;
					}else{
						if (error_msg==""){
							//value = db_v_count;
							value = html;
						}else{
							value = error_msg;
						}	
					}
				}
				$("#video_counter").html(value); //show the html inside .content div	
			},
			error: function(objAJAXRequest, strError){
				//alert(strError);
				if (error_msg==""){
					value = db_v_count;
				}else{
					value = error_msg;
				}
				$("#video_counter").html(value);
			}
		});
	}

});