/*
	File: flower_pop_handler.js

	This file handles the the show and hide events for "pick a flower" menu in home page.
	
	Modifications: 
		2007 Dec 27 - Now display a category image inside PickAFlower popup
	
	
*/

var secs;
var timerID = null;
var timerRunning = false;
var delay = 1000;
var manu_name;

function findPos(obj)
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function setLyr(obj,lyr)
{
	var coors = findPos(obj);
	var x = document.getElementById(lyr);
	var val_x = parseInt(coors[0]) + 60;
	var val_y = parseInt(coors[1]) - 5;
	x.style.top = val_y + 'px';
	x.style.left = val_x + 'px';
}

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 2;
    StopTheClock();
    StartTheTimer();
}

function OSHideAll()
{
document.getElementById('flower_pop').style.visibility = "hidden";
}

/*
	Function: OSShowMenu
	
	last modification:
		2007 Dec 18
	
	it shows the pop up for Pick a Flower. Remember that it uses
	jquery framework :)
	
	Parameters:
		cat_name - String, name of the category
		cat_description - String, description of the category
		cat_image - String, a picture for the category.
*/
function OSShowMenu(menu_name_x,pic,cat_name,cat_description, cat_image)
{
document.getElementById('flower_pop').style.visibility = "hidden";
menu_name = menu_name_x;
setLyr(pic,menu_name);
/*
	we change the content of "cat_name" and "cat_description" pharragraph using
	jquery framework.
*/
$('#cat_name').html(cat_name);
$('#cat_description').html(cat_description);

/*
	Note: 2007 Dec 27
	We change the image for the category
*/

$('#cat_image').attr("src", cat_image);
$('#cat_image').attr("alt", cat_name);

document.getElementById(menu_name).style.visibility = "visible";

}