



goBackBtnJumps = -3;
backBtnNavString = "";
currentNav = "";


function setNav(navString) {
	currentNav = navString;
	showNav(navString);
}

function restoreNav() {
	$("#navAboutUsOptions").css("visibility", "hidden");
	$("#navServicesOptions").css("visibility", "hidden");
	showNav(currentNav);
}

function showNav (navString)  {
	showNavOptions (navString, false);
}

function showNavOptions (navString, showOptions) {
	var navSections = navString.split(":");
	var visibleVal = "hidden";
	switch (navSections[0]) {
		case "home" :
			$("#navDiv").html('<img src="_global/images/spacer.gif" width="12" height="14" /><img src="_global/images/navHome.png" alt="" width="817" height="14" />').css("top","52px");
			break;
		case "aboutus" :
			$("#navDiv").html('<img src="_global/images/navAboutUs.png" alt="" width="829" height="57" />').css("top","17px");
			navSections[1] ? showOptions = false : null;
			showOptions ? visibleVal = "visible" : visibleVal = "hidden";
			$("#navAboutUsOptions").css("visibility", visibleVal);
			break;
		case "services" :
			$("#navDiv").html('<img src="_global/images/spacer.gif" width="12" height="14" /><img src="_global/images/navServices.png" alt="" width="817" height="57" />').css("top","17px");
			navSections[1] ? showOptions = false : null;
			showOptions ? visibleVal = "visible" : visibleVal = "hidden";
			$("#navServicesOptions").css("visibility", visibleVal);
			break;
		case "clients" :
			$("#navDiv").html('<img src="_global/images/spacer.gif" width="12" height="14" /><img src="_global/images/navClients.png" alt="" width="817" height="57" />').css("top","17px");
			break;
		case "press" :
			$("#navDiv").html('<img src="_global/images/navPress.png" alt="" width="829" height="57" />').css("top","17px");
			break;
		case "portfolio" :
		case "portfolio:traditional" :
		case "portfolio:contemporary" :
		case "portfolio:mediterranean" :
		case "portfolio:european" :
			$("#navDiv").html('<img src="_global/images/spacer.gif" width="12" height="14" /><img src="_global/images/navPortfolio.png" alt="" width="817" height="57" />').css("top","17px");
			break;
		case "blog" :
			$("#navDiv").html('<img src="_global/images/spacer.gif" width="12" height="14" /><img src="_global/images/navBlog.png" alt="" width="817" height="57" />').css("top","17px");
			break;
		case "contact" :
			$("#navDiv").html('<img src="_global/images/spacer.gif" width="12" height="14" /><img src="_global/images/navContact.png" alt="" width="818" height="57" />').css("top","17px");
			break;
	}
}

