/********************************************************************************************************
 *RESOLUTION INTERACTIVE MEDIA INC.																		*
 *560 Wellington Street, London, Ontario, Canada														*
 *Jonathan Kochis (jonathan@resolutionim.com)															*
 *Brendan Farr-Gaynor (brendan@resolutionim.com)														*
 *Owain Johnson (owain@resolutionim.com)																*
 *																										*
 *Version: 1.00 Brendan Farr-Gaynor - 11/17/2006: Added handlers for res2.0 ajax cms 					*
 *Version: 0.90 Brendan Farr-Gaynor - 11/17/2006: Extended master ajax functions to run					*
 *												  multiple connections concurrently						*
 ********************************************************************************************************
 *Date Last Modified: 11/17/06																			*
 *Last Modified By: brendan@resolutionim.com												 			*
 *																										*
 ********************************************************************************************************/


/****************************** GIVE ME A BOX TOGGLE GRAPHICS ***********************************/

/*
These are global variables that need to be included on every page. They are used by the toggle js functions in giveMeABox()
*/


		var toggleOpenPic = new Image;
		var toggleClosePic = new Image;
		
		toggleOpenPic.src = "/images/arrow1.gif";
		toggleClosePic.src = "/images/arrow2.gif";
		
function toggleMyGiveMeABoxTog(myGID) {
	var str = document.getElementById(myGID).src;
	
	if(str.indexOf("arrow1.gif") != -1) {
		document.getElementById(myGID).src = toggleClosePic.src;
	} else {
		document.getElementById(myGID).src = toggleOpenPic.src;
	}
	
	//alert();
	//= closePic.src;
	
}


/****************************** END GIVE ME A BOX TOGGLE GRAPHICS ***********************************/




/****************************** RESOLUTION MASTER AJAX FUNCTIONS ***********************************/

/*
The following are global functions to be used with all new AJAX activity, some applications require thier
own AJAX functions but these should cover the majority.
*/

//array that stores all ajax request objects
var masterRO = new Array();

function resCreateNewRequestObject() {
  
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        masterRO[masterRO.length] = new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        masterRO[masterRO.length] = new XMLHttpRequest();
    }
    return masterRO.length - 1;
	//masterRO[masterRO.length];
}





function resSndReq(queryStringToSend, whatFunctionToRun) {
	
	reshttp = masterRO[resCreateNewRequestObject()];
	

		   resAJAXRequestStarted = true;
		   var functionToSend = whatFunctionToRun;
		   reshttp.open('get', queryStringToSend, true);
		   reshttp.onreadystatechange = function() {
				//data is loaded
					if (reshttp.readyState == 4) {
						resAJAXRequestStarted = false;
						
						var resResponse = reshttp.responseText;
						var arrayToSendBack = new Array();
					
						if(resResponse.indexOf('|' != -1)) {
//							alert(resResponse);
							arrayToSendBack = resResponse.split('|');
							eval(functionToSend + "(arrayToSendBack);");
							
						}
					}
				
			// end of data loaded
			 }
			 
			reshttp.send(null);
	
}


/************************** END OF RESOLUTION MASTER AJAX FUNCTIONS ***********************************/


/************************** RESOLUTION ADMIN AJAX FUNCTIONS (these depend upon the master ajax functions) ******/




