function UpdateCart(Action, StoreUID, ProductID, BaseElement, Options) {
    if(typeof document.getElementById("CartCount") == "object") {
            var req = new XMLHttpRequest;
            if(!req)
                return null;
            
            if(typeof BaseElement == "object") {
                var confLoc=findPos(BaseElement);
                var theQty = BaseElement.value;
            }
            
            if(Action == "R") {
                req.open('GET', '/publications/?A=CRT&SA='+Action+'&SID='+StoreUID, false); // get page synchronously
            } else {
                //alert('/publications/?A=CRT&SA='+Action+'&SID='+StoreUID+'&PID='+ProductID+'&QTY='+theQty+'&OPT='+Options);
                req.open('GET', '/publications/?A=CRT&SA='+Action+'&SID='+StoreUID+'&PID='+ProductID+'&QTY='+theQty+'&OPT='+Options, false); // get page synchronously
            }
            req.send(null);
            //alert(req.responseText);
            if(parseInt(req.responseText) > 0) {
                document.getElementById("CartCount").firstChild.nodeValue = req.responseText;
                document.getElementById("Checkout").style.display="inline";
            }
            if(Action != "R") {
                document.getElementById("confirmation").style.display="inline";
                document.getElementById("confirmation").style.top=confLoc[1]-(parseInt(document.getElementById("confirmation").style.height)*2)+(parseInt(document.getElementById("confirmation").style.padding)*2);
                document.getElementById("confirmation").style.left=confLoc[0];            
                setTimeout("document.getElementById(\"confirmation\").style.display=\"none\";",2000);
            }
    }         
}

function ClassChange(theClass,element,value) {
    var theRules;
    if (document.all) {
        theRules = 'rules';
    }
    else if (document.getElementById) {
        theRules = 'cssRules';
    }
    for (var theStyle = 0; theStyle < document.styleSheets.length; theStyle++){
        for (var theRule = 0; theRule < document.styleSheets[theStyle][theRules].length; theRule++) {
            if (document.styleSheets[theStyle][theRules][theRule].selectorText.toUpperCase() == theClass.toUpperCase()) {
                document.styleSheets[theStyle][theRules][theRule].style[element] = value;
                //alert("Changing Value");
            }
        }
    }	
}

function IsNumeric(input){
  return /^-?(0|[1-9]\d*|(?=\.))(\.\d+)?$/.test(input);
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function addLoadEvent(func) { 
  var oldonload = window.onload; 
  if (typeof window.onload != 'function') { 
    window.onload = func; 
  } else { 
    window.onload = function() { 
      if (oldonload) { 
        oldonload(); 
      } 
      func(); 
    } 
  } 
} 



var posLatitude="";
var posLongitude="";

var googleAPI="ABQIAAAAQJXgN2yJozo7WMjXFtv7qxTu4bQZ0NR5_f8z7xhRpKfjbD6fLRRvn3C5XB_csk1RjeCpRwQmnjltIg";

var gl;


try {
  if(typeof(navigator.geolocation) == 'undefined'){
    gl = google.gears.factory.create('beta.geolocation');
  } else {
    gl = navigator.geolocation;
  }
}catch(e){}

/*
try {
    if(geo_position_js.init()){
       gl = geo_position_js;
    }
}catch(e){}
*/


function getPosition() {
    gl.getCurrentPosition(function(position) { 
                                                                    posLatitude = position.coords.latitude;
                                                                    posLongitude = position.coords.longitude;
                                                               },
                                             function(error) { 
                                                                    posLatitude = 0;
                                                                    posLongitude = 0;
                                                               },
                                             {maximumAge:600000});

}

// Cross Browser Ajax Implementation
if(typeof window.XMLHttpRequest !== 'function' &&
    typeof window.ActiveXObject === 'function') {
    window.XMLHttpRequest = function() {
        try { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); } catch(e) {}
        try { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); } catch(e) {}
        try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch(e) {}
        try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) {}
        throw new Error('failed to create an ActiveX XMLHTTP object');
    };
}

try {
    addLoadEvent(function(){ setTimeout(function(){window.scrollTo(0,1)},100); });
}catch(e){}