var xmlHttp;
function openTagDiv() {
	document.getElementById('tag_div').style.display = 'inline';
	document.getElementById('tag_text').style.display = 'none';
	return false;
}

function closeTagDiv() {
	document.getElementById('tag_div').style.display = 'none';
	document.getElementById('tag_text').style.display = 'block';
	return false;
}

function submitTag(photo, album, site){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	var tag = document.getElementById("album_tag"). value;
	var url = "/addAltTag.php?album="+album+"&photo="+photo+"&tag="+tag+"&site="+site;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	if (xmlHttp.status==200) { 
		document.getElementById("tag_div").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;
}
function openGalleryPhotoEmailForm(photo, album, site_id, profile_id, profile_name){
	var url = '/emailForm.php?photo='+photo+'&album='+album+'&site_id='+site_id+'&profile_id='+profile_id+'&profile_name='+profile_name;
	window.open(url,'EmailACopyOfThisAlbumPhotoToAFriend','width=500,height=500'); 
}

function closeCommentDiv() {
	document.getElementById('comments_div').style.display = 'none';
	document.getElementById('tag_text').style.display = 'block';
	return false;
}

function submitComments(photo, site){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	var tag = document.getElementById("commentTextArea"). value;
	if(tag == "Anonymous...please be nice (or it won't be accepted!)") {
		return false;
	}
	var url = "/addImageComments.php?photo="+photo+"&tag="+tag+"&site="+site;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	if (xmlHttp.status==200) { 
		document.getElementById("comments_div").innerHTML=xmlHttp.responseText ;
	}
}

function openCommentsDiv(){
	document.getElementById('comments_div').style.display = 'block';
	document.getElementById('tag_text').style.display = 'none';
	return false;
}
