function switchInfo(id) {
	var info = document.getElementById('section1_2');
	if(id == 2)
		info.innerHTML = 'test';
}

var xmlhttp
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
  try {
  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
   xmlhttp=false
  }
 }
@else
 xmlhttp=false
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
 try {
  xmlhttp = new XMLHttpRequest();
 } catch (e) {
  xmlhttp=false
 }
}

function myXMLHttpRequest() {
  var xmlhttplocal;
  try {
    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
 } catch (e) {
  try {
    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
  } catch (E) {
    xmlhttplocal=false;
  }
 }

if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
 try {
  var xmlhttplocal = new XMLHttpRequest();
 } catch (e) {
  var xmlhttplocal=false;
  alert('couldn\'t create xmlhttp object');
 }
}
return(xmlhttplocal);
}

function getProfileInfo(username, id) {
  url="/includes/profilePanel.php?user="+username+"&id="+id;
  xmlhttp = new myXMLHttpRequest();
  xmlhttp.open("GET",url,true);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
	target = document.getElementById('profileinfo');
	target.innerHTML = xmlhttp.responseText;	
    }
  }
  xmlhttp.send(null);
  return false;
}

function getTabPanel(username, id) {
  url="/includes/tabPanel.php?user="+username+"&id="+id;
  xmlhttp = new myXMLHttpRequest();
  xmlhttp.open("GET",url,true);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
	target = document.getElementById('canvas');
	target.innerHTML = xmlhttp.responseText;	
    }
  }
  xmlhttp.send(null);
  return false;
}

function selectTab(id) {
	for(i=1; i<=6; i++) {
		if(i!=5) {
			tab = document.getElementById('tab'+i);
			tab.style.color='#000';
			tab.style.backgroundImage = 'url(/images/tab.jpg)';
		}
	}
	
	tab = document.getElementById('tab'+id);
	tab.style.backgroundImage = 'url(/images/tab_on.jpg)';
}

function selectSettingTab(id) {
	for(i=1; i<=8; i++) {
		tab = document.getElementById('tab'+i);
		tab.style.color='#000';
		tab.style.backgroundImage = 'url(/images/tab.jpg)';
	}
	
	tab = document.getElementById('tab'+id);
	tab.style.backgroundImage = 'url(/images/tab_on.jpg)';
}

function sendShout(receiver, sender, msg, privacy) {
	
	if(msg!=""){
		id = 1;
		// filter shout
		msg = msg.replace(/(^\s+|\s+$)/g,'');
		msg = encodeMyHtml(msg);
		
		url="/includes/shouts.php?user="+receiver+"&id="+id+"&msg="+msg+"&sender="+sender+"&privacy="+privacy;
		xmlhttp = new myXMLHttpRequest();
		xmlhttp.open("GET",url,true);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			target = document.getElementById('canvas');
			target.innerHTML = xmlhttp.responseText;	
			
		}
		}
		xmlhttp.send(null);
	  return false;
	}
	alert('Please enter a message');
	document.getElementById('btnShout2').disabled=false;
	document.getElementById('btnShout').disabled=false;
	return false;
}

function deleteShout(username, mid) {
	id=2;
	url="/includes/shouts.php";
	xmlhttp = new myXMLHttpRequest();
	var content = "user="+username+"&id="+id+"&mid="+mid;
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  	xmlhttp.send(content);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
		target = document.getElementById('canvas');
		target.innerHTML = xmlhttp.responseText;	
	}
	}
  return false;
}

function getShouts(username, sorted, page) {
  id=3;
  url="/includes/shouts.php";
  xmlhttp = new myXMLHttpRequest();
  var content = "user="+username+"&id="+id+"&sort="+sorted+"&page="+page;
  xmlhttp.open("POST",url,true);
  xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  xmlhttp.send(content);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
	target = document.getElementById('canvas');
	target.innerHTML = xmlhttp.responseText;	
    }
  }
  
  return false;
}

function getSettingTab(username, id) {
  //document.getElementById('loading').style.visibility='visible';
  url="/includes/settings.php?user="+username+"&id="+id;
  xmlhttp = new myXMLHttpRequest();
  xmlhttp.open("GET",url,true);
  xmlhttp.onreadystatechange=function() {
		
    if (xmlhttp.readyState==4) {
		//document.getElementById('loading').style.visibility='hidden';
		target = document.getElementById('settingsPanel');
		target.innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.send(null);
  return false;
}

function friendRequest(sender, receiver) {
	
	id=5;
	url="/includes/shouts.php";
	xmlhttp = new myXMLHttpRequest();
	var content = "sender="+sender+"&receiver="+receiver+"&id="+id;
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  	xmlhttp.send(content);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
		target = document.getElementById('friendButton');
		//target.innerHTML = 'Friendship Pending';	
		//target.style.fontSize = '10px';
		//target.style.color = '#bbb';
	}
	}
  return false;
}

function answerRequest(rid, answer) {
	
	id=6;
	url="/includes/shouts.php";
	xmlhttp = new myXMLHttpRequest();
	var content = "id="+id+"&rid="+rid+"&answer="+answer;
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  	xmlhttp.send(content);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
		target = document.getElementById('friendRequestsTable');
		target.innerHTML = xmlhttp.responseText;	
	}
	}
  return false;
}

