function albumPaginate(selectedDate) {
	window.location = "/galleries/date/" + selectedDate;
}

function openGalleryPhotoEmailForm(photo, album){
	window.open('/emailForm.php?photo='+photo+'&album='+album,'EmailACopyOfThisAlbumPhotoToAFriend','width=500,height=500'); 
}

function openGalleryAlbumEmailForm(album) {
	window.open('/emailForm.php?album='+album,'EmailACopyOfThisAlbumToAFriend','width=500,height=500'); 
}

var xmlHttp;
function openTagDiv() {
	document.getElementById('tag_div').style.display = 'block';
	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){
	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;
	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 prev_nav_link(alb_url, year, month, prev, thumbpage, album){
	if((first_id > prev) && (thumbpage != "all"))
		thumbpage = parseInt(thumbpage)-15;
	/* url ='/galleries/album'+album+'/page'+thumbpage+'/'+prev; */
	url ='/galleries/' + year + '/' + month + '/'+alb_url+'/'+prev+"/";
	//alert(url);
	window.location = url;
}

function next_nav_link(alb_url, year, month, next, thumbpage, album){
	if((last_id < next)&&(thumbpage != "all"))
		thumbpage = parseInt(thumbpage)+15;
	//url ='/galleries/album'+album+'/'+next+"/";
	url ='/galleries/' + year + '/' + month + '/'+alb_url+'/'+next+"/";
	//alert(url);
	window.location = url;
}

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

function submitComments(photo){
	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;
	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;
}
function displayExtraCommentsDiv(id) {
	if(document.getElementById("plusImage"+id).src == 'http://guestofaguest.com/wp-content/themes/2009GofG/images/plus_icon.jpg') {
		document.getElementById("extraCommentsDiv"+id).style.display = "inline";
		document.getElementById("plusImage"+id).src = "http://guestofaguest.com/wp-content/themes/2009GofG/images/gofg_8.jpg";
		
	} else {
		document.getElementById("extraCommentsDiv"+id).style.display = "none";
		document.getElementById("plusImage"+id).src = "http://guestofaguest.com/wp-content/themes/2009GofG/images/plus_icon.jpg";
	}
}
function displayCommentsForm(id) {
	if(document.getElementById("commentsFormDiv"+id).innerHTML  == "") {
		var txtArea="<textarea style='width:493px; height: 50px;' id='commentTextArea"+id+"' onfocus='if(this.value==\"Anonymous...please be nice (or it wont be accepted!)\") this.value = \"\";'>Anonymous...please be nice (or it wont be accepted!)</textarea><br />";
		var btn="<span style='float:right;'><input class='button' type='button' onclick='submitPhotoComment(\""+id+"\");' value='submit' />&nbsp;<input class='button' type='button' onclick='displayCommentsForm(\""+id+"\");' return false;' value='cancel'/></span>";
		document.getElementById("commentsFormDiv"+id).innerHTML = txtArea + btn;
		document.getElementById("commentsFormDiv"+id).style.display="inline";
	} else {
		document.getElementById("commentsFormDiv"+id).innerHTML = "";
	}
}
function submitPhotoComment(id) {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null){
		alert ("Browser does not support HTTP Request");
		return;
	}
	var tag = document.getElementById("commentTextArea"+id). value;
	if(tag == "Anonymous...please be nice(or it won't be accepted!)") {
		return false;
	}
	var url = "/addImageComments.php?photo="+id+"&tag="+tag;
	xmlHttp.open("GET",url,false);
	xmlHttp.send(null);
	if (xmlHttp.status==200) { 
		document.getElementById("commentsFormDiv"+id).innerHTML=xmlHttp.responseText;
	}

}