// JavaScript Document
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2) 
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_form(thisform)
{
with (thisform)
{
	if (name.value == "your name/alias")
	{
		alert("Please enter your name...")
		name.focus();
		return false
	}
	if (validate_email(email,"Not a valid e-mail address!")==false)
  	{
		email.focus();
		return false
	}
	if (comments.value == "your comments")
	{
		alert("Please enter your comments...")
		comments.focus();
		return false
	}
}
	
}

function openemailwindow(id)
{
window.open('email.php?pid='+id+'','jav','width=350,height=550,resizable=no, left=200,top=200,screenX=200,screenY=200');
}

function deleteGallery(id)
{
  if (confirm('Are you sure you want to delete this gallery?'))
   location.href = "edit-photos-galleries.php?cid="+id+"&action=delete";
}

function deletePhoto(id)
{
  if (confirm('Are you sure you want to delete this photo?'))
   location.href = "index.php?adminview=true&action=delete&photo_id="+id+"";
   
}

function deleteComment(id)
{
  if (confirm('Are you sure you want to delete this comment?'))
   location.href = "index.php?adminview=true&action=delete&comment_id="+id+"";
   
}

	function hideLoading() {
		document.getElementById('loading').style.display = "none";
		document.getElementById('loadingPrompt').style.display = "none";
	}
	
	function hideInstall() {
		document.getElementById('loading').style.display = "none";
		document.getElementById('loadingPrompt').childNodes[0].nodeValue = "Complete! Your barrels gallery system is configured for use...";
	}

	function showLogin() {
		document.getElementById('loginContent').style.display = "block";
	}
	
	function toggleExif() {
			  if ($("#exifData").is(":hidden")) {
				$("#exifData").slideDown("slow");
				$("#hideExif").html("<p><a href=\"#\" onclick=\"toggleExif()\" class=\"hideshow\"><img src=\"exif.gif\" alt=\"Hide Exif\"/> <span class=\nl\">Hide Exif</span></a></p>");
					eraseCookie('exifVisible')
			  } else {
				 $("#exifData").slideUp("slow");
				 createCookie('exifVisible','false',1);
				 $("#hideExif").html("<p><a href=\"#\" onclick=\"toggleExif()\" class=\"hideshow\"><img src=\"exif.gif\" alt=\"Show Exif\"/> <span class=\nl\">Show Exif</span></a></p>");
			  }
		
	}
	
	function toggleComments() {
		 if ($("#commentsContent").is(":hidden")) {
				$("#commentsContent").slideDown("slow");
				$("#hideComments").html("<p><a href=\"#\" onclick=\"toggleComments()\" class=\"hideshow\"><img src=\"comments.gif\" alt=\"Hide Comments\"/> <span class=\nl\">Hide Comments</span></a></p>");
					eraseCookie('commentsVisible')
			  } else {
				 $("#commentsContent").slideUp("slow");
				 createCookie('commentsVisible','false',1);
				 $("#hideComments").html("<p><a href=\"#\" onclick=\"toggleComments()\" class=\"hideshow\"><img src=\"comments.gif\" alt=\"Show Comments\"/> <span class=\nl\">Show Comments</span></a></p>");
			  }
		
	}
	function toggleCommentsForm() {
		 if ($("#formContent").is(":hidden")) {
				$("#formContent").slideDown("slow");
			$("#hidePostForm").html("<p><a href=\"#\" onclick=\"toggleCommentsForm()\" class=\"hideshow\"><img src=\"comments.gif\" alt=\"Hide Comments Form\"/> <span class=\nl\">Hide Comments Form</span></a></p>");
					eraseCookie('commentsFormVisible')
			  } else {
				 $("#formContent").slideUp("slow");
				 createCookie('commentsFormVisible','false',1);
			$("#hidePostForm").html("<p><a href=\"#\" onclick=\"toggleCommentsForm()\" class=\"hideshow\"><img src=\"comments.gif\" alt=\"Show Comments Form\"/> <span class=\nl\">Show Comments Form</span></a></p>");
			  }
	}
	
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

	
	document.write("<style type='text/css'>#photo {visibility:hidden;}</style>");
	
	function initImage() {
		imageId = 'photo';
		image = document.getElementById(imageId);
		setOpacity(image, 0);
		image.style.visibility = "visible";
		fadeIn(imageId,0);
	}
	function fadeIn(objId,opacity) {
		if (document.getElementById) {
			obj = document.getElementById(objId);
			if (opacity <= 100) {
				setOpacity(obj, opacity);
				opacity += 5;
				window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 20);
			}
		}
	}
	function setOpacity(obj, opacity) {
		opacity = (opacity == 100)?99.999:opacity;
		// IE/Win
		obj.style.filter = "alpha(opacity:"+opacity+")";
		// Safari<1.2, Konqueror
		obj.style.KHTMLOpacity = opacity/100;
		// Older Mozilla and Firefox
		obj.style.MozOpacity = opacity/100;
		// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = opacity/100;
	}
	window.onload = function() {initImage()}
