﻿

var FXC = {};
FXC.Util = {};
FXC.Util = {
	qs : function () {
		var query = window.location.search.substring(1);
		var qsParm = new Object;
		var parms = query.split('&');
		for (var i=0; i<parms.length; i++) {
			var pos = parms[i].indexOf('=');
			if (pos > 0) {
				var key = parms[i].substring(0,pos);
				var val = parms[i].substring(pos+1);
				qsParm[key] = val;
			}
		}
		
		return qsParm;
		
	}
}; 

FXC.Util.Ajax = {};

FXC.Util.Ajax = {
	FactoryXMLHttpRequest : function () {
		if(window.XMLHttpRequest) {
			return new XMLHttpRequest();
		}
		else if(window.ActiveXObject) {
			var msxmls = new Array( "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XmlHttp" );
			for(var i = 0;i < msxmls.length;i++) {
				try {
					return new ActiveXObject(msxmls[i]);
				}
				catch (e) {} 	
			}	
		}
		throw new Error("Could not instantiate XMLHttpRequest.");
	}
};
FXC.Util.padleft = function(str,chr,howmany) {
str=String(str);
chr=String(chr);
	if(str.length<howmany) {
		var count=howmany-str.length;
		for(var i=0;i<count;i++) {
			str=chr+str;
		}
	}
	return str;
}
//FXC = {
//	id : function(name) {
//		return document.getElementById(name);
//	}
//	tag : function (name) {
//		return document.getElementsByTagName(name);
//	}
//};

//var id = FXC.id;

//var tag = FXC.tag;

var id = function(name) {
	return document.getElementById(name);
}
var tags = function(name) {
	return document.getElementsByTagName(name);
}
var oIFrame = null;

function FactoryXMLHttpRequest() {
	if(window.XMLHttpRequest) {
		return new XMLHttpRequest();
	}
	else if(window.ActiveXObject) {
		var msxmls = new Array( "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp", "Microsoft.XmlHttp" );
		for(var i = 0;i < msxmls.length;i++) {
			try {
				return new ActiveXObject(msxmls[i]);
			}
			catch (e) {} 	
		}	
	}
	throw new Error("Could not instantiate XMLHttpRequest.");
}

function showmenudiv(name) {
	var div = document.getElementById(name);
	var divwidth, nopixwidth, halfwidth,leftpos, divthreshold,clientthreshold;
	if(div) {
		divwidth = div.style.width;
		nopixwidth = divwidth.replace("px","");
		halfwidth=nopixwidth/2;
		leftpos = (tempX-halfwidth);
		if (leftpos < 0){leftpos = 0}
		nopixwidth=nopixwidth-0;
		divthreshold=leftpos+nopixwidth;
		
		if((divthreshold)>document.body.clientWidth)
			leftpos = document.body.clientWidth-(nopixwidth+30);
		div.style.left=leftpos+"px";
		div.style.top=(tempY)+"px";
		div.style.display="block";
	}
		
} 

function createIFrame () {
	var oIFrameElement = document.createElement("iframe");
	oIFrameElement.width=0;
	oIFrameElement.height=0;
	oIFrameElement.frameborder=0;
	oIFrameElement.name="hiddenFrame";
	oIFrameElement.id="hiddenFrame";
	document.body.appendChild(oIFrameElement);
	oIFrame = frames["hiddenFrame"];
}



function makeAjaxIFrameRequest(Url) {
	if(!oIFrame) {
		createIFrame();
		setTimeout(makeAjaxIFrameRequest(),10);
		return;
	}
	
	oIFrame.location=Url;
}

function GetFocus(name) {
var obj = document.getElementById(name);
obj.focus();
}


function hidecontrol(name) {
	var div = document.getElementById(name);
	if(div) {
		div.style.display="none";
	}
	
}
function showfixed(name) {
var div = document.getElementById(name);
if(div)
	div.style.display="block";
}

function showfixedtop(name) {
	var div = document.getElementById(name);
	var divwidth, nopixwidth, halfwidth,leftpos, divthreshold,clientthreshold;
	if(div) {
		divwidth = div.style.width;
		nopixwidth = divwidth.replace("px","");
		halfwidth=nopixwidth/2;
		leftpos = (tempX-halfwidth);
		if (leftpos < 0){leftpos = 0}
		nopixwidth=nopixwidth-0;
		divthreshold=leftpos+nopixwidth;
		
		if((divthreshold)>document.body.clientWidth)
			leftpos = document.body.clientWidth-(nopixwidth+30);
		//if(tempX>document.body.clientWidth
		div.style.left=leftpos+"px";
		//div.style.top=(tempY)+"px";
		div.style.display="block";
	}
			
}

