/**************************************************************************
* iFrame Calendar - By Nathan DeJong for AccessDubuqe.com
* The basic drawing of calendar based off of Basic Calendar
* 3 files required
* calendar.html - drawing and navigating of calendar 
* calendar.js - opening and closing of calendar - included in head
* your page - page you want calendar on - must have iframe defined on it
*
* Basic Calendar-By Brian Gosselin at http://scriptasylum.com/bgaudiodr/
* Script featured on Dynamic Drive (http://www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for full source code
**************************************************************************/

// Variable to store active text box to post date to
var inputbox;

// Positions and then shows calendar
function openCal(textbox){
	inputbox = textbox;
	xOffset = (inputbox.size * 6)+25;
	document.getElementById("CalFrame").style.left = findPosX(inputbox)+xOffset;
	document.getElementById("CalFrame").style.top  = findPosY(inputbox);
	document.getElementById("CalFrame").style.display = "inline";
}

// Hides Calendar from view
function closeCal(){
	document.getElementById("CalFrame").style.display = "none";
}

// Puts date into active text box
function fillInDate(date){
	inputbox.value = date;
}

// Finds the top left x coord of obj passed to it
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

// Finds the top left y coord of obj passed to it
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}