function resTblEditorToggleAdminSlider(editString, listItemString) {
	//HACK to get around bug in mozilla's implementation of designMode
	//designMode = 'On' fails horribly when the target is hidden (hope they fix that soon, till then....)
Effect.toggle(editString, 'slide');	

	//the div is available for init
	tempVar = "global" + listItemString;
	tempVar = eval(tempVar);
	
	if(document.getElementById(editString).style.display == 'none') {
		
		for(i=0; i< tempVar.length; i++) {
						setTimeout("Init('" + tempVar[i] +"')", 500);
				}
	}
	
	
	//THE FOLLOWING SNIPPED WAS DUPLICATED HERE FROM ORDER UPDATE BECAUSE WYSIWYG FIELDS WERE GETTING BLANKED 
	/////////////////////////
		//first figure out if there are any editors here (all WYSIWYG editors are stored in an array with a similar name)
		wyName = "global" + listItemString;
		wysForThisRow = eval(wyName);
		
		for(i=0; i < wysForThisRow.length; i++) {
			//and chaos ensues
			if(navigator.appName == "Netscape") {
				eval("dragStore" + wyName + "["+i+"] = document.getElementById(wysForThisRow["+i+"]).contentDocument.body.innerHTML;");
			} else { //damn IE why can't you be standards compliant
				eval("dragStore" + wyName + "["+i+"] = wysForThisRow[" + i +"].document.body.innerHTML;");
			}	
			
		}
	////////////////////////
	
}


function resTblEditorInsertANewBlankRecord(table, tblKeyString) {
	
	//this will insert a new blank record with 'active' set to 2 so that it's not displayed on the front end
	//when the user updates/saves, the record's 'active' will be set to the tradional default of 1.
	
	//alert("You are creating a new record in: " + table + " with the string: " + tblKeyString);
	//alert('resQuery.php?a=nbl&tbl=' + table + '&tblKeyString=' + tblKeyString);
	resSndReq('resQuery.php?a=nbl&tbl=' + table + '&tblKeyString=' + tblKeyString, 'resTblEditorInsertANewBlankRecordComplete');
	
}

function resTblEditorInsertANewBlankRecordComplete(respArray) {
	//this will pull back the itemID of the latest insert from respArray as well as the table id
	
	//it will then look through the template storage array to pull out the proper template
	// a find and replace will then replace the JSSTRING with the new proper ID
	
	
	//alert('Inserted Record:' + respArray[1]);
	
	document.getElementById(respArray[2]).innerHTML = globalResTblEditorNewItemTemplates[respArray[2]].replace(/IMNEWREPLACEME/g, respArray[1]) + document.getElementById(respArray[2]).innerHTML;
	
	//alert(globalResTblEditorNewItemTemplates[respArray[2]].replace(/IMNEWREPLACEME/g, respArray[1]));
	
	Effect.toggle('table_'+ respArray[3] +'_edit_' + respArray[1], 'slide');
	
	//re-init 'sortable' as a new item has been dynamically added
	
	Sortable.create(respArray[2], {dropOnEmpty:true, containment:[respArray[2]], constraint:false, onUpdate:resTblEditorUpdateOrder});
	
}


var allowChange = true;

function resTblEditorDragChange(whatElement) {
	
	if(allowChange) {
		allowChange = false;
		/*
			sortable will blanks any WYSIWYG editors in this item
			so we must save out the HTML in the editor (if it exists)
			to a variable that can later populate the editor
		*/
		
		//first figure out if there are any editors here (all WYSIWYG editors are stored in an array with a similar name)
		wyName = "global" + whatElement.id;
		wysForThisRow = eval(wyName);
		
		for(i=0; i < wysForThisRow.length; i++) {
			//and chaos ensues
			
			//we only want to run init() if the toggle is open, therefore we must detect the open/close state by determining the parent toggle
			divSet = whatElement.id.split('num');
			idSet = whatElement.id.split('_');
							
			if(document.getElementById("table_" + divSet[0] + "_edit_" + idSet[1]).style.display != 'none') { // run this *ONLY* if the toogle is open (haven't added that yet)
				if(navigator.appName == "Netscape") {
					eval("dragStore" + wyName + "["+i+"] = document.getElementById(wysForThisRow["+i+"]).contentDocument.body.innerHTML;");
				} else { //damn IE why can't you be standards compliant
					eval("dragStore" + wyName + "["+i+"] = wysForThisRow[" + i +"].document.body.innerHTML;");
				}	
			}
			
		}
	}

}


