

// WINDOW OPENER FUNCTION
newWin = '';
function openWindow(pageName,winWidth,winHeight){
	
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
 /* window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );*/

	

if (!self.screenX){ // Opera, IE: ignore chrome - gives screen coords of start of browser content
		//alert(self.screenLeft);    alert(self.screenTop);
		
		leftCoord = self.screenLeft + 150;
		topCoord = self.screenTop + -10
		
		
		//alert(leftCoord+ " "+topCoord);
	} else if (self.screenX){ // Mozilla, NN: returns position of outside chrome. top,left corner of chrome
		//alert(self.screenX); alert(self.screenY); 
		leftCoord = self.screenX + 150;
		topCoord = self.screenY + 140;
		//alert(leftCoord+ " "+topCoord);
	}

		
attributes = eval("'width=" + winWidth + ",height=" + winHeight +  ",left=" + leftCoord + ",top="+ topCoord + ",resizable=1,toolbar=0,location=0,status=0,scrollbars=1'");


if (newWin && newWin.open){

newWin.close();
newWin = window.open(pageName,'newWin',attributes);
newWin.focus();
//newWin='';

} else if (newWin && newWin.closed){

newWin = window.open(pageName,'newWin',attributes);

newWin='';
}else{

newWin = window.open(pageName,'newWin',attributes);

newWin='';
}

return false;


}



// ########## TESTIMONIALS FUNCTION ################

//GENERATE RANDOM NUMBER
function randomNumber(limit){
  return Math.floor(Math.random()*limit);

}



function writeTestimonial(whichPosition){ // whichPosition==left, right or only
// DECLARE GLOBAL VARIABLES
testimonial = new Array(6);
testimonyName = new Array(6);
limit = testimonial.length;



//POPULATE ARRAY
testimonial[1]="Thank you for the great job you and your team did on the sale of our home... you exceeded our expectations in every way.  Your responsiveness, professionalism, teamwork and willingness to go the extra mile for your clients truly diferentiate you from any other agent I have ever worked with.";
testimonyName[1] = "Chris Xystros";

testimonial[2]="Paul&#39;s professionalism, responsiveness, knowledge, and genuine level of care are of tremendous value to his clients... I have moved several times and Paul is the best I have met by far!";
testimonyName[2]="Mr. &amp; Mrs. Keith R. Brown";

testimonial[3]="... I highly recommend Paul Fuqua... he and his staff are, simply put, &quot;The Best&quot; team I have ever seen assembled.";
testimonyName[3]="Bruce Jones";

testimonial[4]="Paul and his team were always there for us!  They always supported us and helped us through the whole process.  We love them and everything they did for us.  We will most certainly use them in the future and will continue to refer our friends to them.  Thanks for everything!";
testimonyName[4]="Mr. &amp; Mrs. Sean W. Boyer";

testimonial[5]="I would like to thank you for the professionalism that you and your staff exhibited during the sale of my home in Suffolk.  This was a difficult time for me and you assured me whenever I had a question.";
testimonyName[5]="John M. Nemish";

testimonial[6]="I just wanted to thank you for your assistance in closing out the Jonathan&#39;s Cove subdivision... we appreciate the outstanding job you have done.";
testimonyName[6]="C. Torrey Breeden, President<br>Lynnhaven Homes";


	
	//TAKE RANDOM NUMBER AND OUTPUT CORRESPONDING TESTIMONIAL AND NAME
	whichTestimonial = (randomNumber(limit) +1);
	
	
	
	// if this is on the home page, make sure you don't get duplicate testimonials both boxes.
	
if (whichPage=="home"){
	
		
	leftTestimonial = whichTestimonial; // the random number from above
	
	if (leftTestimonial == limit){
		rightTestimonial = whichTestimonial-1;
	} else {
	
		rightTestimonial = whichTestimonial +1
	}

	
			if (whichPosition=="left"){
					htmlOutput = '&quot;' + testimonial[leftTestimonial] + '&quot;';
					htmlOutput += '<br /><span class="testimonialName">' + testimonyName[leftTestimonial] + '</span>';
					leftTest=leftTestimonial; //set a flag so that rhe Right if statement can determine if it will be a duplicate of this testimonial.
					//alert("LEFT left="+leftTestimonial + " right=" +rightTestimonial +" leftTest="+leftTest);
			} 
			
			if (whichPosition=="right"){
				//alert("RIGHT left="+leftTestimonial + " right=" +rightTestimonial +" leftTest="+leftTest);
				
				// if this testimonial is the same one as the left box,
				if (rightTestimonial == leftTest){ 
				
				//test to see if the # is greater than the # of testimonials in the array
				// if righttestimonial is greater than total # of testimonials, & the left Test. is the last one, make Right testimonial the first testimonial
				if ((rightTestimonial > limit) && (leftTest == limit)){ 
				rightTestimonial = 1;
				//alert("RIGHT left="+ leftTestimonial + " right=" + rightTestimonial+" limit="+limit);

		 			  } else { // if the left testimonial is not the last one, subtract 1 from it
						  rightTestimonial = leftTest -1;
					  }
				}
				
				htmlOutput = '&quot;' + testimonial[rightTestimonial] + '&quot;';
					htmlOutput += '<br /><span class="testimonialName">' + testimonyName[rightTestimonial] + '</span>';
			}
				
							
	document.write(htmlOutput);
			
			
	} else if (whichPage!="home")  {
		
	
	htmlOutput = '&quot;' + testimonial[whichTestimonial] + '&quot;';
	htmlOutput += '<br /><span class="testimonialName">' + testimonyName[whichTestimonial] + '</span>';
							
	document.write(htmlOutput);
	}


} // end function




 //THIS FUNCTION GETS THE URL OF THE LINK ASSOCIATED WITH THE CURRENTLY SELECTED
 // TD CELL  or other element (ie, h1, h2) SO THAT YOU CAN CLICK ON IT AS A BUTTON, NOT JUST THE LINK.
 // link must have an id

function go(linkID,theTarget,nwidth,nheight){

if (!theTarget){
newURL = document.getElementById(linkID);
document.location.href = newURL;
} else if (theTarget){

//If height or width is specified, rewrite the options to include them. Otherwise default to 800wide by 500high

	newOptions = "";

	if (nwidth){
	newOptions = "width="+nwidth+",";
	} else {
	newOptions = "width=800,";
	}
	
	if (nheight){
	newOptions += "height="+nheight+",";
	} else {
	newOptions += "height=500,";
	}

newOptions += "scrollbars=1,toolbar=1,location=1,status=1,resizable=1";
//alert (newOptions);


newURL = document.getElementById(linkID);
newWin = window.open(newURL, 'newWin', newOptions);

 } //endif


} //end function

