﻿function decode_utf8(utftext) {
  var plaintext = ""; var i=0; var c=c1=c2=0;
  // while-Schleife, weil einige Zeichen uebersprungen werden
  while(i<utftext.length)
      {
      c = utftext.charCodeAt(i);
      if (c<128) {
          plaintext += String.fromCharCode(c);
          i++;}
      else if((c>191) && (c<224)) {
          c2 = utftext.charCodeAt(i+1);
          plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
          i+=2;}
      else {
          c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
          plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
          i+=3;}
      }
  return plaintext
}


function encode_utf8(rohtext) {
    // dient der Normalisierung des Zeilenumbruchs
    rohtext = rohtext.replace(/\r\n/g,"\n");
    var utftext = "";
    for(var n=0; n<rohtext.length; n++)
        {
        // ermitteln des Unicodes des  aktuellen Zeichens
        var c=rohtext.charCodeAt(n);
        // alle Zeichen von 0-127 => 1byte
        if (c<128)
            utftext += String.fromCharCode(c);
        // alle Zeichen von 127 bis 2047 => 2byte
        else if((c>127) && (c<2048)) {
            utftext += String.fromCharCode((c>>6)|192);
            utftext += String.fromCharCode((c&63)|128);}
        // alle Zeichen von 2048 bis 66536 => 3byte
        else {
            utftext += String.fromCharCode((c>>12)|224);
            utftext += String.fromCharCode(((c>>6)&63)|128);
            utftext += String.fromCharCode((c&63)|128);}
        }
    return utftext;
}


