	/* Date/Time Format v0.2; MIT-style license
	By Steven Levithan <http://stevenlevithan.com> */
	
	Date.prototype.format = function(mask) {
		var d = this; // Needed for the replace() closure
		
	// If preferred, zeroise() can be moved out of the format() method for performance and reuse purposes
		var zeroize = function (value, length) {
			if (!length) length = 2;
			value = String(value);
			for (var i = 0, zeros = ''; i < (length - value.length); i++) {
				zeros += '0';
			}
			return zeros + value;
		}
		
		return mask.replace(/"[^"]*"|'[^']*'|\b(?:d{1,4}|m{1,4}|yy(?:yy)?|([hHMs])\1?|TT|tt|[lL])\b/g, function($0) {
			switch($0) {
				case 'd':	return d.getDate();
				case 'dd':	return zeroize(d.getDate());
				case 'ddd':	return ['Sun','Mon','Tue','Wed','Thr','Fri','Sat'][d.getDay()];
				case 'dddd':	return ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][d.getDay()];
				case 'm':	return d.getMonth() + 1;
				case 'mm':	return zeroize(d.getMonth() + 1);
				case 'mmm':	return ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][d.getMonth()];
				case 'mmmm':	return ['January','February','March','April','May','June','July','August','September','October','November','December'][d.getMonth()];
				case 'yy':	return String(d.getFullYear()).substr(2);
				case 'yyyy':	return d.getFullYear();
				case 'h':	return d.getHours() % 12 || 12;
				case 'hh':	return zeroize(d.getHours() % 12 || 12);
				case 'H':	return d.getHours();
				case 'HH':	return zeroize(d.getHours());
				case 'M':	return d.getMinutes();
				case 'MM':	return zeroize(d.getMinutes());
				case 's':	return d.getSeconds();
				case 'ss':	return zeroize(d.getSeconds());
				case 'l':	return zeroize(d.getMilliseconds(), 3);
				case 'L':	var m = d.getMilliseconds();
						if (m > 99) m = Math.round(m / 10);
						return zeroize(m);
				case 'tt':	return d.getHours() < 12 ? 'am' : 'pm';
				case 'TT':	return d.getHours() < 12 ? 'AM' : 'PM';
				// Return quoted strings with the surrounding quotes removed
				default:	return $0.substr(1, $0.length - 2);
			}
		});
	};
	
	var http_request = false;
	/*tinyMCE.init( {
		mode : "none", 
		theme_advanced_toolbar_location : "bottom", 
		plugins : "flash,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,bullist,numlist,outdent,indent,sub,sup,fontsizeselect",
		theme_advanced_buttons2 : "cut,copy,paste,undo,redo,separator,link,unlink,separator,image,separator,cleanup,charmap,removeformat,hr,separator,code,separator,help",
		theme_advanced_buttons3 : "",
		height : "200",
		width : "99%",
		theme : "advanced",
		extended_valid_elements : "object[width|height|classid|codebase],param[name|value],embed[src|type|width|height|flashvars|wmode]",
		theme_advanced_resizing : true	
	

		// Drop lists for link/image/media/template dialogs
	

	
	});*/
	function uploadFilePopUp(taskID)
	{
		window.open('uploadFilePopUp.php?taskID='+taskID,'popup',"Upload FIle","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=540,screenX=150,screenY=150,top=150,left=150"); 
	}
	
	function uploadFilePopUp_New(taskID)
	{
		//window.open('uploadFilePopUp.php?taskID='+taskID,'popup',"Upload FIle","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=100,screenX=150,screenY=150,top=150,left=150"); 
		window.open('uploadFilePopUp.php?taskID='+taskID,'popup',"title=Upload FIle,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=0,copyhistory=no,width=900,height=300,screenX=100,screenY=100,top=100,left=100");
	}
			
	function EditorOn(id){
		//if (tinyMCE.getInstanceById(id) == null) tinyMCE.execCommand('mceAddControl', false, id);
	}
	
	function EditorOff(id){
	//	tinyMCE.execCommand('mceRemoveControl', false, id);
	}
	
	function ToggleEditor_TinyMCE(id) {
		var elm = document.getElementById(id);
		var svImg='SvImg'+id;
		
		if (tinyMCE.getInstanceById(id) == null) {
			tinyMCE.execCommand('mceAddControl', false, id);
			document.getElementById(svImg).style.display="block"; 
		} else {
			tinyMCE.execCommand('mceRemoveControl', false, id);
			document.getElementById(svImg).style.display="none"; 
		}
	}
	
	
	function multiReplace(Strin) {
		 var replacements = [];
		 replacements.push(['**conversionandquot;', '"']);
		 replacements.push(['**conversionand', '&']);
		 replacements.push(['**andconversion', '&']);
		 //replacements.push(['&quot;', '"']);
		 replacements.push(['**spaceconversion', ' ']);
		 replacements.push(["d", "d"]);
		
		var str = Strin.split("**667");
		var i,j;
		var stringret='';
		
		for(j=0; j<str.length; j++){
			for (i = 0; i < replacements.length; i++ ) {
				str[j] = str[j].replace(replacements[i][0], replacements[i][1]);
			}
			stringret = stringret +str[j];
		}
		return trim(stringret);
	}
	
	function ToggleEditor(id,id2,val) {
		//alert(val);
		var elm = document.getElementById(id);
		var svImg='SvImg'+id;
		var TextAreaImg='textarea'+id;
		//var value = multiReplace(val);

		var temp = new FCKeditor( svImg ) ;
		if(screen.width == '1152'){
			temp.Width	= 660 ;
		}else if(screen.width == '1024'){
			temp.Width	= 500 ;
		}else{
			temp.Width	= 660 ;
		}
		temp.Height	= 200 ;
		temp.ToolbarSet	= 'Manual' ;
		temp.Value	= document.getElementById(id).innerHTML;
		
		document.getElementById(svImg).style.display="block";
		document.getElementById(TextAreaImg).style.display="block";
		document.getElementById(id).style.display="none";
		document.getElementById(id2).style.display="none";
		document.getElementById(svImg).innerHTML = document.getElementById(svImg).innerHTML;
		document.getElementById(TextAreaImg).innerHTML = temp.CreateHtml();
						
		/*if (tinyMCE.getInstanceById(id) == null) {
			
			tinyMCE.execCommand('mceAddControl', false, id);
			document.getElementById(svImg).style.display="block"; 
		} else {
			tinyMCE.execCommand('mceRemoveControl', false, id);
			document.getElementById(svImg).style.display="none"; 
		}*/
	}
	
	
	function ToggleEditorEdit(id,id2,val) {
		var elm = document.getElementById(id);
		var svImg2='SvImg2'+id;
		
		var TextAreaImg2='textarea2'+id;
		var value2 = multiReplace(val);
		
		var temp2 = new FCKeditor( svImg2 ) ;
		temp2.Width	= 660 ;
		temp2.Height	= 200 ;
		temp2.ToolbarSet	= 'Manual' ;
		temp2.Value	= document.getElementById(id).innerHTML;
		
		document.getElementById(svImg2).style.display="block";
		document.getElementById(TextAreaImg2).style.display="block";
		document.getElementById(id).style.display="none";
		document.getElementById(id2).style.display="none";
		document.getElementById(svImg2).innerHTML = document.getElementById(svImg2).innerHTML;
		document.getElementById(TextAreaImg2).innerHTML = temp2.CreateHtml();
		//alert(document.getElementById(TextAreaImg2).innerHTML);
	}
	
	/*function ToggleEditorEdit(id) {
	 
		var elm = document.getElementById(id);
		var svImg='svimg2'+id;
		
		
		if (tinyMCE.getInstanceById(id) == null) {
			tinyMCE.execCommand('mceAddControl', false, id);
			document.getElementById(svImg).style.display="block"; 
	
		} else {
			tinyMCE.execCommand('mceRemoveControl', false, id);
			document.getElementById(svImg).style.display="none"; 
		}
	}*/
	
	
	function SaveItem(editorId, tmpActId, colName, colValue){
		if(tinyMCE.getInstanceById(editorId) != null){
			colValue = tinyMCE.getInstanceById(editorId).getContent();
			tinyMCE.execCommand('mceRemoveControl', false, editorId);
		}
		//var arHeaders = new Array('"Content-type", "application/x-www-form-urlencoded"','"Content-length", params.length','"Connection", "close"');
		//var url = 'saveActionItem.php?divID='+id+'&key='+myKey+'&itm='+myItm	// this is where the MySql work will get done
	
		var poststr = "tmpActId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editTmpAction";
		makePOSTRequest('updateTemplateAction.php', poststr);
	/**	
		var myAjax = new Ajax.Request(
			url, 
			{
				method: 'post', 
				postBody: myFrm,
				requestHeaders: arHeaders,
				onComplete: update_page
			}	);
	
	**/
	}
	
	function checkEitherManditory(editorId, tmpActId, colName, colValue, actionType,mand,oldValue,frm,type){
		if(type == "Project"){
			if(mand == 1 && colValue == 0){
				alert("This is manditory task. You could not change its status to N/A.");
				document.getElementById(colName+""+tmpActId).value = oldValue;
				return false;
			}else{
				//updateActualDate(colValue,tmpActId);
				
				updateAction_all(editorId, tmpActId, colName, colValue, 'Task');
				//updateAction(editorId, tmpActId, colName, colValue, actionType);
			}
		}else{
			if(mand == 1 && colName == "tmpActStatus" && colValue == 0){
				alert("This is manditory task. You could not change its status to N/A.");
				frm.tmpActStatus.value = oldValue
				return false;
			}else{
				//updateAction_all(actPriID,tmpActId,  colName, colValue,actionType);
				updateAction_all(editorId, tmpActId, colName, colValue, 'Task');
				
				//updateAction(editorId, tmpActId, colName, colValue, actionType);
			}
		}
	}
	
	function updateAction(editorId, tmpActId, colName, colValue, actionType){
		/*if(tinyMCE.getInstanceById(editorId) != null){
			colValue = tinyMCE.getInstanceById(editorId).getContent();
			tinyMCE.execCommand('mceRemoveControl', false, editorId);*/
			colValue = colValue.replace(/&/g, "**667**andconversion");
			colValue = colValue.replace(/&/g, "**667**conversionand");
		//}
		
		//var arHeaders = new Array('"Content-type", "application/x-www-form-urlencoded"','"Content-length", 	params.length','"Connection", "close"');
		//var url = 'saveActionItem.php?divID='+id+'&key='+myKey+'&itm='+myItm	// this is where the MySql work will get done
		
		
		if(actionType == 'template'){
			var poststr = "tmpActId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editTmpAction";
			makePOSTRequest('updateTemplateAction.php', poststr);
		}else if(actionType == 'project'){
			var poststr = "actId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editProjAction";
			makePOSTRequest('updateProjectAction.php', poststr);
		}else if(actionType == 'Task'){
			var poststr = "actId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editProjAction";
			makePOSTRequest('updateProjectAction.php', poststr);
			//window.location='edit-tasks.php?actId='+ tmpActId;
		}
	}
	
	
	function updateEditorText11(meetID){
		var chkking;
		var currentFile; 
		//document.getElementById('afterendMeet').innerHTML = "nOt : ("+document.getElementById("BlockUpdate").innerHTML+")";
		if(document.getElementById("BlockUpdate").innerHTML == ""){
			editorTextMeeting = tinyMCE.getInstanceById('newsText').getContent();
			currentFile = document.getElementById('currentFile').value;
			//document.getElementById('newsText').value ="";
			editorTextMeeting = editorTextMeeting.replace(/&amp;/g,"and ");
			editorTextMeeting = editorTextMeeting.replace(/&#39;/g,"\\'");
			editorTextMeeting = editorTextMeeting.replace(/&quot;/g,"\"");
			editorTextMeeting = editorTextMeeting.replace(/&lt;/g,"<");
			editorTextMeeting = editorTextMeeting.replace(/&gt;/g,">");
			//document.getElementById('afterendMeet').innerHTML = "File Name: <b>"+currentFile + "</b><br /> File Contents: <strong>"+editorTextMeeting+"</strong>";
			var poststr = "textmeeting="+editorTextMeeting+"&meetID="+meetID+"&fileNameSet="+currentFile;
			makePOSTRequest('getfileText.php', poststr);
		}
	}
	
	function checkChild(tmpActId,isParent,value,oldVal){
		if(isParent==1){
			POSTChildRequest(tmpActId,isParent,value,oldVal);
		}	
	}
	
	function blankFunction()
	{}
	
		
	function updateAction_all(editorId, tmpActId, colName, colValue, actionType, SvImType,txArType){
		//alert(editorId+'====>'+tmpActId+'====>'+colName+'====>'+colValue+'====>'+actionType+'====>'+SvImType+'====>'+txArType);
		var svImg,TextAreaImg;
		
		if(SvImType==''){
			svImg='SvImg'+editorId;
		}else{
			svImg='SvImg'+SvImType+editorId;
		}
		
		if(txArType == ''){
			TextAreaImg='textarea'+editorId;
		}else{
			TextAreaImg='textarea'+txArType+editorId;
		}
		
		colValue = colValue.replace(/&/g, "**667**andconversion");
		colValue = colValue.replace(/&/g, "**667**conversionand");
		
		if (typeof(FCKeditorAPI)!=='undefined'){
			if(FCKeditorAPI.GetInstance(svImg)){
				colValue = FCKeditorAPI.GetInstance(svImg).GetData();
				colValue = unhtmlspecialchars(colValue);
				var editorInstance = FCKeditorAPI.GetInstance(svImg);
				editorInstance.ToolbarSet.Collapse() ;
				editorInstance.EditorDocument.body.contentEditable = false;
			}
		}else{
			colValue = htmlspecialchars(colValue);	
		}
		
		if((colName == 'tmpActDescription')||(colName == 'tmpActComments')||(colName == 'actComments')){
			document.getElementById(TextAreaImg).innerHTML =='';
			document.getElementById(TextAreaImg).style.display="none";
		}
		

		/*if(tinyMCE.getInstanceById(editorId) != null)
		{
			
			colValue = tinyMCE.getInstanceById(editorId).getContent();
			tinyMCE.execCommand('mceRemoveControl', false, editorId);
			colValue = unhtmlspecialchars(colValue);
		}else 
		{
			
			colValue = htmlspecialchars(colValue);	
			
		}*/
		
		/*if(colName == "tmpActTitle")
		{
			colValue = colValue.replace(/'/g,'&#39;');	
			colValue = colValue.replace(/"/g,'&quot;');	
			colValue = colValue.replace(/&/g, "**667**andconversion");
			
		}*/
		//alert(colValue);
		//var arHeaders = new Array('"Content-type", "application/x-www-form-urlencoded"','"Content-length", 	params.length','"Connection", "close"');
		//var url = 'saveActionItem.php?divID='+id+'&key='+myKey+'&itm='+myItm	// this is where the MySql work will get done
		
		
		if(actionType == 'template'){
			var pt = colValue;
			pt = multiReplace(pt);
			if(document.getElementById(editorId)!=null){
				document.getElementById(editorId).innerHTML = pt;
			}
			
			var poststr = "tmpActId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editTmpAction";
			makePOSTRequest('updateTemplateAction.php', poststr);
		}else if(actionType == 'project'){
			var pt = colValue;
			pt = multiReplace(pt);
			if(document.getElementById(editorId)!=null){
				document.getElementById(editorId).innerHTML = pt;
			}
			
			var poststr = "actId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editProjAction";
			makePOSTRequest('updateProjectAction.php', poststr);
		}else if(actionType == 'Task'){

			if(colName == "tmpActStatus_child"){
				
				var inner_actdate1=null;
				inner_actdate = "inner_actdate"+tmpActId;
				inner_tmpActSta = "tmpActStatus"+tmpActId;
				today=new Date(); // Initialize Date in raw form
				date=today.getDate(); // Get the numerical date
				year=today.getYear(); // Get the year
				month=today.getMonth()+1; // Get the month
				
				if (year < 2000){
					year = year+1900;
				}
				
				if(date < 10){
					date = '0'+date;	
				}
				
				if(month < 10){
					month = '0'+month;	
				}
				
				var datevalNew = month+'/'+date+'/'+year;
				
				if(colValue == '2'){
					window.opener.document.getElementById('pencil2'+tmpActId).style.display="none"; 
					window.opener.document.getElementById('inner_actdate'+tmpActId).style.display="block";
					window.opener.document.getElementById('dateval2'+tmpActId).innerHTML = '';
					window.opener.document.getElementById(inner_tmpActSta).options[2].selected = true;
				}else if(colValue == '1'){
					window.opener.document.getElementById('pencil2'+tmpActId).style.display="block";
					window.opener.document.getElementById('inner_actdate'+tmpActId).style.display="none";
					window.opener.document.getElementById('dateval2'+tmpActId).innerHTML = datevalNew;
					window.opener.document.getElementById(inner_tmpActSta).options[1].selected = true;
				}else if(colValue == '0'){	
					window.opener.document.getElementById('pencil2'+tmpActId).style.display="block"; 
					window.opener.document.getElementById('inner_actdate'+tmpActId).style.display="none"; 
					window.opener.document.getElementById('dateval2'+tmpActId).innerHTML = datevalNew;
					window.opener.document.getElementById(inner_tmpActSta).options[0].selected = true;
				}
								
				var poststr = "actId="+tmpActId+"&colName=tmpActStatus&colValue="+colValue+"&funName=editProjAction";
				makePOSTRequest('updateProjectAction.php', poststr);
				
				refreshChildPopup("'"+tmpActId+"'","'"+colValue+"'","","");
				//window.setTimeout("refreshChildPopup('"+tmpActId+"','"+colValue+"','','');",1500);
			}else{
				var inner_actdate1=null;
				inner_actdate = "inner_actdate"+tmpActId;
				
				if(document.getElementById(inner_actdate)){
					inner_actdate1 = document.getElementById(inner_actdate);
				}else{
					inner_actdate1 = document.getElementById('dateval2'+tmpActId);
				}
				
				
				if((colValue == null || colValue == "" || colValue == 'null' ) && colName!="tmpActComments"){
					if(document.getElementById('dateval2'+tmpActId)){
						colValue = document.getElementById('dateval2'+tmpActId).innerHTML;
					}else if(document.getElementById('inner_actdate'+tmpActId)){
						colValue = document.getElementById('inner_actdate'+tmpActId).innerHTML;
					}
					
					var pt = colValue;
					pt = multiReplace(pt);
					if(document.getElementById(editorId)!=null){
						document.getElementById(editorId).innerHTML = pt;
					}
					
				}else{
					var pt = colValue;
					pt = multiReplace(pt);
					pt1 = htmlspecialchars_New(pt);
					if(document.getElementById(editorId)!=null){
						document.getElementById(editorId).innerHTML = pt1;
					}
				}
				
				//alert("'"+colValue+"'");
				
				var poststr = "actId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editProjAction";
				makePOSTRequest('updateProjectAction.php', poststr);
				
				
				if(colName == "tmpActStatus" ){
					var date = new Date();
					var mydate = date.format("mm/dd/yyyy");
					if(colValue == "2"){
						document.getElementById('pencil2'+tmpActId).style.display="none"; 
						document.getElementById('inner_actdate'+tmpActId).style.display="block";
						inner_actdate1.innerHTML = '';
						colValue = "";
						colName = "tmpActActualDate";
						var poststr = "actId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editProjActionDate";
					}else if(colValue == "1"){
						document.getElementById('pencil2'+tmpActId).style.display="block"; 
						document.getElementById('inner_actdate'+tmpActId).style.display="none"; 
						document.getElementById('dateval2'+tmpActId).innerHTML = mydate;			
						colValue = mydate;
						colName = "tmpActActualDate";
						var poststr = "actId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editProjActionDate";
					}else if(colValue == "0"){
						document.getElementById('pencil2'+tmpActId).style.display="block"; 
						document.getElementById('inner_actdate'+tmpActId).style.display="none"; 
						document.getElementById('dateval2'+tmpActId).innerHTML = mydate;			
						colValue = mydate;
						colName = "tmpActActualDate";
						var poststr = "actId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editProjActionDate";
					}
					makePOSTRequest('updateProjectAction.php', poststr);
				}
			}
		}
	}
	
	function updateAction_Save(tmpActId, actionType){
		//alert(tmpActId+','+actionType);
		
		var actCommentID='edC'+tmpActId;
		var actDescriptionID = 'edDESC'+tmpActId;
		
		var	svImg='SvImg'+actCommentID;
		var	svImg2='SvImg2'+actDescriptionID;
		
		var TextAreaImg='textarea'+actCommentID;
		var TextAreaImg2='textarea2'+actDescriptionID;
		
		var colValue1='';
		var colValue2='';
		
		if (typeof(FCKeditorAPI)!=='undefined'){
			if(FCKeditorAPI.GetInstance(svImg)){
				colValue1 = FCKeditorAPI.GetInstance(svImg).GetData();
				colValue1 = colValue1.replace(/&/g, "**667**andconversion");
				colValue1 = colValue1.replace(/&/g, "**667**conversionand");
				colValue1 = unhtmlspecialchars(colValue1);
				var editorInstance = FCKeditorAPI.GetInstance(svImg);
				editorInstance.ToolbarSet.Collapse() ;
				editorInstance.EditorDocument.body.contentEditable = false;
			}
			
			if(FCKeditorAPI.GetInstance(svImg2)){
				colValue2 = FCKeditorAPI.GetInstance(svImg2).GetData();
				colValue2 = colValue2.replace(/&/g, "**667**andconversion");
				colValue2 = colValue2.replace(/&/g, "**667**conversionand");
				colValue2 = unhtmlspecialchars(colValue2);
				var editorInstance = FCKeditorAPI.GetInstance(svImg2);
				editorInstance.ToolbarSet.Collapse() ;
				editorInstance.EditorDocument.body.contentEditable = false;
			}
			
			if(actionType == 'Task'){
				if(colValue1!=''){
					var poststr1 = "actId="+tmpActId+"&colName=actComments&colValue="+colValue1+"&funName=editProjAction";
					makePOSTRequest('updateProjectAction.php', poststr1);
				}
				if(colValue2!=''){
					var poststr2 = "actId="+tmpActId+"&colName=actDescription&colValue="+colValue2+"&funName=editProjAction";
					makePOSTRequest('updateProjectAction.php', poststr2);
				}
			}
		}
	}
	
	function updateAction_Save_temp(tmpActId, actionType){
		
		var actCommentID = tmpActId;
		
		var	svImg = 'SvImgedC'+actCommentID;
		
		var TextAreaImg='textarea'+svImg;
		
		var MainTD = 'editDiv'+tmpActId;
		
		var colValue1='';
		var colValue = '';
		
		if (typeof(FCKeditorAPI)!=='undefined'){
			if(FCKeditorAPI.GetInstance(svImg)){
				colValue1 = FCKeditorAPI.GetInstance(svImg).GetData();
				colValue1 = colValue1.replace(/&/g, "**667**andconversion");
				colValue1 = colValue1.replace(/&/g, "**667**conversionand");
				colValue1 = unhtmlspecialchars(colValue1);
				colValue = unhtmlspecialchars(colValue1);
				var editorInstance = FCKeditorAPI.GetInstance(svImg);
				editorInstance.ToolbarSet.Collapse() ;
				editorInstance.EditorDocument.body.contentEditable = false;
			}
			
			if(actionType == 'template'){
				if(colValue1!=''){
					colValue1 = colValue1.replace(/&/g, "**667**andconversion");
					colValue1 = colValue1.replace(/&/g, "**667**conversionand");
					colValue1 = RemoveUnhtmlSpecialChars(colValue1);
					document.getElementById('edC'+actCommentID).innerHTML = colValue1;
					document.getElementById('edC'+actCommentID).style.display = "block";
					document.getElementById('EdImgedC'+actCommentID).style.display = "block";
					document.getElementById('SvImgedC'+actCommentID).style.display = "none";
					document.getElementById(MainTD).style.display = "none";
					var poststr1 = "tmpActId="+tmpActId+"&colName=tmpActDescription&colValue="+colValue+"&funName=editTmpAction";
					makePOSTRequest('updateTemplateAction.php', poststr1);
				}else{
					document.getElementById(MainTD).style.display = "none";
				}
			}
		}else{
			document.getElementById(MainTD).style.display = "none";
		}
	}
	
	function trim(s){
		
		var l=0; 
		var r=s.length -1;
		
		while(l < s.length && s[l] == ' ')
		{	
			l++; 
		}
		while(r > l && s[r] == ' ')
		{	
			r-=1;
		}
		return s.substring(l, r+1);
}


	function abcd_update(a,b,c)
	{
		
	}
	function updateAction_ViewTaskList(editorId, tmpActId, colName, colValue, actionType)
	{
		if(colValue == 'null')
		{
			colValue = document.getElementById(editorId).innerHTML;		
		}
		/*if(tinyMCE.getInstanceById(editorId) != null)
		{
			colValue = tinyMCE.getInstanceById(editorId).getContent();
			tinyMCE.execCommand('mceRemoveControl', false, editorId);
		}*/
		
		//var arHeaders = new Array('"Content-type", "application/x-www-form-urlencoded"','"Content-length", 	params.length','"Connection", "close"');
		//var url = 'saveActionItem.php?divID='+id+'&key='+myKey+'&itm='+myItm	// this is where the MySql work will get done
		if(actionType == 'template')
		{
			var poststr = "tmpActId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editTmpAction";
			makePOSTRequest('updateTemplateAction.php', poststr);
		}
		else if(actionType == 'project')
		{
			var poststr = "actId="+tmpActId+"&colName="+colName+"&colValue="+colValue+"&funName=editProjAction";
			makePOSTRequest('updateProjectAction.php', poststr);
		}
		else if(actionType == 'Task')
		{
			var alt_check = null;
			if(colName == "tmpActEndDate" )
			{
				new Ajax.Request('gethint.php', { 
				onSuccess : function(resp1) 
				{ 
					
					var alt=null;
					var txt = resp1.responseText;
					var txt1= txt.split("_");
					document.getElementById("dueDateAgainstParent").innerHTML=txt1[0].replace(/\t/g,"");
					//alert(document.getElementById('dueDateAgainstParent').value);
					if(document.getElementById('dueDateAgainstParent').innerHTML == "Parent")
					{
						alt = confirm("You have set the due date of this task to be after the due date of its child task. Do you want to update the due date of all child task to be the same date?");
					}else if(document.getElementById('dueDateAgainstParent').innerHTML =="Child")
					{
						alt = confirm("You have set the due date of this task to be after the due date of its parent task. Do you want to update the due date of parent task to be the same date?");
						alt_check = 'fix';
					}
					
					if(txt1[1] != "" || txt1[1] != null )
					{
						if(alt)
						{
							if(alt_check == 'fix'){
								new Ajax.Updater('', 'gethint.php?value=updateParentDueDateOfChild&parent=1&actIds='+txt1[1]+"&colValue="+colValue, {
									method: 'get'
									});
							}else{
								new Ajax.Updater('', 'gethint.php?value=updateParentDueDateOfChild&parent=0&actIds='+txt1[1]+"&colValue="+colValue, {
									method: 'get'
									});	
							}
							
							var actddd = txt1[1];
							var actdd = actddd.split(",");
							for(i=0;i<actdd.length;i++)
							{
								if(alt_check == 'fix'){
									if(document.getElementById('dateval'+actdd[i])){
										if(document.getElementById('dateval'+actdd[i]).innerHTML<=colValue)
											document.getElementById('dateval'+actdd[i]).innerHTML = colValue;
									}else if(document.getElementById('pencilDate'+actdd[i])){
										if(document.getElementById('pencilDate'+actdd[i]).innerHTML<=colValue)
											document.getElementById('pencilDate'+actdd[i]).innerHTML = colValue;
									}
								}else{
									if(document.getElementById('dateval'+actdd[i])){
										if(document.getElementById('dateval'+actdd[i]).innerHTML>colValue)
											document.getElementById('dateval'+actdd[i]).innerHTML = colValue;
									}else if(document.getElementById('pencilDate'+actdd[i])){
										if(document.getElementById('pencilDate'+actdd[i]).innerHTML>colValue)
											document.getElementById('pencilDate'+actdd[i]).innerHTML = colValue;
									}								
								}
							}
						}
					}
					else 
					{
						document.getElementById('dueDateAgainstParent').innerHTML = "";
					}
				}, 
				onFailure : function(resp1) { 
						alert("Oops, there\'s been an error."); 
					 }, 
				parameters : "value=dueDateAgainstParent&actId="+tmpActId+"&colValue="+colValue
				});
				
				
			}
			if(alt_check == 'fix'){
				var poststr = "actId="+tmpActId+"&parent=1&colName="+colName+"&colValue="+colValue+"&funName=editProjAction";
			}else{
				var poststr = "actId="+tmpActId+"&parent=0&colName="+colName+"&colValue="+colValue+"&funName=editProjAction";
			}
			makePOSTRequest('updateProjectAction.php', poststr);
			//window.location='edit-tasks.php?actId='+ tmpActId;
			/*if(colName == "tmpActEndDate" )
			{
				inner_enddate = "inner_enddate"+tmpActId;
				var inner_enddate1=document.getElementById(inner_enddate);
				inner_enddate1.innerHTML = colValue;
			}*/
			
			if(colName == "tmpActEndDate"){
				//inner_enddate = "inner_enddate"+tmpActId;
				inner_enddate = "datEnd"+tmpActId;
				var inner_enddate1=document.getElementById(inner_enddate);
				inner_enddate1.innerHTML = colValue;
			}
			
			if(colName == "tmpActActualDate" )
			{
				inner_actdate = "inner_actdate"+tmpActId;
				var inner_actdate1=document.getElementById(inner_actdate);
				inner_actdate1.innerHTML = colValue;
			}
		}
	}
	function DeleteAction(tmpActId){
		 var a;
		 a= confirm("Are you sure you want to delete this action");
		 if(a){
			var poststr = "actId="+tmpActId+"&colName=&colValue=&funName=editProjAction";
			makePOSTRequest('DeleteProjectAction.php', poststr);
			window.location='edit-tasks.php?action=delete';
		 }else{
			 return false;
		 }
	}
	
	function makePOSTRequest(url, parameters) {
	//alert(url+" - "+parameters);
		//http_request = false;
		if (window.XMLHttpRequest){ // Mozilla, Safari,...
		 	http_request = new XMLHttpRequest();
			if (http_request.overrideMimeType) {
				// set type accordingly to anticipated content type
				//http_request.overrideMimeType('text/xml');
				http_request.overrideMimeType('text/html');
			}
		}else if(window.ActiveXObject){ // IE
			try {
				http_request = new ActiveXObject("Msxml2.XMLHTTP");
			}catch (e){
				try {
			   		http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
		 	}
		}
		if(!http_request) {
			 alert('Cannot create XMLHTTP instance');
			return false;
		}
		
		http_request.onreadystatechange = alertContents;
		http_request.open('POST', url, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.setRequestHeader("Content-length", parameters.length);
		http_request.setRequestHeader("Connection", "close");
		http_request.send(parameters);
	}
	function alertContents() {
		if(http_request.readyState == 4){
			if(http_request.status == 200){
				//alert(http_request.responseText);
				var result = http_request.responseText;
				//alert(window.getAjaxReturnValue);
				//window.status=result;
				//alert("'"+result+"'");
				//if(result){
				if(window.getAjaxReturnValue){
					getAjaxReturnValue(result);
				}
			} else {
				alert('There was a problem with the request.');
			}
		}
	}
	
	function replaceCharacters() {
		var origString = document.form1.inTB.value;
		var inChar = document.form1.inC.value;
		var outChar = document.form1.outC.value;
		var newString = origString.split(inChar);
		newString = newString.join(outChar);
		document.form1.outTB.value = newString;
	}
	
	function RemoveUnhtmlSpecialChars(str)
	{
		var converg = null;
		var origString = str;
		var newString = origString.split("**667**andconversion");
		newString = newString.join("&");
		
		var newString1 = newString.split("**667**conversionand");
		newString = newString1.join("&");
		/*converg = str;
		converg = converg.replace(/&amp;/g,"**667**andconversion");
		converg = converg.replace(/&amp;/g,"**667**conversionand");
  		converg = converg.replace(/&nbsp;/g,"**667**andconversionnbsp;");
		converg = converg.replace(/&nbsp;/g,"&ampnbsp;");
		converg = converg.replace(/&nbsp;/g,"**667**spaceconversion");
  		converg = converg.replace(/\'/g,"&amp;lsquo;");
		converg = converg.replace(/\'/g,"&lsquo;");
		converg = converg.replace(/\'/g,"&amp;rsquo;");
		converg = converg.replace(/\'/g,"&rsquo;");
		converg = converg.replace(/\'/g,"&#39;");
  		converg = converg.replace(/\"/g,"&quot;");
  		converg = converg.replace(/&lt;/g,"<");
  		converg = converg.replace(/&gt;/g,">");	
		converg = converg.replace(/&/g,"**667**conversionand");
		alert(converg);*/
		return newString;
	}
	
	function unhtmlspecialchars(str){
		converg = str;
		converg = converg.replace(/&amp;/g,"**667**andconversion");
		converg = converg.replace(/&amp;/g,"**667**conversionand");
  		converg = converg.replace(/&nbsp;/g,"**667**andconversionnbsp;");
		converg = converg.replace(/&nbsp;/g,"&ampnbsp;");
		converg = converg.replace(/&nbsp;/g,"**667**spaceconversion");
  		converg = converg.replace(/\'/g,"&amp;lsquo;");
		converg = converg.replace(/\'/g,"&lsquo;");
		converg = converg.replace(/\'/g,"&amp;rsquo;");
		converg = converg.replace(/\'/g,"&rsquo;");
		converg = converg.replace(/\'/g,"&#39;");
  		converg = converg.replace(/\"/g,"&quot;");
  		converg = converg.replace(/&lt;/g,"<");
  		converg = converg.replace(/&gt;/g,">");	
		converg = converg.replace(/&/g,"**667**conversionand");
		return converg;
	}
	
	function htmlspecialchars(str)
	{
		var cng = null;
		cng = str;
		cng = cng.replace(/&/g,'&amp;');
		cng = cng.replace(/'/g,'&#39;');	
		cng = cng.replace(/"/g,'&quot;');	
		cng = cng.replace(/&/g, "**667**andconversion");
		return cng;
	}
	
	
	function htmlspecialchars_New(str)
	{
		var cng = null;
		cng = str;
		cng = cng.replace("**667**andconversion", '&');
		cng = cng.replace("&amp;",'&');
		cng = cng.replace("&#39;","'");	
		cng = cng.replace("&quot;",'"');
		cng = cng.replace("&lquot;","'");
		cng = cng.replace("&rquot;","'");
		cng = cng.replace("&lt;","<");
		cng = cng.replace("&gt;",">");
		cng = cng.replace("&nbsp;"," ");
		return cng;
	}
	
	function update_page(originalRequest) {
		var rXML = originalRequest.responseXML;
	//		var pIDs = rXML.getElementsByTagName('tgtID').item(0);
	//		var pID = pIDs.firstChild.data;
		var values = rXML.getElementsByTagName('value').item(0);
		var value = values.firstChild.data;
	//		$(pID).innerHTML = value;	
		window.status=value;
	}
	
	window.onload=function(){
		if ( document.getElementById('newsText')){
			EditorOn('newsText');
		}//cycle();
		if(document.getElementById("completDiv")){
			completeDiv();
		}
	}