function isDate(sDate) {
    var scratch = new Date(sDate);
    if (scratch.toString() == "NaN" || scratch.toString() == "Invalid Date") {
        
        return false;
    } else {
        return true;
    }
}

function updatelist(strListType, intKeyValue, strObjectName)
                {
              var this_update = strListType + "_" + strObjectName;
                       var currentlist=document.getElementById(this_update).value;
                        if (currentlist=="")
                               {
                                document.getElementById(this_update).value=intKeyValue;
                              }
                       else 
                                {
                                        // can't put the key into the list twice
                                       var strList = new String(document.getElementById(this_update).value)
                                       if  (strList.indexOf(intKeyValue) == -1)
                                                {
                                                document.getElementById(this_update).value=currentlist + "," + intKeyValue;
                                                }
                               }
                 }     
				
	 function updatelistelement(listElement, intKeyValue)
                {
     
                       var currentlist=listElement.value;
                        if (currentlist=="")
                               {
                                listElement.value=intKeyValue;
                              }
                       else 
                                {
                                        // can't put the key into the list twice
                                       var strList = new String(listElement.value)
                                       if  (strList.indexOf(intKeyValue) == -1)
                                                {
                                                listElement.value=currentlist + "," + intKeyValue;
                                                }
                               }
                 }    
	function changestyle(divid)
		/* this function is used to flip the visibility of the text input
		 * controls. each div must have a unique id */
		{
			if (document.getElementById(divid).style.display == "block")
				{
					document.getElementById(divid).style.display = "none";
				}
			else
				{
					document.getElementById(divid).style.display = "block";
				}
		} 
		
	
		
	function show(divid) {
					document.getElementById(divid).style.display = "block";
		} 

	function hide(divid){
					document.getElementById(divid).style.display = "none";
		}

	function changespanstyle(spanid)
		/* this function is used to flip the visibility of the text input
		 * controls. each div must have a unique id */
		{
			if (document.getElementById(spanid).style.display == "inline")
				{
					document.getElementById(spanid).style.display = "none";
				}
			else
				{
					document.getElementById(spanid).style.display = "inline";
				}
		} 
		
	function changecolor(divid)
		/* this function is used to flip the visibility of the text input
		 * controls. each div must have a unique id */
		 {		
			
			if (document.getElementById(divid).style.color == "black")
				{
					
					document.getElementById(divid).style.color = "red";
				}
			else
				{
					document.getElementById(divid).style.color = "black";
				}
		}      

	function changebutton (buttonid,closedValue,altText){
			var currentValue = document.getElementById(buttonid).value;
		
			if (currentValue == closedValue){
				document.getElementById(buttonid).value = altText;
			}
			else
			{
				document.getElementById(buttonid).value = closedValue;
			}
		}
/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}


/*
  name - name of the desired cookie
  return string containing value of specified cookie or null
  if cookie does not exist
*/

function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}


/*
   name - name of the cookie
   [path] - path of the cookie (must be same as path used to create cookie)
   [domain] - domain of the cookie (must be same as domain used to
     create cookie)
   path and domain default if assigned null or omitted if no explicit
     argument proceeds
*/

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"

function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0)
    date.setTime(date.getTime() - skew);
}


function go_to(urlstring){

window.location = urlstring ;
}

function go_to_home(urlstring){
var iav = document.getElementById('isAccountVisible').value
var icpv = document.getElementById('isControlPanelVisible').value
var inv = document.getElementById('isNetworkVisible').value
window.location = urlstring + '?iav=' + iav + '&icpv=' + icpv + '&inv=' + inv;
}

function set_flag(flagfield,setto){
	if (document.getElementById(flagfield)) {
	document.getElementById(flagfield).value = setto;
	}
}

var xmlHttp;
function createXMLHttpRequest() {
	if (window.ActiveXObject){
		xmlHttp = new ActiveXObject("Microsoft.xMLHTTP");
	}
	else if (window.XMLHttpRequest){
		xmlHttp= new XMLHttpRequest();
	}
} 

