	// JavaScript Document
	function createRefreshObj(name)
	{
		d=document.getElementById(name);
		refreshing(d);
	}

	function refreshing(obj){
		
		tblHeight = obj.offsetHeight;
		obj.innerHTML = "<table height=\""+tblHeight+"\" width=\"100%\"><tr height=\"145\" style=\"background-color:#fff;\"><td height=\""+tblHeight+"\" style=\"background-color:#fff;\"><div align=\"center\"><img src='images/loading.gif' border='0'></div></td></tr></table>";
	}

	function ajaxResSorter(sortby, url, numheaders, id)
	{
		// set all to off
		//alert("calling:"+url);
		
		// we need the next line because on fileupload we refersh the ajax.
		window.document.saveparts.lastsort.value = sortby;
		window.document.saveparts.lastpage.value=1;
		
		for (var i = 1; i <= numheaders; i++) {
				setClass("header_"+i,"");
		  }
		setClass("header_"+id,"active");

		for (var i = 1; i <= window.document.saveparts.numpages.value; i++) {
				setClass("pagerlink_"+i,"");
		  }
		setClass("pagerlink_1","active");
		
		if (window.document.forms['resourcesearch'].searchFilter.value)
		{
			url = "resource_ajaxsearch.php?";
		}
		ajaxWizardRun('tableholder', url+"pagenum=1&sortby="+sortby+"&strFilter="+window.document.forms['resourcesearch'].searchFilter.value);
	}

	function filterResources(val)
	{
	//alert(val);
	//hide the pager
	setClass("pagerlist", "off");
	ajaxWizardRun('tableholder', "resource_ajaxsearch.php?strFilter="+val);
	}

	function filterContactList(val,ajaxURL)
	{
	//alert(val);
	//hide the pager
	setClass("pagerlist", "off");

	ajaxWizardRun('tableholder', ajaxURL+"&strFilter="+val);
	}

	// we want to get the whole table component again...
	function getlinkabletabl(val, recordID, linkageTable)
	{
	ajaxWizardRun('dataTableComponent', "databases_ajax_entirebox.php?name="+val+"&recordID="+recordID+"&linkageTable="+linkageTable);
	}

	function linkrecords(checkedID, recordID, linkageTable, dspTable)
	{
		ajaxNoResponse("databases_ajax_linktables.php?dspTable="+dspTable+"&recordID="+recordID+"&linkageTable="+linkageTable+"&checkedID="+checkedID);
			//ajaxWizardRun('dataTableComponent', "databases_ajax_linktables.php?dspTable="+dspTable+"&recordID="+recordID+"&linkageTable="+linkageTable+"&checkedID="+checkedID);

	}

	function ajaxSorter(sortby, url, numheaders, id)
	{
		// set all to off
		//alert("calling:"+url);
		
		// we need the next line because on fileupload we refersh the ajax.
		window.document.saveparts.lastsort.value = sortby;
		window.document.saveparts.lastpage.value=1;
		
		for (var i = 1; i <= numheaders; i++) {
				setClass("header_"+i,"");
		  }
		setClass("header_"+id,"active");

		for (var i = 1; i <= window.document.saveparts.numpages.value; i++) {
				setClass("pagerlink_"+i,"");
		  }
		setClass("pagerlink_1","active");

		ajaxWizardRun('tableholder', url+"pagenum=1&sortby="+sortby);
	}

	function changeListDSP(on, off)
	{
		setClass(on,"active");
		setClass(off,"");

		if (on=="listdsp_thumbs")
		{
			on="";
		}
		setClass('resourcelisting',"recources"+on);
	}
	
	function toggleShow(nameobj)
	{
			var elem, vis;  
			if( document.getElementById ) // this is the way the standards work    
			{
				elem = document.getElementById( nameobj );
			} else if( document.all ) // this is the way old msie versions work
			{
				elem = document.all[nameobj];  
			} else if( document.layers ) // this is the way nn4 works    
			{
				elem = document.layers[nameobj];  
				// if the style.display value is blank we try to figure it out here
			}

			if(elem != null)
			{
				if(elem.className=="off")
					elem.className="show";
				else
					elem.className="off";
			}
	}

	function ajaxPager(pagenum, url, numpages)
	{		
		// set all to off
		//alert("calling:"+url);
		for (var i = 1; i <= numpages; i++) {
				setClass("pagerlink_"+i,"");
		  }
		 
		var sortVar = "";	
		 if(window.document.forms["saveparts"].lastsort.value!="")
			sortVar="&sortby="+window.document.forms["saveparts"].lastsort.value;

		
		window.document.saveparts.lastpage.value=pagenum;
		setClass("pagerlink_"+pagenum,"active");
		ajaxWizardRun('tableholder', url+"pagenum="+pagenum+""+sortVar);
	}
	function validatePassTableName(obj)
	{		
		ajaxWizardRunNoHolder('passable', "pages_validatepassabletable.php?strTable="+obj.value);
	}
	function ajaxRecordMod(url,sortBy)
	{
		//need these because they may not be set on first page load
		if(!window.document.saveparts.lastpage.value)
			window.document.saveparts.lastpage.value=1;
		if(!window.document.saveparts.lastsort.value)
			window.document.saveparts.lastsort.value=sortBy;
		ajaxWizardRun('tableholder', url+"pagenum="+window.document.saveparts.lastpage.value+"&sortby="+window.document.saveparts.lastsort.value);
	}

	function ajaxSpecificDiv(url,divName)
	{
		ajaxWizardRun(divName, url);
	}

	function ajaxWizardRunNoHolder(param1, url)
	{
			d=document.getElementById(param1);
			var opt = {
				method: 'post',
				on404: function(t) {
					alert('Error 404: location "' + t.statusText + '" was not found.');
				},
				onFailure: function(t) {
					alert('Error ' + t.status + ' -- ' + t.statusText);
				}
			}
		
		new Ajax.Updater(param1,url, opt);
		
	}
	

	function ajaxNoResponse(url)
	{
			var opt = {
				method: 'post',
				on404: function(t) {
					alert('Error 404: location "' + t.statusText + '" was not found.');
				},
				onFailure: function(t) {
					alert('Error ' + t.status + ' -- ' + t.statusText);
				}
			}
		
			new Ajax.Request(url, opt);
		
	}

	function ajaxWizardRun(param1, url)
	{
			d=document.getElementById(param1);
			refreshing(d);
			var opt = {
				method: 'post',
				on404: function(t) {
					alert('Error 404: location "' + t.statusText + '" was not found.');
				},
				onFailure: function(t) {
					alert('Error ' + t.status + ' -- ' + t.statusText);
				}
			}
		
		new Ajax.Updater(param1,url, opt);
	}

	function ajaxWizardRunContacts(param1, url)
	{
			d=document.getElementById(param1);
			refreshing(d);
			var opt = {
				method: 'post',
				onComplete: function(t){ 
					if(t.getResponseHeader("Content-Type")=="text/javascript;")
					{
						window.document.getElementById(param1).innerHTML = "<div align=\"center\"><img src='../../../abendago/images/loading.gif' border='0'></div>";
					}
					else
					{
						//set suggested to true so we know we have already suggested names
						window.document.forms['pagemod'].suggested.value="true";
					}
				},
				on404: function(t,json) {
					alert('Error 404: location "' + t.statusText + '" was not found.');
				},
				onFailure: function(t,json) {
					alert('Error ' + t.status + ' -- ' + t.statusText);
				}
			}
		
		new Ajax.Updater(param1,url, opt);
		
	}
	
	function ajaxWizardRunJS(param1, url)
	{
			d=document.getElementById(param1);
			refreshing(d);
			var opt = {
				method: 'post',
				onComplete: function(t){ 
					if(t.getResponseHeader("Content-Type")=="text/javascript;")
					{
						//it knows if header coming back is javascript, and runs it as javascript AUTOMATICALLY
								//eval(t.responseText);
						//and then set div to blank, rather than displaying javascript code
						window.document.getElementById(param1).innerHTML = "<div align=\"center\"><img src='../../../abendago/images/loading.gif' border='0'></div>";
					}
				},
				on404: function(t,json) {
					alert('Error 404: location "' + t.statusText + '" was not found.');
				},
				onFailure: function(t,json) {
					alert('Error ' + t.status + ' -- ' + t.statusText);
				}
			}
		
		new Ajax.Updater(param1,url, opt);
		
	}

