<!-- Begin
var timeoutID=0;

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=525,height=350,left =0,top =0');");
}

 function addToFavorites()
 {
  if (window.external)
  {
   window.external.AddFavorite(urlAddress,pageName)
  }
  else
  { 
   alert("Sorry! Your browser doesn't support this function.");
  }
 }

function findObj(theObj, theDoc){
  var p, i, foundObj;
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  return foundObj;
}
 
// ************************
//  AJAX FUNCTIONS
// ************************
function OkDisable(e) {
	if (timeoutID != 0) {
		clearTimeout(timeoutID);
	}
	var obj = eval('document.'+e);
	obj.disabled = true;
	timeoutID = setTimeout('OkEnable(\''+e+'\')', 15000);
}
function OkEnable(e){
	var obj = eval('document.'+e);
	obj.disabled = false;
}

function sendContact() {
	var cn = document.contact_form.name.value;
	var em = document.contact_form.email.value;
	var msg = document.contact_form.msg.value;
	var hn = document.contact_form.hncaptcha.value;
	var hn_pub = document.contact_form.hncaptcha_public_key.value;
	var hn_priv = document.contact_form.hncaptcha_private_key.value;
	OkDisable('contact_form.Ok');
	remotePool.getObject().docontact(cn, em, msg, hn, hn_pub, hn_priv);
}
function sendHelp() {
	var em = document.contact_form.email.value;
	OkDisable('contact_form.Ok');
	remotePool.getObject().dosendlink(em);
}
function addVendor() {
	var cats = '';
	$$('input.c').each(function(el){
	 if (el.checked) {cats=cats+','+el.id;}
	});
	var locs = '';
	$$('input.l').each(function(el){
	 if (el.checked) {locs=locs+','+el.id;}
	});
	var cn = document.vendor_form.name.value;
	var em = document.vendor_form.email.value;
	var d = document.vendor_form.description.value;
	var add1 = document.vendor_form.add1.value;
	var add2 = document.vendor_form.add2.value;
	var li = document.vendor_form.linkin.value;
	var lo = document.vendor_form.linkout.value;
	var id = document.vendor_form.id.value;
	var ec = document.vendor_form.ec.value;
	OkDisable('vendor_form.Ok');
	remotePool.getObject().doaddvendor(cn, em, d, li, lo, cats, locs, add1, add2, id, ec);
}
// ************************
// callback class - used to receive back from AJAX
// ************************
function InventoryCallback() {} 

// ************************
// ADD callbacks
// ************************

InventoryCallback.prototype.docontact = function(result) {
		if (result['status'] == 0) {
			alert(result['msg']);
			document.contact_form.Ok.disabled=false;
		}
		if (result['status'] == 3) {
			findObj('err').innerHTML = result['err'];
			document.contact_form.Ok.disabled=false;
		    var object = findObj('err').style; 
			object.visibility='visible';
			object.display='block';

			if (result['cv'] == 2) {
				findObj('hncaptcha').value=result['hn'];
				findObj('hncaptcha_public_key').value=result['pub'];
				findObj('captchapict').src=result['img'];
			}
			if (result['cv'] == 3) {
				document.contact_form.Ok.disabled=true;				
			}
		}
		if (result['status'] == 1) {
			findObj('okmsg').innerHTML = result['msg'];
		    var object = findObj('err').style; 
			object.visibility='hidden';
			object.display='none';
		    var object = findObj('contact_form').style; 
			object.visibility='hidden';
			object.display='none';
		    var object = findObj('okmsg').style; 
			object.visibility='visible';
			object.display='block';
		}
	remotePool.returnObject(this.parent.poolId);
}

InventoryCallback.prototype.doaddvendor = function(result) {
	
		if (result['status'] == 0) {
			alert(result['msg']);
			document.vendor_form.Ok.disabled=false;
		}
		if (result['status'] == 3) {
			findObj('err').innerHTML = result['err'];
			document.vendor_form.Ok.disabled=false;
		    var object = findObj('err').style; 
			object.visibility='visible';
			object.display='block';
		}
		if (result['status'] == 1) {
			findObj('okmsg').innerHTML = result['msg'];
		    var object = findObj('err').style; 
			object.visibility='hidden';
			object.display='none';
		    var object = findObj('vendor_form').style; 
			object.visibility='hidden';
			object.display='none';
		    var object = findObj('okmsg').style; 
			object.visibility='visible';
			object.display='block';
			window.scrollTo(0,150);
		}
	remotePool.returnObject(this.parent.poolId);
}

InventoryCallback.prototype.dosendlink = function(result) {
		if (result['status'] == 0) {
			alert(result['msg']);
			document.contact_form.Ok.disabled=false;
		}
		if (result['status'] == 3) {
			findObj('err').innerHTML = result['err'];
			document.contact_form.Ok.disabled=false;
		    var object = findObj('err').style; 
			object.visibility='visible';
			object.display='block';
		}
		if (result['status'] == 1) {
			findObj('okmsg').innerHTML = result['msg'];
		    var object = findObj('err').style; 
			object.visibility='hidden';
			object.display='none';
		    var object = findObj('contact_form').style; 
			object.visibility='hidden';
			object.display='none';
		    var object = findObj('okmsg').style; 
			object.visibility='visible';
			object.display='block';
//			alert(result['msg']);
		}
	remotePool.returnObject(this.parent.poolId);
}

function taLimit() {
	var taObj=findObj('description');
	if (taObj.value.length==250) return false;
}
function taCount() { 
	var visCnt=findObj('myCounter');
	var taObj=findObj('description');
	if (taObj.value.length>250) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	if (visCnt) visCnt.innerHTML='Characters Left: '+(250-taObj.value.length);
}

function objectPool() {
	this.pool = new Array();

	this.avail = new Array();
}

/**
 * Should be overridden, creates a new object and returns it
 */
objectPool.prototype.createObject = function() {
	return new Object();
}

/**
 * Grabs a new object from the pool
 */
objectPool.prototype.getObject = function() {
	// see if we have any objects in the avail array
	if (this.avail.length == 0) {
		var o = this.createObject();
		o.poolId = this.pool.length;
		this.pool.push(o);
		this.avail.push(o.poolId);
	}

	var poolId = this.avail.pop();
	//alert('objectPool.getObject poolId: '+poolId);
	return this.pool[poolId];
}

/**
 * returns an object to the pool
 */
objectPool.prototype.returnObject = function(poolId) {
	this.avail.push(poolId);
}
// jpspan remote proxy class pool
var remotePool = new objectPool();
remotePool.createObject = function() { 
	var callback = new InventoryCallback(); 
	var remote = new inventory_remote(callback); 
	callback.parent = remote; 
	return remote;  
}
// -->
