// oghp.js (common javascript for oghp web site)
// columnscroll.js incorporated here
// ColumnScroll.js may be copied freely but I do request a follow,index link (from any Google indexed related page) to www.galleries.com
// smoothly scrolls three columns (wrapped_menu, wrapped_content+wrapped_trailer, and wrapped_ads) so that they are all proportional to the total window size
// The largest column scrolls normally, the other two proportionally such that all start at the top and and at the bottom.
var new_menu_top=0;
var new_content_top=0;
// var new_ads_top=0; // three columns supported - uncomment to get the third. Arbitrary div names are 'menu', 'content', and 'ads'. 
var cs_timeout=null;
function scrolling()
{
  var scrOfY = 0; 
  var menu_height = 0;
//  var ads_height = 0;
  var content_height = 0;
  var body_height = 0;
  var window_height=0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    window_height = window.innerHeight;
  } else if( document.documentElement && document.documentElement.clientHeight ) {
    //IE 6+ in 'standards compliant mode'
    window_height = document.documentElement.clientHeight;
  } else if( document.body && document.body.clientHeight ) {
    //IE 4 compatible
    window_height = document.body.clientHeight;
  }
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
  } else if( document.body && document.body.scrollTop ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
  } else if( document.documentElement && document.documentElement.scrollTop ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
  }

      srcobj=document.getElementById('menu');
      if (srcobj.innerHeight)
      {
	   menu_height = srcobj.innerHeight;
//	   ads_height = document.getElementById('ads').innerHeight;
	   content_height = document.getElementById('content').innerHeight;
	  }
      else
      { 
         if (document.documentElement && document.documentElement.clientHeight)
         {
	      menu_height = srcobj.clientHeight;
//	      ads_height = document.getElementById('ads').clientHeight;
	      content_height = document.getElementById('content').clientHeight;
         }
         else
         {
            if (document.body)
            {
 	         menu_height = srcobj.clientHeight;
//	         ads_height = document.getElementById('ads').clientHeight;
	         content_height = document.getElementById('content').clientHeight;
            }
         }
      }
 body_height=Math.max(menu_height,content_height);//,ads_height);
 var percentage = Math.round(100*scrOfY/(body_height - window_height));
 new_menu_top = Math.round(percentage*(body_height - menu_height)/100);
// new_ads_top = Math.round(percentage*(body_height - ads_height)/100);
 new_content_top = Math.round(percentage*(body_height - content_height)/100);
 if (cs_timeout) clearTimeout(cs_timeout); // this code cancels a pending scroll if user wants more
 cs_timeout = setTimeout("cs_timeout=null;smoothscroll();",200); // idea is this becomes a single timeout occuring 200 ms AFTER the last scroll
}
function smoothscroll()
{
 var done=true;
 var menu_adjust=0;
// var ads_adjust=0;
 var content_adjust=0;
 var sf=1; // minimum step size
 var menu_top = parseInt(document.getElementById('menu').style.top); 
// var ads_top = parseInt(document.getElementById('ads').style.top); 
 var content_top = parseInt(document.getElementById('content').style.top); 
 menu_adjust = new_menu_top - menu_top; 
// ads_adjust = new_ads_top - ads_top; 
 content_adjust = new_content_top - content_top; 
 // adjust the step size to be the square root of the needed adjustment - this will start fast and ramp down. Extra code to handle negatives properly.
 if (menu_adjust > sf) { menu_adjust = Math.round(Math.sqrt(menu_adjust)); done=false; }
 else if (menu_adjust < (-sf)) { menu_adjust = -Math.round(Math.sqrt(-menu_adjust)); done=false; }
 if (content_adjust > sf) { content_adjust = Math.round(Math.sqrt(content_adjust)); done=false; }
 else if (content_adjust < (-sf)) { content_adjust = -Math.round(Math.sqrt(-content_adjust)); done=false; }
// if (ads_adjust > sf) { ads_adjust = Math.round(Math.sqrt(ads_adjust)); done=false; }
// else if (ads_adjust < (-sf)) { ads_adjust = -Math.round(Math.sqrt(-ads_adjust)); done=false; }
 document.getElementById('menu').style.top = (menu_top + menu_adjust) +"px";
// document.getElementById('ads').style.top = (ads_top + ads_adjust)+"px";
 document.getElementById('content').style.top = (content_top + content_adjust)+"px";
 if (!done) setTimeout("smoothscroll()",50); // go one adjustment stepsize every 50 milliseconds
}

