// JavaScript Document
// here we define global variable
var twitter_end="";
var location_end=""
var width = getWidth();

function load_twitter(location,id) { // get data from source (what)
 try {
   var xmlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }

 document.getElementById(id).innerHTML ='<div id="tweet">loading...</div>';
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 twitter_end=id;
 xmlhttp.onreadystatechange = function(){triggered_twitter(xmlhttp)}; // when request finished, call the function to put result to destination DIV
 xmlhttp.open("GET", location+'?width='+width);
 xmlhttp.send(null);
  return false;
}

function triggered_twitter(xmlhttp) { // put data returned by requested URL to selected DIV
  if (xmlhttp.readyState == 4) if (xmlhttp.status == 200) 
    document.getElementById(twitter_end).innerHTML =xmlhttp.responseText;
}

function load_location(location,id) { // get data from source (what)
 try {
   ymlhttp = window.XMLHttpRequest?new XMLHttpRequest():
  		new ActiveXObject("Microsoft.XMLHTTP");
 }
 catch (e) { /* do nothing */ }
 document.getElementById(id).innerHTML ='<div id="tweet">loading...</div>';
// we are defining the destination DIV id, must be stored in global variable (ajaxdestination)
 location_end=id;
 ymlhttp.onreadystatechange = function(){triggered_location(xmlhttp)}; // when request finished, call the function to put result to destination DIV
 ymlhttp.open("GET", location+'?width='+width);
 ymlhttp.send(null);
  return false;
}

function triggered_location(xmlhttp) { // put data returned by requested URL to selected DIV
  if (ymlhttp.readyState == 4) if (ymlhttp.status == 200) 
    document.getElementById(location_end).innerHTML =ymlhttp.responseText;
}

function getWidth(){
	var viewportwidth;
	 
	 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
	 
	 if (typeof window.innerWidth != 'undefined'){
		  viewportwidth = window.innerWidth;
	 }
	 
	// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
	
	 else if (typeof document.documentElement != 'undefined'
		 && typeof document.documentElement.clientWidth !=
		 'undefined' && document.documentElement.clientWidth != 0)
	 {
		   viewportwidth = document.documentElement.clientWidth;
	 }
	 
	 // older versions of IE
	 
	 else{
		   viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
	 }
	
	return(viewportwidth);
}