function f(name) {
	return document.getElementById(name);
}
function fn(name) {
	return document.getElementsByName(name);
}
function showorder(name) {
var div = document.getElementById(name);
	div.style.left="150px";
	var top = tempY-50;
	div.style.top=top+"px";
	div.style.display="block";
}
function showleft(name) {
var div = document.getElementById(name);
	div.style.right="300px";
	var top = tempY-50;
	div.style.top=top+"px";
	div.style.display="block";
}
function makeAjaxRequest(url, container) {
var div = document.getElementById(container);
	var xml = FactoryXMLHttpRequest();
	xml.open("GET",url,true);
	xml.onreadystatechange=function() {
		if (xml.readyState==4) {
			div.innerHTML=xml.responseText;
		}
	}
	xml.send(null)
}


var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = getMouseXY;
var tempX = 0
var tempY = 0
var x = 0;
var y = 0;


function getMouseXY(e) {
var isOpera = (navigator.userAgent.indexOf('Opera') != -1);
var isIE = (!isOpera && navigator.userAgent.indexOf('MSIE') != -1);

	if (!e) var e = window.event;

	if (e.pageX || e.pageY)	{
		tempX = e.pageX;
		tempY = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		tempX = e.clientX;
		tempY = e.clientY;
		if (isIE) {
			Loadtempv();
		}
	}
	

  return true;
}