function setClass(whichLayer, newClassName){  

	var elem, vis;  
	if( document.getElementById ) // this is the way the standards work    
	{
		elem = document.getElementById( whichLayer );
	} else if( document.all ) // this is the way old msie versions work
	{
		elem = document.all[whichLayer];  
	} else if( document.layers ) // this is the way nn4 works    
	{
		elem = document.layers[whichLayer];  
		// if the style.display value is blank we try to figure it out here
	}

	if(elem != null)
	{
		elem.className=newClassName;
	}
}

function uploadDoneRefreshResources(strFileName){
	// this needs correcting, doesn't work if its not a pager page. IE: show all is set
	//ajaxPager('1', 'resource_ajax_recordlist.php?bPager=1&','1');
	//alert("resource_ajax_recordlist.php?sortBy="+lastsort.value);
	//alert(lastpage.value);
	if (!window.document.saveparts.lastpage.value)
	{
		window.document.saveparts.lastpage.value=1;
	}
	//alert(lastpage.value);
	//alert("resource_ajax_recordlist.php?pagenum="+lastpage.value+"&sortBy="+lastsort.value);
	ajaxWizardRun('tableholder', "resource_ajax_recordlist.php?pagenum="+window.document.saveparts.lastpage.value+"&sortby="+window.document.saveparts.lastsort.value);

}

