﻿
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;
var $bool = function(test) {
    test = test.toString();
    switch (test) {
        case '1':
            return true;
            break;
        case '0':
            return false;
            break;
        case 'true':
            return true;
            break;
        case 'false':
            return false;
            break;
    }

}
var $int = parseInt;
var $flt = parseFloat;
var cint = parseInt;
var cflt = parseFloat;
//var id = document.getElementById;
//var tags = document.getElementsByTagName;
var $id = function(name) {
    return document.getElementById(name);
}
var id = function(name) {
    return document.getElementById(name);
}
var $name = function(name) {
    return document.getElementsByName(name);
}
var $tags = function(name) {
    return document.getElementsByTagName(name);
}

String.prototype.rtrim = function() {
	var str = new String();
	str = this;
	return str.replace(/\s$/,'');
}
String.prototype.ltrim = function() {
	var str = new String();
	str = this;
	return str.replace(/^\s/,'');
}
String.prototype.trim = function() {
	var str = new String();
	str = this;
	return str.rtrim().ltrim();
}
String.prototype.toCurrency = function() {
    var hasDecimal = false;
    var alpha = new RegExp('[^0-9\.]', 'g');
    var str = this;

    str = str.replace(alpha, '');
    hasDecimal = str.indexOf('.') > -1 ? true : false;
    var ary = null;
    if (hasDecimal) {
        ary = str.split('.');
        var dec = $.trim(ary[1]);
        if (dec.length > 2) {
            if (parseInt(dec.substr(2, 1)) > 5) {
                ary[1] = dec.substr(0, 1).toString() + (parseInt(dec.substr(1, 1)) + 1).toString();
                str = ary[0] + '.' + ary[1];
            }
            else if (parseInt(dec.substr(2, 1)) < 5) {
                ary[1] = dec.substr(0, 1).toString() + dec.substr(1, 1);
                str = ary[0] + '.' + ary[1];
            }
        }
        else if (dec.length == 1) {
            ary[1] = dec + '0';
            str = ary[0] + '.' + ary[1];
        }
    }
    else {
        str = str + '.00';
    }
    return '$' + str;
}

String.prototype.removelast = function(n) {
	n = n>this.length?this.length:n;
	return this.substring(0,this.length-n);
}
String.prototype.endswith = function(s) {
	var pattern = new RegExp("\w*"+s+"$","i");
	if(pattern.test(this)) {
		return true;
	}
	else {
		return false;
	}
}
String.prototype.startswith = function(s) {
	var pattern = new RegExp('^'+s+'\w*','i');
	if(pattern.test(this)) {
		return true;
	}
	else {
		return false;
	}
}
String.prototype.replaceall = function(pattern,replacement) {
	var str = this;
	while(str.indexOf(pattern)>-1) {
		str = str.replace(pattern,replacement);
	}
	return str;
}
String.format = function(str) {
	var length = arguments.length;
	var target = new String();
	target = arguments[0];
	
	for(var i=1;i<length;i++) {
		var j = i-1;
		var val = "{"+j+"}";
		target = target.replaceall(val,arguments[i].toString());
	}
	return target;
}
String.prototype.format = function() {
	var length = arguments.length;
	var target = new String();
	target = this;
	
	for(var i=0;i<length;i++) {
		var j = i;
		var val = "{"+j+"}";
		target = target.replaceall(val,arguments[i].toString());
	}
	return target;
}
String.concat = function() {
	var str= new String();
	for(var i=0;i<arguments.length;i++) {
		str+=arguments[i].toString();
	}
	return str;
}

//this function is for the filtering of arrays of objects with named fields.
Array.prototype.find = function(field,value,exact) {
	var pattern = null;
	var length = this.length;
	var outputarray = new Array();
	for(var i=0;i<length;i++) {
		if(exact) {
			pattern = new RegExp("^"+value+"$","i");
			if(pattern.test(this[i][field])) {
				outputarray.push(this[i]);
			}
		}
		else {
			pattern = new RegExp(value,"i");
			if(this[i][field].search(pattern)>-1) {
				outputarray.push(this[i]);
			}
		}
	}
	return outputarray;
}
var getElementsByClass = function (searchClass,node,tag) {
    var classElements = new Array();
	node = node?node:document;
	tag = tag?tag:'*';
	
    var els = node.getElementsByTagName(tag);
    var elsLen = els.length;
    var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
    for (i = 0, j = 0; i < elsLen; i++) {
            if ( pattern.test(els[i].className) ) {
                    classElements[j] = els[i];
                    j++;
            }
    }
    return classElements;
}