function Loadtempv() {
	if(document.body) {
		tempX += (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
		tempY += (document.documentElement.scrollTop ?  document.documentElement.scrollTop : document.body.scrollTop);
	}
	else {
		window.setTimeout(Loadtempv,200);
	}
}


//Aynchronous post request with passed in object
function AsynchronousPostVar () {
	this._xmlhttp = new FactoryXMLHttpRequest();
}
// 
function AsynchronousPostVar_call(url, parameters) {
	var instance = this;
	
	this._xmlhttp.open('POST', url, true);
	this._xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	this._xmlhttp.onreadystatechange= function() {
		switch (instance._xmlhttp.readyState) {
			case 1:
				instance.loading();
				break;
			case 2:
				instance.loaded();
				break;
			case 3:
				instance.interactive();
				break;
			case 4:
				instance.complete(instance._xmlhttp.status,
					instance._xmlhttp.statusText, 
					instance._xmlhttp.responseText, 
					instance._xmlhttp.responseXML, parameters);
				break;		
		}
	}
	this._xmlhttp.send(parameters);
}


function AsynchronousPostVar_loading() {}
function AsynchronousPostVar_loaded() {}
function AsynchronousPostVar_interactive() {}
function AsynchronousPostVar_complete(status,statusText,responseText,responseXML,parameters) {} 
AsynchronousPostVar.prototype.loading = AsynchronousPostVar_loading;
AsynchronousPostVar.prototype.loaded = AsynchronousPostVar_loaded;
AsynchronousPostVar.prototype.interactive = AsynchronousPostVar_interactive;
AsynchronousPostVar.prototype.complete = AsynchronousPostVar_complete;
AsynchronousPostVar.prototype.call = AsynchronousPostVar_call;






//Aynchronous post request 
function AsynchronousPost () {
	this._xmlhttp = new FactoryXMLHttpRequest();
}
// 
function AsynchronousPost_call(url, elements) {
	var instance = this;
	
	this._xmlhttp.open('POST', url, true);
	this._xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	this._xmlhttp.onreadystatechange= function() {
		switch (instance._xmlhttp.readyState) {
			case 1:
				instance.loading();
				break;
			case 2:
				instance.loaded();
				break;
			case 3:
				instance.interactive();
				break;
			case 4:
				instance.complete(instance._xmlhttp.status,
					instance._xmlhttp.statusText, 
					instance._xmlhttp.responseText, 
					instance._xmlhttp.responseXML);
				break;		
		}
	}
	this._xmlhttp.send(elements);
}
function AsynchronousPost_abort() {
	var instance = this;
	instance._xmlhttp.abort();
}

function AsynchronousPost_loading() {}
function AsynchronousPost_loaded() {}
function AsynchronousPost_interactive() {}
function AsynchronousPost_complete(status,statusText,responseText,responseXML) {} 
function AsynchronousPost_abort() {}
AsynchronousPost.prototype.loading = AsynchronousPost_loading;
AsynchronousPost.prototype.loaded = AsynchronousPost_loaded;
AsynchronousPost.prototype.interactive = AsynchronousPost_interactive;
AsynchronousPost.prototype.complete = AsynchronousPost_complete;
AsynchronousPost.prototype.call = AsynchronousPost_call;
AsynchronousPost.prototype.abort = AsynchronousPost_abort;


////End Aynchronous post request 

////Aynchronous get request 
function AsynchronousGet () {
	this._xmlhttp = new FactoryXMLHttpRequest();
}

function AsynchronousGet_call(url) {
	var instance = this;
	
	this._xmlhttp.open('GET', url, true);
	this._xmlhttp.onreadystatechange= function() {
		switch (instance._xmlhttp.readyState) {
			case 1:
				instance.loading();
				break;
			case 2:
				instance.loaded();
				break;
			case 3:
				instance.interactive();
				break;
			case 4:
				instance.complete(instance._xmlhttp.status,
					instance._xmlhttp.statusText, 
					instance._xmlhttp.responseText, 
					instance._xmlhttp.responseXML);
				break;		
		}
	}
	this._xmlhttp.send(null);
}


function AsynchronousGet_loading() {}
function AsynchronousGet_loaded() {}
function AsynchronousGet_interactive() {}
function AsynchronousGet_complete(status,statusText,responseText,responseXML) {} 
AsynchronousGet.prototype.loading = AsynchronousGet_loading;
AsynchronousGet.prototype.loaded = AsynchronousGet_loaded;
AsynchronousGet.prototype.interactive = AsynchronousGet_interactive;
AsynchronousGet.prototype.complete = AsynchronousGet_complete;
AsynchronousGet.prototype.call = AsynchronousGet_call;

//End Aynchronous get request 

function ShippingType(){}
ShippingType.prototype.shipping_name;
ShippingType.prototype.pickUpcharge;
ShippingType.prototype.fuelsurcharge;
ShippingType.prototype.bitvalue;
ShippingType.prototype.shipbit;
ShippingType.prototype.SatDeliveryCharge;
ShippingType.prototype.DeliveryDays;


function VendorType(){}
VendorType.prototype.business_name;
VendorType.prototype.mem_id;
VendorType.prototype.min_weight;
VendorType.prototype.cutofftime;
VendorType.prototype.bitvalue;
VendorType.prototype.shipbit;



function encodeForm0 () {
	var a = new Array();
	var frm = document.forms[0];
	var s = "";
	
	for (var i = 0;i<frm.elements.length;i++) {
		s = encodeURIComponent(frm.elements[i].id);
		s += "=";
		s += encodeURIComponent(frm.elements[i].value);
		a.push(s);
	}
	return a.join("&");

}
function encodeForms (ary) {
	var a = new Array();
	var s = "";
	
	for (var i = 0;i<ary.length;i++) {
		s = encodeURIComponent(f(ary[i]).id);
		s += "=";
		s += encodeURIComponent(f(ary[i]).value);
		a.push(s);
	}
	return a.join("&");

}

function addEvent( obj, eventname, fn ) { 
  if ( obj.attachEvent ) { 
    obj['e'+eventname+fn] = fn; 
    obj[eventname+fn] = function(){obj['e'+eventname+fn]( window.event );} 
    obj.attachEvent( 'on'+eventname, obj[eventname+fn] ); 
  } else 
    obj.addEventListener( eventname, fn, false ); 
} 
function removeEvent( obj, eventname, fn ) { 
  if ( obj.detachEvent ) { 
    obj.detachEvent( 'on'+eventname, obj[eventname+fn] ); 
    obj[eventname+fn] = null; 
  } else 
    obj.removeEventListener( eventname, fn, false ); 
} 


var hidethiscontrol = function(e) {
	if(e.currentTarget) {
		e.currentTarget.style.display="none";
	}
	else {
		event.srcElement.style.display="none";
	}
}

var writemessage = function(msg, obj) {
var m = f("message");
		m.innerHTML=msg;
		m.style.display='block';
		if(obj)
			obj.style.color="red";
	setTimeout(
		function() {
			f("message").style.display="none";
		}
		,3000)
}
var makemessage = function (msg,timeout, classname) {
	var div = document.createElement('div');
	div.style.display="block";
	div.className=classname;
	div.innerHTML=msg;
	addEvent(div,'click',hidethiscontrol);
	document.body.appendChild(div);
	
	setTimeout(
		function() {
			div.style.display="none";
		}
		, timeout)
}


var getTodaysDate =  function() {
	var d = new Date();
	var currdate = d.getDate();
	if(currdate<10)
	currdate='0'+currdate;
	var currmonth = d.getMonth();
	currmonth++;
	if(currmonth<10)
	currmonth='0'+currmonth;
	var curryear = d.getFullYear();
	var result =(currmonth + "/" + currdate + "/" + curryear);
	return result;
}

var formatDate =  function(d) {
	var currdate = d.getDate();
	if(currdate<10)
	currdate='0'+currdate;
	var currmonth = d.getMonth();
	currmonth++;
	if(currmonth<10)
	currmonth='0'+currmonth;
	var curryear = d.getFullYear();
	var result =(currmonth + "/" + currdate + "/" + curryear);
	return result;
}

