﻿var showMsgDuration = 50000; // time in milliseconds


function showMsgDiv(curMsgDuration)
	{
	dContent = document.getElementById('adminMessageContent');
	if (dContent.innerHTML != '')
		{
		if (gettype(curMsgDuration)!='integer') curMsgDuration = showMsgDuration;
		dMessage = document.getElementById('adminMessageDiv');
		h = dContent.offsetHeight;
		inc = Math.floor(h / 20);
		growDiv(dMessage.id, h , inc);
		if (curMsgDuration > 0)  
			{
			setTimeout(hideMsgDiv, curMsgDuration);
			}
		}
	}		


function hideMsgDiv(forceHide)
	{
	dContent = document.getElementById('adminMessageContent');
	h = dContent.offsetHeight;
	inc = Math.floor(h / 20);
	if (showMsgDuration >0 || forceHide) shrinkDiv('adminMessageDiv', 0, inc);
	}


	
////
function dsSearchSubmit(uniqueIdentifier)
	{
	zip =  document.getElementById('dsZip_id_' + uniqueIdentifier).value;
	spec = document.getElementById('dsSpecialty_id_' + uniqueIdentifier).value;
	if (zip == '' || zip == 'ZIP CODE')
		{
		msg = 'Please enter your ZIP code to search for a dentist';
		showHelp(msg);
		setTimeout(hideHelp, 2000);
		} else {
		form = document.getElementById('formDentistSearch_' + uniqueIdentifier);
		form.submit();
		}
	}
	

////
function showHelp(content)
	{
	d2 = document.getElementById('helpdivcontent');
	d2.innerHTML = content;
	document.getElementById('helpdiv').style.display = 'block';
	}
////
function hideHelp()
	{
	document.getElementById('helpdiv').style.display = 'none';
	}

	
// Follow the mouse script

var divName = 'helpdiv'; // div that is to follow the mouse
                       // (must be position:absolute)
var offX = 7;          // X offset from mouse position
var offY = 10;          // Y offset from mouse position

function mouseX(evt) {if (!evt) evt = window.event; if (evt.pageX) return evt.pageX; else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft); else return 0;}
function mouseY(evt) {if (!evt) evt = window.event; if (evt.pageY) return evt.pageY; else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return 0;}

function follow(evt) 
	{
	if (document.getElementById) 
		{
		
		var obj = document.getElementById(divName); 
		obj.style.visibility = 'visible';
		
		
		
		var left =  (parseInt(mouseX(evt))+offX) ;
		var top =  (parseInt(mouseY(evt))+offY) ;
		if (top < 0) top = 0;
		if (left < 0) left = 0;

		w= getWidth();
		h= getHeight();


		if (left + parseInt(obj.offsetWidth) > w) left = w - obj.offsetWidth;
		if (top + parseInt(obj.offsetHeight) > h) top = h - obj.offsetHeight;

		obj.style.left = left + 'px';
		obj.style.top = top + 'px';
		}
	}

function showHideSubNavigation(id)
	{
	var show = true;
	div = document.getElementById('mainSubnav_' + id);
	if (div.style.display == 'block') show = false;
	hideMainSubNavs();
	if (show)
		{
		disableChange = 'mainNavImg_' + id;
		div.style.display = 'block';
		img = document.getElementById('mainNavImg_' + id);
		src = img.src;
		src = src.replace('.gif', '-down.html');
		src = src.replace('-over-down.html', '-down.html');
		img.src = src;
		}	
	}
function hideMainSubNavs()
	{
	disableChange = null;
	divs = document.getElementsByTagName('div');
	for(i=0;i<divs.length;i++)
		{
		if (divs[i].id.substr(0, 'mainSubnav_'.length) == 'mainSubnav_') divs[i].style.display = 'none';
		}
	imgs = document.getElementsByTagName('img');
	str = '';
	for(i=0;i<imgs.length;i++)
		{
		str  += imgs[i].src + "\n";
		if (imgs[i].id.substr(0, 'mainNavImg_'.length) == 'mainNavImg_') 
			{
			src = imgs[i].src;
			src = src.replace('-down.html', '.gif');
			imgs[i].src = src;
			}
		}
	}




document.onmousemove = follow;