function loadSection(navSectionString) {
	//alert (navSectionString);
	// Break the string up into subsections (delimited by :).
	var navSections = navSectionString.split(":");
	//alert (navSections);
	// If we selected the same section that we are already in, don't reload the content.
	if (currentNav != navSectionString) {
		$("#thumbNextBtnDiv").css("visibility","hidden");
		$("#thumbPrevBtnDiv").css("visibility","hidden");
		$("#thumbnailsPortalDiv").css("visibility","hidden");
		$("#backButtonDiv").css("visibility","hidden");
		//alert("section changed.");
		// Load content into main iframe dependent on page that is requested
		$("#emailCopyrightContainerDiv").css("top","0px");
		var targetLoad = "";
		switch (navSections[0]) {
			case 'aboutus' : 
				if (navSections[1]) {
					targetLoad = "aboutus/" + navSections[1].toLowerCase() + ".php";
				}
				else {
					targetLoad = "aboutus/aboutus.php";
				}
				break;
			case 'home' : targetLoad = "home/homecontent.php";
				break;
			case 'services' : 
				if (navSections[1]) {
					targetLoad = "services/" + navSections[1].toLowerCase() + ".php";
				}
				else {
					targetLoad = "services/services.php";
				}
				break;
			case 'clients' : targetLoad = "clients/clients.php";
				break;
			case 'press' : targetLoad = "press/press.php";
				break;
			case 'portfolio' : 
				// If portfolio hash has a 3rd string targetLoad = portfolio/portfolio-details.php? (value of 3rd string)
				if (navSections[2]) {
					targetLoad = "portfolio/portfolio-details.php?propertyName=" + navSections[2];
					$("#backButtonDiv").css("visibility","visible");
					backBtnNavString = navSections[0]+":"+navSections[1];
				}
				// else if portfolio hash has a 2nd string targetLoad = portfolio/(value of 2nd string).php
				else if (navSections[1]) {
					targetLoad = "portfolio/" + navSections[1] + ".php";
					$("#backButtonDiv").css("visibility","visible");
					backBtnNavString = navSections[0];
				}
				else {
					targetLoad = "portfolio/coverpage.php";
				}
				break;
			case 'portfolio:traditional' : targetLoad = "portfolio/traditional.php";
				break;
			case 'portfolio:contemporary' : targetLoad = "portfolio/contemporary.php";
				break;
			case 'portfolio:mediterranean' : targetLoad = "portfolio/mediterranean.php";
				break;
			case 'portfolio:european' : targetLoad = "portfolio/european.php";
				break;
			case 'blog' : targetLoad = "blog/blog.php";
				break;
			case 'contact' : targetLoad = "contact/contact.php";
				break;
		}
		$("#contentIframe").attr("src", targetLoad);
		$("#thumbnailsDiv").html("");
		setNav(navSectionString);
	}
}

function changeHashValue(hashString) {
	//alert(hashString);
	window.location.hash = hashString;
}

var maxScroll = 2141;
var totalThumbnails = 2141;

function showThumbs(thumbImages, propertyName) {

	var numThumbnails = thumbImages.length;
	totalThumbnails = numThumbnails;

	var numImagesToShow = (numThumbnails > 6)?5:numThumbnails;
	var leftCss = (numThumbnails < 5)?(1277-(numImagesToShow*213))/2:0;
	$("#thumbnailsDiv").html("").css("left",leftCss+"px");
	
	for (var i=0; i<numThumbnails; i++) {
		var div = document.createElement('div');
		
		$(div).attr('id', 'thumbDiv'+i).attr('class','thumbnailImageDiv').css('background-image', 'url("' + thumbImages[i] + '")').css('background-repeat','no-repeat').css('width', '213px').css('height','144px');
		$(div).css('position', 'absolute').css('top','0px').css('left', (i*214)+'px');
		$(div).html("<a class='thumbnailCover' href='javascript:showPortfolioImage(\"" + thumbImages[i] + "\", \"" + propertyName + "\", " + i + ");'><img src='portfolio/_images/thumbnail_cover.jpg' width='213' height='144' /></a>");
		$("#thumbnailsDiv").append(div);
			
	}
	


	$("#thumbnailsPortalDiv").css("visibility","visible");
	$("#emailCopyrightContainerDiv").css("top","146px");
	
	
	$("#thumbNextBtnDiv").css("visibility","hidden");
	$("#thumbPrevBtnDiv").css("visibility","hidden");
	if (numThumbnails > 6) {
		$("#thumbNextBtnDiv").css("visibility","visible");
	}
	
	showPortfolioImage(thumbImages[0], propertyName, 0);
	//<div id='thumbDiv"+i+"'>


}