function resTblEditorUpdateOrder(whatElement) {
	
	//re-write the content to any WYSIWYG editors that may exist in this row
	wyName = "global" + whatElement.id;
	allowChange = true;
	
	
	for (var i = 0; i < whatElement.childNodes.length; i++) {
      		//textContent += getTextContent(node.childNodes[i]);
			thisNode = whatElement.childNodes[i];
			
			if(thisNode.nodeName == "LI") { //must be a LI or other html tag
			
			
					if(eval("dragStoreglobal" + thisNode.id)) {
						
						for(j=0; j < eval("dragStoreglobal" + thisNode.id + ".length"); j++) {
							
							if(navigator.appName == "Netscape") {
								document.getElementById(eval('global' + thisNode.id + '['+j+']')).contentDocument.body.innerHTML = eval("dragStoreglobal" + thisNode.id +"["+j+"]");
							} else { //damn IE why can't you be standards compliant
								eval('global' + thisNode.id + '['+j+']').document.body.innerHTML = eval("dragStoreglobal" + thisNode.id +"["+j+"]");
							}
							
							
								//we only want to run init() if the toggle is open, therefore we must detect the open/close state by determining the parent toggle
									divSet = thisNode.id.split('num');
									idSet = thisNode.id.split('_');
							
								if(document.getElementById("table_" + divSet[0] + "_edit_" + idSet[1]).style.display != 'none') {
									
									Init(eval('global' + thisNode.id + '['+j+']'));
								}
							
						}
						
						
					}
	
				
			}
		
		}
	
	
	
	
	
	

	
	
	//send the new order to the db
	
	for(i=0; i < tableIDKeeper.length; i++) {
		if(i==0) {
			newOrderToSend = "&";	
		}
		
		 newOrderToSend += Sortable.serialize(tableIDKeeper[i]);
		 //alert('resQuery.php?a=upo&ts='+ tableIDKeeper[i] + newOrderToSend);
		// alert('resQuery.php?a=upo&ts='+ tableIDKeeper[i] + newOrderToSend);
		 resSndReq('resQuery.php?a=upo&ts='+ tableIDKeeper[i] + newOrderToSend, 'resTblEditorUpdateOrderComplete');
	
	}
	
}

function resTblEditorUpdateOrderComplete(respArray) {
	
	
		
		
		
		for (var i = 0; i < document.getElementById(respArray[1]).childNodes.length; i++) {
      		//textContent += getTextContent(node.childNodes[i]);
			thisNode = document.getElementById(respArray[1]).childNodes[i];
			
			if(thisNode.nodeName == "LI") { //must be a LI or other html tag
				//highlight the parent li (needs to change to reflect new li name)
				new Effect.Highlight(thisNode);
			}
		
		}
}



function resTblEditorConfirmDelete(table, itemID, tblkey, message) {
	
		if(confirm(message)) {
			//show the wait graphic
			document.getElementById('table_' + table + '_waitG_' + itemID).style.display = 'block';
			//table_" .$_REQUEST['tbl'] . "_waitG_" . $_REQUEST['id'];
			
			resSndReq('resQuery.php?a=del&tbl=' + table + '&id=' + itemID + '&tblkey=' + tblkey, 'resTblEditorCompleteDelete');
		}
	
}

function resTblEditorCompleteDelete(respArray) {
		//hide the wait graphic
		document.getElementById(respArray[1]).style.display = 'none';
		//this item is now technically deleted so remove it from the list items
		Effect.Fade(respArray[2]);
}

globalResTblEditorLastVars = "Nothing yet."

