﻿var OpenWindowRef;

//** Calendar functions
function rotate(MoveCal)
{			
    var d = new Date();
    var t = d.getTime();
    var proto = window.location.protocol;
    var host = window.location.host;
    var loc = '' + window.location;
    //alert(proto + '//' + host + '/BidCalendar/GetCalendar.aspx?date=' + MoveCal + '&rt=' + t);
    new Ajax.Request(proto + '//' + host + '/BidCalendar/GetCalendar.aspx?date=' + MoveCal + '&rt=' + t,
      {
        method:'get',
        onSuccess: function(transport){
          var response = transport.responseText || "no response text";
          $('CalLabel').update(response);
        },
        onFailure: function(){ $('CalLabel').update('An error occurred.  Please try again.  If the issue persists, contact support.') }
      });
} // end rotate()

// shouldn't be needed
function rotateNav(MoveCal)
{			
    rotate(MoveCal);
}

// set the calendar to todays date
function goToToday()
{
    var todaysDate = new Date();
    var todaysDateString;
    todaysDateString = todaysDate.getMonth() + 1 + '/' + todaysDate.getDate() + '/' + todaysDate.getFullYear();
    rotate(todaysDateString);
}

function OpenClientBid(bidId)
{
    var url;
    url = 'ViewBid.aspx?BidID=' + bidId;
    OpenWindowRef=window.open(url,'name','height=575,width=675,scrollbars=1,toolbar=0,resizable=1,location=0');
	if (window.focus) {OpenWindowRef.focus()}
	return false;
}

function OpenUpload(bidId)
{
    var url;
    url = 'UploadFile.aspx?BidID=' + bidId;
    OpenWindowRef=window.open(url,'Upload','height=260,width=740,scrollbars=1,toolbar=0,resizable=1,location=0');
	if (window.focus) {OpenWindowRef.focus()}
	return false;
}

function LoadBids()
{
    var d = new Date();
    var t = d.getTime();
    var proto = window.location.protocol;
    var host = window.location.host;
    var loc = '' + window.location;
    
    window.location = proto + '//' + host + '/BidCalendar/_Admin/AdminBids.aspx?rt=' + t;    
}

function LoadSetup()
{
    var d = new Date();
    var t = d.getTime();
    var proto = window.location.protocol;
    var host = window.location.host;
    var loc = '' + window.location;
    
    window.location = proto + '//' + host + '/BidCalendar/_Admin/ManagePackages.aspx?rt=' + t;    
}

function getSpanText(n)
{
    var span_textnode = n.firstChild;
    var span_text = span_textnode.data;
    return span_text;
//  if('textContent' in n) {
//    return n.textContent;
//  } else if('innerText' in n) {
//    return n.innerText;
//  } else {
//    return null;
//  }
}
