// shared.js script, version 2.1, 08-13-03, Hot Pepper, Inc., http://www.hotpepper.com

// global vars ======================================================
var loc = location.pathname.split('/');
loc.length = loc.length - 1; // removes filename 

var d = location.pathname.replace(/\/[^\/]*/g,'../'); // return one depth too deep, see next line for fix
d = d.substring(0,(d.length-3)); // turns this: ../../ into this ../
// /global vars ======================================================

// img preloads =====================================================
/*
hh = new Image(); hh.src = "/pix/hh.gif"; hh_roll = new Image(); hh_roll.src = "/pix/hh_roll.gif";
*/	
// /img preloads =====================================================

// popup window functions ==========================================
function popFlex(URL,winName,W,H,scroll) {
	if (scroll == "no")
		{scroll = "scrollbars=no";}
	else if (scroll == "yes")
		{scroll = "scrollbars";}
	window.open(URL, winName,"top=0,left=30,width="+W+",height="+H+",resizable=no,"+scroll+"");
	}	
// /popup window functions ==========================================

var ver5up = false;
if (document.getElementById) {ver5up = true;}
function showhide(display,divid) {
	// call like this: <a href="" onmouseover="showHide('block','myDiv');" onmouseout="showHide('none','myDiv');"
	if (ver5up) {
		document.getElementById(divid).style.display = display;
		}
	}

/*
function moveup(formname,selectlist)
	{
	if (selectlist.selectedIndex == -1 || selectlist.selectedIndex == 0) {return false;}

	for(var i = 0; i < selectlist.options.length; i++)
		{
		if (selectlist.options[i].selected && selectlist.options[i] != "" && selectlist.options[i] != selectlist.options[0])
			{
			var tmpval = selectlist.options[i].value;
			var tmpval2 = selectlist.options[i].text;
			selectlist.options[i].value = selectlist.options[i - 1].value;
			selectlist.options[i].text = selectlist.options[i - 1].text
			selectlist.options[i-1].value = tmpval;
			selectlist.options[i-1].text = tmpval2;
      }
		}

	var oldpos = selectlist.selectedIndex;
	var newpos = oldpos - 1;
	selectlist.options[oldpos].selected = false;
	selectlist.options[newpos].selected = true;

	sethidden(formname,selectlist);
	}
function movedown(formname,selectlist)
	{
	if (selectlist.selectedIndex == -1 || selectlist.selectedIndex == (selectlist.length -1)) {return false;}

	for(var i = 0; i < selectlist.options.length; i++)
		{
		if (selectlist.options[i].selected && selectlist.options[i] != "" && selectlist.options[i+1] != selectlist.options[selectlist.options.length])
			{
			var tmpval = selectlist.options[i].value;
			var tmpval2 = selectlist.options[i].text;
			selectlist.options[i].value = selectlist.options[i+1].value;
			selectlist.options[i].text = selectlist.options[i+1].text
			selectlist.options[i+1].value = tmpval;
			selectlist.options[i+1].text = tmpval2;
			}
		}

	var oldpos = selectlist.selectedIndex;
	var newpos = oldpos + 1;
	selectlist.options[oldpos].selected = false;
	selectlist.options[newpos].selected = true;

	sethidden(formname,selectlist);
	}

function addremove(formname,fromlist,tolist)
	{
	if (fromlist.value == "") {return false;}
	if (fromlist.length == 1) {alert("Please add another ITEM before removing this one."); return false;}
	if (tolist.selectedIndex == true) {tolist.options[tolist.selectedIndex].selected = false;}

	var newopt = new Option(fromlist.options[fromlist.selectedIndex].text,fromlist.options[fromlist.selectedIndex].value,false,true);
	tolist.options[tolist.options.length] = newopt;
	fromlist.options[fromlist.selectedIndex] = null;

	var selectlist = tolist;
	if (fromlist.name.indexOf('multiitems_') != -1) {var selectlist = fromlist;}
	sethidden(formname,selectlist);
	}

function sethidden(formname,selectlist)
	{
	var newlist = '';
	for (var n = 0; n < selectlist.length; n++)
		{
		var name = selectlist.options[n].text;
		//name = name.replace(/\s/g,'');
		var value = selectlist.options[n].value;
		newlist += name+'='+value+'|';
		}
	var hidden = selectlist.name.replace(/multiitems_/i,'');
	if (selectlist.name.indexOf('singleitems_') != -1) {var hidden = selectlist.name.replace(/singleitems_/i,'');}
	eval('document.'+formname+'.'+hidden).value = newlist;
	//alert(eval('document.'+formname+'.'+hidden).value);
	}
	
function savedate(formname,colname)
	{
	var formatteddate = eval('document.'+formname+'.'+colname);
	var year = eval('document.'+formname+'.'+colname+'_year');
	var month = eval('document.'+formname+'.'+colname+'_month');
	var date = eval('document.'+formname+'.'+colname+'_date');
	
	formatteddate.value = year.value+'-'+month.value+'-'+date.value;
	//alert(formatteddate.value);
	}
	
function savetime(formname,colname)
	{
	var formattedtime = eval('document.'+formname+'.'+colname);
	var hour = eval('document.'+formname+'.'+colname+'_hour');
	var minute = eval('document.'+formname+'.'+colname+'_minute');
	
	formattedtime.value = hour.value+':'+minute.value+':00';
	//alert(formattedtime.value);
	}

var ver5up = false;
if (document.getElementById) {ver5up = true;}
function showhide(display,divid) {
	// call like this: <a href="" onmouseover="showhide('block','myDiv');" onmouseout="showhide('none','myDiv');"
	if (ver5up) {
		document.getElementById(divid).style.display = display;
		}
	}
*/