function inlinePageUploadComplete(strFileName)
{
	// replace the div on the lower right.
	//newimage
	strName = "_veilside-acura-nsx-1.jpg";
	ajaxWizardRun('newimage', "resource_ajax_getlastimage.php?strName="+strFileName);

}


var errmsg = "";
function validate(theForm, errordiv) {
	errmsg = "";
  for (var i=0;i<theForm.elements.length;i++){
	var elm = theForm.elements[i];
	var req = elm.getAttribute('REQUIRED');
	if (req) {
	  var span = document.getElementById(elm.name+'_span')
	  if (span) span.innerHTML="";
	  else {
		var errSpan = document.createElement('span')
		errSpan.id=elm.name+'_span';
		if(elm.nextSibling) elm.parentNode.insertBefore(errSpan,elm.nextSibling);
		else elm.parentNode.appendChild(errSpan); 
		span=errSpan;
	  }  
	  //check if value is empty, or if it's a checkbox that isn't checked
	  if ((elm.value=="")||((elm.getAttribute('type')=="checkbox")&&(elm.checked==false))) {
		span.style.color="orange";
		if (errmsg)
		  {
			errmsg = errmsg+"<br/>"+req;
		  }else{
			errmsg = req;
		  }
		span.innerHTML="*";
		elm.focus();
		//return false
	  }
	}
  }
  if (errmsg)
	{
		d=document.getElementById(errordiv);
		d.innerHTML = "<div id='errorcont'><h3>You Have Missed Some Required Fields</h3><p>"+errmsg+"</p></div>";
		return false;
	} else {

		return true;
	}
}


//resources_popup.php?filter=flv



function PopUp(){
 
// Open the new window with ID selector.
// Pass PopUpHandler() as the data handler
// to which the popup will broadcast its'
// data selection.
window.open(
"resources_popup.php?filter=flv",
"",
"width=300,height=300"
);
 

void( 0 );
}
 

 

function PopUpHandler( strIDs ){
}
 

function uploadDoneRefreshGallery(strFile,nGalleryID)
{
	// this needs correcting, doesn't work if its not a pager page. IE: show all is set
	//ajaxPager('1', 'resource_ajax_recordlist.php?bPager=1&','1');
	//alert("resource_ajax_recordlist.php?sortBy="+lastsort.value);
	//alert(lastpage.value);
	if (!window.document.saveparts.lastpage.value)
	{
		window.document.saveparts.lastpage.value=1;
	}
	//alert(lastpage.value);
	//alert("resource_ajax_recordlist.php?pagenum="+lastpage.value+"&sortBy="+lastsort.value);
	ajaxWizardRun('tableholder', "gallery_ajax_recordlist.php?pagenum="+window.document.saveparts.lastpage.value+"&sortby="+window.document.saveparts.lastsort.value+"&nGalleryID="+nGalleryID+"&highlight="+strFile);

}