function startRequest(pageName,loadText,closeText){
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChange;
	var urlString = "http://www.seedwiki.com/system/seedwiki/" + pageName + ".cfm"
	xmlHttp.open("GET",urlString,true);
	xmlHttp.send(null);
	document.getElementById('display').style.display = 'block';
	loadString =  pageName + "...";
	document.getElementById('display').innerHTML =  "";
}


function handleStateChange() {
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
		var closeString = "<font size='-1'><a href='javascript:closePage();'>close</a></font><br><br>";
		document.getElementById('display').innerHTML= closeString + xmlHttp.responseText;	

		}
	}
}

function getDivContent(pageName,loadText,closeText,elementId,wikiId,wikiURLName,wikiPageId,wikiPageURLName,currentPage,wikipageversionid,accountid,isOwner){
	thisElementId = elementId;
	var currentDisplay = document.getElementById(elementId).style.display;
	
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleDivStateChange;
		var urlString = "http://" + document.location.host + "/system/seedwiki/" + pageName + ".cfm?wikiId=" + wikiId + "&wikiURLName=" + wikiURLName + "&wikiPageId=" + wikiPageId + "&wikiPageURLName=" + wikiPageURLName + "&currentPage=" + currentPage + "&wikiPageVersionID=" + wikipageversionid + "&accountid=" + accountid + "&isOwner=" + isOwner +  "&ms=" + new Date().getTime();

		xmlHttp.open("GET",urlString,true);
		xmlHttp.send(null);
		loadString =  pageName + "";
		document.getElementById(elementId).innerHTML =  "";	
}

function startDivRequest(pageName,loadText,closeText,elementId,wikiId,wikiURLName,wikiPageId,wikiPageURLName,currentPage,wikipageversionid,accountid,isOwner){
	thisElementId = elementId;
	var currentDisplay = document.getElementById(elementId).style.display;
	if (currentDisplay =='none'){
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleDivStateChange;
		var urlString = "http://" + document.location.host + "/system/seedwiki/" + pageName + ".cfm?wikiId=" + wikiId + "&wikiURLName=" + wikiURLName + "&wikiPageId=" + wikiPageId + "&wikiPageURLName=" + wikiPageURLName + "&currentPage=" + currentPage + "&wikiPageVersionID=" + wikipageversionid + "&accountid=" + accountid + "&isOwner=" + isOwner + "&ms=" + new Date().getTime();

		xmlHttp.open("GET",urlString,true);
		xmlHttp.send(null);
		document.getElementById(elementId).style.display = 'block';
		loadString =  pageName + "" ;
		document.getElementById(elementId).innerHTML =  "";
	}
	else {
		document.getElementById(elementId).style.display = 'none';
	}
	
}

function startQuickEditDivRequest(pageName,loadText,closeText,elementId,wikiId,wikiURLName,wikiPageId,wikiPageURLName,wikiPageDataSource){
	thisElementId = elementId;
	var currentDisplay = document.getElementById(elementId).style.display;
	if (currentDisplay =='none'){
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleDivStateChange;
		var urlString = "http://" + document.location.host + "/system/seedwiki/" + pageName + ".cfm?wikiId=" + wikiId + "&wikiURLName=" + wikiURLName + "&wikiPageId=" + wikiPageId + "&wikiPageURLName=" + wikiPageURLName + "&wikiPageDataSource=" + wikiPageDataSource +  "&ms=" + new Date().getTime();

		xmlHttp.open("GET",urlString,true);
		xmlHttp.send(null);
		document.getElementById(elementId).style.display = 'block';
		loadString =  pageName + "" ;
		document.getElementById(elementId).innerHTML =  "";
	}
	else {
		document.getElementById(elementId).style.display = 'none';
	}
	
}


