	
	var riser;
	var level;
	var i;
	var dynamic_node;
		
	function reset_values(){

		riser = 0;
		level = 0;
		i = 10;
		dynamic_node = '';
	}
		
	function expandHeight(){ 

		riser = i * i * (level / 100) ;
			
		dynamic_node.style.height = level - riser + 'px';
		
		if(i > 0 && i < 31) {

			setTimeout('expandHeight()', 15);
			i--;
		}
		
		else reset_values();
	}
	
	function reduceHeight(){

		riser = i * i * (level / 100) ;
			
		dynamic_node.style.height =  riser + 'px';
		
		if(i > 0 && i < 11) {

			setTimeout('reduceHeight()', 15);
			i--;
		}
		
		else reset_values();
	}
	
	function doneComment(node,xmlHttp){
	
		node.innerHTML = xmlHttp.responseText;
		
		var allnode = node.childNodes;
		var nodelist = [];
	
		var n = 0;
		for(i=0;i<allnode.length;i++){
			
			if(allnode[i].nodeType == 1 && allnode[i].tagName != 'BR'){
				
				nodelist[n] = allnode[i];
				n++;
			}
		}
		
		initFields(nodelist[0],nodelist[1])
	}
	
	function addComment(node,id){
	
		get_node_list(node.parentNode);
		if(nodelist[0].value == 'namn' || nodelist[1].value == 'kommentar' )  getPrevious(getPrevious(node.parentNode.parentNode.parentNode.parentNode.parentNode)).style.display = 'block';
		
		else{
		
			node.onclick = null;
			var callback = 'get_comments(node,php_posts[5]);';
			var method = 'POST';
			var fileName = 'set_comment';
			var name = convert_to_entity(nodelist[0].value);
			var comment = convert_to_entity(nodelist[1].value);
			var php_posts = ['name',name,'comment',comment,'postid',id];

			sendAjax(callback,method,fileName,php_posts,node.parentNode.parentNode.parentNode.parentNode.parentNode);
		}
	}
	
	function initFields(nodelist){
	
		for(i=0;i<=1;i++){
		
			nodelist[i].onfocus = function(){
			
				this.value = '';
				this.style.color = 'black';
			}
			
			nodelist[i].onblur = function(){
			
				if(this.value == ''){
				
					this.style.color = '#CCC';
					this.value = this.name;
					
					this.onfocus = function(){
			
						this.value = '';
						this.style.color = '#000';
					}
				}
				
				else this.onfocus = null;
			}
		}
	}
	
	function get_comments_done(node,responseText){
		
		node.innerHTML = responseText;
		
		var table = node.getElementsByTagName('table')[0];
		var name = node.getElementsByTagName('input')[0];
		var comment = node.getElementsByTagName('textarea')[0];
		
		nodelist = [name,comment];
		
		initFields(nodelist);
		node.style.display = "block";
	}
	
	function get_comments(node,id){

		var callback = 'get_comments_done(node,xmlHttp.responseText);';
		var method = 'POST';
		var fileName = 'get_comment';
		var php_posts = ['postid',id];

		sendAjax(callback,method,fileName,php_posts,node);
	}
	
	function showComments(node,id){
	
		node = getNext(node.parentNode);
		
		if(node.style.display != 'block') get_comments(node,id);
		
		else {
		
			node.style.display = 'none';
			node.innerHTML = '';
		}
	}