var userAgent = navigator.userAgent.toLowerCase();var internetExplorer = false;var safari = false;var firefox = false;if ( userAgent.indexOf("firefox") != -1 )	firefox = true;else if ( userAgent.indexOf("safari") != -1 )	safari = true;else if ( userAgent.indexOf("msie") != -1 )	internetExplorer = true;var hideImage = new Image();hideImage.src = "/suppliers/img/interface/hide.gif";var showImage = new Image();showImage.src = "/suppliers/img/interface/show.gif";function clearFilterForm(){	if ( document.filter_form == null )		return;		for ( var a = 0; a < document.filter_form.length; a++ )	{		if ( document.filter_form[a].name.indexOf('filter_') == 0 )		{			if ( document.filter_form[a].type == "radio" )			{				if ( document.filter_form[a].value == "" )					document.filter_form[a].checked = true;				else					document.filter_form[a].checked = false;			}			else				document.filter_form[a].value = "";		}	}		document.filter_form[0].focus();}function toggleFilter(){	var table = document.getElementById("filter_table");			if ( table == null )		return;		if ( table.style.display == "none" )	{		table.style.display = "block";				document.images['option_toggle'].src = hideImage.src;				document.filter_form[0].focus();	}	else	{		table.style.display = "none";				document.images['option_toggle'].src = showImage.src;	}}/* init the administration timer variable */var administration_timer = null;/* display the administration table */function administration_displayMainTable(){	var table = document.getElementById("administration_mainTable");			// clear the administration timer	window.clearTimeout(administration_timer);					// set the table to be visible	if ( table.style.display == 'none' )		table.style.display = "block";}/* hide the administration table */function administration_hideMainTable( hide ){	var table = document.getElementById("administration_mainTable");			// set the table to be hidden	if ( table != null )	{		// if hide is true we want to hide the table		if ( table.style.display == 'block' )		{			// clear the administration timer			window.clearTimeout(administration_timer);						// hide the table			table.style.display = "none";		}		// otherwise set the administration timer		else		{			// set the administration timer			administration_timer = window.setTimeout('administration_hideMainTable(true)', 350);		}	}}/* init the record timer variable */var recordTimerList = new Array();/* display the record table */function record_toggleMainTable( event, id ){	var table = document.getElementById("record_mainTable_" + id);			if ( table == null )		return;					// clear the current record timer if it is already been activated	for ( var a = 0; a < recordTimerList.length; a++ )	{		if ( recordTimerList[a][0] == id )		{			window.clearTimeout(recordTimerList[a][1]);						recordTimerList.splice(a, 1);						break;		}	}			// hide the table if needed; otherwise display it	if ( table.style.visibility == "visible" )		table.style.visibility = "hidden";	else	{		var posx = 0;		var posy = 0;						if ( event.pageX || event.pageY )		{			posx = event.pageX;			posy = event.pageY;		}		else if ( event.clientX || event.clientY )		{			posx = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft - 3;			posy = event.clientY + document.body.scrollTop + document.documentElement.scrollTop - 3;		}						table.style.left = posx;		table.style.top = posy;						// display the table		table.style.visibility = "visible";	}}/* display the record table */function record_displayMainTable( event, id ){	var table = document.getElementById("record_mainTable_" + id);			if ( table == null )		return;					// clear the current record timer if it is already been activated	for ( var a = 0; a < recordTimerList.length; a++ )	{		if ( recordTimerList[a][0] == id )		{			window.clearTimeout(recordTimerList[a][1]);						recordTimerList.splice(a, 1);						break;		}	}	// display the table	table.style.visibility = "visible";}/* hide the record table */function record_hideMainTable( id, hide ){	var table = document.getElementById("record_mainTable_" + id);			if ( table == null )		return;					// if hide is true we want to hide the table	if ( hide == true )	{		// clear the current record timer		for ( var a = 0; a < recordTimerList.length; a++ )		{			if ( recordTimerList[a][0] == id )			{				window.clearTimeout(recordTimerList[a][1]);								recordTimerList.splice(a, 1);								break;			}		}						// hide the table		table.style.visibility = "hidden";	}	// otherwise set the record timer	else	{		// set the record timer		recordTimerList[recordTimerList.length] = new Array(id, window.setTimeout('record_hideMainTable(' + id + ', true)', 250));	}}var dropmenu_timer = null;function dropmenu_displayMainTable( objid ){	var table = document.getElementById(objid);	window.clearTimeout(dropmenu_timer);	if ( table != null ) table.style.display = "block";}function dropmenu_hideMainTable( objid , hide ){	var table = document.getElementById( objid );	if ( table != null )	{		if ( hide == true )		{			window.clearTimeout(dropmenu_timer);			table.style.display = "none";		}else{ dropmenu_timer = window.setTimeout('dropmenu_hideMainTable( \'' + objid + '\' , true)', 350);		}	}}//function selectMenuOption( row ) { if ( row != null ) row.className = "dropmenuon"; }//function deselectMenuOption( row ) { if ( row != null ) row.className = "dropmenuoff"; }function getNodePosition( node ){	var left = 0;	var top = 0;	var position = new Array(0, 0);			left = node.offsetLeft;	top = node.offsetTop;			if ( node.parentNode != null && node.parentNode.nodeName != "BODY" )		position = getNodePosition( node.parentNode );			return new Array((left + position[0]), (top + position[1]));}function selectRecordRow( row ){	if ( row != null )		row.className = "record_row_on";}function deselectRecordRow( row ){	if ( row != null )		row.className = "record_row_off";}function selectOptionRow( row ){	if ( row != null )		row.className = "record_menu_on";}function deselectOptionRow( row ){	if ( row != null )		row.className = "record_menu_off";}/******************************************************************************* * AJAX FUNCTIONS ******************************************************************************* * It is fairly simple to add support for AJAX to your application * step 1: create a div (or span, or other element) you wich to update on the fly * step 2: create something that you wish to trigger the change * step 3: create something similar to this as a javascript function the will be *         from some interaction with the object from step 2: *		    function doUpdate(){ *				 var data = { 'var1': 'var 1 content', *              		      'var2': 'var 2 content'}; *		       xmlhttpPost('updateScript.php','updatableElement', qryString(data) ); *		    } * step 4: create a page (like updateScript.php) that will get the new content *         for your updatableElement (from step 1), n this case a php page. This *         page should "display" its content to the screen, this will be placed *         within updatableElement. * step 5: call the function created in step 3 from some event in the object  *         from step 2, usually onChange or onClick. * step 6: relax, you are finished. no, really. it's that easy. i'm sorry, I do *         not know why you didn't start using AJAX sooner. * NOTE:   the php file (or the file of your preferred language) can be anything *         you want, it can talk to the database and everything, you don't need *         to do anyting special, as long as the page produces output you can *         use it, well you could use one that doesn't produce output but then *         why would you be trying to use it with AJAX, that defeats the purpose. **************************************************************************** *//* * This is the heart of the ajax nation, it will post to the specified page and * display the returned output to the screen (through the updatepage function) * * param strURL: the page that is posted to * param el: the id of the element that will be updated * param qryStr: the query string formatted list of parameters that will be  *               passed to strURL **************************************************************************** */function xmlhttpPost(strURL,el,qryStr) {    var xmlHttpReq = false;    var self = this;    // Mozilla/Safari    if (window.XMLHttpRequest) {        self.xmlHttpReq = new XMLHttpRequest();    }    // IE    else if (window.ActiveXObject) {        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");    }    self.xmlHttpReq.open('POST', strURL, true);    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');    self.xmlHttpReq.onreadystatechange = function() {        if (self.xmlHttpReq.readyState == 4) {            updatepage(self.xmlHttpReq.responseText,el);        }    }    self.xmlHttpReq.send(qryStr);}/* * This function will update the content of the selected element in the page * with the desired content, mainly intended for use with the xmlhttpPost * function **************************************************************************** */function updatepage(str,el){ document.getElementById(el).innerHTML = str; }/* * This function will build a query string that is suitable for passing as form * submission data, it takes an associative array as it's only argurment: * example assoc arry (JavaScript): *		var data = { 'id1': 'value of id 1', *                   'id2': 'value of id 2'}; **************************************************************************** */function qryString( arr ){	var seperator = '&';	qstr = '';	for ( var v in arr )		qstr += v + '=' + arr[v] + seperator;		qstr = qstr.substring(0, (qstr.length - 1));			return qstr;}/* ############################################### */function openRecordDetailsWindow( obj_id, obj_type ){	open("record_details.php?obj_id=" + obj_id + "&obj_type=" + obj_type, "detailsWindow", "height=350, width=600, status=yes, scrollbars=yes, resizable=yes");}function updateRecord( obj_id, page_name ){	window.location.href = (page_name + "?obj_id=" + obj_id);}function deleteRecord( obj_id, page_name ){	if ( confirm("Are you sure you want to delete this record? All data associated with this record will be lost. This is not undoable!") == true )		window.location.href = (page_name + "?obj_id=" + obj_id);}function browseFileSystem( form_input ){	open("browse_file_system.php?form_input=" + form_input, "browseWindow", "height=300, width=600, status=yes, scrollbars=yes, resizable=yes");}			function clearFile( field_name ){	document.clc_form[field_name + "_id"].value = "";	document.getElementById(field_name + "_information").innerHTML = "";	document.getElementById(field_name + "_clear").innerHTML = "";}/*function selectRecordRow( row ){	if ( row != null )		row.className = "record_rowOn";}function deselectRecordRow( row ){	if ( row != null )		row.className = "record_rowOff";}*//* display the record table */function record_toggleOptionTable( event, id ){	var table = document.getElementById("record_optionTable_" + id);			if ( table == null )		return;					// clear the current record timer if it is already been activated	for ( var a = 0; a < recordTimerList.length; a++ )	{		if ( recordTimerList[a][0] == id )		{			window.clearTimeout(recordTimerList[a][1]);						recordTimerList.splice(a, 1);						break;		}	}			// hide the table if needed; otherwise display it	if ( table.style.visibility == "visible" )		table.style.visibility = "hidden";	else	{		if ( navigator.userAgent.toLowerCase().indexOf("msie") != -1 )		{			table.style.left = (event.clientX - 4);			table.style.top = (event.clientY - 4);		}		else if ( navigator.userAgent.toLowerCase().indexOf("firefox") != -1 )		{			table.style.left = (event.clientX - 2);			table.style.top = (event.clientY - 2);		}		else		{			table.style.left = event.clientX;			table.style.top = event.clientY;		}						// display the table		table.style.visibility = "visible";	}}/* display the record table */function record_displayOptionTable( event, id ){	var table = document.getElementById("record_optionTable_" + id);			if ( table == null )		return;					// clear the current record timer if it is already been activated	for ( var a = 0; a < recordTimerList.length; a++ )	{		if ( recordTimerList[a][0] == id )		{			window.clearTimeout(recordTimerList[a][1]);						recordTimerList.splice(a, 1);						break;		}	}	// display the table	table.style.visibility = "visible";}/* hide the record table */function record_hideOptionTable( id, hide ){	var table = document.getElementById("record_optionTable_" + id);			if ( table == null )		return;					// if hide is true we want to hide the table	if ( hide == true )	{		// clear the current record timer		for ( var a = 0; a < recordTimerList.length; a++ )		{			if ( recordTimerList[a][0] == id )			{				window.clearTimeout(recordTimerList[a][1]);								recordTimerList.splice(a, 1);								break;			}		}						// hide the table		table.style.visibility = "hidden";	}	// otherwise set the record timer	else	{		// set the record timer		recordTimerList[recordTimerList.length] = new Array(id, window.setTimeout('record_hideOptionTable(' + id + ', true)', 250));	}}function selectRecordOption( row ){	if ( row != null )		row.className = "record_row_on";}function deselectRecordOption( row ){	if ( row != null )		row.className = "record_row_off";}function ResizeableWindow(URL,w,h) {	if( w == null ) w = 380;	if( h == null ) h = 240;	window.open(URL,'WIN','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width='+w+',height='+h);}