function startMoreDivRequest(pageName,loadText,closeText,elementId,wikiId,wikiURLName,wikiPageId,wikiPageURLName,wikiPageVersionId){
	thisElementId = elementId;
	var currentDisplay = document.getElementById(elementId).style.display;
	if (currentDisplay =='none'){
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleDivStateChange;
		var urlString = "http://" + document.location.host + "/system/seedwiki/" + pageName + ".cfm?wikiId=" + wikiId + "&wikiURLName=" + wikiURLName + "&wikiPageId=" + wikiPageId + "&wikiPageURLName=" + wikiPageURLName + "&wikiPageVersionId=" + wikiPageVersionId + "&ms=" + new Date().getTime();

		xmlHttp.open("GET",urlString,true);
		xmlHttp.send(null);
		document.getElementById(elementId).style.display = 'block';
		loadString =  pageName + "" ;
		document.getElementById(elementId).innerHTML =  "";
	}
	else {
		document.getElementById(elementId).style.display = 'none';
	}
	
}

function startPagesDivRequest(datasource,first_letter,pageName,loadText,closeText,elementId,ownerCanHideLockDelete){
	thisElementId = elementId;
	var currentDisplay = document.getElementById(elementId).style.display;
	if (currentDisplay =='none'){
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleDivStateChange;
		var urlString = "http://" + document.location.host + "/system/seedwiki/" + pageName + ".cfm?datasource=" + datasource + "&first_letter=" + first_letter +  "&ownerCanHideLockDelete=" + ownerCanHideLockDelete + "&ms=" + new Date().getTime();

		xmlHttp.open("GET",urlString,true);
		xmlHttp.send(null);
		document.getElementById(elementId).style.display = 'block';
		loadString =  pageName + "loading ..." + "";
		document.getElementById(elementId).innerHTML =  "";
	}
	else {
		document.getElementById(elementId).style.display = 'none';
	}
	
}



function startContentRequest(elementId,url){
	thisElementId = elementId;
	var currentDisplay = document.getElementById(elementId).style.display;
	if (currentDisplay =='none'){
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleDivStateChange;
		var urlString = url + "&ms=" + new Date().getTime();

		xmlHttp.open("GET",urlString,true);
		xmlHttp.send(null);
		document.getElementById(elementId).style.display = 'block';
		document.getElementById(elementId).innerHTML =  "";
	}
	else {
		document.getElementById(elementId).style.display = 'none';
	}
	
}


function handleDivStateChange() {
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
		var closeString = "<font size='-1'><a href='javascript:closePage();'>close</a></font><br><br>";
		document.getElementById(thisElementId).innerHTML=  xmlHttp.responseText;	

		}
	}
}

function closePage() {
document.getElementById('display').style.display = 'none';
}

function switchPlus (plusId) {
var currentSign = document.getElementById(plusId).innerHTML;

if (currentSign.indexOf('+') > 0){
document.getElementById(plusId).innerHTML="-";
	}
else
	{
	
	document.getElementById(plusId).innerHTML="+";

	}
}

function switchButtonSign (plusId) {
var currentSign = document.getElementById(plusId).value;

if (currentSign == "+"){
document.getElementById(plusId).value="-";
	}
else
	{
	document.getElementById(plusId).value="+";

	}
}

function handleSaveStateChange() {
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
		document.getElementById(thisElementId).value=  xmlHttp.responseText;	
		}
	}
}
function saveText(divId, wikiPageId, accountId){
	var wikiPageContent = document.getElementById(divId).value;	
	var urlString = "http://" + document.location.host + "/system/seedwiki/_save_quick_edit.cfm?wikiPageId=" + wikiPageId + "&accountid=" + accountId + "&wikipagecontent='" + wikiPageContent + "'" + "&ms=" + new Date().getTime();
	
	
	alert(wikiPageContent);
	thisElementId = divId;
	
	createXMLHttpRequest();
		xmlHttp.onreadystatechange = handleSaveStateChange;
		
		xmlHttp.open("get",urlString,true);
		xmlHttp.send(null);
		document.getElementById(divId).value =  "saving your page..." + "";
		
	
}

