var roughList='';

function highlighter(pageTitle) {
	
//var splitter=document.title;
//var pageName=splitter.split(" ");
//var changeIt=pageName[3].toLowerCase();

var changeIt=pageTitle;
if (changeIt=="custom"){
	
} else if (changeIt=="rv"){
	var theTag=document.getElementById(changeIt);
theTag.style.color='#ffffff';
theTag.style.backgroundColor='#9D0224';
} else if (changeIt=="apt"){
	var theTag=document.getElementById('apt');
theTag.style.color='#ffffff';
theTag.style.backgroundColor='#573f97';
} else {
var theTag=document.getElementById(changeIt);
theTag.style.color='#ffffff';
theTag.style.backgroundColor='#788103';
} 


}//end highlighter function

function pictureFlip($number){
	
var thePic=document.getElementById("mainPhoto");
var thePath="photos/lg/";

thePic.src=thePath+$number+".jpg";
}

function forSaleFlip($max,$listing){
var thePict=document.getElementById($listing);
var thePath="homes/";

var chopper=thePict.src.split("_");
var chopper2=chopper[1].split(".");
var $numb=chopper2[0];

if ($numb<$max){
$numb++;
} else {
$numb=1;
}
thePict.src=thePath+$listing+"_"+$numb+".jpg";
}

function bumpUp(){
	
	var counter=document.getElementById('imgCount');
	counter.value ++;

}

function offerPop(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=450,height=330,left=0,top=0');");
}






function aptGallery(curPic,upORdown){

filePath="./apts/";
imgArray=roughList.split(',');
theNav=document.getElementById('imgNav');
curPicName=imgArray[curPic];

totPic=imgArray.length;
lastPic=imgArray.length-1;

if (upORdown=="next"){
	targe=imgArray[curPic];
	whichpic=filePath+targe;
} else if (upORdown=="down"){
	targe=imgArray[curPic-1];
	whichpic=filePath+targe;
} else {
	targe=curPicName
	whichpic=filePath+targe;
}

var nextOne=curPic+1;
var prevOne=curPic-1;

nextLink=" <a href=\"javascript: aptGallery("+nextOne+",'next');\">next ></a>";
prevLink="<a href=\"javascript: aptGallery("+prevOne+",'prev');\">< previous</a> ";


theNumber=targe.replace('.jpg','');

if (curPic==0){
	$message=theNumber+" of "+totPic+nextLink;
} else if (curPic==lastPic){
	$message=prevLink+theNumber+" of "+totPic;
} else{
	$message=prevLink+theNumber+" of "+totPic+nextLink;
}
document.getElementById('aptImg').src = whichpic;	
theNav.innerHTML=$message;


}







function showCase(upORdown,curPic,totPic) {
filePath="./";

if (upORdown=="next"){
	targe=curPic+1;
	whichpic=filePath+targe+".jpg";
}else{
	targe=curPic-1;
	whichpic=filePath+targe+".jpg"
}

document.getElementById('mainImg').src = whichpic;	


//prevPic=curPic-1;
//nextPic=curPic+1;

nextLink=" <a href=\"javascript: showCase('next',"+targe+","+totPic+");\">next ></a>";
prevLink="<a href=\"javascript: showCase('prev',"+targe+","+totPic+");\">< previous</a> ";

if (targe==1){
	$message=targe+" of "+totPic+nextLink;
} else if (targe==totPic){
	$message=prevLink+targe+" of "+totPic;
} else{
	$message=prevLink+targe+" of "+totPic+nextLink;
}

	
document.getElementById('picControl').innerHTML=$message;

}