var xmlHttp5;

var photoId;



function addphotocomment(photoId)
{
  win = new Window( { className: 'alphacube', url: 'includes/photo-comment-form.php?photoId='+photoId,
    title: '<strong>Comment</strong>', width:400,
    height:200, destroyOnClose: true, recenterAuto:false } ); 
 	win.showCenter();
	win.show(true);
}

function hideComment()
{
	document.getElementById('pic').innerHTML = '<div  style="cursor:pointer;color:blue" onclick="getPhotos();">View Comments</div>';
}

function assignPhotoId(photoId2)
{	
	
		photoId = photoId2;

}

function getPhotos()
{
		document.getElementById('load').innerHTML = '<img src="images/loading.gif" />';
		xmlHttp5=GetXmlHttpObject();
		if (xmlHttp5==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }
		  
		var url="includes/get-photo-comments.php?photoId="+photoId;
		url=url+"&sid="+Math.random();
		xmlHttp5.onreadystatechange=stateChanged;
		xmlHttp5.open("GET",url,true);
		xmlHttp5.send(null);


}

var varviewcompleteprofile = 0;

function viewcompleteprofile(userId)
{
		
		varviewcompleteprofile = 1;
		
		document.getElementById('complete-profile').innerHTML = '<img src="images/loading.gif" />';
		xmlHttp5=GetXmlHttpObject();
		if (xmlHttp5==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }
		  
		var url="includes/view-complete-profile.php?userId="+userId;
		url=url+"&sid="+Math.random();
		xmlHttp5.onreadystatechange=stateChanged;
		xmlHttp5.open("GET",url,true);
		xmlHttp5.send(null);


}
var setPrimaryphoto = 0;

function setPhotoAsPrimary(photoId)
{
	
		
		setPrimaryphoto = 1;
		document.getElementById('load').innerHTML = '<img src="images/loading.gif" />';
		xmlHttp5=GetXmlHttpObject();
		if (xmlHttp5==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  }
		  
		var url="includes/set-primary-photo.php?photoId="+photoId;
		url=url+"&sid="+Math.random();
		xmlHttp5.onreadystatechange=stateChanged;
		xmlHttp5.open("GET",url,true);
		xmlHttp5.send(null);


}

function stateChanged() 
{ 

	if (xmlHttp5.readyState==4)
	{ 
			if(varviewcompleteprofile==1)
			{
				document.getElementById("complete-profile").innerHTML=xmlHttp5.responseText;
			}
			else{
				document.getElementById("pic").innerHTML=xmlHttp5.responseText;
				document.getElementById("load").innerHTML='';
			}
			if(setPrimaryphoto==1)
			{
					document.getElementById("load").innerHTML='Redirecting...';
					window.location.href = 'myunitown.php';
			}
	
	}

}


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