function changeInnerHTML(divId,newText){
	document.getElementById(divId).innerHTML=newText;
}

function checkAll(wotForm,wotState,idPrefix,listElement) {
	for (a=0; a<wotForm.elements.length; a++) {
			idElement = wotForm.elements[a];
			idString = idElement.id;
		if (idString.indexOf(idPrefix) == 0) {
			idElement.checked = wotState ;
			underscorePosition = idString.indexOf('_');
			idNumber = idString.substring(underscorePosition + 1,10);
			updatelistelement(listElement,idNumber);
			
		}
	}
}

function isdefined( variable)
{
    return (typeof(window[variable]) == "undefined")?  false: true;
}

function deleteIndex(url,accountId){
	if (accountId > 0){
	 	document.location.href = url;
	 	} else {
		document.getElementById('wikiaccount').style.display = "block";
		document.getElementById('wikiaccount').style.backgroundColor = "#ffffcc";
		alert('please login to delete this index and try again');
	}
}

function logEvent(WikiPageId,WikiPageEventId,WikiPageVersionId,EventText,AccountId,WikiPageName,WikiPageURLName,WikiName,WikiURLName,Accountname,IpAddress,SessionId,EventNote,WikiId){
	
	var urlString = "http://" + document.location.host + "/system/seedwiki/_log_event.cfm?wikiPageId=" + WikiPageId + "&WikiPageEventId=" + WikiPageEventId + "&WikiPageVersionId=" + WikiPageVersionId + "&EventText=" + EventText + "&AccountId=" + AccountId + "&WikiPageName=" + WikiPageName + "&WikiPageURLName=" + WikiPageURLName + "&WikiName=" + WikiName + "&WikiURLName=" + WikiURLName + "&Accountname=" + Accountname + "&IpAddress=" + IpAddress + "&SessionId=" + SessionId + "&EventNote=" + EventNote + "&wikiid=" + WikiId;

	createXMLHttpRequest();
	
		xmlHttp.open("get",urlString,true);
		xmlHttp.send(null);

}

function getSpinner(){
return "<img src='http://www.seedwiki.com/accounts/branczyk_stephan_3023/spinning_progress_icon_first_try.gif' alt='loading...'>"
}


function setPageLock(WikiPageId, isLocked){
	if (isLocked == 1) {
	alert('This page will be temporarily locked for 30 minutes or until you save it.');
	} 
		
	var urlString = "http://" + document.location.host + "/system/seedwiki/_lock_for_edit.cfm?wikiPageId=" + WikiPageId + "&isLocked=" + isLocked;
	createXMLHttpRequest();

		xmlHttp.open("get",urlString,true);
		xmlHttp.send(null);

}

function get_page_tags(elementId,url,wikipagename,wikipageurlname){
	tagElementId = elementId;
	var currentDisplay = document.getElementById(elementId).style.display;
	if (currentDisplay =='none'){
		createXMLHttpRequest();
		xmlHttp.onreadystatechange = handle_page_tags_StateChange;
		var urlString = url + "&ms=" + new Date().getTime();

		xmlHttp.open("GET",urlString,true);
		xmlHttp.send(null);
		document.getElementById(elementId).style.display = 'block';
		document.getElementById(elementId).innerHTML =  "";
	}
	else {
		document.getElementById(elementId).style.display = 'none';
	}
	
}

function handle_page_tags_StateChange() {
	if(xmlHttp.readyState == 4){
		if(xmlHttp.status == 200){
		document.getElementById(tagElementId).innerHTML=  xmlHttp.responseText;	
		}
	}
}

