var aInfo = new Array(6);
aInfo[0] = "Gallery Information";
aInfo[1] = "Portfolios, statements and resumes of current Viridian artists";
aInfo[2] = "2011 - 2012 exhibition calendar and press releases";
aInfo[3] = "Viridian Membership Information and our Annual Juried Exhibition";
aInfo[4] = "Contact us to get more information.";
$("document").ready(function() {
	$("#menuList li a").mouseover(function() {
		showInfo(this.id);
	});
	$("#menuList li a").mouseout(function() {
		hideInfo();
	});
	$("a.inactive").click(function() {
		return false;					   
	});
	$("#website").click(function() {
		getWebsite(website);
		return false;
	});
	$("#mainImage").click(function() {
		openImage(alias, filename);
		return false;
	});
	$("#membership").hide();
	$("#affiliate").hide();
	$("a.membershipBtn").click(function() {
		showMembership();
		return false;
	});
	
	$("a.affiliateBtn").click(function() {
		showAffiliate();
		return false;
		});
		
		$("a.jsBtn").click(function() {
		showJs();
		return false;
		 });
		$('a.aImg').lightBox();
});

function showInfo(src)
{
	var target = $("#messageBox");
	var msg = $("#" + src).attr("title");
	target.text(msg);
	target.css("padding-left", 120 + "px");
}


function hideInfo()
{
	$("#messageBox").text("");
}

function getWebsite(website)
{
	site = "http://" + website;
	var external = window.open(site);
	external.focus();
}

function openImage(alias, filename)
{
	var height = 500;
	var width = 500;
	var newLeft = (window.screen.availWidth - width) / 2;
	var newHeight = (window.screen.availHeight - height) /2;
	var url = "index.php/fa/c.popup/alias/" + alias + "/filename/" + filename;
	var popWin = window.open(url,'popWin','height=' + height + ',width=' + width + ',left=' + newLeft +',top=' + newHeight + ',menubar=0,status=0,resizable=1,scrollbars=0,directories=0');
}

// powers the drop down pagechanger
function PageChanger(page)
{
 	var b = document.getElementsByTagName('base');
 	if (b && b[0] && b[0].href) {
   	if (b[0].href.substr(b[0].href.length-1) == '/')
   	page = b[0].href + page;
	location.href = page;
	}
	document.NavForm.PullDown.options[0].selected=true;
}

	function validate_email(email)
		{

			var apos = email.indexOf("@")
			var dotpos = email.lastIndexOf(".")
			if (apos<1 || dotpos- apos<2)
			{
  			return false
			}
			else 
			{
			return true
			}
		}

//checks the mail form
function chkMailForm()
{
	var returnValue = false;
	var name = $("#name").val();
	var email = $("#email").val();
	var chkAddress = validate_email(email);
	var msg = $("#msg").val();
	if (name == "")
	{
		alert("Please give your name.");
		$("#name").focus();
	}
	else if (!chkAddress)
	{
		alert("Please enter a valid email address.");
		$("#email").focus();
	}
	else if (msg == "")
	{
		alert("You haven't entered a message.");
		$("#msg").focus();
	}
	else
	{
		returnValue = true;	
	}
	return returnValue;
}

// show the juried application
function showJs()
{

		$("#membership").hide();
		$("#affiliate").hide();
		$("#js").fadeIn("slow");
		$("a.membershipBtn").click(function() {
			showMembership();
			return false;
		});
}

// show membership information
function showMembership()
{
		$("#js").hide();
		$("#affiliate").hide();
		$("#membership").fadeIn("slow");
		$("a.jsBtn").click(function() {
			showJs(this.name);
			return false; 
		});
}

// show the affiliate information
function showAffiliate()
{
	$("#js").hide();
	$("#membership").hide();
	$("#affiliate").fadeIn("slow");
	$("a.jsBtn").click(function() {
			showJs(this.name);
			return false; 
		});
}

// open a slide show
function openSS()
{
	var height = 700;
	var width = 900;
	var newLeft = (window.screen.availWidth - width) / 2;
	var newHeight = (window.screen.availHeight - height) /2;
	var url = "index.cfm/fa/main.ss"
	var popWin = window.open(url,'popWin','height=' + height + ',width=' + width + ',left=' + newLeft +',top=' + newHeight + ',menubar=0,status=0,resizable=1,scrollbars=0,directories=0');	
}

