var desProjects = [['proj_01',3],['proj_02',2],['proj_03',2],['proj_04',2]];
var conProjects = [['proj_01',5],['proj_02',3],['proj_03',6],['proj_04',3],['proj_05',3],['proj_06',4]];
var slidesPlayed = false;
var intval=""

function loadVictorianHouse(aPage){
	document.location.href = aPage;
}
function turnPicsOn(thisObj,aCat,aProj){
	baseFolder = 'photos/portfolio/';
	projFolder = aProj + '/';
	folderType = 'lg/';
	lgPicDivHTML = 	"<img id='lgportfoliopic' src='" + baseFolder + aCat + '/' + folderType + projFolder + "01_lg.jpg' name='1' title='" + aProj + "' alt='" + aCat + "'>";
	largePicDiv = document.getElementById('lgpic');
	largePicDiv.innerHTML = lgPicDivHTML;

	divToShow = document.getElementById('portfoliosliders');
	divToShow.style.display = "none";

	divToShow = document.getElementById('picviewer');
	divToShow.style.display = "block";
}
function showNextPage(anObj,anArr){
	for(i=0;i<anArr.length;i++){
		thisElem = document.getElementById(anArr[i]);
		thisElemDisplay = thisElem.style.display;
		if(thisElemDisplay == 'block'){
			(i!=anArr.length-1) ? nextElem = document.getElementById(anArr[i+1]) : nextElem = document.getElementById(anArr[0]);
			nextElemDisplay = nextElem.style.display;

//alert(nextElemDisplay);

			thisElem.style.display = 'none';
			nextElem.style.display = 'block';
			break;
		}
		
		
//		thisElemOn = i;
	
	}

}
function showPic(thisObj,outerObjId){
	thePicObj = document.getElementById(outerObjId);
	thePicNum = thePicObj.name;
	thePicProject = thePicObj.title;
	thePicProjectType = thePicObj.alt;
	(thePicProjectType == 'construction') ? typProjects = conProjects : typProjects = desProjects ;
	whichProj = findProj(thePicProject,typProjects);		
	totalPics = whichProj[1];
	nextOn = document.getElementById('picviewernext');
	prevOn = document.getElementById('picviewerprev');
	nextOff = document.getElementById('picviewernextlast');
	prevOff = document.getElementById('picviewerprevfirst');
	if(thisObj.id == 'picviewernext'){
		newPicNum = makePicNumPlus(thePicNum,totalPics);
		newSRCImg = makeNewSrcImg(newPicNum,thePicProject,thePicProjectType);
		if(newPicNum > 0 && newPicNum <= ((totalPics-0)-1)){
			(prevOff != null) ? prevOff.id = 'picviewerprev' : '';
			thePicObj.name = newPicNum;
			thePicObj.src = newSRCImg;
		}else if(newPicNum == (totalPics-0)){
			(nextOn != null) ? nextOn.id = 'picviewernextlast' : '';
			(prevOff != null) ? prevOff.id = 'picviewerprev' : '';
			thePicObj.name = newPicNum;
			thePicObj.src = newSRCImg;
		}else if(newPicNum == 'last'){
			(nextOn != null) ? nextOn.id = 'picviewernextlast' : '';
		}
	}else if(thisObj.id == 'picviewerprev'){
		newPicNum = makePicNumMinus(thePicNum,totalPics);
		newSRCImg = makeNewSrcImg(newPicNum,thePicProject,thePicProjectType);
		if(newPicNum > 1 && newPicNum < (totalPics-0)){
			(nextOff != null) ? nextOff.id = 'picviewernext' : '';
			thePicObj.name = newPicNum;
			thePicObj.src = newSRCImg;
		}else if(newPicNum == 1){
			(prevOn != null) ? prevOn.id = 'picviewerprevfirst' : '';
			(nextOff != null) ? nextOff.id = 'picviewernext' : '';
			thePicObj.name = newPicNum;
			thePicObj.src = newSRCImg;
		}else if(newPicNum == 'first'){
			(prevOn != null) ? prevOn.id = 'picviewerprevfirst' : '';
}}}
function makePicNumPlus(aNum,aTotal){
	if(aNum-0 < aTotal-0){
		return((aNum-0)+1);
	} else if (aNum-0 >= aTotal-0){
		return('last');
}}
function makePicNumMinus(aNum){
	if(aNum-0 > 1){
		return((aNum-0)-1);
	} else if (aNum-0 <= 1){
		return('first');
}}
function makeNewSrcImg(aNum,aProjNum,aProj){
		baseFolder = 'photos/portfolio/';
		projFolder = aProj + '/';
		folderType = 'lg/';
		theNum = aNum - 0;
		(theNum < 10) ? aNum = '0' + aNum: '';
		aSRCImg = baseFolder + projFolder + folderType + aProjNum + '/' + aNum + '_lg.jpg';
		return aSRCImg;
}
function findProj(thePicProject, aProjTyp){
	for (i=0; i<aProjTyp.length; i++){
		aProj = aProjTyp[i];
		aProjName = aProj[0];
		aProjQty = aProj[1];
		if(aProjName == thePicProject){
			return aProj;
}}}
function start_Int(anObj){
	if(intval==""){	
		if(anObj.id == 'picturelistdesign'){
		  intval=window.setInterval("updatePhotos('picturelistdesign',-1150)",50);
		}else{
		  intval=window.setInterval("updatePhotos('picturelistconstruction',-1395)",50);
		}
	  }else{
		  stop_Int();
	  }
}
function stop_Int(){
	if(intval!=""){
	  window.clearInterval(intval);
	  intval="";
}}
function hideParentDiv(anObj){
	divToShow = document.getElementById('portfoliosliders');
	divToShowStyle = divToShow.style;
	divToShowStyleDisplay = divToShowStyle.display;
	divToShowStyle.display = "block";
	divToShow = document.getElementById('picviewer');
	divToShowStyle = divToShow.style;
	divToShowStyleDisplay = divToShowStyle.display;
	divToShowStyle.display = "none";
	prevOn = document.getElementById('picviewerprev');
	(prevOn != null) ? prevOn.id = 'picviewerprevfirst' : '';
	nextOff = document.getElementById('picviewernextlast');
	(nextOff != null) ? nextOff.id = 'picviewernext' : '';
}
function updatePhotos(anObjId,aWidth){
	var increment = 1;
	var thePicsObj = document.getElementById(anObjId);
	var pixOffset = thePicsObj.style.marginLeft;
	var picOffset = getNumValue(pixOffset);
	if(slidesPlayed == false){
		if(picOffset < 0){
			newLocation = ((picOffset - 0) + increment);
			thePicsObj.style.marginLeft = newLocation + 'px';
			if(picOffset == -1){
				slidesPlayed = true;
			}
		}
	}else if(slidesPlayed == true){
		if (picOffset > (aWidth - 0)){
			newLocation = ((picOffset - 0) - increment);
			thePicsObj.style.marginLeft = newLocation + 'px';
			if(picOffset == (aWidth - 0) + 1){
				slidesPlayed = false;
}}}}
function getNumValue(pixVal){
	return pixVal.substr(0,pixVal.lastIndexOf('px'));
}















/*
function changeTheState(evt){
	var objId = (evt.target) ? evt.target.id : ((evt.srcElement) ? evt.srcElement.id : null);
	if(objId.lastIndexOf('_ini') > -1 || objId.lastIndexOf('_ov') > -1){
	
	//alert('h');
	
		thisObj = document.getElementById(objId);
		changeState(thisObj);
	}
}

function changeState(anObj){
	objId = anObj.id;
	ovEx = '_ov';
	iniEx = '_ini';
	ovOffset = objId.lastIndexOf(ovEx);
	iniOffset = objId.lastIndexOf(iniEx);
	if(ovOffset != -1){
		baseId = objId.substr(0,ovOffset);
		newId = baseId + iniEx;
	}else if(iniOffset != -1){
		baseId = objId.substr(0,iniOffset);
		newId = baseId + ovEx;
	}
	document.getElementById(objId).id = newId;
}
*/
