function RequestGet(url, params) {
    http.open("POST", url, false);
    http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
    http.send(params);

    //if (http.status == 200) {
	    return http.responseText;
	//} else {
	//	resultRe = "Error : "+ http.status;
	//	return resultRe
	//}
}

function getHTTPObject() {
	var xmlhttp;
	
	if (window.XMLHttpRequest) {
    	xmlhttp = new XMLHttpRequest();
    	//xmlhttp.overrideMimeType("text\xml");
    } 
    else if (window.ActiveXObject) 
    {
		try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
       	catch (e1) {
			try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
           	catch (e2) { }
       	}
	}
	return xmlhttp;
}

var http = getHTTPObject(); // We create the HTTP Object


try { 
 document.execCommand("BackgroundImageCache", false, true); 
} catch(err) {}

function LogOnProc(RID,SID,LID,PWD) {
    var pageurl = "/library/ECommPlus/LogOnProc.asp";
    var params  = "RID="+ RID +"&SID="+ SID +"&logonid="+ LID +"&pwd="+ PWD;
    var resRe   = "";

    try {
        resRe = RequestGet(pageurl, params);
    } catch (e) { }

    return resRe;
}


function LogOutProc(RID) {
    var pageurl = "/library/ECommPlus/LogOutProc.asp";
    var params  = "RID="+ RID;
    var resRe   = "";

    try {
        resRe = RequestGet(pageurl, params);
    } catch (e) { }

    return resRe;
}

function CheckLogOnIDProc(RID,SID,logonid) {
    var pageurl = "/library/ECommPlus/LogOnIDCheck_Proc.asp";
    var params  = "RID="+ RID +"&SID="+ SID +"&logonid="+ logonid;
    var resRe   = "";

    try {
        resRe = RequestGet(pageurl, params);
    } catch (e) { }

    return resRe;
}


function getShipMethod(RID,SID,CtyCode,ZipCode,StateCode,nTItems,mTWeight,mTAmt) {
	var pageurl = "/library/ECommPlus/Lib/getShipMethod.asp";
    var params  = "vRID="+ RID +"&vSID="+ SID +"&vCtyCode="+ CtyCode +"&vZipCode="+ ZipCode +"&vStateCode="+ StateCode +"&nTItems="+ nTItems +"&mTWeight="+ mTWeight +"&mTAmt="+ mTAmt;
	//alert(params);
    var resRe   = "";

    try {
        resRe = RequestGet(pageurl, params);
    } catch (e) { }

    return resRe;	
}

function CheckZipCode(RID,SID,CtyCode,ZipCode) {
	var pageurl = "/library/ECommPlus/Lib/CheckZipCode.asp";
    var params  = "vRID="+ RID +"&vSID="+ SID +"&vCtyCode="+ CtyCode +"&vZipCode="+ ZipCode;
	//alert(params);
    var resRe   = "";

    try {
        resRe = RequestGet(pageurl, params);
    } catch (e) { }

    return resRe;	
}

function getTaxRate(RID,SID,CtyCode,StateCode) {
	var pageurl = "/library/ECommPlus/Lib/getTaxRate.asp";
    var params  = "vRID="+ RID +"&vSID="+ SID +"&vCtyCode="+ CtyCode +"&vStateCode="+ StateCode;
    var resRe   = "";

    try {
        resRe = RequestGet(pageurl, params);
    } catch (e) { }

    return resRe;	
}

function getFreeShipOffer(RID,SID,CtyCode,ShipMID) {
	var pageurl = "/library/ECommPlus/Lib/getFreeShipOffer.asp";
    var params  = "vRID="+ RID +"&vSID="+ SID +"&vCtyCode="+ CtyCode +"&vShipMID="+ ShipMID;
    var resRe   = "";

    try {
        resRe = RequestGet(pageurl, params);
    } catch (e) { }

    return resRe;	
}

function getMultiOptInventory(RID,SID,ItemID) {
	var pageurl = "/library/ECommPlus/Lib/getMultiOptInventory.asp";
    var params  = "vRID="+ RID +"&vSID="+ SID +"&vCartItemID="+ ItemID;
    var resRe   = "";

    try {
        resRe = RequestGet(pageurl, params);
    } catch (e) { }

    return resRe;	
}