//prototype implementation
//document.getElementsByClassName = function(className, parentElement) {
//  if (Prototype.BrowserFeatures.XPath) {
//    var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]";
//    return document._getElementsByXPath(q, parentElement);
//  } else {
//    var children = ($(parentElement) || document.body).getElementsByTagName('*');
//    var elements = [], child;
//    for (var i = 0, length = children.length; i < length; i++) {
//      child = children[i];
//      if (Element.hasClassName(child, className))
//        elements.push(Element.extend(child));
//    }
//    return elements;
//  }
//};

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;

    },
    getElementsByClass: function(searchClass, node, tag) {
        var classElements = new Array();

        node = node ? node : document;
        tag = tag ? tag : '*';

        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
        for (i = 0, j = 0; i < elsLen; i++) {
            if (pattern.test(els[i].className)) {
                classElements[j] = els[i];
                j++;
            }
        }
        return classElements;
    }
};
document.getElementsByClass = FXC.Util.getElementsByClass;
FXC.Data = {};
FXC.Data = {
	//objarray is an array of data rows,field is the column to look for, value is the sought value for that column,
	//exact is true false for an exact or contains match. returns the first row that matches
	Find : function(objary,field,value,exact) {
		var pattern = null;
		var length = objary.length;
		for(var i=0;i<length;i++) {
			if(exact) {
				pattern = new RegExp("^"+value+"$","i");
				if(pattern.test(objary[i][field])) {
					return objary[i];
				}
			}
			else {
				pattern = new RegExp(value,"i");
				if(objary[i][field].search(pattern)>-1) {
					return objary[i];
				}
			}
		}
	},
	//objarray is an array of data rows,field is the column to look for, value is the sought value for that column,
	//exact is true false for an exact or contains match. an array of rows that can be nested again to refine search
	FindMore : function(objary,field,value,exact) {
		var pattern = null;
		var length = objary.length;
		var outputarray = new Array();
		for(var i=0;i<length;i++) {
			if(exact) {
				pattern = new RegExp("^"+value+"$","i");
				if(pattern.test(objary[i][field])) {
					outputarray.push(objary[i]);
				}
			}
			else {
				pattern = new RegExp(value,"i");
				if(objary[i][field].search(pattern)>-1) {
					outputarray.push(objary[i]);
				}
			}
		}
		return outputarray;
	}
}

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.Util.Cookies = {};
FXC.Util.Cookies = {
    setCookie: function(name, value, days) {
        if (days) {
            var date = new Date();
            date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
            var expires = "; expires=" + date.toGMTString();
        }
        else var expires = "";
        document.cookie = name + "=" + value + expires + "; path=/";
    },
    getCookie: function(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return '';
    },
    deleteCookie: function(name) {
        FXC.Util.Cookies.setCookie(name, "", -1);
    }
}
FXC.Dom = {};
FXC.Dom = {
    getStyle: function(elem, name) {
        if (elem.style[name]) {
            return elem.style[name];
        }
        else if (elem.currentStyle) {
            return elem.currentStyle[name];
        }
        else if (document.defaultView && document.defaultView.getComputedStyle) {
            name = name.replace(/([A-Z])/g, "-$1");
            name = name.toLowerCase();

            var s = document.defaultView.getComputedStyle(elem, "");
            return s && s.getPropertyValue(name);
        }
        else return null;
    },
    //find the x (horizontal, left ) postion of an element
    pageX: function(elem) {
        return elem.offsetParent ? elem.offsetLeft + FXC.Dom.pageX(elem.offsetParent) : elem.offsetLeft;
    },
    //find the Y (vertical, top ) postion of an element
    pageY: function(elem) {
        return elem.offsetParent ? elem.offsetTop + FXC.Dom.pageY(elem.offsetParent) : elem.offsetTop;
    },
    //find the horizontal positioning of an element within it's parent
    parentX: function(elem) {
        elem.parentNode == elem.offsetParent ? elem.offsetLeft : FXC.Dom.pageX(elem) - FXC.Dom.pageX(elem.parentNode);
    },
    //find the vertical positioning of an element within it's parent
    parentY: function(elem) {
        elem.parentNode == elem.offsetParent ? elem.offsetTop : FXC.Dom.pageY(elem) - FXC.Dom.pageY(elem.parentNode);
    },
    //find the left postion of an element
    posX: function(elem) {
        return $int(FXC.Dom.getStyle(elem, "left"));
    },
    //find the top postion of an element
    posY: function(elem) {
        return $int(FXC.Dom.getStyle(elem, "top"));
    },
    //set the left ot horizontal position
    setX: function(elem, pos) {
        elem.style.left = pos + "px";
    },
    //set the top ot horizontal position
    setY: function(elem, pos) {
        elem.style.top = pos + "px";
    },
    //a function for adding a number of pixels to the horizontal position
    addX: function(elem, pos) {
        //get the horizontal position and add the offset to it
        setX(posX(elem) + pos);
    },
    //a function for adding a number of pixels to the vertical position
    addY: function(elem, pos) {
        //get the vertical position and add the offset to it
        setY(posY(elem) + pos);
    },
    //get the actual height using the compued css of the element
    getHeight: function(elem) {
        //get the compued css and parse out the usable number
        return $int(FXC.Dom.getStyle(elem, 'height'));
    },
    //get the actual width using the compued css of the element
    getWidth: function(elem) {
        //get the compued css and parse out the usable number
        return $int(FXC.Dom.getStyle(elem, 'width'));
    },
    resetCSS: function(elem, prop) {
        var old = {};
        for (var i in prop) {
            old[i] = elem.style[i];
            elem.style[i] = prop[i];
        }
        return old;
    },
    restoreCSS: function(elem, prop) {
        for (var i in prop) {
            elem.style[i] = prop[i];
        }
    },
    //find the full potential height of an element not the current actual height
    fullHeight: function(elem) {
        if (FXC.Dom.getStyle(elem, 'display') != 'none') {
            return elem.offsetHeight || FXC.Dom.getHeight(elem);
        }
        var old = FXC.Dom.resetCSS(elem, {
            display: '',
            visibility: 'hidden',
            position: 'absolute'
        });
        var h = elem.clientHeight || FXC.Dom.getHeight(elem);
        FXC.Dom.restoreCSS(elem, old);
        return h;
    },
    //find the full potential width of an element not the current actual width
    fullWidth: function(elem) {
        if (FXC.Dom.getStyle(elem, 'display') != 'none') {
            return elem.offsetWidth || FXC.Dom.getWidth(elem);
        }
        var old = FXC.Dom.resetCSS(elem, {
            display: '',
            visibility: 'hidden',
            position: 'absolute'
        });
        var w = elem.clientWidth || FXC.Dom.getWidth(elem);
        FXC.Dom.restoreCSS(elem, old);
        return w;
    },
    //mouse position
    mouseX: function(e) {
        e = e || event;
        return e.pageX || e.clientX + document.body.scrollLeft;
    },
    //mouse position
    mouseY: function(e) {
        e = e || event;
        return e.pageY || e.clientY + document.body.scrollTop;
    },
    //mouse position relative to the current element
    mouseElementX: function(e) {
        (e && e.layerX) || window.event.offsetX;
    },
    //mouse position relative to the current element
    mouseElementY: function(e) {
        (e && e.layerY) || window.event.offsetY;
    },
    //web page height
    pageHeight: function() {
        return document.body.scrollHeight;
    },
    //web page width
    pageWidth: function() {
        return document.body.scrollWidth;
    },
    //for determning where the viewposrt isFinite positioned in the webpage
    scrollX: function() {
        var de = document.documentElement;
        return self.pageXOffset || (de && de.scrollLeft) || document.body.scrollLeft;
    },
    //for determning where the viewposrt isFinite positioned in the webpage
    scrollY: function() {
        var de = document.documentElement;
        return self.pageYOffset || (de && de.scrollTop) || document.body.scrollTop;
    },
    //for determining the size of the viewport
    windowHeight: function() {
        var de = document.documentElement;
        return self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;
    },
    //for determining the size of the viewport
    windowWidth: function() {
        var de = document.documentElement;
        return self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    },
    stopBubble: function(e) {
        if (e && e.stopPropagation) {
            e.stopPropagation();
        }
        else {
            window.event.cancelBubble = true;
        }
    },
    stopDefault: function(e) {
        if (e && e.preventDefault) {
            e.preventDefault();
        }
        else {
            window.event.returnValue = false;
        }
    }
}
FXC.Date = {};
FXC.Date = {
	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;
	}, 
	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;
	}
}