function Ajax() {
  this.req = null;
  this.url = null;
  this.status = null;
  this.statusText = '';
  this.method = 'GET';
  this.async = true;
  this.dataPayload = null;
  this.readyState = null;
  this.responseText = null;
  this.responseXML = null;
  this.handleResp = null;
  this.responseFormat = 'text', // 'text', 'xml', 'object'
  this.mimeType = null;
  this.headers = [];

  
  this.init = function() {
    var i = 0;
    var reqTry = [ 
      function() { return new XMLHttpRequest(); },
      function() { return new ActiveXObject('Msxml2.XMLHTTP') },
      function() { return new ActiveXObject('Microsoft.XMLHTTP' )} ];
      
    while (!this.req && (i < reqTry.length)) {
      try { 
        this.req = reqTry[i++]();
      } 
      catch(e) {}
    }
    return true;
  };
  this.doGet = function(url, hand, format) {
    this.url = url;
    this.handleResp = hand;
    this.responseFormat = format || 'text';
    this.doReq();
  };
  this.doPost = function(url, dataPayload, hand, format) {
    this.url = url;
    this.dataPayload = dataPayload;
    this.handleResp = hand;
    this.responseFormat = format || 'text';
    this.method = 'POST';
    this.doReq();
  };
  this.doReq = function() {
    var self = null;
    var req = null;
    var headArr = [];
    
    if (!this.init()) {
      alert('Could not create XMLHttpRequest object.');
      return;
    }
    req = this.req;
    req.open(this.method, this.url, this.async);
    if (this.method == "POST") {
      this.req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }
    if (this.method == 'POST') {
      req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    }
    self = this;
    req.onreadystatechange = function() {
      var resp = null;
      self.readyState = req.readyState;
      if (req.readyState == 4) {
        
        self.status = req.status;
        self.statusText = req.statusText;
        self.responseText = req.responseText;
        self.responseXML = req.responseXML;
        
        switch(self.responseFormat) {
          case 'text':
            resp = self.responseText;
            break;
          case 'xml':
            resp = self.responseXML;
            break;
          case 'object':
            resp = req;
            break;
        }
        
        if (self.status > 199 && self.status < 300) {
          if (!self.handleResp) {
            alert('No response handler defined ' +
              'for this XMLHttpRequest object.');
            return;
          }
          else {
            self.handleResp(resp);
          }
        }
        
        else {
          self.handleErr(resp);
        }
      }
    }
    req.send(this.dataPayload);
  };
  this.abort = function() {
    if (this.req) {
      this.req.onreadystatechange = function() { };
      this.req.abort();
      this.req = null;
    }
  };
  this.handleErr = function() {
    var errorWin;
    // Create new window and display error
    try {
      errorWin = window.open('', 'errorWin');
      errorWin.document.body.innerHTML = this.responseText;
    }
    // If pop-up gets blocked, inform user
    catch(e) {
      alert('An error occurred, but the error message cannot be' +
      ' displayed because of your browser\'s pop-up blocker.\n' +
      'Please allow pop-ups from this Web site.');
    }
  };
  this.setMimeType = function(mimeType) {
    this.mimeType = mimeType;
  };
  this.setHandlerResp = function(funcRef) {
    this.handleResp = funcRef;
  };
  this.setHandlerErr = function(funcRef) {
    this.handleErr = funcRef; 
  };
  this.setHandlerBoth = function(funcRef) {
    this.handleResp = funcRef;
    this.handleErr = funcRef;
  };
  this.setRequestHeader = function(headerName, headerValue) {
    this.headers.push(headerName + ': ' + headerValue);
  };
  
}

function get_random_number(){
	return Math.random() * 10;
}

function get_content(page_name,div_id){
	var src = "";
	var ajax = new Ajax();
	var ajax_path = "";
	var get_content_Func = function (str){
document.getElementById(div_id).style.display = "block";
document.getElementById(div_id).innerHTML = str;
}
if (page_name.indexOf('?') > 0){
	ajax_path = "http://www.seedwiki.com/system/ajax/" + page_name + "&i=" + get_random_number() + ";";
}
else{
	ajax_path = "http://www.seedwiki.com/system/ajax/" + page_name + "?i=" + get_random_number() + ";";
}	

ajax.doGet(ajax_path, get_content_Func);	



}

