var votepath = '/own_includes/vote/js/';

function voteCount(id,db_id){
	var entry=document.getElementById('vote_'+db_id);
	var stl_class = document.createAttribute("class");

	stl_class.nodeValue = "vote_inactive";
	entry.setAttributeNode(stl_class);
	
	entry.innerHTML = 'Danke';
	new Ajax.Updater( id, votepath+'responses/update_count.php?db_id='+db_id, {asynchronous:true});
	
}

function updateList(id,list_id){
	var cat_id = document.getElementById(id).value;
	
	new Ajax.Updater( 'counter_list', votepath+'responses/updated_list.php?cat_id='+cat_id+'&list_id='+list_id, {asynchronous:true});
}

function saveComment(){
	//Achtung das sind Clientseitige Daten unbedingt vorher Checken bevor die Daten in die DB gehen.
	var list_id=document.getElementById('comment_list_id').value;
	var name=document.getElementById('comment_name').value;
	var mail=document.getElementById('comment_mail').value;
	var url=document.getElementById('comment_url').value;
	var text=document.getElementById('comment_text').value;
	
	//text = text.replace(/\n/g, "<br>");
	
	new Ajax.Updater( 'comments_list', votepath+'responses/insert_comment.php?name='+name+'&mail='+mail+'&url='+url+'&text='+text+'&list_id='+list_id, {asynchronous:true});
	
	if ((text!='') && (text!=' ')){
	    document.CommentForm.reset();
	}
}

/*
 * Administrator Funktionen
 */

function showCreateList(){
	document.getElementById('create_list').style.display = 'block';
}

function showCreateCategory(){
	document.getElementById('create_category').style.display = 'block';
}

function activateCreateSelect(id){
	var list_id = document.getElementById(id).value;
	
	if(list_id==-1){
		document.getElementById('cat_select').disabled = true;	
		document.getElementById('cat_select').innerHTML ='<option value="-1">Bitte ausw&auml;hlen</option>';
	}
	else{
		document.getElementById('cat_select').disabled = false;
		new Ajax.Updater( 'cat_select', '../js/responses/updated_cat_select.php?list_id='+list_id, {asynchronous:true});
	}
}