function showThumbs2(thumbImages, propertyName) {
	var htmlString = "";
	// If there are more then 6 images to show, then only show 5 leaving space for previous and next slider buttons.
	var numImages = (thumbImages.length > 6)?5:thumbImages.length;
	for (var i=0; i<thumbImages.length; i++) {
		htmlString += "<a href='javascript:showPortfolioImage(\"" + thumbImages[i] + "\", \"" + propertyName + "\");'><img src='" + thumbImages[i] + "' width='213' height='144'></a><img src='_global/images/spacer.gif' width='1' height='1'>";
	}
	// Approximate calculations.
	//var leftCss = (1281-(numImages*213))/2;
	var leftCss = (thumbImages.length < 5)?(1277-(numImages*213))/2:0;
	maxScroll = thumbImages.length * 213 + ((thumbImages.length-1));
	var widthCss = 10000;
	$("#thumbNextBtnDiv").css("visibility","hidden");
	$("#thumbPrevBtnDiv").css("visibility","hidden");
	// If there are more then 6 images to show, then we need to add previous and next slider buttons.
	if (thumbImages.length > 6) {
		//htmlString = "<img src='portfolio/_images/prev_thumnail.png' alt='' width='24' height='144' /><img src='_global/images/spacer.gif' width='3' height='1'>" + htmlString + "<img src='_global/images/spacer.gif' width='3' height='1'><img src='portfolio/_images/next_thumbnail.png' alt='' width='24' height='144' />";
		//leftCss = leftCss - 27;
		//widthCss = widthCss + 54;
		$("#thumbNextBtnDiv").css("visibility","visible");
	}
	$("#thumbnailsDiv").html(htmlString).css("left",leftCss+"px").css("width",widthCss+"px");
	$("#thumbnailsPortalDiv").css("visibility","visible");
	$("#emailCopyrightContainerDiv").css("top","146px");
	showPortfolioImage2(thumbImages[0], propertyName);
}

function showPortfolioImage2 (thumbImage, propertyName) {
	//alert(thumbImage);
	//$("#contentIframe").showPicture(thumbImage);
	var imageName = thumbImage.substr(thumbImage.lastIndexOf("/")+1);
	//alert(imageName + ", " + propertyName);
	//var navSections = currentNav.split(":");
	//window.location.hash=navSections[0]+":"+navSections[1]+":"+navSections[2]+":"+imageName;
	top.frames['contentIframe'].showPicture(imageName, propertyName);
}

function showPortfolioImage (thumbImage, propertyName, thumbnailID) {
	//alert(thumbImage);
	//$("#contentIframe").showPicture(thumbImage);
	var imageName = thumbImage.substr(thumbImage.lastIndexOf("/")+1);
	//alert(imageName + ", " + propertyName);
	//var navSections = currentNav.split(":");
	//window.location.hash=navSections[0]+":"+navSections[1]+":"+navSections[2]+":"+imageName;
	top.frames['contentIframe'].showPicture(imageName, propertyName);
	$(".thumbnailImageDivOn").attr("class", "thumbnailImageDiv");
	$("#thumbDiv"+thumbnailID).attr("class","thumbnailImageDivOn");
}

var currentScroll = 0;

function prevThumbs() {
	$("#thumbnailsDiv").animate({left: '+=' + 1070}, 1000);
	currentScroll -= 1070;
	if (currentScroll == 0) {
		$("#thumbPrevBtnDiv").css("visibility","hidden");
	}
	$("#thumbNextBtnDiv").css("visibility","visible");
}

function nextThumbs() {
	// 213 (width of one image) * 5 (images) + 4 pixels of spacer.gif = 1069px;
	$("#thumbnailsDiv").animate({left: '-=' + 1070}, 1000);
	$("#thumbPrevBtnDiv").css("visibility","visible");
	currentScroll += 1070;
	//alert ("currentScroll: " + currentScroll + ", maxScroll: " + maxScroll);
	if ((currentScroll + 1070) > ((totalThumbnails/6)*1070)) {
		$("#thumbNextBtnDiv").css("visibility","hidden");
	}
}

function turnImageOn (imageObj) {
	imageObj.src = imageObj.src.replace("_off","_on");
}

function turnImageOff (imageObj) {
	imageObj.src = imageObj.src.replace("_on","_off");
}