function get_wikipage_content(page_url_name,div_id){
	var src = "";
	var strdifferentname = "";
	var ajax = new Ajax();
	var ajax_path = "";
	ajax_path = "http://www.seedwiki.com/system/ajax/get_wikipage_content.cfm?page_url_name=" + page_url_name ;

console.log(page_url_name);
console.log(div_id);
	
	var get_wikipage_content_Func = function (str){
document.getElementById(div_id).style.display = "block";
document.getElementById(div_id).innerHTML = str;
console.log(str);
}

	

ajax.doGet(ajax_path, get_wikipage_content_Func);	



}

/*
 * Copyright 2005 Matthew Eernisse (mde@fleegix.org)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * Original code by Matthew Eernisse (mde@fleegix.org), March 2005
 * Additional bugfixes by Mark Pruett (mark.pruett@comcast.net), 12th July 2005
 * Multi-select added by Craig Anderson (craig@sitepoint.com), 24th August 2006
 *
 * Version 1.3
*/

/**
 * Serializes the data from all the inputs in a Web form
 * into a query-string style string.
 * @param docForm -- Reference to a DOM node of the form element
 * @param formatOpts -- JS object of options for how to format
 * the return string. Supported options:
 *    collapseMulti: (Boolean) take values from elements that
 *    can return multiple values (multi-select, checkbox groups)
 *    and collapse into a single, comman-delimited value
 *    (e.g., thisVar=asdf,qwer,zxcv)
 * @returns query-string style String of variable-value pairs
 */
function formData2QueryString(docForm, formatOpts) {
  
  var opts = formatOpts || {};
  var str = '';
  var formElem;
  var lastElemName = '';
  
  for (i = 0; i < docForm.elements.length; i++) {
    formElem = docForm.elements[i];
    
    switch (formElem.type) {
      // Text fields, hidden form elements
      case 'text':
      case 'hidden':
      case 'password':
      case 'textarea':
      case 'select-one':
        str += formElem.name + '=' + encodeURI(formElem.value) + '&'
        break;
        
      // Multi-option select
      case 'select-multiple':
        var isSet = false;
        for(var j = 0; j < formElem.options.length; j++) {
          var currOpt = formElem.options[j];
          if(currOpt.selected) {
            if (opts.collapseMulti) {
              if (isSet) {
                str += ',' + encodeURI(currOpt.value);
              }
              else {
                str += formElem.name + '=' + encodeURI(currOpt.value);
                isSet = true;
              }
            }
            else {
              str += formElem.name + '=' + encodeURI(currOpt.value) + '&';
            }
          }
        }
        if (opts.collapseMulti) {
          str += '&';
        }
        break;
      
      // Radio buttons
      case 'radio':
        if (formElem.checked) {
          str += formElem.name + '=' + encodeURI(formElem.value) + '&'
        }
        break;
        
      // Checkboxes
      case 'checkbox':
        if (formElem.checked) {
          // Collapse multi-select into comma-separated list
          if (opts.collapseMulti && (formElem.name == lastElemName)) {
            // Strip of end ampersand if there is one
            if (str.lastIndexOf('&') == str.length-1) {
              str = str.substr(0, str.length - 1);
            }
            // Append value as comma-delimited string
            str += ',' + encodeURI(formElem.value);
          }
          else {
            str += formElem.name + '=' + encodeURI(formElem.value);
          }
          str += '&';
          lastElemName = formElem.name;
        }
        break;
        
    }
  }
  // Remove trailing separator
  str = str.substr(0, str.length - 1);
  return str;
}

function change_focus_to(controlId){
	document.getElementById(controlId).focus();
}

function check_login_email(){
	var ajax = new Ajax();
	var ajax_path = "";
	var email_to_check = "";
	var check_email_Func = function (str){

document.getElementById('email_message').innerHTML = str;	
}
	email_to_check = document.getElementById('useremail').value;
	
	if (email_to_check.length) {
		ajax_path = '../../system/ajax/check_login_email.cfm?check_email=' + email_to_check;
		ajax.doGet(ajax_path, check_email_Func);	
}
else
{return false}
}

