var win;

GB_myShow = function(url, /* optional */ height, width, callback_fn) {
	var options = {
		caption: '',
		height: height || 370,
		width: width || 485,
		fullscreen: false,
		overlay_click_close: true,
		show_loading: false,
		callback_fn: null,
		center_win: true
	}
	win = new GB_Window(options);
	return win.show(url);
}
function showPopupVideo(video) {
	$('#bigViewerImage').html('<div id="flashcontent"><!-- No flash content here --><a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" target="_blank" class="detection">Click here to download Flash</a></div> <!-- flashcontent --><script type="text/javascript">var so = new SWFObject("acumen_videoPlayer_two.swf", "cp", "484", "271", "8");so.addVariable("loadVar","'+video+'");so.addParam("allowScriptAccess","always");so.addParam("wmode","window");so.write("flashcontent");</script>');
	$("#GB_window").fadeOut(function() {
	$('#bigViewer').fadeIn();
	});
	/*
	$('#bigViewer').click(function() {
		if() {
			$('#bigViewer').fadeOut(function() {
				$("#GB_window").fadeIn();
			});
		}
	});*/
	return false;
}
function closeSecondaryPopup() {
	$('#bigViewer').fadeOut(function() {
		$("#GB_window").fadeIn();
	});	
}
function showPopupImage(img) {
	//GB_hide();
	
	//this.fancyZoom();
	//this.FancyZoomBox.show();
	$('#bigViewerImage').html('<img src="' + img + '" />');
	$('#bigViewer').fadeIn();
	$('#bigViewerImage').click(function() {
		$('#bigViewer').fadeOut();									
	});
	return false;
	
	//showPopup(3);
	//GB_myShow2 = function(url, height, width, callback_fn) {
	/*
	
	GB_hide();
	
	win.removeFrame();
	
	//document.getelementbyid('GB_overlay').hide();
	
	var options = {
		caption: '',
		height: 480,
		width: 640,
		fullscreen: false,
		overlay_click_close: true,
		show_loading: false,
		callback_fn: '',
		center_win: true
	}
	var win2 = new GB_Window(options);
	win2.show(url);
	/*
	var options = {
		caption: '',
		height: 480,
		width: 640,
		fullscreen: false,
		overlay_click_close: true,
		show_loading: false,
		callback_fn: '',
		center_win: true
	}
	win = GB_Window(options);
	win.show(url);
	*/
	
	
}

function showPopup(project) {
	if (project.value != "-") {
		if (project.value.indexOf("project_list_") == -1) {
			var url = '../popup.php?project=' + project.value;
			GB_myShow(url, /* optional */ 370, 485);
		} else {
			window.open("/pdfs/" + project.value);
		}
	}
}

function changeProjectHeader(projectName, projectLocation) {
	document.getElementById('projectHeader').innerHTML = buildProjectHeader(projectName, 40, projectLocation);
}

function buildProjectHeader(projectName, maxCharLength, projectLocation) {
	var headerContent = '<ul class="heading" style="margin-top:10px;width:710px;list-style-type:none;">';
	headerContent += '<li style="padding-right:15px;"><h1 style="float:none;">';

	var numChars = 0;
	var words = projectName.split(" ");
	
	for(var x=0; x<words.length; x++) {
		if((numChars + words[x].length) < maxCharLength) {
			headerContent += words[x] + ' ';
			numChars = numChars + words[x].length;
		} else {
			headerContent += '</h1></li></ul>\r\t<ul class="heading" style="margin-top:0px;width:710px;list-style-type:none;"><li style="padding-right: 15px;"><h1 style="float:none;">' + words[x] + ' ';
			numChars = words[x].length;
		}
	}
	
	headerContent += '</h1></li></ul>';
	headerContent += '<div style="float:left;width:710px;padding-top:5px;">';
	headerContent += '<span style="color: #000;">' + projectLocation + '</span>';
	headerContent += '</div>';
	return headerContent;
}

function changeImage(link,imagePath,alt,credits) {

	
	document.getElementById('projectImage').innerHTML = '<a href="upload/' + imagePath + '" onclick="parent.parent.showPopupImage(this); return false;"><img src="upload/medium/' + imagePath + '"  style="width:160px;height:120px;padding-bottom:5px;" alt="' + alt + '" /></a>';
		
	var links = document.getElementById('images').getElementsByTagName('a');
	
	for(var i=0; i<links.length; i++) {
		links[i].setAttribute("class", "");
	}			
	link.setAttribute("class", "selectedLink");
	
	if (credits == "") {
		document.getElementById('creditsDiv').innerHTML = '';	
	} else {
		document.getElementById('creditsDiv').innerHTML = 'Photo/rendering courtesy of<br />' + credits;
	}
}

function checkContactForm() {
	resetRequiredFields();
	var form = document.getElementById('contactform');
	
	var first = form.first;
	var last = form.last;
	var email = form.email;
	var message = form.message;
	
	var isValid = true;
	
	if(first.value == "first name*") {
		isValid = false;
		first.style.color = "#d31400";
	}
	
	if(last.value == "last name*") {
		isValid = false;
		last.style.color = "#d31400";
	}
	
	if(email.value == "email*") {
		isValid = false;
		email.style.color = "#d31400";
	}
	
	if(message.value == "your message*") {
		isValid = false;
		message.style.color = "#d31400";
	}
		
	return isValid;
}

function resetRequiredFields() {
	var form = document.getElementById('contactform');
	
	form.first.style.color = "#999999";
	form.last.style.color = "#999999";
	form.email.style.color = "#999999";
	form.message.style.color = "#999999";
}