//document.getElementById('menu').style.top = "2px";
//document.getElementById('ads').style.top = "2px";
//document.getElementById('content').style.top = "2px";
window.onscroll=scrolling;
// end columnscroll.js

// dynamic tooltip code - used to display course image and info
// This code is from Dynamic Web Coding www.dyn-web.com 
// Copyright 2002 by Sharon Paine Permission granted to use this code as long as this entire notice is included.
// Courtesy of SimplytheBest.net - http://simplythebest.net/scripts/

var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ns6 = (dom && !ns4 && !ns5 && !ie5) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns6 && !ns5 && !ns4 && !ie4 && !ie5) ? true : false;

var origWidth, origHeight;
if (ns4) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

if (nodyn) { event = "nope" }
var tipFollowMouse	= true;	
var tipWidth		= 500;
var offX		 	= 30;	// how far from mouse to show tip
var offY		 	= -100; 
var tipFontFamily 	= "Verdana, arial, helvetica, sans-serif";
var tipFontSize		= "10pt";
var tipFontColor		= "#000000";
var tipBgColor		= "#DDECFF"; 
var origBgColor 		= tipBgColor; // in case no bgColor set in array
var tipBorderColor 	= "#000080";
var tipBorderWidth 	= 2;
var tipBorderStyle 	= "ridge";
var tipPadding	 	= 4;
var scrOllY = 0;

var messages = new Array();
messages[0] = new Array("images/null.gif","null","#ffffff");  // for golf course communities
messages[1] = new Array("images/null.gif","null","#ffffff");  // for oceanfront properties
messages[2] = new Array("images/null.gif","null","#ffffff");  // for maps homes
messages[3] = new Array("images/crosshairs.gif","null","#ffffff");  // for maps X

if (document.images) {
	var theImgs = new Array();
	for (var i=0; i<messages.length; i++) {
  	theImgs[i] = new Image();
		theImgs[i].src = messages[i][0];
  }
}

var startStr = '<table width="' + tipWidth + '"><tr><td valign="top"><img src="';
var midStr = '" border="0" align=left hspace="3" vspace="2">';
var endStr = '</td></tr></table>';

var tooltip, tipcss;

function initTip() {
	if (nodyn) return;
	tooltip = (ns4)? document.tipDiv.document: (ie4)? document.all['tipDiv']: document.getElementById('tipDiv');
	tipcss = (ns4)? document.tipDiv: tooltip.style;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tipcss.width = tipWidth+"px";
		tipcss.fontFamily = tipFontFamily;
		tipcss.fontSize = tipFontSize;
		tipcss.color = tipFontColor;
		tipcss.backgroundColor = tipBgColor;
		tipcss.borderColor = tipBorderColor;
		tipcss.borderWidth = tipBorderWidth+"px";
		tipcss.padding = tipPadding+"px";
		tipcss.borderStyle = tipBorderStyle;
	}
	if (tooltip&&tipFollowMouse) {
		if (ns4) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = trackMouse;
	}
}

