// Scriupts for PDCWEB.NET

// Generates email address "safe" from harvesters
// <SCRIPT language=javascript>generateAntiSpiderEmail('user', 'domain', 'tld', 'display_text');</SCRIPT>
function generateAntiSpiderEmail(Username, DomainName, TLD, Text, ExtraTagStr) {
	Address = Username + "&#64;" + DomainName + "." + TLD;

	if (!(Text)) {DisplayText = Address}
	else {DisplayText = Text};

	document.write("<a href=\"ma" + "il" + "to:" + Address + "\"" + ExtraTagStr + ">" + DisplayText + "</a>");
}

// Refresh Skype Status
function StatusRefresh() {
	document.status_bill.src = "http://mystatus.skype.com/smallclassic/pdcweb-billyb#" + (new Date()).getTime();
	document.status_brent.src = "http://mystatus.skype.com/smallclassic/eppb12#" + (new Date()).getTime();
	t=setTimeout("StatusRefresh()",10000)
}

// Open Paypal Payment Page
function update_paypal_link(form) {
	var strINV = document.Payments.Invoices.value
	var strAMT = document.Payments.Amount.value
	var strCUR = document.Payments.Currency.value
	var strPaymentURL = ""
	if (!(strINV) || !(strAMT))    {
          alert ("You must Enter the Invoice Number and the Amount")
	}
	else {
	  // Validate Amount Field
	  var Chars = "0123456789.,";
	  for (var i = 0; i < strAMT.length; i++) {
	    if (Chars.indexOf(strAMT.charAt(i)) == -1) {
	      alert("Only numbers (0-9) and a decimal are allowed in the Amount Field.");
	      return;
	    }
          }
          if (strCUR == "CAD") {
	    var strCOU = "CA";
	  }
	  else {
	    var strCOU = "US";
	  }
	  strPaymentURL = "https://www.paypal.com/xclick/business=payments@pdcweb.net&item_name=" + strINV + "&country=" + strCOU + "&currency_code=" + strCUR + "&amount=$" + strAMT;
	  openWindow (strPaymentURL, 800, 500)
	}
}

// Validate $$
function validateDollar( fld )
{
   var temp_value = fld.value;

   if (temp_value == "")
   {
     fld.value = "0.00";
     return;
   }
   var Chars = "0123456789.";
   for (var i = 0; i < temp_value.length; i++)
   {
       if (Chars.indexOf(temp_value.charAt(i)) == -1)
       {
           alert("Only numbers (0-9) and a decimal are allowed in the Amount Field.");
           fld.focus();
           fld.select();
           return;
       }
   }
}


// Open popup window
function openWindow(url, iwidth, iheight) {
  var params = 'resizable,scrollbars,menubar,location,status,width='+iwidth+',height='+iheight
  popupWin = window.open(url, 'popup', params)
}

// Open popup window for to-do's
function openToDoWindowBill(url, iwidth, iheight) {
  var params = 'resizable,scrollbars,menubar,location,status,width='+iwidth+',height='+iheight
  popupWinBill = window.open(url, 'Bill', params)
}
function openToDoWindowBrent(url, iwidth, iheight) {
  var params = 'resizable,scrollbars,menubar,location,status,width='+iwidth+',height='+iheight
  popupWinBrent = window.open(url, 'Brent', params)
}