function removeFileFromPageMod(obj, param1)
{
	if (confirm("Removing this image will erase it from the server and remove it from this page. Continue?"))
	{
		obj.value="";
		d=document.getElementById(param1);
		d.innerHTML = "<p>No file is linked to this location yet. Upload a file via the form below!</p>";
	}
	
}

function newuploadviaswf(fieldname, filename)
{
	
		h=document.getElementById("hidden_"+fieldname);
		h.value=filename;

		d=document.getElementById(fieldname);
		d.innerHTML = "<p>Success! You have linked the file: <strong>"+filename+"</strong> to this location. <img src='images/checkcircle.jpg' /></p>";

}

function pagerBox(numOfPages,ajaxURL)
{
	//make sure they didn't request a page greater than the last page
	if(window.document.gotopage.pagenumber.value>numOfPages)
	{
		window.document.gotopage.pagenumber.value=numOfPages;
		document.getElementById('nextpagebutton').innerHTML="";
	}
	else if(window.document.gotopage.pagenumber.value==numOfPages)
	{
		document.getElementById('nextpagebutton').innerHTML="";
	}
	else
	{
		document.getElementById('nextpagebutton').innerHTML="&nbsp;<a onClick=\"pagerNextPage("+numOfPages+",'"+ajaxURL+"');\" title=\"Next Page\">></a>";
	}

	//set next and previous links
	if(window.document.gotopage.pagenumber.value>1)
		document.getElementById('previouspagebutton').innerHTML="<a onClick=\"pagerPrevPage("+numOfPages+",'"+ajaxURL+"');\" title=\"Previous Page\"><</a>&nbsp;";
	else
		document.getElementById('previouspagebutton').innerHTML="";

	document.getElementById('currentpagenumberspan').innerHTML=window.document.gotopage.pagenumber.value;
	window.document.gotopage.pagenumber.value='';
	
	//call ajax after pagenumber is updated
	ajaxPager(document.getElementById('currentpagenumberspan').innerHTML, ajaxURL,numOfPages);
}

function pagerNextPage(numOfPages,ajaxURL)
{
	window.document.gotopage.pagenumber.value=eval(document.getElementById('currentpagenumberspan').innerHTML)+1;
	pagerBox(numOfPages,ajaxURL)
}

function pagerPrevPage(numOfPages,ajaxURL)
{
	window.document.gotopage.pagenumber.value=eval(document.getElementById('currentpagenumberspan').innerHTML)-1;
	pagerBox(numOfPages,ajaxURL)
}

function contactsFilter(param1, url)
{
/*
loop through form, and grab all the variables
*/
	theForm=window.document.getElementById("filtercontactform");
	var filterVars;
	for (var i=0;i<theForm.elements.length;i++)
	  {
		var elm = theForm.elements[i];
		if (elm.value!="")
			filterVars+="&filter["+elm.name+"]="+elm.value;
	  }

	ajaxWizardRun(param1, url+filterVars);
}

function contactFilter(sortby, url, numheaders, id)
{
	/*
	loop through form, and grab all the variables
	*/
		theForm=window.document.getElementById("filtercontactform");
		var filterVars;
		for (var i=0;i<theForm.elements.length;i++)
		  {
			var elm = theForm.elements[i];
			if (elm.value!="")
				filterVars+="&filter["+elm.name+"]="+elm.value;
		  }
	

	ajaxSorter(sortby, url+filterVars+"&", numheaders, id)
}

function nextLocation(url)
{
	/*
	loop through form, and grab all the variables
	*/
		theForm=window.document.getElementById("filtercontactform");
		var filterVars;
		for (var i=0;i<theForm.elements.length;i++)
		  {
			var elm = theForm.elements[i];
			if (elm.value!="")
				filterVars+="&filter["+elm.name+"]="+elm.value;
		  }
	document.location.href=url+"&"+filterVars;
}

function saveMarker(xVar,yVar,scaleVar,rotationVar,iconVar)
{
	document.getElementById('nX').value=xVar;
	document.getElementById('nY').value=yVar;
	document.getElementById('nScale').value=scaleVar;
	document.getElementById('nRotation').value=rotationVar;
	document.getElementById('strIcon').value=iconVar;
}