function getPageSize(){
   var xScroll, yScroll;
   if (window.innerHeight && window.scrollMaxY) {
      xScroll = document.body.scrollWidth;
      yScroll = window.innerHeight + window.scrollMaxY;
   } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
      xScroll = document.body.scrollWidth;
      yScroll = document.body.scrollHeight;
   } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
      xScroll = document.body.offsetWidth;
      yScroll = document.body.offsetHeight;
   }
   var windowWidth, windowHeight;
   if (self.innerHeight) { // all except Explorer
      windowWidth = self.innerWidth;
      windowHeight = self.innerHeight;
   } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
      windowWidth = document.documentElement.clientWidth;
      windowHeight = document.documentElement.clientHeight;
   } else if (document.body) { // other Explorers
      windowWidth = document.body.clientWidth;
      windowHeight = document.body.clientHeight;
   }
   if(yScroll < windowHeight){
      pageHeight = windowHeight;
   } else {
      pageHeight = yScroll;
   }

   if(xScroll < windowWidth){
      pageWidth = windowWidth;
   } else {
      pageWidth = xScroll;
   }

   arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
   return arrayPageSize;
}


// Get states based on fickle_forms - We do this as an ajax call so I only
// have to maintain the list in PHP as opposed to JS and PHP.  Same for getCountries below

function getStates() {
	var text_result='';
	new Ajax.Request('/orders/ajax/getStates.php?', {
		onSuccess: function(response) {
			text_result=response.responseText.evalJSON(true);
		},
		onFailure: function(response) {
			if(response.status==403) {
				location.replace('/login.php?timedout=1');
			} 
		},
		method: 'get',
		asynchronous: false
	});
	return text_result;
} 

function getCountries() {
	var text_result='';
	new Ajax.Request('/orders/ajax/getCountries.php?', {
		onSuccess: function(response) {
			text_result=response.responseText.evalJSON(true);    
		},
		onFailure: function(response) {     
			if(response.status==403) {
				location.replace('/login.php?timedout=1');
			}
		},
		method: 'get', 
		asynchronous: false
	});
	return text_result;
}



Array.prototype.count = function() {
	return this.length;
};



function PopupWindow(url,width,height,windowName) {
   _PopupWindow(url,width,height,150,windowName);
}

function popup(url,width,height,windowName) {
   _PopupWindow(url, 510, height,150,windowName);
}

function _PopupWindow(url,width,height,top,windowName) {
   var center_x = (screen.width - width)/2;
   var center_y = (screen.height - height)/2;
//    var num = Math.round(Math.random()*10000000);
//    var str = new String(num);
    var win = window.open(url,windowName,"toolbar=no,location=no,directories=no,"+
      "status=no,menubar=no,scrollbars=yes,resizable=no,"+
      "copyhistory=no,left="+center_x+",top="+center_y+",width="+width+",height="+height);
}


