<!--


function DEF_OBJ_ZINAS() {


	this.addComment = function() {
		
		var obj_user_id	= fns_getElementById('id_f_c_user_id');
		var obj_id 		= fns_getElementById('id_f_c_article_id');
		var obj_comment = fns_getElementById('id_f_c_comment');
		var obj_msg 	= fns_getElementById('id_f_c_msg');
		var obj_name 	= fns_getElementById('id_f_c_name');
		var obj_code 	= fns_getElementById('id_f_c_code');
		
		if (obj_user_id && obj_id && obj_comment && obj_msg && (obj_user_id.value > 0 || (obj_user_id.value == 0 && obj_name && obj_code))) {
			
			var article_id = obj_id.value;
			
			if (obj_comment.value.length > 1 && (obj_user_id.value > 0 || (obj_user_id.value == 0 && obj_name.value.length > 0 && obj_code.value.length == 3))) {
				
				var name = ''; if (obj_user_id.value == 0) name = obj_name.value;
				var code = ''; if (obj_user_id.value == 0) code = obj_code.value;
				
				var link = HTTP_ROOT + 'v2008/act/zinas/add_comment.php';
				var vars = 'article_id=' + article_id + '&comment=' + encodeURIComponent(obj_comment.value) + '&name=' + encodeURIComponent(name) + '&code=' + encodeURIComponent(code) + '&ajax=1';
				
				OBJ_AH.doPost(link, 'id_f_c_msg', 'OBJ_ZINAS.displayAddCommentRes(' + article_id + ', resp)', vars);
				
			}else {
				if (obj_user_id.value > 0) {
					obj_msg.innerHTML = 'Nav ievadīts komentārs!';
				}else {
					obj_msg.innerHTML = 'Nav aizpildīti visi nepieciešamie lauki!';
				}
			}
			
		}
		
		return false;
		
	}// END addComment
	
	
	this.displayAddCommentRes = function(article_id, resp) {
		
		var obj_user_id	= fns_getElementById('id_f_c_user_id');
		var obj_comment = fns_getElementById('id_f_c_comment');
		var obj_msg 	= fns_getElementById('id_f_c_msg');
		var obj_name 	= fns_getElementById('id_f_c_name');
		var obj_code 	= fns_getElementById('id_f_c_code');
		
		if (obj_user_id && obj_comment && obj_msg) {
			
			if (resp == 'ok') {
				this.getCommentsList(article_id, 'DESC', 1);
				obj_comment.value = '';
				if (obj_user_id.value == 0 && obj_name && obj_code) {
					//obj_name.value = '';
				}
			}else {
				obj_msg.innerHTML = resp;
			}
			
		}
		
	}// END displayAddCommentRes
	
	
	this.getCommentsList = function(article_id, order, page) {
		
		var obj = fns_getElementById('id_comments_list');
		
		if (obj) {
			
			var link = HTTP_ROOT + 'v2008/act/zinas/display_article_comments.php?article_id=' + article_id + '&order=' + order + '&page=' + page;
			OBJ_AH.doGet(link, 'id_comments_list_loading', 'OBJ_ZINAS.displayCommentsList(resp)');
			
		}
		
		return false;
		
	}// END getCommentsList
	
	
	this.displayCommentsList = function(resp) {
		
		var obj = fns_getElementById('id_comments_list');
		
		if (obj) {
			
			obj.innerHTML = resp;
			var top = this.getObjPosY(obj);
   			window.scroll(0, top); // horizontal and vertical scroll targets
   			
		}
		
	}// END displayCommentsList
	
	
	this.getObjPosY = function(obj) {
		
		var curtop = 0;
		
		if(obj.offsetParent)
			while (1) {
				curtop += obj.offsetTop;
				if(!obj.offsetParent) break;
				obj = obj.offsetParent;
			}else if(obj.y) curtop += obj.y;
		
		return curtop;
		
	}// END getObjPosY
	
	
	this.getTopArticlesTabContent = function(obj, type) {
		
		var obj_content = fns_getElementById('id_tab_top_articles_content');
		
		if (obj_content) {
			
			var obj_list = obj.parentNode.parentNode;
			var obj_li = obj.parentNode;
			
			var li_list = obj_list.getElementsByTagName('li');
			
			for (var i = 0; i < li_list.length; i++) {
				li_list[i].className = '';
			}
			
			obj_li.className = 'active';
			
			var link = HTTP_ROOT + 'v2008/act/zinas/show_top_articles.ajax.php?type=' + type;
			OBJ_AH.doGet(link, 'id_tab_top_articles_content', 'OBJ_ZINAS.displayTopArticlesTabContent(resp)');
			
		}
		
		return false;
		
	}// END getTopArticlesTabContent
	
	
	this.displayTopArticlesTabContent = function(resp) {
		
		var obj_content = fns_getElementById('id_tab_top_articles_content');
		
		if (obj_content) {
			obj_content.innerHTML = resp;
		}
		
	}// END displayTopArticlesTabContent


}// END of class DEF_OBJ_ZINAS

var OBJ_ZINAS = new DEF_OBJ_ZINAS();

// -->