function setMaxLength()
{
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'counter';
	for (var i=0;i<x.length;i++)
	{
		if (x[i].getAttribute('maxlength'))
		{
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = '<span>0</span> of '+x[i].getAttribute('maxlength') + ' characters used';
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function checkMaxLength()
{
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.relatedElement.className = 'toomuch';
	else
		this.relatedElement.className = '';
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}

function addMovieComment(movie, sender, msg, owner) {
	
	if(msg!=""){
		id = 7;
		// filter shout
		msg = msg.replace(/(^\s+|\s+$)/g,'');
		
		var content ="movie="+movie+"&id="+id+"&msg="+msg+"&sender="+sender+"&owner="+owner;
		url="/includes/shouts.php";
		xmlhttp = new myXMLHttpRequest();
		xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(content);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			target = document.getElementById('movieComments');
			target.innerHTML = xmlhttp.responseText;	
			document.forms.movieComment.comment.value='';
			document.getElementById('btnShout').disabled=false;	
		}
		}
	  return false;
	}
	alert('Please enter a message');
	document.getElementById('btnShout').disabled=false;
	return false;
}

function addPhotoComment(pid, sender, msg) {
	
	if(msg!=""){
		id = 10;
		// filter shout
		msg = msg.replace(/(^\s+|\s+$)/g,'');
		
		var content ="pid="+pid+"&id="+id+"&msg="+msg+"&sender="+sender;
		url="/includes/shouts.php";
		xmlhttp = new myXMLHttpRequest();
		xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(content);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				target = document.getElementById('photoComments');
				target.innerHTML = xmlhttp.responseText;	
				document.forms.photoComment.comment.value='';
				document.getElementById('btnShout').disabled=false;	
			}
		}
	  return false;
	}
	alert('Please enter a message');
	document.getElementById('btnShout').disabled=false;
	return false;
}

function addBlogComment(eid, sender, msg) {
	
	if(msg!=""){
		id = 11;
		// filter shout
		msg = msg.replace(/(^\s+|\s+$)/g,'');
		
		var content ="eid="+eid+"&id="+id+"&msg="+msg+"&sender="+sender;
		url="/includes/shouts.php";
		xmlhttp = new myXMLHttpRequest();
		xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(content);
		xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) {
				target = document.getElementById('blogComments');
				target.innerHTML = xmlhttp.responseText;	
				document.forms.blogComment.comment.value='';
				document.getElementById('btnShout').disabled=false;	
			}
		}
	  return false;
	}
	alert('Please enter a message');
	document.getElementById('btnShout').disabled=false;
	return false;
}



function deletePhoto(username, pid, filename) {
	id=8;
	url="/includes/shouts.php";
	xmlhttp = new myXMLHttpRequest();
	var content = "user="+username+"&id="+id+"&pid="+pid+"&filename="+filename;
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  	xmlhttp.send(content);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
		
		document.location.href='/settings';
		//target = document.getElementById('canvas');
		//target.innerHTML = xmlhttp.responseText;	
	}
	}
  return false;
}

function deleteBookmark(bid) {
	id=9;
	url="/includes/shouts.php";
	xmlhttp = new myXMLHttpRequest();
	var content = "id="+id+"&bid="+bid;
	xmlhttp.open("POST",url,true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  	xmlhttp.send(content);
	xmlhttp.onreadystatechange=function() {
	if (xmlhttp.readyState==4) {
		document.location.href='/settings';
	}
	}
  return false;
}

/*******************************
* used to encode special chars
*******************************/
function encodeMyHtml(code) {
     encodedHtml = escape(code);
     encodedHtml = encodedHtml.replace(/\//g,"%2F");
     encodedHtml = encodedHtml.replace(/\?/g,"%3F");
     encodedHtml = encodedHtml.replace(/=/g,"%3D");
     encodedHtml = encodedHtml.replace(/&/g,"%26");
     encodedHtml = encodedHtml.replace(/@/g,"%40");
     return encodedHtml;
   } 
   

function updateIt(){
   try{
      var url = "/includes/whoisonline.php"
	  xmlhttp = new myXMLHttpRequest();
      var content = "upd=1";  
      xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(content);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status == 200) {
			//alert(xmlhttp.responseText);
		}
		}
   }catch(e){
   }
   setTimeout("updateIt()",30000); // recall the function every 10 seconds
} 
function reportUser(username){
   try{
      var url = "/includes/reportuser.php"
	  xmlhttp = new myXMLHttpRequest();
      var content = "username="+username;  
      xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(content);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status == 200) {
			alert('You have reported/blocked this user');
		}
		}
   }catch(e){
   }
} 
function unblockUser(username){
   try{
      var url = "/includes/reportuser.php"
	  xmlhttp = new myXMLHttpRequest();
      var content = "username="+username+"&unblock=1";  
      xmlhttp.open("POST",url,true);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlhttp.send(content);
		xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 && xmlhttp.status == 200) {
			//alert('You have reported/blocked this user');
			document.location.href=document.location.href;
		}
		}
   }catch(e){
	   	
      //location = "online.php";
	// alert(e);
   }
} 

function toggleDisplay(me){
	me = document.getElementById(me);
		if (me.style.display=="block"){
			me.style.display="none";
			
			}
		else {
			if (me.style.display=="inline"){
				me.style.display="none";
				alert("Text is now 'none'. It will reappear in three seconds.");
				window.setTimeout("blueText.style.display='block';",3000,"JavaScript");
				}
			else {
				me.style.display="block";
				}
			}
		}