var t1,t2;	// for setTimeouts
var tipOn = false;	// check if over tooltip link
function doTooltip(evt,num) {

	if (!tooltip) return;
//	if (num==2) { tipWidth = 600; tipcss.width = "600px"; } else { tipWidth = 500; tipcss.width = "500px"; }
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	// set colors if included in messages array
	if (messages[num][2])	var curBgColor = messages[num][2];
	else curBgColor = tipBgColor;
	if (messages[num][3])	var curFontColor = messages[num][3];
	else curFontColor = tipFontColor;
	if (ns4) {
		var tip = '<table bgcolor="' + tipBorderColor + '" width="' + tipWidth + '" cellspacing="0" cellpadding="' + tipBorderWidth + '" border="0"><tr><td><table bgcolor="' + curBgColor + '" width="100%" cellspacing="0" cellpadding="' + tipPadding + '" border="0"><tr><td>'+ startStr + messages[num][0] + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr + '</td></tr></table></td></tr></table>';
		tooltip.write(tip);
		tooltip.close();
	} else {//if (ie4||ie5||ns5) {
        if (num==1) var tip = startStr + messages[num][0] + '" width="150" height="100' + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
        if (num==2) var tip = startStr + messages[num][0] + '" width="128" height="100' + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		else        var tip = startStr + messages[num][0]                               + midStr + '<span style="font-family:' + tipFontFamily + '; font-size:' + tipFontSize + '; color:' + curFontColor + ';">' + messages[num][1] + '</span>' + endStr;
		tipcss.backgroundColor = curBgColor;
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}

var mouseX, mouseY;
function trackMouse(evt) {
	mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
	mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	if (tipOn) positionTip(evt);
}

function positionTip(evt) {

  scrollX = document.body.scrollLeft;
  scrollY = document.body.scrollTop+document.documentElement.scrollTop;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOllX = window.pageXOffset;
    scrOllY = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOllX = document.body.scrollLeft;
    scrOllY = document.body.scrollTop;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOllX = document.documentElement.scrollLeft;
    scrOllY = document.documentElement.scrollTop;
  } 
  //if (scrollY == 0) scrollY = map.scrollTop;

	if (!tipFollowMouse) {
		mouseX = (ns4||ns5)? evt.pageX: window.event.clientX + scrollX;
		mouseY = (ns4||ns5)? evt.pageY: window.event.clientY + scrollY;
	}

	// tooltip width and0 height
	var tpWd = (ns4)? tooltip.width: (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ns4)? tooltip.height: (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	// document area in view (subtract scrollbar width for ns)
	//var winWd = (ns4||ns5)? window.innerWidth-20+window.pageXOffset: document.body.clientWidth+document.body.scrollLeft;
	//var winHt = (ns4||ns5)? window.innerHeight-20+window.pageYOffset: document.body.clientHeight+document.body.scrollTop;
        if( typeof( window.innerWidth ) == 'number' ) {
           //Non-IE
           winWd = window.innerWidth;
           winHt = window.innerHeight;
         } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
           //IE 6+ in 'standards compliant mode'
           winWd = document.documentElement.clientWidth;
           winHt = document.documentElement.clientHeight;
         } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
            //IE 4 compatible
           winWd = document.body.clientWidth;
           winHt = document.body.clientHeight;
         }

	// check mouse position against tip and window dimensions
	// and position the tooltip 
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = (ns4)? mouseX-(tpWd+offX): mouseX-(tpWd+offX)+"px";
	else tipcss.left = (ns4)? mouseX+offX: mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = (ns4)? winHt-(tpHt+5): winHt-(tpHt+5)+"px";
    else if ((mouseY+offY)<(scrollY+5)) tipcss.top = (ns4)?scrollY+5 : scrollY+5+"px";
    	 else tipcss.top = (ns4)? mouseY+offY: mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);

//window.status="scrollY="+scrollY+"\nmouseY="+mouseY+"\noffY="+offY+"\ntpHt="+tpHt+"\nclientY="+window.event.clientY+"\nwinHt="+winHt+"\ntipcss.top="+tipcss.top+"\nbody.scrolltop="+document.body.scrollTop+"\nelement.scrolltop="+document.documentElement.scrollTop;
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

function showTip(image,text)
{
 messages[0][0]=image;
 messages[0][1]=text; 
 doTooltip(event,0); 
} 

function showHome(image,text)
{
 messages[2][0]=image;
 messages[2][1]=text; 
 doTooltip(event,2); 
} 

var scrolltimer;
var maptop;
var scrolltop;
function scrollmap()
{
//if (document.documentElement && !document.documentElement.scrollTop) scrolltop=0;
//else if (document.documentElement && document.documentElement.scrollTop) scrolltop=document.documentElement.scrollTop;
//else if (document.body) scrolltop=document.body.scrollTop;
 scrolltop = document.body.scrollTop+document.documentElement.scrollTop;
 if( typeof( window.pageYOffset ) == 'number' ) {
   //Netscape compliant
   scrolltop = window.pageYOffset;
 } else if( document.body && document.body.scrollTop ) {
   //DOM compliant
   scrolltop = document.body.scrollTop;
 } else if( document.documentElement && document.documentElement.scrollTop ) {
   //IE6 standards compliant mode
   scrolltop = document.documentElement.scrollTop;
 } else scrolltop = (document.compatMode=="CSS1Compat")?document.documentElement.scrollTop : document.body.scrollTop;
 
if (scrolltop>maptop) document.getElementById('map_canvas').style.top=scrolltop+"px";
else document.getElementById('map_canvas').style.top=maptop+"px";
scrolltimer=setTimeout("scrollmap()",250);
}
function stoptimer()
{
 if (scrolltimer) clearTimeout(scrolltimer);
}

function initstuff() 
{
 initTip();
 maptop = document.getElementById('map_canvas').offsetTop;
// scrollmap(); // this code disabled to allow map_canvas to float with the rest of the menu div
}

window.onload = initstuff;
window.unload = stoptimer;