function Layer_Show(lID, szPos) {
	var objLyr = document.getElementById(lID);
	if (typeof(objLyr) != "object")
		return;
	
	if (objLyr.style) {
		objLyr.style.display = "";
		
		if (typeof(szPos) == "string" && szPos == "cursor") {
			objLyr.style.top = event.clientY + document.body.scrollTop;
			objLyr.style.left = event.clientX + document.body.scrollLeft;
		}
	}
}

function Layer_Hide(lID) {
	var objLyr = document.getElementById(lID);
	if (typeof(objLyr) != "object")
		return;
	
	if (objLyr.style)
		objLyr.style.display = "none";
}

function mouseOverOnButton(obj) {
	obj.style.backgroundColor = "#ACCCEE";
	obj.style.border ="1 solid black"; 
}

function mouseOutOnButton(obj) {
	obj.style.backgroundColor = "#dddddd";
	obj.style.border ="1 solid slategray"; 
}

function ShowHelp(obj,field,hide) {
	//Get help object
	var helpObj;
	if (document.all) {
		helpObj = document.all[field+"_help"];
	}
	else if (document.getElementById) {
		helpObj = document.getElementById(field+"_help");
	}

	if (helpObj) {
		var helpObjName = field +"_help";
		//if help object is shown, hide it ; if object hidden, show it
		if (hide) {helpObj.style.display = "none";}
		else {helpObj.style.display = "";}

		//Get location of mouseover object, move help object to the left if will display off-screen
		var divWidth = 340;
		var offsetLeft = getOffsetLeft(obj);
		var screenWidth = (window.innerWidth) ? window.innerWidth - 25 : document.body.clientWidth;
		if ((offsetLeft + divWidth) > screenWidth) offsetLeft = screenWidth - divWidth;
		newX = offsetLeft;
	
		//Get location of mouseover object, move help object on top if will display off-screen
		var divHeight = helpObj.offsetHeight;
		var offsetTop = getOffsetTop(obj) + obj.offsetHeight;
		var screenHeight = (window.innerHeight) ? window.innerHeight - 25 : document.body.clientHeight;
		if ((offsetTop + divHeight) > screenHeight + getScrollY()) offsetTop = getOffsetTop(obj) - divHeight;
		newY = offsetTop;	
	
		helpObj.style.top = newY;
		helpObj.style.left = newX;

		if (!hide){
		  qh_hideElement("select",helpObj);  
		  qh_hideElement("object",helpObj);  
		  qh_hideElement("embed",helpObj);  }
		else{
		  qh_showElement("select");  
		  qh_showElement("object");  
		  qh_showElement("embed");}
	}
}

function getOffsetTop (elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetTop;
}

function getOffsetLeft (elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while (mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;}
	return mOffsetLeft;
}

function getScrollY() {
	var scrOfY = 0;
  	if( typeof( window.pageYOffset ) == 'number' ) {
    	//Netscape
    	scrOfY = window.pageYOffset;
    }
  	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    	//DOM
    	scrOfY = document.body.scrollTop;
    }
  	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    	//IE6
    	scrOfY = document.documentElement.scrollTop;
    }
  	return scrOfY;
}

function qh_hideElement( elmID, overDiv ) {
	if(document.all) {
    	for(i = 0; i < document.all.tags( elmID ).length; i++) {
      		obj = document.all.tags( elmID )[i];
      		if(!obj || !obj.offsetParent) continue;

      		// Find the element's offsetTop and offsetLeft relative to the BODY tag.
      		objLeft   = obj.offsetLeft;
      		objTop    = obj.offsetTop;
      		objParent = obj.offsetParent;

      		while(objParent.tagName.toUpperCase() != 'BODY') {
        		objLeft  += objParent.offsetLeft;
        		objTop   += objParent.offsetTop;
        		objParent = objParent.offsetParent;
      		}

			objHeight = obj.offsetHeight;
      		objWidth  = obj.offsetWidth;

      		if((overDiv.offsetLeft + overDiv.offsetWidth) <= objLeft);
      		else if((overDiv.offsetTop + overDiv.offsetHeight) <= objTop);
      		else if(overDiv.offsetTop >= (objTop + objHeight));
      		else if(overDiv.offsetLeft >= (objLeft + objWidth));
      		else {
        		obj.style.visibility = 'hidden';
      		}
    	}
	}
}

