/***********************************************************************
*              Author: Klaus Hentschel [ All rights reserved ].                        				   *
************************************************************************
* Copyright (C) by Klaus Hentschel, http//javarea.de
*
* www: http://javaera.de.de
*
* Dieses Script ist Bestandteil des JavBB 2.0.0
*
* TopicEditModCP.class.js
*
***********************************************************************/


/**
* Description: Massenbearbeitung von Themen und Beitraegen
* Autor: Klaus Hentschel <javarea.de>
* category: EDIT TOPIC
*
* TopicMassEdit()
* @param: <string> DivClassName		Aktion
* @param: <string> what 					Post or Thread			 			
**/
TopicMassEdit = function(divIDName, what)
{
	//var docInputs = document.getElementsByTagName("input");
	var docInputs = document.getElementsByName("topicMark"); 
  var x=0, y=0;
	var topicTrueArray = new Array();
	var topicFalseArray = new Array();   
	
	//Hauptcheckbox demarkieren
	//document.getElementsByName("topicMarkAll")[0].checked = false;
	for (var i=0; i < docInputs.length; i++)
	{
		if (parseInt(docInputs[i].id)) 
		{
			var topicID = docInputs[i].id; 			
			if (topic[topicID]['isMarked'] == true)
			{			
				// alle Markierungen nach klick Demarkieren
				//MarkedList.marked(topicID);
				//document.getElementsByName("topicMark")[i].checked = false;
				
				if (divIDName == "Sticky" && perm['canstickyThread']){
					if (topic[topicID]['isPinned'] == false){	topicTrueArray[x] = topicID; x++ }
					if (topic[topicID]['isPinned'] == true)	{	topicFalseArray[y] = topicID; y++	};
				}
				if (divIDName == "MarkAsDone" && perm['candoneThread']){
					if (topic[topicID]['isDone'] == false) 	{	topicTrueArray[x] = topicID; x++ }
					if (topic[topicID]['isDone'] == true) 	{	topicFalseArray[y] = topicID; y++	};
				}
				
				if (divIDName == "ActivateReActivate" && (perm['canactivateThread'] || perm['canactivatePost'])){
					if (topic[topicID]['isActiv'] == false)  {	topicTrueArray[x] = topicID; x++ }
					if (topic[topicID]['isActiv'] == true)	{	topicFalseArray[y] = topicID; y++	};
				}
				
				if (divIDName == "OpenClose" && perm['canopencloseThread']){
					if (topic[topicID]['isClose'] == false) 	{	topicTrueArray[x] = topicID; x++ }
					if (topic[topicID]['isClose'] == true) {	topicFalseArray[y] = topicID; y++ };
				}
				
				if (divIDName == "DeleteRestore" && (perm['candelThread'] || perm['candelPost'])){
					if (topic[topicID]['isDelete'] == false)	{	topicTrueArray[x] = topicID; x++ }
					if (topic[topicID]['isDelete'] == true){	topicFalseArray[y] = topicID; y++	};
				}
				if (divIDName == "CompleteDelete" && (perm['candelThread'] || perm['candelPost'])){
					if (topic[topicID]['isDelete'] == true)	{	topicTrueArray[x] = topicID; x++ }
					if (topic[topicID]['isDelete'] == false){	topicFalseArray[y] = topicID; y++	};
				}
									
				// Tabellenzelle und Grafik updaten					
				showTableStatus(topicID, divIDName);
			}	
		}
  }	
	
	var trueIDs = topicTrueArray;
	var falseIDs = topicFalseArray;
	
	//alert("True: "+trueIDs + "\n False:" +falseIDs);
	
	if (divIDName == "Sticky" && (falseIDs != "" || trueIDs != "") && what == "thread")
		ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModSticky&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			          
	
	if (divIDName == "MarkAsDone" && (falseIDs != "" || trueIDs != "") && what == "thread")
		ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModMarkAsDone&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			          
	
	if (divIDName == "ActivateReActivate" && (falseIDs != "" || trueIDs != ""))
	{
		if (what == "thread")
			ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModActivateReActivate&isThread=1&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			          
			
		if (what == "post")
			ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModActivateReActivate&isPost=1&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			          
	}

	if (divIDName == "OpenClose" && (falseIDs != "" || trueIDs != "") && what == "thread")
		ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModOpenClose&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			        
	
	if (divIDName == "DeleteRestore" && (falseIDs != "" || trueIDs != ""))
	{
		if (what == "thread")
			ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModDeleteRestore&isThread=1&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			        
		
		if (what == "post")
			ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModDeleteRestore&isPost=1&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			        	
	}
	
	if (divIDName == "CompleteDelete" && (falseIDs != "" || trueIDs != ""))
	{
		if (what == "thread")
			ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModCompleteDelete&isThread=1&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			        
		
		if (what == "post")
			ajaxRequest.openGetRequest(BOARD_AJAXPATH + '?action=ModCompleteDelete&isPost=1&true='+trueIDs+'&false='+falseIDs, 'modCPButton');			        	
	}
	if (divIDName == "MarkedUnmarked")	{}		
}

