// Code for Popup
// Made for Two River Mortgage
// Tempus Web Services
//
DynAPI.setLibraryPath('lib/')
DynAPI.include('dynapi.api.*')
DynAPI.include('dynapi.ext.inline.js')
DynAPI.include('dynapi.event.*')
DynAPI.include('dynapi.util.thread.js')
DynAPI.include('dynapi.util.pathanim.js')

var midPos=0
var rightPos=0
DynAPI.onLoad = function() {
	setPositions();
}
function setPositions()	{

	DynAPI.document.findDimensions();
	var listener = new EventListener();
	listener.onpathstart = function(e) {
		status = "start";
	}
	listener.onpathrun = function(e) {
		var o = e.getSource();
		status = "play "+o.x+" "+o.y;
	}
	listener.onpathstop = function(e) {
		var o = e.getSource();
		status = "stop "+o.x+" "+o.y;
	}
	popupx=220;
	popupy=500;
	myconventionaldescription=DynAPI.document.all["conventionaldescription"]
	myconventionaldescription.setSize(300,120);
	myconventionaldescription.setBgColor('#ffffff')
	myconventionaldescription.moveTo(popupx,popupy);
	myconventionaldescription.addEventListener(listener);

	myjumbodescription=DynAPI.document.all["jumbodescription"]
	myjumbodescription.setSize(300,90);
	myjumbodescription.setBgColor('#ffffff')
	myjumbodescription.moveTo(popupx,popupy);
	myjumbodescription.addEventListener(listener);
	
	myrefinance=DynAPI.document.all["refinancedescription"]
	myrefinance.setSize(300,140);
	myrefinance.setBgColor('#ffffff')
	myrefinance.moveTo(popupx,popupy);
	myrefinance.addEventListener(listener);

	myinterestonly=DynAPI.document.all["interestonlydescription"]
	myinterestonly.setSize(500,200);
	myinterestonly.setBgColor('#ffffff')
	myinterestonly.moveTo(popupx,popupy);
	myinterestonly.addEventListener(listener);
	
}
function showPopup (popupName)	{
	if( popupName == "refinancedescription")	{
		myrefinance.setVisible(true)
	} else if ( popupName == "conventionaldescription"){
		myconventionaldescription.setVisible(true)
	} else if ( popupName == "jumbodescription"){
		myjumbodescription.setVisible(true)
	} else if ( popupName == "interestonlydescription"){
		myinterestonly.setVisible(true)
	}
}
function hidePopup (popupName)	{
	if( popupName == "refinancedescription")	{
		myrefinance.setVisible(false)
	} else if ( popupName == "conventionaldescription"){
		myconventionaldescription.setVisible(false)
	} else if ( popupName == "jumbodescription"){
		myjumbodescription.setVisible(false)
	} else if ( popupName == "interestonlydescription"){
		myinterestonly.setVisible(false)
	}

}
function togglePopup(whichOne, myevent,myToggle)	{
	if(myToggle)	{
		getLocation(myevent);	
		myobject=document.getElementById(whichOne).style;
		myobject.top=ycurs-20;
		myobject.left=xcurs+16;
		myobject.MozOpacity = 0;
	    myobject.KhtmlOpacity = 0;
    	myobject.filter = "alpha(opacity=0)"; 
		document.getElementById(whichOne).style.display="block";
		opacity(whichOne, 0, 100, 500);
	} else {
		opacity(whichOne, 100, 0, 500);
		document.getElementById(whichOne).style.display="none";
	}
}
//declare these as global variables so they can be used by all functions
var xcurs=0;
var ycurs=0;

//this function stores the cursor position after each mousemove event
//see the second half of this function at the bottom of html body
function getLocation(e){
	if (navigator.appName == 'Netscape'){
		xcurs = e.pageX;
		ycurs = e.pageY;
	}else{
	//IE version
		xcurs = event.clientX;
		ycurs = event.clientY + document.body.scrollTop;
	}
	//alert("x="+xcurs+" y="+ycurs);
}