/*
	Submit Once
	
	Add the following onclick event to a button to only allow the first pressing of the button
	to send a request to the server.
		onclick="return submitOnce()"
	If your using a cfform you should add the following line to the form itself instead.
		onsubmit="return submitOnce()"
*/
formSubmitted	= 0
function submitOnce() {
	if(!formSubmitted)
		formSubmitted	= formSubmitted + 1
	else
		return false
}

function changePic (objName,picName) {
	objName.src = picName
}

function toggleSection(i){
	if(document.getElementById(i).style.display == "block")
		document.getElementById(i).style.display = "none"
	else
		document.getElementById(i).style.display = "block"
}

function artworkPopup() {
	var winl = (screen.width-650)/2;
	var wint = (screen.height-530)/2;
	window.open("artworkPopup.html","mywindow","scrollbars=no,toolbar=no,menubar=0,resizable=0,width=650,height=530,top=0,left=" & winl);
}

var win= null;
function OpenNewWindow(mypage,w,h,myname){
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
settings='height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,toolbar=no'
win=window.open(mypage,myname,settings)
if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}

	function MakeProfileLink(authorName) {
		var pid = team[authorName];
		
		if (typeof(pid) == "undefined")
			document.write (authorName);
		else
			document.write ('<a href="http://www.blogger.com/profile/' + pid + '" target="_blank">' + authorName + "</a>");
	}

	function Search_Input_OnFocus() {
		if (document.getElementById("searchInput").value == "Search")
			document.getElementById("searchInput").value = "";
	}

function Anchor_Mailto_Set(id, name, domain) {
	var anchor = document.getElementById(id);
	
	anchor.href = "mailto:" + name + "@" + domain;
	anchor.innerHTML = name + "@" + domain;
}

//***** Project Category Page - begin

var att_list = new Array();
function ProjAtt_OnMouseOver(attId) {
	var project_list;
	var count;
	
	document.getElementById("projAtt_" + attId).className = "on";
	
	project_list = att_list["att" + attId];
	for (count=0; count<project_list.length; count++)
		document.getElementById("proj_" + project_list[count]).className = "projThumbGridLabel_on";
}

function ProjAtt_OnMouseOut(attId) {
	var project_list;
	var count;
	
	document.getElementById("projAtt_" + attId).className = "";
	
	project_list = att_list["att" + attId];
	for (count=0; count<project_list.length; count++)
		document.getElementById("proj_" + project_list[count]).className = "projThumbGridLabel";
}

function Project_OnMouseOver(projectId) {
	var attribute_list;
	var count;
	
	attribute_list = att_list["proj" + projectId];
	for (count=0; count<attribute_list.length; count++)
		document.getElementById("projAtt_" + attribute_list[count]).className = "on";
}

function Project_OnMouseOut(projectId) {
	var attribute_list;
	var count;
	
	attribute_list = att_list["proj" + projectId];
	for (count=0; count<attribute_list.length; count++)
		document.getElementById("projAtt_" + attribute_list[count]).className = "";
}

//***** Project Category Page - end
//***** Project Page - begin

var project_list = new Array();
function TabList_OnClick(selected) {
	var tab_list = new Array("Overview", "Process", "Team", "Stats");
	var count;
	var item;
	
	for (count=0; count<tab_list.length; count++) {
		item = document.getElementById("tabList_" + tab_list[count]);
		if (item != null)
			if (tab_list[count] == selected)
				item.className = "tabListOn";
			else
				item.className = "";
	}
	document.getElementById("projDetailDesc").innerHTML = '<div id="scrollToMe"></div>' + project_list[selected];
	document.getElementById("scrollToMe").scrollIntoView(false);
	
	return false;
}

function ImageList_OnClick(imageId) {
	if (!isNaN(project_list["image_last"]))
		document.getElementById("thumbnail" + project_list["image_last"]).className = "";
	else if(project_list["image_last"] == "map")
		document.getElementById("tabList_Map").className = "";
		
	document.getElementById("thumbnail" + imageId).className = "imageListOn";
	document.getElementById("map").style.display = "none";
	document.getElementById("photo_large").src = project_list["image" + imageId];
	document.getElementById("projDetailImage").style.display = "block";
	project_list["image_last"] = imageId;
	return false;
}

var mapInit = false;
var map;

function TabList_Map_OnClick() {
	document.getElementById("projDetailImage").style.display = "none";
	document.getElementById("map").style.display = "block";
	
	if (!mapInit) {
	    map = new GMap(document.getElementById("map"));
	    map.enableScrollWheelZoom();
	    map.enableContinuousZoom();
        map.addControl(new GMapTypeControl());
        map.addControl(new GLargeMapControl());
    
	    point = ShowMap(map);
	    map.savePosition();
	    mapInit = true;
	}
	else {
	    map.returnToSavedPosition();
	}
		
	
	if (!isNaN(project_list["image_last"]))
		document.getElementById("thumbnail" + project_list["image_last"]).className = "";
	document.getElementById("tabList_Map").className = "tabListOn";
	project_list["image_last"] = "map";
	
	return false;
}

//***** Project Page - end
//***** Search Form - begin

function ProjectId_OnClick() {
	var projectId = document.getElementById("projectId");
	var option = projectId[projectId.selectedIndex];
	var child;
	
	if (projectId.selectedIndex == 0) {
		alert ("Please select a project.");
		return false;
	}
	
	if (option.className == "jump") {
		child = window.open(option.value, "GGLO_popup");
	} else
		return true;
		
	return false;
}

//***** Search Form - end
//***** Image pre-loader stuff - begin

var image_count = 0;
var image_list = new Array();
var Image_Preloader = {
    
    image_add : function(url) {
        image_list[image_count] = url;
        image_count++;
    },
    
    image_preload : function() {
		var i;
		var imageObj = new Image();

		// start preloading
		for(i=0; i < image_count; i++)
			imageObj.src	= image_list[i];
	}
} 
window.onload = Image_Preloader.image_preload;

//***** Image pre-loader stuff - end