//<![CDATA[

var sF = {
	// we run the init function once the dom is ready
	init: function() {
	
		sF.width = sF.getBrowserWidth();	
		sF.height = sF.getBrowserHeight();	
		
		sF.ajaxFunction();

	}, 
	
	getBrowserWidth: function(){
		if (window.innerWidth){
			return window.innerWidth;}	
		else if (document.documentElement && document.documentElement.clientWidth != 0){
			return document.documentElement.clientWidth;	}
		else if (document.body){return document.body.clientWidth;}		
			return 0;
	},
	
	getBrowserHeight: function(){
		if (window.innerHeight){
			return window.innerHeight;}	
		else if (document.documentElement && document.documentElement.clientHeight != 0){
			return document.documentElement.clientHeight;	}
		else if (document.body){return document.body.clientHeight;}		
			return 0;
	},
	
	ajaxFunction: function(form){
		var ajaxRequest;  
		
		try{
			// Opera 8.0+, Firefox, Safari
			ajaxRequest = new XMLHttpRequest();
		} catch (e){
			// Internet Explorer Browsers
			try{
				ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try{
					ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e){
					// Something went wrong
					//alert("Your browser broke!");
					return false;
				}
			}
		}
		// Create a function that will receive data sent from the server
		ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 4){
				var response = ajaxRequest.responseText;
					//alert(response);
					return;
			}
		}
		
		// add random num so page don't cache!
  	var random_num = (Math.round((Math.random()*5999)+1));
		var url = "/modules/content/screen_ajax.php?w="+sF.width+"&h="+sF.height+"&rdm="+escape(random_num);

		//document.write(url);
		ajaxRequest.open("GET", url, true);
		ajaxRequest.send(null); 
	},
	
  
  // function to add event listener, also caches events so they can be removed when the
	// page unloads to avoid memory leaks in IE
  addEvent: function(elm, evType, fn, useCapture) {
		// for W3C DOM complience
    if (elm.addEventListener) {
      elm.addEventListener(evType, fn, useCapture);
      return true;
    } 
		// for IE...
		else if (elm.attachEvent) {
      var r = elm.attachEvent('on' + evType, fn);
      //EventCache.add(elm, evType, fn);
      return r;
    } else {
			// for anyone else not IE or Moz... Safari etc
      elm['on' + evType] = fn;
    }
  },

	// cross-browser get target
	find_target: function(e) 	{
		var target; 	
		// for IE, target is held in window.event array
		if (window.event && window.event.srcElement) 
			target = window.event.srcElement;
		else if (e && e.target)
			target = e.target;
		if (!target)
			return null;

		return target;
	}

}

sF.addEvent(window, 'load', sF.init, false);

//]]>