function check_login_password(isAnonymous){
var ajax = new Ajax();
var ajax_path = "";
var email_to_check = "";
var password_to_check = "";
var is_anonymous = "";

var check_password_Func = function (str){
	if (str.indexOf("found you")){
	document.getElementById('password_message').innerHTML = str;
	javascript:get_form_page('inner_wiki_list','login_wiki_list');
	}
	else
	{
	document.getElementById('password_message').innerHTML = str;	
	}

}
document.getElementById('email_message').style.display="block";
email_to_check = document.getElementById('useremail').value;
is_anonymous = document.getElementById('is_anonymous').value;
password_to_check = document.getElementById('userlogin').value;
ajax_path = '../../system/ajax/check_login_password.cfm?check_email=' + email_to_check + '&check_password=' + password_to_check + '&is_anonymous=' + is_anonymous;
ajax.doGet(ajax_path, check_password_Func);	
}

function log_out(){
var ajax = new Ajax();
var ajax_path = "";
var email_to_check = "";
var password_to_check = "";

var log_out_Func = function (str){	

		get_form_page('logout','you_display');	
}

ajax_path = '../../system/ajax/log_out_user.cfm';
ajax.doGet(ajax_path, log_out_Func);	
}

function start_new_wiki(isAnonymous){
var ajax = new Ajax();
var ajax_path = "";
var new_wiki_name = "";


var start_new_wiki_Func = function (str){
	
	document.getElementById('new_wiki_message').innerHTML = str;	
	

}

new_wiki_name = document.getElementById('new_wiki_name').value;

ajax_path = '../../system/ajax/insert_new_wiki.cfm?new_wiki_name=' + new_wiki_name;
ajax.doGet(ajax_path, start_new_wiki_Func);	
}



function get_href_for_new_pg(wikiId, wikiURLName){
	var ajax = new Ajax();
	var ajax_path = "";
	var new_page_name = "";
	var use_id = 'new_page_message';
	new_page_name = document.getElementById("new_page_name").value;
	var insert_new_page_Func = function (str){
document.getElementById(use_id).innerHTML = str;
}
	
ajax_path = '../../system/ajax/get_href_for_new_pg.cfm?wikiId=' + wikiId + '&wikiPageName=' + new_page_name + '&wikiURLName=' + wikiURLName;
ajax.doGet(ajax_path, insert_new_page_Func);	


}

function copy_wiki_pg(){
	var ajax = new Ajax();
	var ajax_path = "";
	var target_wiki_id = "";
	var use_id = 'copy_page_message';
	target_wiki_id = document.getElementById("copy_to_wikiid").value;
	var copy_wiki_pg_Func = function (str){
document.getElementById(use_id).innerHTML =  str;
}
	
ajax_path = '../../system/ajax/insert_pg_copy.cfm?wikiId=' + target_wiki_id;
ajax.doGet(ajax_path, copy_wiki_pg_Func);	


}
//functions from line menu


function get_widget(widget_name,commandArgument,div_id,counter){
	var ajax = new Ajax();
	var ajax_path = "";
	var random_number = "";
	
	var get_form_Func = function (str){

	//alert(document.getElementById(div_id).innerHTML);
document.getElementById(div_id).innerHTML = str;
	
}

random_number = get_random_number();
ajax_path = "../../widgets/" + widget_name + ".cfm?i=" + random_number + "&commandArgument=" + commandArgument + "&counter=" + counter;

ajax.doGet(ajax_path, get_form_Func);
	
}


function get_form_page(form_name,div_id){
	var ajax = new Ajax();
	var ajax_path = "";
	var random_number = "";
	
	var get_form_Func = function (str){

	//alert(document.getElementById(div_id).innerHTML);
document.getElementById(div_id).innerHTML = str;
	
}

random_number = get_random_number();
ajax_path = "../../system/ajax/" + form_name + ".cfm?i=" + random_number;

ajax.doGet(ajax_path, get_form_Func);
	
}

