function display_Messages(parent,named,link){
  var menu_element = document.getElementById(named);
  menu_element.innerHTML = "&nbsp;&nbsp;<button onclick=Hide_menu('Messages')>Close</button><br><iframe border=0 height=250 width=470 src="+link+"></iframe>";
  menu_element.style.display = "";
	var placement = findPosImage(parent);
  menu_element.style.right =  "";
  menu_element.style.top = "";
}

function display_div(parent,named,msg){
  var menu_element = document.getElementById(named);
  menu_element.innerHTML = "+msg+";
  menu_element.style.display = "";
	var placement = findPosImage(parent);
  menu_element.style.right =  "";
  menu_element.style.top = "";
}

function display_login(parent,named,link){
  var menu_element = document.getElementById(named);
  menu_element.innerHTML = "<iframe border=0 height=180 width=200 src="+link+"></iframe>";
  menu_element.style.display = "";
	var placement = findPosImage(parent);
  menu_element.style.right =  "";
  menu_element.style.top = "";
}


function display_OnlineUsers(parent,named)
{
 	var menu_element = document.getElementById(named);
 	if(menu_element.style.display == "none"){
    menu_element.style.display = "";
   	menu_element.style.bottom = "20px";
 	}else {
   menu_element.style.display = "none";
  }
}
function display_menu(parent,named)
{
 	var menu_element = document.getElementById(named);
 	if(menu_element.style.display == "none"){
    menu_element.style.display = "";
  	var placement = findPosImage(parent);
   	menu_element.style.right =  "5%";
   	menu_element.style.bottom = "0%";
 	}else {
   menu_element.style.display = "none";
  }
}

function findPosImage(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop 
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft - 40
			curtop += obj.offsetTop - 25
		}
  }
	return [curleft,curtop];
}

function hide_menu_image(named)
{
	var menu_element = document.getElementById(named);
	menu_element.style.display = "none";
}
function Hide_menu(named)
{
	var menu_element = document.getElementById(named);
	menu_element.style.display = "none";
}
//////////////////////////////////////////////////////
var x = 0;
var tt = 0;

//Browser Support Code
function ajaxFunctionMarkIt(echome){
	var ajaxRequest;  // The variable that makes Ajax possible!
	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;
			}
		}
	}
	var queryString = "?touser=" + echome +"&and=4";
	ajaxRequest.open("GET", "./../../include/getmsg.php" + queryString, true);
	ajaxRequest.send(null); 
}

var reloadpage = document.getElementById('MsgViewIframe');

//Browser Support Code
function ajaxFunction(echome,nr){
	var no = nr;
  var ajaxRequest;  // The variable that makes Ajax possible!
	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;
			}
		}
	}
	x+=1;
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('MM').innerHTML = ajaxRequest.responseText + x;
			if(ajaxRequest.responseText=='No') {
          if(!document.getElementById('showmessage').style.display == ""){
            ajaxFunctionMarkIt(echome);
            display_menu(this,'showmessage');
            reloadpage.contentWindow.location.reload(true);
         }else { 
            ajaxFunctionMarkIt(echome);
            reloadpage.contentWindow.location.reload(true);
         }
			}
		}
	}
	var queryString = "?touser=" + echome +"&and="+no;
	ajaxRequest.open("GET", "./../../include/getmsg.php" + queryString, true);
	ajaxRequest.send(null);
}
////////////////////////////////////////////////////////////////////////
function PopUpMainFrame() {
	window.open(window.frames['MainFrame'].location,'name','height=800,width=1000,scrollbars=yes');
}
////////////////////////////////////////////////////////////////////////
//Browser Support Code
function MyajaxFunction(echome,ControlDiv,nr){
	var no = nr;
  var MyajaxRequest;  // The variable that makes Ajax possible!
	try{
		// Opera 8.0+, Firefox, Safari
		MyajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			MyajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				MyajaxRequest = 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
	MyajaxRequest.onreadystatechange = function(){
		if(MyajaxRequest.readyState == 4){
			   var MyajaxDisplay = document.getElementById(ControlDiv);
		     if(MyajaxDisplay != null) {
			     MyajaxDisplay.innerHTML = MyajaxRequest.responseText;
         }
         if(nr=='7') {
			     var DisplayOnlineUserOnFooter = document.getElementById('GetOnlineUsersUsersOntheFooter').innerHTML = MyajaxRequest.responseText;
         }else 			
			   if(nr=='8') {
			     var DisplayOnlineUserOnFooter = document.getElementById('GetOnlineUsersCounterOntheFooter').innerHTML = MyajaxRequest.responseText;
         } 			
       
		}
	}
	var queryString = "?touser=" + echome +"&and="+no;
	MyajaxRequest.open("GET", "./../../include/getmsg.php" + queryString, true);
	MyajaxRequest.send(null);
}
////////////////////////////////////////////////////////////////////////
function display_c(MyName){
  var refresh=3000; 
  var mytime=setTimeout("display_ct(MyName)",refresh)
}
function display_ct(echoname) {
  ajaxFunction(echoname,'1');
  MyajaxFunction(echoname,'GetOnlineUsersCounter','8');
  if(!echoname ==''){
 	  ajaxFunction(echoname,'6'); 
 	  MyajaxFunction(echoname,'GetOnlineUsers','7');
  }
  tt = display_c(echoname);
  clearTimeout(tt);
}