FXC.Bitvalue = {};
FXC.Shipping = {};
FXC.Shipping = {
	dateIsNonServiceDate : function (dt) {
		dt = FXC.Date.formatDate(dt);
		var obj = new Object();
			$.ajax({
				url: 'ajaxpages/Shipping.aspx'+location.search+'&method=DateIsNonServiceDate&date='+dt,
				async: false, 
				success: function(d) {
					obj = eval(d);
				}
			});
			return obj.DateIsNonServiceDate;
	},
	dateIsServiceDate : function (dt) {
		return !FXC.Shipping.dateIsNonServiceDate(dt);
	},
	BitToShippingString:function(bit) {
		var returnvalue=new String();
		switch(bit) {
			case 8:
			returnvalue='Fedex Standard';
			break;
			case 16:
			returnvalue='Fedex Priority';
			break;
			case 256:
			returnvalue='Fedex Two Day';
			break;
			case 512:
			returnvalue='Fedex Express Saver';
			break;
			case 33554432:
			returnvalue='Fedex Ground';
			break;
			case 67108864:
			returnvalue='Local Express';
			break;
		}
		return returnvalue;
	}, 
	BitToArrayOfDays:function(bit) {
		var days= new Array();
		var i = 0;
		if((bit&2)!=0) {
			i++;
			days[i]='Sunday';
		}
		if((bit&4)!=0) {
			i++;
			days[i]='Monday';
		}
		if((bit&8)!=0) {
			i++;
			days[i]='Tuesday';
		}
		if((bit&16)!=0) {
			i++;
			days[i]='Wednesday';
		}
		if((bit&32)!=0) {
			i++;
			days[i]='Thursday';
		}
		if((bit&64)!=0) {
			i++;
			days[i]='Friday';
		}
		if((bit&128)!=0) {
			i++;
			days[i]='Saturday';
		}
		
		return days;
		
	}, 
	GetDateBit:function(day) {
		switch(day) {
			case 0:
				return 2;
				break;
			case 1:
				return 4;
				break;
			case 2:
				return 8;
				break;
			case 3:
				return 16;
				break;
			case 4:
				return 32;
				break;
			case 5:
				return 64;
				break;
			case 6:
				return 128;
				break;
		}
	},
	CalculateDeliveryDate : function(ShipDate,Days,Shipbit,deliverydays) {
		var today = new Date(ShipDate.getTime());
		//deldate = deldate.AddDays(Days);
		//var DeliveryDays = ShippingTypes.SelectDeliveryDaysByShipbit(Shipbit);
		var deldate = new Date();
		var addDaysDate = new Date();
		var i = 0;
		var j = 0;
		while (i < Days) {
			addDaysDate.setDate(today.getDate()+(j+1));
			var one = (deliverydays & FXC.Shipping.GetDateBit(addDaysDate.getDay())) != 0?true:false;
			var two = FXC.Shipping.dateIsNonServiceDate(addDaysDate);
			if ((deliverydays & FXC.Shipping.GetDateBit(addDaysDate.getDay())) != 0 || FXC.Shipping.dateIsServiceDate(addDaysDate)) {
				deldate = addDaysDate;
				i++;
			}
			j++;
		}
		return deldate;
	}, 
	CalculateShipDate : function(Shipbit,currentdate,customer,vendor) {
		//DateTime ShipDate = UTIL.GetDateTime<string>(DateTime.Now.ToString("MM/dd/yyyy"));
		//var vendor = FXC.Data.Find(vendors,"mem_id",vendid,true);
		var shiptype = FXC.Data.Find(shipping,"shipbit",Shipbit,true);

		var today=new Date(currentdate);
		
		var isValidShipDay = false;
		var todayshours = new Date();
		var cuttoff = new Date(vendor.cutofftime);
		cuttoff = cuttoff.getHours();
		var hours = todayshours.getHours();
		
		if(parseInt(hours)>parseInt(cuttoff)) {
			var thisday = today.getDay();
			thisday = today.getDate()+1;
			today.setDate(thisday);
		}
		var day = today.getDay();
		
		
		if((FXC.Shipping.GetDateBit(day)&customer.AllShipdays)!=0&&FXC.Shipping.dateIsServiceDate(today)) {
			isValidShipDay = true;
		}
		
		if(day!=5&&isValidShipDay) {
			return today;
		}
		var CanUseFridayOneDayGround = Customer.CanUseFridayOneDayGround;
		//String true false
		var CanShipOneDayGround = vendor.CanShipOneDayGround;
		
		if(Shipbit==16|(CanUseFridayOneDayGround&CanShipOneDayGround&Shipbit==67108864)) {
			return today;
		}



		var ShippingDays = shiptype.ShippingDays;
		var DeliveryDays = shiptype.DeliveryDays;
		var i = 0;
		if ((Shipbit & 33554432) != 0) {
			while (true) {
				i++;
				if (i == 20) {
					throw new Error("ShipDate out of range");
				}
				var one = (FXC.Shipping.GetDateBit(today.getDay()) & ShippingDays) == 0?true:false;
				var two = dateIsNonServiceDate(today)?true:false;

				if (one ||two ) {
					today = today.setDate(today.getDate()+1);
					today = new Date(today);
				}
				else {
					break;
				}
			}
		}
		else {
			while (true) {
				i++;
				if (i == 20) {
					throw new Exception("ShipDate out of range");
				}
				var one = (FXC.Shipping.GetDateBit(today.getDay()) & ShippingDays) == 0?true:false;
				var foo = dateIsNonServiceDate(today);
				var oneb = dateIsNonServiceDate(today)?true:false;
				var todayplusone = new Date(today.getTime());
				todayplusone = todayplusone.setDate(todayplusone.getDate()+1);
				todayplusone = new Date(todayplusone);
				var two = (FXC.Shipping.GetDateBit(todayplusone.getDay()) & DeliveryDays) == 0?true:false;
				var twob = dateIsNonServiceDate(todayplusone)?true:false;

				if (one || oneb) {
					today = today.setDate(today.getDate()+1);
					today = new Date(today);
					continue;
				}
				if (two || twob) {
					today = today.setDate(today.getDate()+1);
					today = new Date(today);
					continue;
				}
				break;

			}
		}
		
		return today;
	}
};

