// JavaScript Document
var xmlHttp

function displayLoading(element) { 
  while (element.hasChildNodes()) { 
    element.removeChild(element.lastChild); 
  } 
  var image = document.createElement("img"); 
  image.setAttribute("src","indicator.gif"); 
  image.setAttribute("alt","Loading..."); 
  element.appendChild(image); 
} 


function getContact(member_id){ 
displayLoading(document.getElementById("member_info_container")); 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
 alert ("Browser does not support HTTP Request")
 return
 }
var url="includes/portfolio_getMemberContact.php"
url=url+"?member_id="+member_id
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=profileStateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function getItems(member_id,itemtype,curPage){ 
displayLoading(document.getElementById("member_info_container")); 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
 alert ("Browser does not support HTTP Request")
 return
 }
var url="ajax_portfolio_user_items.php";
url=url+"?member_id="+member_id;
if(itemtype){
url=url+"&display="+itemtype;
}
if(curPage){
url=url+"&curPage="+curPage;
}
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=profileStateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}



function getStatement(member_id){ 
displayLoading(document.getElementById("member_info_container")); 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
 alert ("Browser does not support HTTP Request")
 return
 }
var url="includes/portfolio_getMemberStatement.php"
url=url+"?member_id="+member_id
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=profileStateChanged; 
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function sendEmail(data){ 
	displayLoading(document.getElementById("contact_load")); 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null){
		 return
	 }
	var url="includes/portfolio_processContact.php";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=profileStateChanged ;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.send(data);
}

function getPortfolioImage(member_id, photo_id){ 
displayLoading(document.getElementById("images_container")); 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
 alert ("Browser does not support HTTP Request")
 return
 }
var url="includes/portfolio_getImage.php"
url=url+"?photo="+photo_id;
url=url+"&member_id="+member_id;
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=portfolioStateChanged;
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function profileStateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
 		document.getElementById("member_info_container").innerHTML=xmlHttp.responseText;
 		prepareForm();
 	} 
}

function portfolioStateChanged() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
 		document.getElementById("images_container").innerHTML=xmlHttp.responseText;
 	} 
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}