function packageThisAndUpdate(table, itemID, tblkey, formID) {
	
	globalResTblEditorLastVars = new Object();
	
	//loop through the items in the provided form
	stringToWrite = "";
	fToSecure = "";
	
	thisForm = document.getElementById(formID).elements;
	
		for(i=0; i < thisForm.length; i++) {
			stringToWrite+= "&" + thisForm[i].name + "=" + escape(thisForm[i].value);
			//save this so we may update the screen later (after 'save changes') to simulate a page refresh
			globalResTblEditorLastVars[thisForm[i].name] =  thisForm[i].value;
			
			fToSecure += thisForm[i].name;
		}
		
		//alert("Updating: " + itemID);
		//////////////////////
		
		//first figure out if there are any editors here (all WYSIWYG editors are stored in an array with a similar name)
		
		wyName = "global" + table + "num" + tblkey + "_" + itemID;
		wysForThisRow = eval(wyName);
		
		for(i=0; i < wysForThisRow.length; i++) {
			//and chaos ensues
				//alert(wysForThisRow[i]);
				
				if(navigator.appName == "Netscape") {
					stringToWrite+= "&" + wysForThisRow[i] + "=" + escape(document.getElementById(wysForThisRow[i]).contentDocument.body.innerHTML);
					globalResTblEditorLastVars[wysForThisRow[i]] =  document.getElementById(wysForThisRow[i]).contentDocument.body.innerHTML;
					fToSecure += wysForThisRow[i];
				} else { //damn IE why can't you be standards compliant
					stringToWrite+= "&" + wysForThisRow[i] + "=" + escape(wysForThisRow[i].document.body.innerHTML);
					globalResTblEditorLastVars[wysForThisRow[i]] =  document.getElementById(wysForThisRow[i]).contentDocument.body.innerHTML;
					fToSecure += wysForThisRow[i];
				}	
			
			
		}
		
		//////////////////////
		   	
	resSndReq('resQuery.php?fToSecure=' + fToSecure + '&a=upd&tbl=' + table  + '&tblkey=' + tblkey + '&id=' + itemID + stringToWrite, 'resTblEditorCompleteUpdate');
	
	//alert(stringToWrite);
}

function resTblEditorCompleteUpdate(respArray) {
		//hide the wait graphic
		document.getElementById(respArray[1]).style.display = 'none';
		
		//highlight the parent li (needs to change to reflect new li name)
		new Effect.Highlight(respArray[2]);
		
		//update the div data in the divs located in the display div (then say it 3 times fast)
		whatToAlert = "";
		for (var i = 0; i < document.getElementById(respArray[3]).childNodes.length; i++) {
      		//textContent += getTextContent(node.childNodes[i]);
			thisNode = document.getElementById(respArray[3]).childNodes[i];
			
			if(thisNode.nodeName == "DIV") { //must be a div or other html tag
				//alert(thisNode.id);
				
				myFieldNameArray = thisNode.id.split('_');
				
				//now loop through the labels in globalResTblEditorLastVars to see if we have matches
				for(var currentFieldName in globalResTblEditorLastVars) {
						//whatToAlert = 'getting here' + currentFieldName + " = " + myFieldNameArray[0];
						if(currentFieldName.substr(7) == myFieldNameArray[0]) {
							thisNode.innerHTML = globalResTblEditorLastVars[currentFieldName];
						}
				}
				
			}
    	}
		
		
		
		
}

/************************** END OF RESOLUTION ADMIN AJAX FUNCTIONS ************************************/



//Resolution WYSIWYG functions

function confirmDownloadDelete(loc) {
		if(confirm("You are about to permanently delete this file. Are you sure you want to do this?")) {
			window.location = loc;
		}
	}


function confirmDelete(loc) {
		if(confirm("Are you sure you would like to delete this listing?")) {
			window.location = loc;
		}
	}
	

var x = null;
var xSet = false;


function setActiveName(nameToSet) { //switches X var to the active
	
	if(navigator.appName == "Netscape") {
		
		x = document.getElementById(nameToSet).contentDocument;
	
	} else { //damn IE why can't you be standards compliant
	
		x = eval(nameToSet + ".document"); //iView.document;
	}	
	
	
	
}


function Init(myName) { //turns on designMode and sets the first X
	
	//alert('calling init');
	setActiveName(myName);
	x.designMode = 'on'; //turns them all on
	x.execCommand('contentReadOnly', false, false);
	x.execCommand('readonly', true, true);
	x.designMode = 'on'; //turns them all on
	x.body.style.fontFamily = "Verdana";
	x.body.style.fontSize = "12px";
	x.body.bgColor = "";	
	x.body.text = '#000000';
	xSet = true;
}

