function showOverlay() {
	document.getElementById("overlay").style.display = "block";
	document.getElementById("overlay").style.height = document.body.clientHeight;
}
function hideOverlay() {
	document.getElementById("overlay").style.display = "none";
}
function clickOverlay() {
	hideMessage();
}
function hideMessage() {
	document.getElementById("message").style.display = "none";
	createCookie('legalage','yes',90);
	hideOverlay();
}
 
function showStartMessage() {
	var message = document.getElementById("message");
	message.style.display = "block";
	message.style.marginLeft = -(message.offsetWidth / 2) + "px";
	showOverlay();
}

function areyousurefrienddelete(){
  if(confirm("Are you sure you want to delete this friend")==true){
	return true;
  }
  else{
	return false;  
  }
}

function areyousuremasterphoto(){
  if(confirm("Warning: You are about to change your master photo, this will put your account into pending status, and you will have restricted access to the site until the Admin approves your new master photo. Your master photo must be of a couple or single female, and may not show any genitalia, or nipples.  Be sure your master photo meets our guidelines to ensure quick reactivation of your account")==true){
	return true;
  }
  else{
	return false;  
  }
}

//Specify highlight behavior. "TD" to highlight table cells, "TR" to highlight the entire row:
var highlightbehavior="TD"

var ns6=document.getElementById&&!document.all
var ie=document.all

function changeto(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!=highlightbehavior && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function contains_ns6(master, slave) { //check if slave is contained by master
while (slave.parentNode)
if ((slave = slave.parentNode) == master)
return true;
return false;
}

function changeback(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}

function changeto2(e,highlightcolor){
source=ie? event.srcElement : e.target
if (source.tagName=="TABLE")
return
while(source.tagName!="TR" && source.tagName!="HTML")
source=ns6? source.parentNode : source.parentElement
if (source.style.backgroundColor!=highlightcolor&&source.id!="ignore")
source.style.backgroundColor=highlightcolor
}

function changeback2(e,originalcolor){
if (ie&&(event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id=="ignore")||source.tagName=="TABLE")
return
else if (ns6&&(contains_ns6(source, e.relatedTarget)||source.id=="ignore"))
return
if (ie&&event.toElement!=source||ns6&&e.relatedTarget!=source)
source.style.backgroundColor=originalcolor
}
function startmeup(memberid){
window.open('startchat.aspx?memberid='+memberid,'DPchat','width=400, height=380, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
}

///////////////////////////////////////////////////////////////////////////
			var sendReq = getXmlHttpRequestObject();
			var receiveReq = getXmlHttpRequestObject();
			var lastMessage = 0;
			var mTimer;
			//Function for initializating the page.
			function startListening() {
				checkForInvites();
			}		
			//Gets the browser specific XmlHttpRequest Object
			function getXmlHttpRequestObject() {
				if (window.XMLHttpRequest) {
					return new XMLHttpRequest();
				} else if(window.ActiveXObject) {
					return new ActiveXObject("Microsoft.XMLHTTP");
				} else {
					document.getElementById('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object.  Consider upgrading your browser.';
				}
			}
			
			//Gets the current messages from the server
			function checkForInvites() {
				if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
					receiveReq.open("GET", 'getinvites.aspx', true);
					receiveReq.onreadystatechange = handleInvite; 
					receiveReq.send(null);
				}			
			}
			//Function for handling the return of chat text
			function handleInvite() {
				if (receiveReq.readyState == 4) {
					var xmldoc = receiveReq.responseXML;
					var message_nodes = xmldoc.getElementsByTagName("invite"); 
					var n_messages = message_nodes.length
					for (i = 0; i < n_messages; i++) {
						var user_node = message_nodes[i].getElementsByTagName("user");
						var inviteid_node = message_nodes[i].getElementsByTagName("inviteid");
						var chatid_node = message_nodes[i].getElementsByTagName("chatid");
						//prompt user
						var answer=confirm(user_node[0].firstChild.nodeValue+" would like to chat with you\nIf you would like to chat with this user click \"OK\" or click \"Cancel\" if you don't wish to chat");
						if(answer!=0){
							//open new window
							window.open('chat.aspx?chat='+chatid_node[0].firstChild.nodeValue ,'DPchat'+chatid_node[0].firstChild.nodeValue,'width=400, height=380, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no');
						}
						else{
							// send cancel request
							sendReq.open("GET", 'denyChat.aspx?invite='+inviteid_node[0].firstChild.nodeValue+'&chat='+chatid_node[0].firstChild.nodeValue, true);
							sendReq.send(null);
						}
					}
					mTimer = setTimeout('checkForInvites();',5000); //Refresh our chat in 2 seconds
				}
			}
			window.onload=startListening;