// Other Default / Nifty Functions
function checkedAll(id,checked){$("#" + id + " input:checkbox").prop("checked",checked);}
function getStyle(oElm, strCssRule){var strValue = "";if(document.defaultView && document.defaultView.getComputedStyle){strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);}else if(oElm.currentStyle){strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){return p1.toUpperCase();});strValue = oElm.currentStyle[strCssRule];}return strValue;}
function disp(div){GetElm(div).style.display="block";}
function hide(div){GetElm(div).style.display="none";}
function dispHide(ElementID){if(!GetElm(ElementID)){return;}else{if(GetElm(ElementID).style.display == "none"){disp(ElementID);GetElm('btnDispHide' + ElementID).innerHTML = "-";}else if(GetElm(ElementID).style.display == "block"){hide(ElementID);GetElm('btnDispHide' + ElementID).innerHTML = "+";}}}
function confirmAct(){var conf = confirm("Are you sure you want to take this action?");if(true == conf){return true;}else if(false == conf){return false;}}
function confirmDel(){var conf = confirm("Are you sure you want to delete the selected items?");if(true == conf){return true;}else if(false == conf){return false;}}
function fixForURL(val){return escape(encodeURI(val));}
function GetElm(fld){return document.getElementById(fld);}
function GetElmVal(fld){if(GetElm(fld)){return GetElm(fld).value;}}
function CreateElm(val){return document.createElement(val);}
function Trim(s) {while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r')){ s = s.substring(1,s.length); }while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r')){ s = s.substring(0,s.length-1); }return s;}
function Left(str, n){if (n <= 0){return "";} else if (n > String(str).length){return str;} else {return String(str).substring(0,n);}}
function Right(str, n){if (n <= 0){return "";} else if (n > String(str).length){return str;} else {var iLen = String(str).length;return String(str).substring(iLen, iLen - n);}}
function PopWindow(url,name,h,w,left,top) {var optiontxt;optiontxt = "height=" + h + ",width=" + w + ",left=" + left + ",top=" + top + ",status=0,location=0,scrollbars=1,toolbar=0,resizable=1";var w = window.open(url,name,optiontxt);w.focus();return false;}
function scrollToMark(mrk){$('html, body').animate({scrollTop: $("#" + mrk).offset().top}, 2000);}
function FollowMouse(ElmID){document.onmousemove = MoveElm;function MoveElm(){if(GetElm(ElmID)){if (!posx){mX = 10;} else {mX = posx + 5;}if (!posy){mY = 10;} else {mY = posy + 5;}GetElm(ElmID).style.left = mX + "px";GetElm(ElmID).style.top = mY + "px";}}}
function DoCheckedBox(id,tf){if(tf){if (tf=="t"){GetElm(id).checked = true;}if(tf=="f"){GetElm(id).checked = false;}} else {if(GetElm(id).checked == false){GetElm(id).checked = true;}else if(GetElm(id).checked == true){GetElm(id).checked = false;}}}
function doHighlight(Container, searchTerm, highlightStartTag, highlightEndTag){bodyText = GetElm(Container).innerHTML;if ((!highlightStartTag) || (!highlightEndTag)) {highlightStartTag = "<span style='color: blue; background-color: yellow;'>";highlightEndTag = "</span>";}var newText = "";var i = -1;var lcSearchTerm = searchTerm.toLowerCase();var lcBodyText = bodyText.toLowerCase();while (bodyText.length > 0) {i = lcBodyText.indexOf(lcSearchTerm, i+1);if (i < 0) {newText += bodyText;bodyText = "";} else {if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;bodyText = bodyText.substr(i + searchTerm.length);lcBodyText = bodyText.toLowerCase();i = -1;}}}}GetElm(Container).innerHTML = newText;}
function getPageScrollPosition(){var yScroll;if (self.pageYOffset) {yScroll = self.pageYOffset;} else if (document.documentElement && document.documentElement.scrollTop) {yScroll = document.documentElement.scrollTop;} else if (document.body) {yScroll = document.body.scrollTop;}return yScroll;}
function getInternetExplorerVersion(){var rv = -1;if(navigator.appName == 'Microsoft Internet Explorer'){var ua = navigator.userAgent;var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");if(re.exec(ua) != null){rv = parseFloat(RegExp.$1);}}return rv;}
var posx;var posy;$(document).ready(function(){$(document).mousemove(function(e){posx = e.pageX;posy = e.pageY;});});
// ==========================================================================================================================
function AddCart(id){
	if (id.length == 0){return;}
	var xmlhttp_AddCart;
	if(window.XMLHttpRequest){xmlhttp_AddCart = new XMLHttpRequest();}
	if(window.ActiveXObject){xmlhttp_AddCart = new ActiveXObject("Microsoft.XMLHTTP");}
	if (xmlhttp_AddCart == null){alert ("Your browser does not support XMLHTTP!");return;}
	xmlhttp_AddCart.onreadystatechange = function(){
		if (xmlhttp_AddCart.readyState == 1){GetElm("quotebut_" + id).innerHTML = '<center><img src="images/load_cart_but.gif" /></center>';}
		if (xmlhttp_AddCart.readyState == 4){GetElm("quotebut_" + id).innerHTML = xmlhttp_AddCart.responseText;}
	};
	var url = "cart_add.php?id=" + id;
	xmlhttp_AddCart.open('POST',url,true);
	xmlhttp_AddCart.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp_AddCart.send(url);
}
function RemCart(id,r,p){
	if (id.length == 0){return;}
	var xmlhttp_RemCart;
	if (window.XMLHttpRequest){xmlhttp_RemCart = new XMLHttpRequest();}
	if (window.ActiveXObject){xmlhttp_RemCart = new ActiveXObject("Microsoft.XMLHTTP");}
	if (xmlhttp_RemCart == null){alert ("Your browser does not support XMLHTTP!");return;}
	xmlhttp_RemCart.onreadystatechange = function(){
		if (xmlhttp_RemCart.readyState == 1){GetElm("quotebut_" + id).innerHTML = '<center><img src="images/load_cart_but.gif" /></center>';}
		if (xmlhttp_RemCart.readyState == 4){
			if(r){
				if(r==1){
					if(p){window.location=p;}
					else{window.location='cart.php';}
				}
			}else{
				GetElm("quotebut_" + id).innerHTML = xmlhttp_RemCart.responseText;
			}
		}
	};
	var url = "cart_rem.php?id=" + id;
	xmlhttp_RemCart.open('POST',url,true);
	xmlhttp_RemCart.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp_RemCart.send(url);
}
function displayShip(chk){if (chk.checked == true){GetElm('divShip').style.display = 'block';} else {GetElm('divShip').style.display = 'none';}}
function DisDiv(SelVal){if (SelVal == "EFT"){document.getElementById('DivDeposit').style.display = "inline";} else {document.getElementById('DivDeposit').style.display = "none";}}
