var size_timer = false;                                                                                                                                     
// Subroutine to get the size of the window                                                                                                                 
function getSize() {                                                                                                                                        
var myWidth = 0, myHeight = 0;                                                                                                                              
if(typeof(window.innerWidth) == 'number') {                                                                                                                 
//Non-IE                                                                                                                                                    
myWidth = window.innerWidth;                                                                                                                                
myHeight = window.innerHeight;                                                                                                                              
}else if(document.documentElement &&                                                                                                                        
(document.documentElement.clientWidth || document.documentElement.clientHeight)) {                                                                          
//IE 6+ in 'standards compliant mode'                                                                                                                       
myWidth = document.documentElement.clientWidth;                                                                                                             
myHeight = document.documentElement.clientHeight;                                                                                                           
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {                                                                     
//IE 4 compatible                                                                                                                                           
myWidth = document.body.clientWidth;                                                                                                                        
myHeight = document.body.clientHeight;                                                                                                                      
}                                                                                                                                                           
return [myWidth, myHeight];                                                                                                                                 
}                                                                                                                                                           
                                                                                                                                                            
// Pass fields to server given a URL and fields in name/value pairs                                                                                         
function passFields(url,args) {                                                                                                                             
url += "?";                                                                                                                                                 
for(var i=0; i<args.length; i=i+2) {                                                                                                                        
url += args[i] + "=" + args[i+1] + "&";                                                                                                                     
}                                                                                                                                                           
//Set up the AJAX communication                                                                                                                             
if (window.XMLHttpRequest) {                                                                                                                                
req = new XMLHttpRequest();                                                                                                                                 
} else if (window.ActiveXObject) {                                                                                                                          
req = new ActiveXObject("Microsoft.XMLHTTP");                                                                                                               
}                                                                                                                                                           
try {                                                                                                                                                       
// Pass the URL to the server                                                                                                                               
req.open("GET", url, true);                                                                                                                                 
req.send(null);                                                                                                                                             
}catch(e) {                                                                                                                                                 
//nothing;                                                                                                                                                  
}                                                                                                                                                           
}                                                                                                                                                           
function resetSizeTimer() {                                                                                                                                 
size_timer = false;                                                                                                                                         
}                                       
// Get the size and pass to the server                                                                                                                      
function getBrowserSize() {                                                                                                                                 
if(size_timer)return;                                                                                                                                       
size_timer = true;                                                                                                                                          
self.setTimeout('resetSizeTimer()',1000);                                                                                                                   
var theArray = getSize();                                                                                                                                   
var url = "getBrowserSize.php";                                                                                                                             
var args = new Array();                                                                                                                                     
args.push("width");                                                                                                                                         
args.push(theArray[0]);                                                                                                                                     
args.push("height");                                                                                                                                        
args.push(theArray[1]);                                                                                                                                     
args.push("screenwidth");                                                                                                                                   
args.push(screen.width);                                                                                                                                    
args.push("screenheight");                                                                                                                                  
args.push(screen.height);                                                                                                                                   
args.push("pagename");                                                                                                                                      
args.push(window.location);                                                                                                                                 
passFields(url, args);                                                                                                                                      
}                      