function qh_showElement(elmID) {
	if(document.all) {
    	for(i = 0; i < document.all.tags( elmID ).length; i++) {
      		obj = document.all.tags(elmID)[i];
      		if(!obj || !obj.offsetParent) continue;
      		obj.style.visibility = '';
    	}
  	}
}

// Start : Scrolling /////////////////////////
function OSpotScroll() {
    this.version = "0.2";
    this.name = "OSpotScroll";
    this.item = new Array();
    this.itemcount = 0;
    this.currentspeed = 0;
    this.scrollspeed = 50;
    this.pausedelay = 1000;
    this.pausemouseover = false;
    this.stop = false;
    this.type = 1;
    this.height = 100;
    this.width = 100;
    this.stopHeight=0;
    this.i=0;

    this.add = function () {
    	var text = arguments[0];
    	this.item[this.itemcount] = text;
    	this.itemcount = this.itemcount + 1;
    };

    this.add2 = function () {
    	var url = arguments[0];
    	var title = arguments[1];
    	this.item[this.itemcount] = "<a href=" + url + ">" + title + "</a>";
    	this.itemcount = this.itemcount + 1;
    };

    this.start = function () {
    	if ( this.itemcount == 1 ) { this.add(this.item[0]); }

    	this.display();
    	this.currentspeed = this.scrollspeed;
    	if ( this.type == 1 || this.type == 2 ) {
    		this.stop = true;
    		setTimeout(this.name+'.scroll()',this.currentspeed);
    		window.setTimeout(this.name+".stop = false", this.pausedelay);
    	} else if ( this.type == 3 ) {
    		this.stop = true;
    		setTimeout(this.name+'.rolling()',this.currentspeed);
    		window.setTimeout(this.name+".stop = false", this.pausedelay);
    	}
    };

    this.display = function () {
    	document.write('<div id="'+this.name+'" style="height:'+this.height+'; width:'+this.width+'; position:relative; overflow:hidden; " OnMouseOver="'+this.name+'.onmouseover(); " OnMouseOut="'+this.name+'.onmouseout(); ">');
    	for(var i = 0; i < this.itemcount; i++) {
    		if ( this.type == 1 ) {
    			document.write('<div id="'+this.name+'item'+i+'"style="left:0px; width:'+this.width+'; position:absolute; top:'+(this.height*i)+'px; ">');
    			document.write(this.item[i]);
    			document.write('</div>');
    		} else if ( this.type == 2 || this.type == 3 ) {
    			document.write('<div id="'+this.name+'item'+i+'"style="left:'+(this.width*i)+'px; width:'+this.width+'; position:absolute; top:0px; ">');
    			document.write(this.item[i]);
    			document.write('</div>');
    		}
    	}
    	document.write('</div>');
    };

    this.scroll = function () {
    	if ( this.pause == true ) {
    		window.setTimeout(this.name+".scroll()",this.pausedelay);
    		this.pause = false;
    	} else {
    		this.currentspeed = this.scrollspeed;
    		if ( !this.stop ) {
    			for (i = 0; i < this.itemcount; i++) {
    				obj = document.getElementById(this.name+'item'+i).style;
    				if ( this.type == 1 ) {
    					obj.top = parseInt(obj.top) - 1;
    					if ( parseInt(obj.top) <= this.height * (-1) ) obj.top = this.height * (this.itemcount-1);
    					if ( parseInt(obj.top) == 0 ) this.currentspeed = this.pausedelay;
    				} else if ( this.type == 2 ) {
    					obj.left = parseInt(obj.left) - 1;
    					if ( parseInt(obj.left) <= this.width * (-1) ) obj.left = this.width * (this.itemcount-1);
    					if ( parseInt(obj.left) == 0 ) this.currentspeed = this.pausedelay;
    				}
    			}
    		}
    		window.setTimeout(this.name+".scroll()",this.currentspeed);
    	}
    };

    this.rolling = function () {
    	if ( this.stop == false  ) { this.next(); }
    	window.setTimeout(this.name+".rolling()",this.scrollspeed);
    }

    this.onmouseover = function () {
    	if ( this.pausemouseover ) { this.stop = true; }
    };

    this.onmouseout = function () {
    	if ( this.pausemouseover ) { this.stop = false; }
    };

    this.next = function() {
    	for (i = 0; i < this.itemcount; i++) {
    		obj = document.getElementById(this.name+'item'+i).style;
    		if ( parseInt(obj.left) < 1 ) {
    			width = this.width + parseInt(obj.left);
    			break;
    		}
    	}
    	for (i = 0; i < this.itemcount; i++) {
    		obj = document.getElementById(this.name+'item'+i).style;
    		if ( parseInt(obj.left) < 1 ) {
    			obj.left = this.width * (this.itemcount-1);
    		} else {
    			obj.left = parseInt(obj.left) - width;
    		}
    	}
    }

    this.prev = function() {
    	for (i = 0; i < this.itemcount; i++) {
    		obj = document.getElementById(this.name+'item'+i).style;
    		if ( parseInt(obj.left) < 1 ) {
    			width = parseInt(obj.left) * (-1);
    			break;
    		}
    	}
    	if ( width == 0 ) {
    		total_width = this.width * (this.itemcount-1);
    		for (i = 0; i < this.itemcount; i++) {
    			obj = document.getElementById(this.name+'item'+i).style;
    			if ( parseInt(obj.left) + 1 > total_width ) {
    				obj.left = 0;
    			} else {
    				obj.left = parseInt(obj.left) + this.width;
    			}
    		}
    	} else {
    		for (i = 0; i < this.itemcount; i++) {
    			obj = document.getElementById(this.name+'item'+i).style;
    			if ( parseInt(obj.left) < 1 ) {
    				obj.left = 0;
    			} else {
    				obj.left = parseInt(obj.left) + width;
    			}
    		}
    	}
    }

    this.unext = function () {
    	this.onmouseover();
    	this.next();
    	window.setTimeout(this.name+".onmouseout()",this.pausedelay);
    }

    this.uprev = function () {
    	this.onmouseover();
    	this.prev();
    	window.setTimeout(this.name+".onmouseout()",this.pausedelay);
    }
}
// End : Scrolling /////////////////////////