function ajaxFunction(parameters,URL,handleResult,resultId) {
  var xmlHttp;
  try {
  	// Firefox, Opera 8.0+, Safari    
  	xmlHttp=new XMLHttpRequest();    
  } catch (e) {    
  	// Internet Explorer    
  	try {
  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
  		}
    catch (e) {
    	try {
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
    	} catch (e) {        
    		alert("Your browser does not support AJAX!");        
    	return false;        
      }      
    }    
  }

  xmlHttp.onreadystatechange=function() {
  	if (xmlHttp.readyState==4) {
  		response=xmlHttp.responseText;
		//response = decode_utf8(response);
        if (handleResult) document.getElementById(resultId).innerHTML=response;
  		//alert(xmlHttp.responseText);

  	 
  	}
  } 
  //xmlHttp.open("POST","date.php",true);
  //xmlHttp.send(null);
  xmlHttp.open('POST', URL, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", parameters.length);
  xmlHttp.setRequestHeader("Connection", "close");
  xmlHttp.send(parameters);

}


function ajaxFunctionJS(parameters,URL,jsKey,param) {
  var xmlHttp;
  try {    
  	// Firefox, Opera 8.0+, Safari    
  	xmlHttp=new XMLHttpRequest();    
  } catch (e) {    
  	// Internet Explorer    
  	try {      
  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
  		}
    catch (e) { 
    	try {
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
    	} catch (e) {        
    		alert("Your browser does not support AJAX!");        
    	return false;        
      }      
    }    
  } 
  xmlHttp.onreadystatechange=function() {
  	if (xmlHttp.readyState==4) {
  		if (jsKey=="poolall" || jsKey=="eval" || jsKey=="cfilist" || jsKey=="cfdlist") refreshIdeas(); 
  		if (jsKey=="start") refreshAll(); 
  		if (jsKey=="imagepool") {
  			window.opener.updateMainImage(xmlHttp.responseText);
  	    window.close();
  	  }
  	  if (jsKey=="interest") {
  	  	//window.open("commEvalSummary.php?id="+xmlHttp.responseText, "", "width=440,height=220,left=300,top=300,dependent=yes,scrollbars=yes");
        //alert(unescape("Vielen Dank f%FCr Ihre Empfehlung!"));
  	  }
  	  if (jsKey=="adminreload") {
  	  	window.location="idea.php?act=4&"+param;
  	  }
  	  if (jsKey=="evaltodo") {
  		  //alert("Vielen Dank für Ihre Bewertung!");
  		  window.location="pool.php?topic=0&evalC=2";
  	} 
  	  if (jsKey=="cfdover") refreshCFD(); 
  	}		
  } 
  //xmlHttp.open("POST","date.php",true);
  //xmlHttp.send(null);
  xmlHttp.open('POST', URL, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", parameters.length);
  xmlHttp.setRequestHeader("Connection", "close");
  xmlHttp.send(parameters);

}

function ajaxFunctionCT(parameters,URL,tabName,tabCnt,showTab,topicSend) {  
  var xmlHttp;
  try {    
  	// Firefox, Opera 8.0+, Safari    
  	xmlHttp=new XMLHttpRequest();   
  } catch (e) {    
  	// Internet Explorer    
  	try {      
  		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
  		}
    catch (e) { 
    	try {
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
    	} catch (e) {        
    		alert("Your browser does not support AJAX!");        
    	return false;        
      }      
    }    
  } 
  xmlHttp.onreadystatechange=function() {
  	if (xmlHttp.readyState==4) {
  		if (tabName=="enter" && showTab==4) {
  			window.location="thankYou.php?topic="+topicSend;
  		} else {
  			//changeTab(tabName,tabCnt,showTab);
  	  }
  	  
  	}
  } 
  //xmlHttp.open("POST","date.php",true);
  //xmlHttp.send(null);
  xmlHttp.open('POST', URL, true);
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", parameters.length);
  xmlHttp.setRequestHeader("Connection", "close");
  xmlHttp.send(parameters);

}

function sendInvitationEvalAjax(email,userid,ideaid) {
	parameters ="ajax=true";
	parameters+="&email="+encodeURI(email);
	parameters+="&userid="+encodeURI(userid);
	parameters+="&ideaid="+encodeURI(ideaid);
	ajaxFunction(parameters,'sendInvitationEval.php',false,"");
}

function submitData(showTab,ideaid,selfEval) {
	var selectedTopic = 0;
	for (var k=0; k<document.getElementsByName("topic2").length; k++){
		if (document.getElementsByName("topic2")[k].checked) {
			selectedTopic = document.getElementsByName("topic2")[k].value;
		}
	}
	topicSend=encodeURIComponent(selectedTopic);
	title=document.getElementById("title").value;
	desc=document.getElementById("description").value;
	special=document.getElementById("special").value;
  	
	tabCnt=3;
	if ((selectedTopic == 0) && showTab>2) {
		alert(unescape("Bitte w%E4hlen Sie ein Thema zu Ihrer Idee!"));
	} else if ((title.length==0 || desc.length==0) && showTab>1) {
		alert(unescape("Bitte geben Sie Ihrer Idee erst einen Titel und f%FCllen Sie die Beschreibung aus!"));
	} else if (special.length==0 && showTab>1) {
		alert(unescape("Bitte geben Sie an, was das Besondere an Ihrer Idee ist!"));
//	} else if(document.getElementById("enterMainImage").style.display=='none' && showTab>1) {
//		alert(unescape("Bitte laden Sie ein Bild f%FCr Ihre Idee hoch!"));
	} else if((document.getElementById("eval_val1").value==0 || document.getElementById("eval_val2").value==0) && showTab>1) {
		alert(unescape("Bitte bewerten Sie Ihre Idee!"));
	} else {
	
	  catCnt=document.getElementById("catcnt").value;
	  // description
	  parameters ="id="+encodeURI(ideaid);
	  parameters+="&topic="+encodeURIComponent(selectedTopic);
	  parameters+="&title="+encodeURIComponent(document.idea.title.value);
	  parameters+="&description="+encodeURIComponent(document.idea.description.value);
	  parameters+="&technology="+encodeURIComponent(document.idea.technology.value);
	  parameters+="&special="+encodeURIComponent(document.idea.special.value);
	  parameters+="&usefulfor="+encodeURIComponent(document.idea.usefulfor.value);
  	  parameters+="&implementer="+encodeURIComponent(document.idea.implementer.value);
	  parameters+="&targetgroup="+encodeURIComponent(document.idea.targetgroup.value);
	  parameters+="&costs="+encodeURIComponent(document.idea.costs.value);
	  parameters+="&necessity="+encodeURIComponent(document.idea.necessity.value);
	  if (document.getElementById("questioninput")) {
			parameters+="&question="+encodeURIComponent(document.getElementById("questioninput").value);
		}
	  
	  // categorization
	  parameters+="&cnt="+encodeURI(catCnt);
	  for (var i=0; i<catCnt; i++) {
	  	val=0;
	  	if (document.getElementById("filter_"+i).checked) val=1;
	  	interestid=document.getElementById("filter_"+i+"_id").value;
	  	parameters+="&id"+i+"="+interestid;
	  	parameters+="&val"+i+"="+val;
	  }
	  /*
	  parameters+="&tags="+encodeURI(document.getElementById("tags_id").value);
	  parameters+="&tags="+document.getElementsByName('tags[]').join(',');
	  */
	  var tagger_elements = $('input[name="tags[]"]');
	  var tags = new Array();
	  tagger_elements.each(function(item) {
		  tags.push(jQuery(tagger_elements[item]).val());
	  });
	  
	  parameters+="&tags="+encodeURI(tags.join(','));
      evalCnt=0;
	   if (selfEval) {
	    tabCnt=4;
		realizeVal=0;
	  	if (document.getElementById("realizable") && document.getElementById("realizable").checked) {
	  		realizeVal=1;
	  	}
	    evalCnt=document.getElementById("evalcnt").value;
	    parameters+="&selfeval=1";
	    parameters+="&evalcnt="+encodeURI(evalCnt);
	    for (var i=1; i<=evalCnt; i++) {
		    val=document.getElementById("eval_val"+i).value;
		    key=document.getElementById("eval_key"+i).value;
		    text=encodeURI((document.getElementById("eval_text"+i).value));
		    parameters+="&evalval"+i+"="+val;
		    parameters+="&evalkey"+i+"="+key;
		    parameters+="&evalcomment"+i+"="+text;
	    }
	    parameters+="&realizable="+realizeVal;
		/*if ((document.getElementById("eval_text11").value == "") && showTab == 4) {
			showTab = 3;
			alert(unescape("Sie müssen die Frage 'Nutzen' beantworten um Ihre Bewertung absenden zu können!"));
		}*/
	   }
	  ajaxFunctionCT(parameters,'storeIdea.php','enter',tabCnt,showTab,topicSend);
	  //changeTab('enter',4,1+dir);
	}
}


function submitCat(cnt,dir) {
	parameters ="cnt="+encodeURI(cnt);
	for (var i=0; i<cnt; i++) {
		val=0;
		if (document.getElementById("filter_"+i).checked) val=1;
		interestid=document.getElementById("filter_"+i+"_id").value;
		parameters+="&id"+i+"="+interestid;
		parameters+="&val"+i+"="+val;
	}
	parameters+="&tags="+encodeURI(document.getElementById("tags_id").value);
	//alert(parameters);
	ajaxFunction(parameters,'storeIdeaCategorization.php',false,"");
	changeTab('enter',4,2+dir);
}

function ideaAddToFavs(ideaid) {
	parameters ="ajax=true";
	parameters +="&ideaid="+encodeURI(ideaid);
	ajaxFunction(parameters,'addToFavs.php',false,"");
}

function updateFavList(page) {
	parameters ="ajax=true";
	parameters+="&page="+encodeURI(page);
	ajaxFunction(parameters,'myIdeanetFavs.php',true,'favs');
}

function updateMyFavouriteIdeasList(listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	ajaxFunction(parameters,'myIdeanetFavs.php',true,"favs");
}

function submitEval(cnt,dir) {
	parameters ="cnt="+encodeURI(cnt);
	for (var i=1; i<=cnt; i++) {
		val=document.getElementById("eval_val"+i).value;
		key=document.getElementById("eval_key"+i).value;
		parameters+="&val"+i+"="+val;
		parameters+="&key"+i+"="+key;
	}
	ajaxFunction(parameters,'storeIdeaEval.php',false,"");
	if (dir==-1) {
		changeTab('enter',4,2);
	} else {
		window.location="thankYou.php";
	}
}

function delMainImage(imageName,selfEval) {
	var data = {
		'filename': encodeURI(imageName),
		'delmain': 'true',
		'ajax': 'true',
		'selfeval': encodeURI(selfEval)
	};

	var title = $('#title').val();
	var desc = $('#description').val();
	
	$.post('enterIdeaDescription.php', data, function(response) {
		$('#content_enter1').html(response);
		$('#title').val(title);
		$('#description').val(desc);
	});
}

function delImage(imageName,selfEval) {
	parameters ="filename="+encodeURI(imageName);
	parameters +="&delimage=true";
	parameters +="&ajax=true";
	parameters +="&selfeval="+encodeURI(selfEval);
	ajaxFunction(parameters,'enterIdeaDescription.php',true,"content_enter1");
}

function delFile(imageName,selfEval) {
	var data = {
		'filename': encodeURI(imageName),
		'delfile': 'true',
		'ajax': 'true',
		'selfeval': encodeURI(selfEval)
	};
	
	var title = $('#title').val();
	var desc = $('#description').val();
	
	$.post('enterIdeaDescription.php', data, function(response) {
		$('#content_enter1').html(response);
		$('#title').val(title);
		$('#description').val(desc);
	});
}


function delCommentStore(id) {
	parameters ="id="+encodeURI(id);
	parameters +="&ajax=true";
	ajaxFunction(parameters,'delComment.php',false,"");
}


function updateAddImages(selfEval) {
	var data = {
		'ajax': 'true',
		'selfeval': encodeURI(selfEval)
	};
	
	var title = $('#title').val();
	var desc = $('#description').val();
	
	$.post('enterIdeaDescription.php', data, function(response) {
		$('#content_enter1').html(response);
		$('#title').val(title);
		$('#description').val(desc);
	});
}


function updateComments(ideaid) {
	parameters ="ajax=true";
	parameters+="&ideaid="+ideaid;
	ajaxFunction(parameters,'ideaDiscussion.php',false,"content_idea1");
}


function storeInterest(ideaid,val) {
    //alert(unescape("Vielen Dank f%FCr Ihre Bewertung!"));
	parameters ="ideaid="+encodeURI(ideaid);
	parameters+="&val="+encodeURI(val);
	ajaxFunctionJS(parameters,'storeInterest.php',"interest","");
}

function storeInterest1(ideaid,val) {
    //alert(unescape("Vielen Dank f%FCr Ihre Bewertung!"));
	parameters ="ideaid="+encodeURI(ideaid);
	parameters+="&val="+encodeURI(val);
	ajaxFunctionJS(parameters,'storeInterest1.php',"interest","");
}

function storeInterest2(ideaid,val) {
    //alert(unescape("Vielen Dank f%FCr Ihre Bewertung!"));
	parameters ="ideaid="+encodeURI(ideaid);
	parameters+="&val="+encodeURI(val);
	ajaxFunctionJS(parameters,'storeInterest2.php',"interest","");
}

function submitExpertEval(ideaid,cnt,dir,userid) {
	parameters ="cnt="+encodeURI(cnt);
	parameters+="&ideaid="+encodeURI(ideaid);
	parameters+="&userid="+encodeURI(userid);
	
	for (var i=1; i<=cnt; i++) {
		val=document.getElementById("eval_val"+i).value;
		key=document.getElementById("eval_key"+i).value;
		parameters+="&val"+i+"="+val;
		parameters+="&key"+i+"="+key;
		parameters+="&comment"+i+"="+encodeURI(document.getElementById("eval_text"+i).value);
	}
/*	if ((document.getElementById("eval_text11").value) == "..." ) {
		alert("Sie müssen die Frage 'Nutzen' beantworten um Ihre Bewertung absenden zu können!");
		return false;
	}*/
	//ajaxFunction(parameters,'storeExpertEval.php',true,"evaltodo");
	ajaxFunctionJS(parameters,'storeExpertEval.php',"evaltodo",ideaid);
}

function updateRequest(searchString) {
	parameters ="string="+encodeURI(searchString);
	ajaxFunction(parameters,'presenterSearch.php',true,"presenterList");
}

function updateMemberRequest(searchString) {
	parameters ="string="+encodeURI(searchString);
	ajaxFunction(parameters,'memberSearchResult.php',true,"presenterList");
}


function updateMemberSearchRequest(searchString) {
	parameters ="string="+encodeURI(searchString);
	ajaxFunction(parameters,'membersListSearchResult.php',true,"memberslistresult");
}



function storePresenter(userid) {
	parameters ="ajax=true";
	parameters+="&action=add";
	parameters+="&userid="+encodeURI(userid);
	ajaxFunction(parameters,'ideaPresenter.php',true,"ideaPres");
}

function delPresenter(userid) {
	parameters ="ajax=true";
	parameters+="&action=del";
	parameters+="&userid="+encodeURI(userid);
	ajaxFunction(parameters,'ideaPresenter.php',true,"ideaPres");
}

function storeManualPresenter(username,email,phone,dep) {
	parameters ="ajax=true";
	parameters+="&action=add";
	parameters+="&username="+encodeURI(username);
	parameters+="&email="+encodeURI(email);
	parameters+="&phone="+encodeURI(phone);
	parameters+="&dep="+encodeURI(dep);
	ajaxFunction(parameters,'ideaPresenter.php',true,"ideaPres");
}

function updateIdeaList(orderby,orderdir,useFilter,listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&order="+encodeURI(orderby);
	parameters+="&orderdir="+encodeURI(orderdir);
	parameters+="&usefilter="+encodeURI(useFilter);
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	parameters+="&target=allideas";
	ajaxFunction(parameters,'poolAllIdeas.php',true,'pool_all');
}

function updateIdeaListJQuery(orderby,orderdir,useFilter,listIndex,listCnt, topic, evalC, expertEval) {
    parameters = { ajax:"true", order:orderby, orderdir:orderdir, usefilter:useFilter, index:listIndex, listcnt: listCnt, target: "allideas", topic: topic, evalC: evalC, expertEval: expertEval};
    $.post('poolAllIdeas.php', parameters, function(data){
        $('#pool_all').html(data);
    });
}

function updateCommentsJQuery(listIndex,listCnt) {
    parameters = { ajax:"true", index:listIndex, listcnt: listCnt, target: "allquestions"};
    $.post('poolCommunityQuestions.php', parameters, function(data){
        $('#questions_all').html(data);
    });
}

function updateIdeaListAdmin(orderby,orderdir,useFilter,listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&order="+encodeURI(orderby);
	parameters+="&orderdir="+encodeURI(orderdir);
	parameters+="&usefilter="+encodeURI(useFilter);
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	parameters+="&target=allideas";
	ajaxFunction(parameters,'ideasAll.php',true,'pool_all');
}

function updateIdeaListAdminNew(orderby,orderdir,useFilter,listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&order="+encodeURI(orderby);
	parameters+="&orderdir="+encodeURI(orderdir);
	parameters+="&usefilter="+encodeURI(useFilter);
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	parameters+="&target=allideas";
	ajaxFunction(parameters,'ideasNew.php',true,'pool_new');
}

function updateIdeaListAdminCfd(orderby,orderdir,useFilter,listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&order="+encodeURI(orderby);
	parameters+="&orderdir="+encodeURI(orderdir);
	parameters+="&usefilter="+encodeURI(useFilter);
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	parameters+="&target=allideas";
	ajaxFunction(parameters,'ideasCfd.php',true,'ideas_cfd');
}

function updateIdeaListAdminArch(orderby,orderdir,useFilter,listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&order="+encodeURI(orderby);
	parameters+="&orderdir="+encodeURI(orderdir);
	parameters+="&usefilter="+encodeURI(useFilter);
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	parameters+="&target=allideas";
	ajaxFunction(parameters,'ideasArch.php',true,'pool_arch');
}

function updateHpList(orderby,orderdir,useFilter,listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&order="+encodeURI(orderby);
	parameters+="&orderdir="+encodeURI(orderdir);
	parameters+="&usefilter="+encodeURI(useFilter);
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	parameters+="&target=allideas";
	ajaxFunction(parameters,'poolHighPotentials.php',true,'pool_hp');
}


function updateEvalList(useFilter,listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&usefilter="+encodeURI(useFilter);
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	ajaxFunction(parameters,'evaluationListCurrent.php',true,'eval_list');
}

function updateCfdList(orderby,orderdir,useFilter,listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&order="+encodeURI(orderby);
	parameters+="&orderdir="+encodeURI(orderdir);
	parameters+="&usefilter="+encodeURI(useFilter);
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	ajaxFunction(parameters,'callForDiscussionList.php',true,"cfd_list");
}

function updateCfiList(listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	ajaxFunction(parameters,'callForIdeasListData.php',true,"cfi_list");
}

function updateMemberList(listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	ajaxFunction(parameters,'membersListAll.php',true,"memberslistall");
}

function updateMemberListByDate(listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	ajaxFunction(parameters,'membersListNew.php',true,"memberslistnew");
}

function updateMemberListAdmin(listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	ajaxFunction(parameters,'membersList.php',true,"memberslist");
}


function updateMyIdeaList(listIndex,listCnt) {
	parameters ="ajax=true";
	parameters+="&index="+encodeURI(listIndex);
	parameters+="&listcnt="+encodeURI(listCnt);
	ajaxFunction(parameters,'myIdeanetIdeas.php',true,"content_ideas0");
}


function storeVisitor(target_id,viewer) {
	parameters ="id="+encodeURI(target_id);
	parameters+="&type=user";
	parameters+="&visitor="+encodeURI(viewer);
	ajaxFunction(parameters,'storeVisitor.php',false,"");
}

function storeIdeaVisitor(target_id,viewer) {
	parameters ="id="+encodeURI(target_id);
	parameters+="&type=idea";
	parameters+="&visitor="+encodeURI(viewer);
	ajaxFunction(parameters,'storeVisitor.php',false,"");
}

function storeProfileData(parameters) {
	ajaxFunction(parameters,'myIdeanetShowProfile.php',true,"content_profile0");
}

function delUserImage(userid) {
	parameters ="userid="+encodeURI(userid);
	parameters +="&ajax=true";
	parameters +="&delimage=true";
	ajaxFunction(parameters,'myIdeanetShowProfile.php',true,"content_profile0");
}

function delUserImageRegister() {
	parameters="ajax=true";
	parameters +="&delimage=true";
	ajaxFunction(parameters,'registerNewUser.php',true,"content_profile0");
}

function delPickIdea(ideaid,userid) {
	parameters ="ideaid="+encodeURI(ideaid);
	parameters +="&userid="+encodeURI(userid);
	parameters +="&ajax=true";
	ajaxFunction(parameters,'delPickUser.php',false,"");
}




function updateInterestFilter(interest_id,ok) {
	parameters ="ajax=true";
	parameters+="&interest_id="+interest_id;
	newval="0";
	if (ok) newval="1";
	parameters+="&newval="+newval;
	ajaxFunctionJS(parameters,'updateInterestFilter.php',currentPool,"");	
}

function updateStateFilter(state_id,ok) {
	parameters ="ajax=true";
	parameters+="&state_id="+state_id;
	newval="0";
	if (ok) newval="1";
	parameters+="&newval="+newval;
	ajaxFunctionJS(parameters,'updateStateFilter.php',currentPool,"");	
}

function updateAdminStateFilter(state_id,ok) {
	parameters ="ajax=true";
	parameters+="&state_id="+state_id;
	newval="0";
	if (ok) newval="1";
	parameters+="&newval="+newval;
	ajaxFunctionJS(parameters,'updateAdminStateFilter.php',currentPool,"");	
}


function updateDateFilter(fDay,fMon,fYear,tDay,tMon,tYear) {
	parameters ="ajax=true";
	parameters+="&fDay="+encodeURI(fDay);
  parameters+="&fMon="+encodeURI(fMon);
  parameters+="&fYear="+encodeURI(fYear);
  parameters+="&tDay="+encodeURI(tDay);
  parameters+="&tMon="+encodeURI(tMon);
  parameters+="&tYear="+encodeURI(tYear);
	ajaxFunctionJS(parameters,'updateDateFilter.php',currentPool,"");	
}


function activateFilter(id,state) {
	parameters ="ajax=true";
	parameters+="&filter="+id;
	newval="0";
	if (state) newval="1";
	parameters+="&state="+newval;
  document.getElementById("filter"+(id-1)+"a").checked=state;
	document.getElementById("filter"+(id-1)).checked=state;
	ajaxFunctionJS(parameters,'activateFilter.php',currentPool,"");	
}


function showTagIdeaList(tag) {
	parameters ="ajax=true";
	parameters+="&tag="+encodeURI(tag);
	//alert(parameters);
	ajaxFunction(parameters,'showTagIdeas.php',true,"tag_ideas");
}


function setIdeaImage(Folder,imagename) {
	parameters ="folder="+encodeURI(Folder);
	parameters+="&filename="+encodeURI(imagename);
	parameters+="&ajax=true";
	ajaxFunctionJS(parameters,'imagePoolSetImage.php',"imagepool","");
}


function updatePfIdeas(id,action) {
	parameters ="ajax=true";
	parameters+="&target=pf";
	parameters+="&id="+encodeURI(id);
	parameters+="&action="+encodeURI(action);
	//alert(parameters);
	ajaxFunction(parameters,'poolPortfolio.php',true,"pool_pf");
}


function archIdeaStore(ideaid) {
	parameters ="ideaid="+encodeURI(ideaid);
	ajaxFunction(parameters,'ideaArch.php',false,"");
	alert("Idee archiviert");
}

function deArchIdeaStore(ideaid) {
	parameters ="ideaid="+encodeURI(ideaid);
	ajaxFunction(parameters,'ideaArchDel.php',false,"");
	alert("Arvhivierung entfernt");
}


function ideaSetDiscussion(ideaid,val) {
	parameters ="ideaid="+encodeURI(ideaid);
	parameters+="&val="+encodeURI(val);
	ajaxFunctionJS(parameters,'ideaSetDiscussion.php',"adminreload","id="+ideaid);
}

function ideaSetEvaluation(ideaid,val) {
	parameters ="ideaid="+encodeURI(ideaid);
	parameters+="&val="+encodeURI(val);
	ajaxFunctionJS(parameters,'ideaSetEvaluation.php',"adminreload","id="+ideaid);
}

function updateDiscussionUser(searchString) {
	parameters ="string="+encodeURI(searchString);
	ajaxFunction(parameters,'discussionUserResult.php',true,"result");
}


function updateEvaluationUser(searchString) {
	parameters ="string="+encodeURI(searchString);
	ajaxFunction(parameters,'evaluationUserResult.php',true,"result");
}

function adminUpdateInterests(cnt) {
	parameters ="cnt="+encodeURI(cnt);
	
	var selectedTopic = 0;
	for (var k=0; k<document.getElementsByName("topic").length; k++){
		if (document.getElementsByName("topic")[k].checked) {
			selectedTopic = document.getElementsByName("topic")[k].value;
		}
	}
	parameters+="&topic="+encodeURIComponent(selectedTopic);
	
	//for (var i=0; i<cnt; i++) {
	//	val=0;
	//	if (document.getElementById("filter_"+i).checked) val=1;
	//	interestid=document.getElementById("filter_"+i+"_id").value;
	//	parameters+="&id"+i+"="+interestid;
	//	parameters+="&val"+i+"="+val;
	//}
	parameters+="&tags="+encodeURI(document.getElementById("tags_id").value);
	ajaxFunction(parameters,'admin/updateIdeaCategorization.php',false,"");
	alert(unescape("%C4nderungen gespeichert"));
}

function updateIdeaAuth(idea,index) {
	parameters ="idea="+encodeURI(idea);
	parameters+="&val="+encodeURI((index+1));
	//alert(parameters);
	ajaxFunction(parameters,'admin/updateIdeaAuth.php',false,"");
	alert(unescape("Berechtigung wurde ge%E4ndert!"));
}


function makeIdeaOfMonth(id) {
	parameters ="id="+encodeURI(id);
	ajaxFunction(parameters,'admin/updateIdeaOfMonth.php',false,"");
	alert("Idee gespeichert");
	document.getElementById("iom1").style.display="none";
	document.getElementById("iom2").style.display="block";
}

function updatePortfolioAjax(xVal,yVal) {
	parameters ="ajax=true";
	parameters+="&xval="+encodeURI(xVal);
	parameters+="&yval="+encodeURI(yVal);
	ajaxFunction(parameters,'poolPortfolio.php',true,'pool_pf');
}

function updateEvalIdea(ideaid,crit,val,checkbox,selfeval) {	
  	for (var i=1; i<=5; i++) {
  		newImg="";
  		if (val>=i) newImg="_a";
  		document.getElementById("eval"+crit+"_img_"+i).src="images/crystal"+newImg+".png";
  	}
  	if (checkbox == 1) {
	  	document.getElementById("none"+(crit-1)).checked=false;
  	}
  	document.getElementById("eval_val"+crit).value=val;

  	parameters ="ideaid="+encodeURI(ideaid);
  	parameters+="&eval_key=crit"+encodeURI(crit);
  	parameters+="&val="+encodeURI(val);
  	parameters+="&selfeval="+encodeURI(selfeval);
  	ajaxFunction(parameters,'storeEvaluation.php',false,'');
}
