var calendarWin;

function radioValue(radio){
	for(i=0;i<radio.length;i++){
		if(radio[i].checked){return radio[i].value}
	}
	
	return '';
}

function heartbeat(interval) {
	var now = new Date();
	$.get('/heartbeat.asp', {rnd: now.getTime()});
	setTimeout('heartbeat(' + interval + ')', interval);
}

function ddlValue(ddl){
	return ddl.options[ddl.selectedIndex].value;
}

function setStage(stage, params){
	var URL = '/default.asp?PageId=' + gPageId + '&stage=' + stage;
	
	if(params != ''){
		URL += ('&' + params);
	}

	document.location.href = URL;
}

function pickDate(destField, selectedDate) {

	var url = '/calendar.asp?Dest=' + destField + '&Date=';

	url += eval('document.' + destField + '.value');
	
	if(calendarWin && !calendarWin.closed){
		calendarWin.document.location.href = url;
		calendarWin.focus()
	}
	else{
		calendarWin = window.open(url, 'calendarWin', 'toolbars=no,status=no,scroll=no,menubar=no,resizeable=no,width=300,height=300,top=0,left=0')
	}

}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/*************************************************************************
  This code is from Dynamic Web Coding at www.dyn-web.com
  Copyright 2001-5 by Sharon Paine 
  See Terms of Use at www.dyn-web.com/bus/terms.html
  regarding conditions under which you may use this code.
  This notice must be retained in the code as is!
*************************************************************************/

function initScrollers(logoCount) {
  // arguments: id of layer that scrolls, width and height of scroller (of wn), 
  // number of items (including repeated 1st item), axis ("v" or "h")
  // set up pause/resume onmouseover/out? (true or false)  
  var scr = new dw_scroller('cnt', 246, 85, logoCount, "h", true);
  // adjust timing (defaults are set at 60, 5000)
  scr.setTiming(160, 2000);  // speed, pause duration
}

function goToPage(PageID){
	document.location.href = '/default.asp?PageID=' + PageID;
}

function openEditWin(theURL, theWidth, theHeight){
	var myDate = new Date();
	var winName = 'EditWin'+myDate.getMinutes()+myDate.getMilliseconds()
	MM_openBrWindow(theURL, winName,'status=yes,scrollbars=yes,resizable=yes,left=0,top=0,width=' + theWidth +',height=' + theHeight);
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