function setContent(theContent, myName) {
	setActiveName(myName);
	x.body.innerHTML = theContent;
}


function postIt(textareaName, myName) {  
	setActiveName(myName);
	document.getElementById(textareaName).value = x.body.innerHTML;

}




/// specific action functions

function boldIt(myName) { 
	setActiveName(myName);
	x.execCommand('bold', false, null);
}
	
function italIt(myName) {
	setActiveName(myName);
	x.execCommand('italic', false, null); 
}


function ordListIt(myName) {
	setActiveName(myName);
	x.execCommand('insertorderedlist', false, null); 
}

function supIt(myName) {
	setActiveName(myName);
	x.execCommand('superscript', false, null); 
}

function subIt(myName) {
	setActiveName(myName);
	x.execCommand('subscript', false, null); 
}

function bulListIt(myName) {
	setActiveName(myName);
	x.execCommand('insertunorderedlist', false, null); 
}

function linkIt(myName) { 
	setActiveName(myName);
	
	if(navigator.appName == "Netscape") {
		var szURL = prompt("URL (ex. http://www.google.com)", ""); //Mozilla doensn't support new interface rendering and does not work with safari yet (as of 1.3)
		x.execCommand('createlink',false,szURL); 
	 } else {
		x.execCommand('CreateLink');
	 }
}

function selOn(ctrl) {
	ctrl.style.borderColor = '#CDDAD7';
	ctrl.style.backgroundColor = '#FFFFFF';
	ctrl.style.cursor = 'hand';	
}

function selOff(ctrl) {
	ctrl.style.borderColor = '#E7EEEC';  
	ctrl.style.backgroundColor = '#E7EEEC';
}

function selDown(ctrl) {
	ctrl.style.backgroundColor = '#D3E4DF';
}

function selUp(ctrl) {
	ctrl.style.backgroundColor = '#E7EEEC';
}


//END OF WY FUNCTIONS



/* Resolution Interactive Media */
/* Developed By: Jonathan Kochis And Brendan Farr-Gaynor */
/* jonathan@teamresolution.com / brendan@teamresolution.com */



//Resolution Multi-Selector functions

function addToList(listField, newText, newValue) {
if ( ( newValue == "" ) || ( newText == "" ) ) {
alert("You cannot add blank values!");
} else {
var len = listField.length++; // Increase the size of list and return the size
listField.options[len].value = newValue;
listField.options[len].text = newText;

listField.selectedIndex = len; // Highlight the one just entered (shows the user that it was entered) //BUG FIX
} // Ends the check to see if the value entered on the form is empty
}	

function removeFromList(listField) {
if ( listField.length == -1) { // If the list is empty
alert("There are no values which can be removed!");
} else if (listField.options[listField.selectedIndex].text == "") { //If no value is selected
alert("You cannot remove blank values!"); 
} else {
var selected = listField.selectedIndex;
if (selected == -1) {
alert("You must select an entry to be removed!");
} else { // Build arrays with the text and values to remain
var replaceTextArray = new Array(listField.length-1);
var replaceValueArray = new Array(listField.length-1);
for (var i = 0; i < listField.length; i++) {
// Put everything except the selected one into the array
if ( i < selected) { replaceTextArray[i] = listField.options[i].text; }
if ( i > selected ) { replaceTextArray[i-1] = listField.options[i].text; }
if ( i < selected) { replaceValueArray[i] = listField.options[i].value; }
if ( i > selected ) { replaceValueArray[i-1] = listField.options[i].value; }
}
listField.length = replaceTextArray.length; // Shorten the input list
for (i = 0; i < replaceTextArray.length; i++) { // Put the array back into the list
listField.options[i].value = replaceValueArray[i];
listField.options[i].text = replaceTextArray[i];
}
} // Ends the check to make sure something was selected
} // Ends the check for there being none in the list
}


