// ===================================================================
// Company: Attendee Interactive
// Author: Jason Daiger
// Website: http://www.attendeeinteractive.com/
// Description: This file contains generic global javascript functions
//	used by the ai-evolution system.
// 	
// NOTICE: You may *NOT* re-distribute this code in any way.
// That means, you cannot include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// ===================================================================

var submitting = 0;

function submitForm( formName ) {
    if( submitting == 0 ) {
        submitting = 1;
        document.getElementById(formName).submit();
    }
}

function openAIEditWindow(url, windowID) {
	var aWindow;
   aWindow = window.open(url, windowID, "top=10,left=10,toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=800,height=500");
   aWindow.focus();
}
function openAIPreviewWindow(url, windowID) {
	var aWindow;
   aWindow = window.open(url, windowID, "top=15,left=15,toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=800,height=500");
   aWindow.focus();
}
function openAISmallPreviewWindow(url, windowID) {
	var aWindow;
   aWindow = window.open(url, windowID, "top=15,left=15,toolbar=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=350,height=250");
   aWindow.focus();
}
function redirectAIPage(url) {
	document.location.href = url;
}
function checkLength(formElement,maxLength) {
   //Find the desired element.
   if (document.getElementById(formElement).value.length > maxLength) {
      document.getElementById(formElement).value = document.getElementById(formElement).value.substring(0,maxLength - 1);
      alert("The entered text exceeds the allowable limit.  Only " + maxLength + " characters are allowed.  You must shorten this text before it can be saved.");
      return false;
   }
   else
      return true;
}

function openAINewWindow(url, windowID) {
	var aWindow;
   aWindow = window.open(url, windowID, "status=1,location=1,menubar=1,directories=1,resizable=1,scrollbars=1,top=15,left=15,width=1024,height=768");
   aWindow.focus();
}

function heartBeat(){
   var xmlhttp;
   var url = 'index.cfm?do=cnt.publicHeartBeat';
   xmlhttp=null;
   xmlhttp = ( window.XMLHttpRequest ) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP") ;
   //build XMLObject
   if (xmlhttp!=null) {      
      xmlhttp.open("GET",url,true);  //build/open server object       
      xmlhttp.send(null);  //send request
   }
}


   function elementExists(){

      var allEls=document.getElementsByTagName("table");
      var l=allEls.length,i;
      for(i=0;i<l;i++){
         if(allEls[i].getAttribute("summary")=="This table store a list the deadlines for each form"){
           //table reference
           tbl = allEls[i]

           //add row after last row
				var lastRow = tbl.rows.length-1;
				var iteration = lastRow;
				var row = tbl.insertRow(lastRow);

				// left cell
				var cellLeft = row.insertCell(0);
				var textNode = document.createTextNode("Mon 5/10");
				cellLeft.appendChild(textNode);

				// right cell
				var cellRight = row.insertCell(1);
				var textNode = document.createTextNode("Submit/update bios and photos");
            cellRight.appendChild(textNode);

            //add row after last row
				var lastRow = tbl.rows.length-1;
				var iteration = lastRow;
				var row = tbl.insertRow(lastRow);

				// left cell
				var cellLeft = row.insertCell(0);
				var textNode = document.createTextNode("Fri 8/27");
				cellLeft.appendChild(textNode);

				// right cell
				var cellRight = row.insertCell(1);
				var textNode = document.createTextNode("Registration Form");
            cellRight.appendChild(textNode);


            //add row after last row
				var lastRow = tbl.rows.length-1;
				var iteration = lastRow;
				var row = tbl.insertRow(lastRow);

				// left cell
				var cellLeft = row.insertCell(0);
				var textNode = document.createTextNode("Fri 8/27");
				cellLeft.appendChild(textNode);

				// right cell
				var cellRight = row.insertCell(1);
				var textNode = document.createTextNode("A/V Requirement Form");
            cellRight.appendChild(textNode);


           // add row before last row
			  var lastRow = tbl.rows.length-1;
			  var iteration = lastRow;
			  var row = tbl.insertRow(lastRow);

			  // left cell
			  var cellLeft = row.insertCell(0);
			  var textNode = document.createTextNode("Mon 9/13");
			  cellLeft.appendChild(textNode);

			  // right cell
			  var cellRight = row.insertCell(1);
			  var textNode = document.createTextNode("Submit draft presentation to review");
           cellRight.appendChild(textNode);
            //alert(allEls[i].getAttribute("summary"))
         }
        }
   }