function squreRoundTopHtmlinner(wI) {
	var sRTHi;

	sRTHi =	"<table cellpadding=0 cellspacing=0 border=0 width="+wI+">"+
			"<tr height=1>"+
			"   <td rowspan=4 width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td rowspan=3 width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td rowspan=2 width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td width=2><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td width=2><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td rowspan=2 width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td rowspan=3 width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td rowspan=4 width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"<tr height=1>"+
			"   <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"<tr height=1>"+
			"   <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td colspan=3><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"<tr height=2>"+
			"   <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td colspan=5><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"</table>"+
			" "+
			"<table cellpadding=0 cellspacing=0 border=0 width="+wI+">"+
			"<tr>"+
			"   <td width=1 class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td valign=middle>"+
			"       <table cellpadding=0 cellspacing=0 border=0 width=100%>"+
			"       <tr>"+
			"           <td style='padding:0 4 0 4;'>";
	document.write(sRTHi);
}
    
function squreRoundDownHtmlinner(wI) {
	var sRDHi;

	sRDHi = "			</td>"+
			"	    </tr>"+
			"       </table>"+
			"	</td>"+
			"   <td width=1 class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"</table>"+
			" "+
			"<table cellpadding=0 cellspacing=0 border=0 width="+wI+">"+
			"<tr height=2>"+
			"    <td rowspan=4 width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td width=1 class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td width=2><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td width=2><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td width=1 class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td rowspan=4 width=1><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"<tr height=1>"+
			"    <td rowspan=3><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td colspan=3><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"    <td rowspan=3><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"<tr height=1>"+
			"	<td rowspan=2><img src=/library/ecommplus/images/blank.gif></td>"+
			"	<td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"	<td><img src=/library/ecommplus/images/blank.gif></td>"+
			"	<td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td rowspan=2><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"<tr height=1>"+
			"	<td><img src=/library/ecommplus/images/blank.gif></td>"+
			"	<td class=sys_line><img src=/library/ecommplus/images/blank.gif></td>"+
			"   <td><img src=/library/ecommplus/images/blank.gif></td>"+
			"</tr>"+
			"</table>";

		document.write(sRDHi);
}

function BlankHtml(wI,hI) {
	var sRBHi;
	sRBHi =	"<table cellpadding=0 cellspacing=0 border=0 width="+wI+">"+
			"<tr><td width="+wI+" height="+hI+"><img src=/library/ecommplus/images/blank.gif></td></tr>"+
			"</table>";
			
	document.write(sRBHi);
}