function moveUpList(listField) {
if ( listField.length == -1) { // If the list is empty
alert("There are no values which can be moved!");
} else {
var selected = listField.selectedIndex;
if (selected == -1) {
alert("You must select an entry to be moved!");
} else { // Something is selected 
if ( listField.length == 0 ) { // If there's only one in the list
alert("There is only one entry!\nThe one entry will remain in place.");
} else { // There's more than one in the list, rearrange the list order
if ( selected == 0 ) {
alert("The first entry in the list cannot be moved up.");
} else {
// Get the text/value of the one directly above the hightlighted entry as
// well as the highlighted entry; then flip them
var moveText1 = listField[selected-1].text;
var moveText2 = listField[selected].text;
var moveValue1 = listField[selected-1].value;
var moveValue2 = listField[selected].value;
listField[selected].text = moveText1;
listField[selected].value = moveValue1;
listField[selected-1].text = moveText2;
listField[selected-1].value = moveValue2;
listField.selectedIndex = selected-1; // Select the one that was selected before  //BUG FIX
} // Ends the check for selecting one which can be moved
} // Ends the check for there only being one in the list to begin with
} // Ends the check for there being something selected
} // Ends the check for there being none in the list
}


function moveDownList(listField) {
if ( listField.length == -1) { // If the list is empty
alert("There are no values which can be moved!");
} else {
var selected = listField.selectedIndex;
if (selected == -1) {
alert("You must select an entry to be moved!");
} else { // Something is selected 
if ( listField.length == 0 ) { // If there's only one in the list
alert("There is only one entry!\nThe one entry will remain in place.");
} else { // There's more than one in the list, rearrange the list order
if ( selected == listField.length-1 ) {
alert("The last entry in the list cannot be moved down.");
} else {
// Get the text/value of the one directly below the hightlighted entry as
// well as the highlighted entry; then flip them
var moveText1 = listField[selected+1].text;
var moveText2 = listField[selected].text;
var moveValue1 = listField[selected+1].value;
var moveValue2 = listField[selected].value;
listField[selected].text = moveText1;
listField[selected].value = moveValue1;
listField[selected+1].text = moveText2;
listField[selected+1].value = moveValue2;
listField.selectedIndex = selected+1; // Select the one that was selected before //BUG FIX
} // Ends the check for selecting one which can be moved
} // Ends the check for there only being one in the list to begin with
} // Ends the check for there being something selected
} // Ends the check for there being none in the list
}


function submitBuckets(textfieldName, listField1) {
var len1 = listField1.length;
var buck1 = "";


for(i=0; i<len1; i++){
	buck1 += listField1.options[i].value;
}


document.getElementById(textfieldName).value = buck1.substring(1);
//alert(buck1);


}

//End Of Multi-Selector functions


function submitDateItem(textfieldName, prefix) {
	//submitDateItem('itemDateTimeEnd', 'ed');
	
	day = document.getElementById(prefix + "Day").value;
	month = document.getElementById(prefix + "Month").value;
	year = document.getElementById(prefix + "Year").value;
	hour = document.getElementById(prefix + "Hour").value;
	minute = document.getElementById(prefix + "Minute").value;
	AMPM = document.getElementById(prefix + "AMPM").value;
	
//vvvvvvvvvvvv was setting 08/20 and 09/21 to 12/00	
//	hour = parseInt(hour);
//^^^^^^^^^^^^ was setting 08/20 and 09/21 to 12/00	
	hour = Number(hour);
	needsExtraZero = true;
	
	if(AMPM == "PM") {
		if(hour != 12) {
			hour = hour + 12;
		}
	} else {
		if(hour == 12) {
			hour = '00';
			needsExtraZero = false;
		}
		
	}
	
	
	if(needsExtraZero) {
		if(hour < 10) {
			hour = "0" + hour;	
		}
	}
		
	
	document.getElementById(textfieldName).value = year + "-" + month + "-" + day + " " + hour + ":" + minute + ":00";
	
}

