initialize = function(){
	showHideNav();
},


//for IE bug
showHideNav = function() {
	var dropdownDiv = document.getElementById("topnav");
	
	if(dropdownDiv){
		var dropdowns = dropdownDiv.getElementsByTagName("li");
	
		for (var i=0; i<dropdowns.length; i++) {
			dropdowns[i].onmouseover=function() {
				this.className+=" over";
			}
			dropdowns[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" over\\b"), "");
			}
		}
	}
},

//turn on photo credits for certain photos
showCredits = function(portfolioName,photoNum) {	
	if(portfolioName == "wilton_house"){
		if(photoNum=="3"||photoNum=="4"||photoNum=="5"||photoNum=="6"||photoNum=="7"||photoNum=="8")
			$("photo-author").style.display = "block";	
		else	
			$("photo-author").style.display = "none";
	}
	
	if(portfolioName == "west_village"){
		if(photoNum=="1"||photoNum=="2"||photoNum=="4") {
			$("photo-author-1").style.display = "block";
			$("photo-author").style.display = "none";			
		} else if (photoNum=="3") {
			$("photo-author-1").style.display = "none";		
			$("photo-author").style.display = "block";
		} else {	
			$("photo-author").style.display = "none";
			$("photo-author-1").style.display = "none";
		}	
	}
	
	if(portfolioName == "showhouse"){
      if(photoNum=="1") {
			$("photo-author").style.display = "block";
			$("photo-author-1").style.display = "none";       
      } else if (photoNum=="2") {
			$("photo-author").style.display = "none";
			$("photo-author-1").style.display = "block";       
      } else {
			$("photo-author").style.display = "none";
			$("photo-author-1").style.display = "none";      
      }
    }      

	if(portfolioName == "hd_showhouse"){
        if(photoNum=="1" || photoNum=="2" || photoNum=="3") {
            $("photo-author").style.display = "block";
		} else {	
			$("photo-author").style.display = "none";
	   }
	}			
},

showImg = function(type, imgCnt){
	var showcaseImg = $("showcase_img");
	var folder = $("showcase_img").className;
	showcaseImg.src = "/images/"+type+"/"+folder+"/"+folder+"-"+imgCnt+".jpg";
	showCredits(folder,imgCnt);
},

iterator = function(direction, iteratorType){
	var totalImgCnt = parseInt($("total-photo-number").innerHTML);
	var currentImgCnt = parseInt($("current-photo-number").innerHTML);	
	
	if(currentImgCnt=="1"){
		if(direction == "next"){
			currentImgCnt++;
			showImg(iteratorType, currentImgCnt);
			$("previous_off").style.display = "none";
			$("previous_btn").style.display = "inline";
			
			if(currentImgCnt==totalImgCnt){ //in cases where totalImgCnt=2
				$("next_off").style.display = "inline";
				$("next_btn").style.display = "none";
			}
		}	
	} else if( currentImgCnt < totalImgCnt ){
		
		if(direction == "previous") currentImgCnt--;
		if(direction == "next") currentImgCnt++;
		showImg(iteratorType, currentImgCnt);
		
		if (currentImgCnt==1){ 
			$("previous_off").style.display = "inline";
			$("previous_btn").style.display = "none";	
		}
		
		if (currentImgCnt == totalImgCnt){ 
			$("next_off").style.display = "inline";
			$("next_btn").style.display = "none";	
		}
		
	} else if (currentImgCnt == totalImgCnt){ 
		
		if(direction == "previous"){
			currentImgCnt--;
			showImg(iteratorType, currentImgCnt);
			$("next_off").style.display = "none";
			$("next_btn").style.display = "inline";
			
			if(totalImgCnt==2){ //in cases where totalImgCnt=2
				$("previous_off").style.display = "inline";
				$("previous_btn").style.display = "none";
			}
		}	
	}
	
	$("current-photo-number").innerHTML = currentImgCnt;
},

Event.observe(window, 'load', initialize);