/****************************************************************************************************/
/*GETELEMENTSBYATTRIBUTE FUNCTION***********************************************************/
/*COPYRIGHT ROBERT NYMAN, HTTP://WWW.ROBERTNYMAN.COM*******************************/
/****************************************************************************************************/
function getElementsByAttribute(oElm, strTagName, strAttributeName, strAttributeValue){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	var oAttributeValue = (typeof strAttributeValue != "undefined")? new RegExp("(^|\\s)" + strAttributeValue + "(\\s|$)") : null;
	var oCurrent;
	var oAttribute;
	for(var i=0; i<arrElements.length; i++){
		oCurrent = arrElements[i];
		oAttribute = oCurrent.getAttribute && oCurrent.getAttribute(strAttributeName);
		if(typeof oAttribute == "string" && oAttribute.length > 0){
			if(typeof strAttributeValue == "undefined" || (oAttributeValue && oAttributeValue.test(oAttribute))){
				arrReturnElements.push(oCurrent);
			}
		}
	}
	return arrReturnElements;
}

function lightbox(box){
	if(document.getElementById("lightbox").style.display=="none"){
		document.getElementById("lightbox").style.display = "block";
		document.getElementById("overlay").style.display = "block";
		document.getElementById(box).style.display = "block";
	} else {
		document.getElementById("lightbox").style.display = "none";
		document.getElementById("overlay").style.display = "none";
		document.getElementById(box).style.display = "none";
	}
}

function photoLightbox(id){
	if(document.getElementById("project_"+id).style.display=="none"){
		document.getElementById("project_"+id).style.display = "block";
		document.getElementById("overlay").style.display = "block";
	} else {
		document.getElementById("project_"+id).style.display = "none";
		document.getElementById("overlay").style.display = "none";
	}
}

function tabPhotos(id,number,projectid){
	var displayPhoto = getElementsByAttribute(document.body,"div","name","display_photo_"+projectid);
	for(var i=0;i<displayPhoto.length;i++){
		displayPhoto[i].style.display = "none";	
	}
	document.getElementById("display_"+id).style.display = "block";
	
	var choosePhoto = getElementsByAttribute(document.body,"div","name","choose_photo_"+projectid);
	for(var i=0;i<choosePhoto.length;i++){
		choosePhoto[i].className = "photo_number";	
	}
	document.getElementById("photo_"+id).className = "photo_number photo_select";
}
