//-----------------------------------------------

function printit()
{
   window.print();
}
//-----------------------------------------------

function close_detail_page()
{
   window.close();
}
//-----------------------------------------------

function show_event(str)
{
  w = window.open(str, "MyWin", "scrollbars=yes,resizable=yes,status=yes,height=550,innerHeight=550,width=650,innerWidth=650");
  w.defaultStatus = "National Bicycle Tour Directors Association";
  w.focus();
}

//-----------------------------------------------

function display_event(str)
{
  w = window.open(str, "EventWin", "scrollbars=yes,resizable=yes,status=yes,height=550,innerHeight=550,width=550,innerWidth=550");
  w.opener=self.opener;
  w.defaultStatus = "National Bicycle Tour Directors Association";
  w.focus();
}

//-----------------------------------------------

function display_vendor(str)
{
  w = window.open(str, "VendorWin", "scrollbars=yes,resizable=yes,status=yes,height=550,innerHeight=550,width=550,innerWidth=550");
  w.defaultStatus = "National Bicycle Tour Directors Association";
  w.focus();
}

//-----------------------------------------------

function full_display_company(str)
{
  w = window.open(str, "CompanyWin", "scrollbars=yes,resizable=yes,status=yes,height=550,innerHeight=550,width=550,innerWidth=550");
  w.defaultStatus = "National Bicycle Tour Directors Association";
  w.focus();
}

//-----------------------------------------------

function full_display_event(str)
{
  w = window.open(str, "EventWin", "scrollbars=yes,resizable=yes,status=yes,height=550,innerHeight=550,width=550,innerWidth=550");
  w.defaultStatus = "National Bicycle Tour Directors Association";
  w.focus();
}

//-----------------------------------------------

function jump_date(str)
{
  w = window.open(str, "JumpWin", "scrollbars=no,resizable=no,status=no,height=270,innerHeight=270,width=415,innerWidth=415");
  w.focus();
}

//-----------------------------------------------

function login_proc(str)
{
  w = window.open(str, "MyWin", "scrollbars=no,resizable=no,status=no,height=100,innerHeight=100,width=200,innerWidth=200");
  w.focus();
}

//-----------------------------------------------

var duration=startDuration();
var wreq = null;

function handleClose(id)
{
	duration=updateDuration();

	var url = "http://www.nbtda.com/record_stat.php?id="+id+"&num="+duration;

	if (window.XMLHttpRequest)
	{
		//For Mozilla/Firefox, Safari
		wreq = new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		//For Internet Explorer
		wreq = new ActiveXObject("Microsoft.XMLHTTP");
	}

	wreq.onreadystatechange = wcallback;
	wreq.open('GET', url, false);
      	wreq.send(null);
}

//------------------------------------------------

function wcallback()
{ 
    	if (wreq.readyState == 4)
	{ 
		if (wreq.status == 200)
		{
			var cType = wreq.getResponseHeader("Content-Type");
         		if (cType == 'text/xml')
			{
            			// XML response
         		}
			else if (cType == 'text/html')
			{
            			// HTML response
         		}
			else if (cType == 'text/plain')
			{
            			// Plain Text response
			}
		}
		else
		{
			// problem fulfilling the request
			alert('Error : Status '+wreq.status+' returned.');
		}
	}
}

//---------------------------------------------------

function startDuration()
{
	var d = new Date();
	duration=d.getSeconds();
	return duration;
}

//---------------------------------------------------

function updateDuration()
{
	var d = new Date();
	var temp=d.getSeconds();
	var num=Math.abs(temp-duration);
	return num;
}