//FXC = {
//	id : function(name) {
//		return document.getElementById(name);
//	}
//	tag : function (name) {
//		return document.getElementsByTagName(name);
//	}
//};

//var id = FXC.id;

//var tag = FXC.tag;


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 zxcWWHS() {
    if (document.all) {
        zxcCur = 'hand';
        zxcWH = document.documentElement.clientHeight;
        zxcWW = document.documentElement.clientWidth;
        zxcWS = document.documentElement.scrollTop;
        if (zxcWH == 0) {
            zxcWS = document.body.scrollTop;
            zxcWH = document.body.clientHeight;
            zxcWW = document.body.clientWidth;
        }
    }
    else if (document.getElementById) {
        zxcCur = 'pointer';
        zxcWH = window.innerHeight - 15;
        zxcWW = window.innerWidth - 15;
        zxcWS = window.pageYOffset;
    }
    zxcWC = Math.round(zxcWW / 2);
    return [zxcWW, zxcWH, zxcWS];
}



//function showtracking(name) {
//    var div = document.getElementById(name);
//    div.style.left = "150px";
//    var top = $int(tempY) - 50;
//    div.style.top = top.toString() + "px";
//    div.style.top = "20px";
//    $(div).show();
////    var height = $(div).height();
////    var docheight = null;
////    if (document.documentElement.scrollHeight) {
////        docheight = $int(document.documentElement.scrollHeight);
////    }
////    else {
////        docheight = $int(document.scrollHeight);
////    }


////    


////    if (($int(top) + $int(height)) > $int(docheight)) {
////        top = (docheight - (height + 100));
////        div.style.top = top.toString() + "px";
////    }



//}
function showtracking(name) {
    var div = document.getElementById(name);
    div.style.left = "150px";
    var top = tempY - 50;
    div.style.top = top + "px";
    div.style.display = "block";
}
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) {
try {
	var div = document.getElementById(container);
	var xml = FactoryXMLHttpRequest();
	xml.open("GET",url,true);
	xml.onreadystatechange=function() {
		if (xml.readyState==4) {
			try {
			div.innerHTML=xml.responseText;
			}
			catch(e) {
			
			var foo="this";
			
			}
		}
	}
	xml.send(null);
	}
	catch (e) {
		var foo=e.message;
	}
}


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) {
		    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);
		    }
		}
	}
	

  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($id(ary[i]).id);
		s += "=";
		s += encodeURIComponent($id(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 = $id("message");
		m.innerHTML=msg;
		m.style.display='block';
		if(obj)
			obj.style.color="red";
	setTimeout(
		function() {
			$id("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;
}