/******************************In Out Board Functions ***********************************/
function inOutCreateRequestObject() {
    var inOut;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        inOut = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        inOut = new XMLHttpRequest();
    }
    return inOut;
}

var httpInOut = inOutCreateRequestObject();
var globalInOutWindow = ""; 
var globalInOutCurUser = "";
var globalInOutStatus = "";

function inOutSndReq(inOutWindow, currentUser, status, message, time) {
	globalInOutWindow = inOutWindow;

	httpInOut.open('get', '/tools/companyDirectory/dirCommon.php?inOutWindow='+inOutWindow+'&currentUser='+
								currentUser+'&status='+status+'&message='+message+'&time='+time);
    httpInOut.onreadystatechange = inOutHandleResponse;
    httpInOut.send(null);
}

function inOutHandleResponse() {
    if(httpInOut.readyState == 4){
        var inOutResponse = httpInOut.responseText;
        var inOutUpdate = new Array();

        if(inOutResponse.indexOf('|' != -1)) {
///*debug*/	alert("Response:"+inOutResponse);
            inOutUpdate = inOutResponse.split('|');
            document.getElementById(inOutUpdate[0]).innerHTML = inOutUpdate[1];
			document.getElementById(inOutUpdate[2]).innerHTML = inOutUpdate[3];
/*errorfix*///document.getElementById(inOutUpdate[4]).innerHTML = inOutUpdate[5];
        }
    }
}

function inOutToggleMe() 
{
	if (document.getElementById('itemInList').style.display == 'none') 
	{
		document.getElementById('itemInList').style.display = 'block';
		document.getElementById('itemOutList').style.display = 'none';
		document.getElementById('btnView').value = 'View Out';
	} 
	else 
	{ 
		document.getElementById('itemInList').style.display = 'none';
		document.getElementById('itemOutList').style.display = 'block';
		document.getElementById('btnView').value = 'View In';

	}
}
function refreshIndexRand() 
{
	setTimeout('window.location.href = "/index.php"', 5 * (60 * 1000));
}

/**************************END In Out Board Functions ***********************************/



function commentingHandler(update) {
//alert(update[0]);
//alert(update[1]);
//alert(update[2]);
//alert(update[3]);
//alert(update[4]);
//alert(update[5]);
//alert(update[6]);
//alert(update[7]);
//alert(update[8]);
//alert(update[9]);

try {
	document.getElementById(update[0]).innerHTML = update[1]; //calLabel
	try { Effect.Appear('alertBoxFunction'); } catch(e) { }

	try {  
		if(update[2] == 'Error') {
			window.location.href = '/login.php?t=7&cf='+update[8]+'&state='+update[3]+'&tb='+					update[4]+'&a='+update[5]+'&c='+update[7];
		}
	} catch(e) { alert('Sorry, we could not forward you to login screen.'); }

} catch(e) {
	//alert(update[0]);
	alert('Sorry, we could not proccess your comment.  Please try again later');
	//alert('Error: '+e);
	//alert('FirstReturnBlock: ' +update[0]);
}
	
resSndReq('/inc/rating.php?rand='+Math.random()+'&tb='+update[4]+'&a='+update[5], 'ratingHandler');

}
 
function ratingHandler(update) {
//alert(':'+update[0]+':');
//alert(':'+update[1]+':');
//alert(':'+update[2]+':');
//alert(':'+update[3]+':');
//alert(':'+update[4]+':');
//alert(':'+update[5]+':');
try {
		document.getElementById(update[0]).innerHTML = update[1]; //calLabel


		//try { Effect.Appear('alertBoxFunction'); } catch(e) { }
	} catch(e) {
		//alert(update[0]);
		alert('Sorry, we could not proccess your rating.  Please try again later');
		//alert('Error: '+e);
		//alert('FirstReturnBlock: ' +update[0]);
	}
}
