// Domain Direct universal JavaScript file
// Written 2 October 2002
// Updated 20 January 2003
// By Robert Cook (rcook@tucows.com)

function openTrellix(url,name) {
 var wid = screen.availWidth - 11;
 var hi = screen.availHeight - 30;
 opentrellix_window = window.open(url,name,"top=0,left=0,width="+wid+",height="+hi+",directories=no,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=yes");
 opentrellix_window.focus();
}

function popUp(url,windowname,width,height) {
 // Functions below shoud use this, or things that use this should use the ones below...centralize!
 new_window = window.open(url,windowname,"width="+width+",height="+height+",directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 new_window.focus();
}

function popupPurchase(filename,wid,hi) {
 new_window = window.open(filename,"purchase_window","width="+wid+",height="+hi+",top=0,left=0,directories=no,toolbar=no,resizable=no,menubar=no,scrollbars=yes,status=yes");
}

function popupFAQ(filename) {
 faq_window = window.open(filename,"faq_window","width=400,height=430,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 faq_window.focus();
}

function popupGeneric(filename,wid,hi) {
 generic_window = window.open(filename,"generic_window","width=" + wid + ",height=" + hi + ",directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 generic_window.focus();
}

function popupWhatis(filename,wid,hi) {
 whatis_window = window.open(filename,"whatis_window","width=" + wid + ",height=" + hi + ",directories=no,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=no");
 whatis_window.focus();
}

function popupHelpRoute(filename) {
 helproute_window = window.open(filename,"helproute_window","width=500,height=450,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 helproute_window.focus();
}

function popupExcite(filename) {
 excite_window = window.open(filename,"excite_window","width=400,height=430,directories=no,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=no");
 excite_window.focus();
}

function popupYahoo(filename) {
 yahoo_window = window.open(filename,"yahoo_window","width=400,height=430,directories=no,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=no");
 yahoo_window.focus();
}

function popupWIA(filename) {
 wia_window = window.open(filename,"wia_window","width=600,height=400,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 wia_window.focus();
}

function popupPIA(filename) {
 pia_window = window.open(filename,"pia_window","width=600,height=400,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 pia_window.focus();
}

function popupParking(filename) {
 parking_window = window.open(filename,"parking_window","width=600,height=400,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 parking_window.focus();
}

function popupToTransfer(filename) {
 wid = 400
 hi = 150
 maxwid = screen.availWidth - 11;
 maxhi = screen.availHeight - 30;
 leftpos = (maxwid) ? (maxwid - wid)/2 : 0
 toppos = (maxhi) ? (maxhi - hi)/2 : 0
 totransfer_window = window.open(filename,"totransfer_window","width="+wid+",height="+hi+",top="+toppos+",left="+leftpos+",directories=no,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=no");
 totransfer_window.focus();
}

function popupLoginHelp(filename) {
 loginhelp_window = window.open(filename,"loginhelp_window","width=600,height=450,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 loginhelp_window.focus();
}

function popupLegal(filename) {
 legal_window = window.open(filename,"legal_window","width=400,height=430,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 legal_window.focus();
}

function popupZoneEdit(filename) {
 zoneedit_window = window.open(filename,"zoneedit_window","width=450,height=400,directories=no,toolbar=no,menubar=no,location=no,scrollbars=yes,status=no,resizable=no");
 zoneedit_window.focus();
}

function popupWebsiteBuilder(filename) {
 websitebuilder_window = window.open(filename,"websitebuilder_window","width=735,height=600,directories=no,toolbar=no,menubar=no,location=no,scrollbars=no,status=no,resizable=no");
 websitebuilder_window.focus();
}

function closePopup(filename) {
 if (!filename) {
  self.close();
 } else if (filename == "opener") {
  if (self.opener.open && !self.opener.closed) self.opener.close();
 } else {
  if (filename.lastIndexOf('_window') > 0) win = filename
   else win = getNameRoot(filename) + '_window';
  if (eval('window.' + win + ' && ' + win + '.open && !' + win + '.closed')) eval(win + '.close()');
 }
}

function newPage(newURL) {
 self.opener.location.href = newURL;
 closePopup();
}

// custAgree() refuses to allow the customer to submit the purchase form unless they've checked 'I Agree'.
// How to use: <form method="post" onSubmit="return custAgree(this);">
// <input type="checkbox" name="agree" value="yes">
function custAgree(box) {
 if (box.agree.checked == false) {
  alert("In order to proceed with the registration, you have to indicate that you have read, understood, and agreed with our terms and conditions by checking the 'I Agree' box!");
  return false;
 } else return true;
}

function agreeSubmit(el){
 checkobj = el
 if (document.all || document.getElementById) {
  for (i = 0; i < checkobj.form.length; i++) {
   var tempobj = checkobj.form.elements[i];
   if (tempobj.type.toLowerCase() == "submit") tempobj.disabled = !checkobj.checked
  }
 }
}

function defaultAgree(el){
 if (!document.all && !document.getElementById){
  if (window.checkobj && checkobj.checked)
   return true
  else{
   alert("In order to proceed with the registration, you have to indicate that you have read, understood, and agreed with our terms and conditions by checking the 'I Agree' box!");
   return false
  }
 }
}


// submitOnce() prevents idiot users from clicking Submit over and over again by disabling the button.  Also disables reset buttons, just to be safe.
// How to use: <form method="POST" onSubmit="submitOnce(this)">
function submitOnce(theform) {
 if (document.all||document.getElementById) {
  for (i=0; i<theform.length; i++) {
   var tempobj=theform.elements[i];
   if (tempobj.type.toLowerCase()=="submit"||tempobj.type.toLowerCase()=="reset") tempobj.disabled=true;
  }
 }
}

// confirmRemove() adds an 'Are you sure?' when customer checks a box.  Unchecks the box if they say No.
// How to use: <input type="checkbox" onClick="confirmRemove(this.form.id,this.id)" id="giveitanid">
// Form and element both need id values set
function confirmRemove(formID,checkboxID) {
 if (document.forms[formID].elements[checkboxID].checked) {
  var answer = confirm("Are you sure you want to remove this?\n\nClick OK if you're sure.\nClick Cancel to stop.");
  if (!answer) document.forms[formID].elements[checkboxID].checked = false;
 }
}