function get_random_number(){
	return Math.random() * 10;
}

function close_menu (menu_div){
document.getElementById(menu_div).style.display="none";	
}

function close_form () {
document.getElementById('page_frame').style.visibility = "hidden";

}



function update_single_value(tableName,fieldName,keyValue,newValue,fKey,fKeyValue){
	var ajax = new Ajax();
	var ajax_path = "";
	var new_value = "";
	var update_single_value_Func = function (str){
	
        document.getElementById('update_message').innerHTML = str;
        	
        }
    	if (newValue.length) {
    		if (fKey.length){
    		ajax_path = "../../system/ajax/update_single_value.cfm?tablename=" + tableName + "&fieldname=" + fieldName + "&keyValue=" + keyValue + "&new_value=" + newValue + "&fKey=" + fKey + "&fKeyValue=" & fKeyValue;
    			
    		}
    		else{
    		ajax_path = "../../system/ajax/update_single_value.cfm?tablename=" + tableName + "&fieldname=" + fieldName + "&keyValue=" + keyValue + "&new_value=" + newValue;
    		}
    		
    		ajax.doGet(ajax_path, update_single_value_Func);}
    	else
    	{return false}
    }

    function set_wiki_variable(var_name,var_value){
	var ajax = new Ajax();
	var ajax_path = "";
	var set_wiki_variable_Func = function (str){
	    document.location.href = document.location.href;
       // alert(str);
        	
        }
    	
    		ajax_path = "../../widgets/_set_wiki_variable_.cfm?var_name=" + var_name + "&var_value=" + var_value ;
    		ajax.doGet(ajax_path, set_wiki_variable_Func);
    }
    
function change_menu(menuToShow){
	
	if (menuToShow == "you_menu") {
		document.getElementById("you_menu").style.display="block"
	}
	else{
		document.getElementById("you_menu").style.display="none"
		}
	if (menuToShow == "host_menu") {
		document.getElementById("host_menu").style.display="block"
	}
	else{
		document.getElementById("host_menu").style.display="none"
		}
	if (menuToShow == "wiki_menu") {
		document.getElementById("wiki_menu").style.display="block"
	}
	else{
		document.getElementById("wiki_menu").style.display="none"
		}
	if (menuToShow == "page_menu") {
		document.getElementById("page_menu").style.display="block"
	}
	else{
		document.getElementById("page_menu").style.display="none"
		}
	close_form();
}

		pageTimeoutId = 0;
		function set_timer(divName){
			codeString = "change_menu('" + divName + "');";
			pageTimeoutId = setTimeout(codeString, 250);
		}


 

function isNumeric(sText) {
   var ValidChars = "0123456789.";
   var Char;
   for (i = 0; i < sText.length; i++) {
       Char = sText.charAt(i);
       if (ValidChars.indexOf(Char) == -1) {
          return false;
       }
    }
   return true;
}



if (!window.console || !console.firebug)
{
    var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
    "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

    window.console = {};
    for (var i = 0; i < names.length; ++i)
        window.console[names[i]] = function() {}
}


	
	function save_quick_edit(){
			var edit_form = document.getElementById('edit_form');
			var ajax = new Ajax();
			var current_location = document.location.href;
		
			var save_changes_Func = function (str){
				/* document.getElementById('quick_edit_message_top').innerHTML = str;
				document.getElementById('quick_edit_message_bottom').innerHTML = str;
				*/
				alert(str);
				document.location.href = current_location;
				}
			
	var form_data = '';
	form_data += 'quickwikitext=' + document.getElementById('quick_wikitext');
	ajax_path = '../../system/ajax/update_quick_page.cfm';
	ajax.doPost(ajax_path, form_data, save_changes_Func);
			}
	
	function cancel_quick_edit(){
			var current_location = document.location.href;
			document.location.href = current_location;
	}
	 function test(){
	 	alert('test');
	 }
    



















