// JC 02/08/2004 contains all JavaScript functions from Resources.asp

function openPage(url) {
  var width = 500;
  var height = 415;
  var popup = new PopupNewPageWithNav( url, "newwindow", 100, 100, width, height);
  popup.open();
}

function PopupNewPageWithNav(url, name, x, y, width, height) {
  this.url = url;
  this.name = name;
  this.x = x;
  this.y = y;
  this.width = width;
  this.height = height;

  this.status = true;
  this.toolbar = true;
  this.location = true;
  this.scrollbars = true;
  this.resizable = true;
  this.dependent = false;

  this.open = PopupWindow_open;
}

function body_onLoad() {

	// Add validation to hidden field that ensures no emails are entered in Email Documents to me fields
	document.page.checkdomainfieldcheck.validate = _checkdomain_fieldsempty;
	
	// Set the validation rules for the checkdotcom form
  document.checkdotcom.name.validate = validateDataEntered;
  document.checkdotcom.name.mandatory = true;
  document.checkdotcom.name.text = ".com Check availability now:";

	// Set the validation rules for the checkdotcomau form
  document.checkdotcomau.name.validate = validateDataEntered;
  document.checkdotcomau.name.mandatory = true;
  document.checkdotcomau.name.text = ".com.au Check availability now:";
	
}

function _checkdomain_fieldsempty()
{
	var dotcomvalue = document.checkdotcom.name.value; //.replace(/^\s*(.*)\s*$/, '$1');
	var dotcomauvalue = document.checkdotcomau.name.value; //.replace(/^\s*(.*)\s*$/, '$1');
  
	if ( (!dotcomvalue || dotcomvalue == "") && (!dotcomauvalue || dotcomauvalue == "") )
		return true;
	
	alert( 'You have clicked the \'Continue\' button whilst there are entries (even if only \'invisible\' spaces) in either or both of the \'Check availability now:\' domain name fields above.  If you want to use either or both of the domain name \'Check availability now:\' functions, you must do so by clicking on its (or their) associated \'GO\' button(s) above. Alternatively, if you do not want to use (or again use) either or both of the domain name \'Check availability now;\' functions, but instead simply want to continue to the next page, you must first remove (delete) all entries (even \'invisible\' spaces) from the \'Check availability now\' domain name fields above, and then click on the \'Continue\' button.' );
	
	if( !(!dotcomvalue || dotcomvalue == "") )
	{
	    document.checkdotcom.name.focus();
	    document.checkdotcom.name.select();
	}
	else
	{
		if( !(!dotcomauvalue || dotcomauvalue == "") )
		{
	    document.checkdotcomau.name.focus();
	    document.checkdotcomau.name.select();
		}
	}
	
	return false;
}

function _checkdotcom_continue( theForm )
{
    // Works for both availability checking forms as they both use a name field
    
    var successful = true;
    var elements = theForm.elements;
    for (var i = 0; successful && i < elements.length; i++) {
      if (elements[i].validate) {
        successful = elements[i].validate();
      }
    }

    if( successful )
    {
    	    // Open the window for the results.
          openDotComCheck();
          return true;
    }
    else
    {
      		return false;
    }
}

function _checkdotcomau_continue( theForm )
{
    // Works for both availability checking forms as they both use a name field
    
    var successful = true;
    var elements = theForm.elements;
    for (var i = 0; successful && i < elements.length; i++) {
      if (elements[i].validate) {
        successful = elements[i].validate();
      }
    }
    if( successful )
    {
    	    // Open the window for the results.
          openDotComAuCheck();
          return true;
    }
    else
    {
      		return false;
    }
}

function PopupNewPage(url, name, x, y, width, height) {
  this.url = url;
  this.name = name;
  this.x = x;
  this.y = y;
  this.outerWidth = width;
  this.outerHeight = height;
  this.width = width;
  this.height = height;

  this.status = true;
  this.toolbar = false;
  this.location = false;
  this.scrollbars = true;
  this.resizable = true;
  this.dependent = false;

  this.open = PopupWindow_open;
}

function PopupNewPageWithNav(url, name, x, y, width, height) {
  this.url = url;
  this.name = name;
  this.x = x;
  this.y = y;
  this.width = width;
  this.height = height;

  this.status = true;
  this.toolbar = true;
  this.location = true;
  this.scrollbars = true;
  this.resizable = true;
  this.dependent = false;

  this.open = PopupWindow_open;
}

function openPage(url) {
  var width = 500;
  var height = 415;
  var popup = new PopupNewPageWithNav( url, "newwindow", 100, 100, width, height);
  popup.open();
}

function PopupPDF(pdf) {

  var pdfwidth = 450;
  var pdfheight = 400;
  var xpos = 160;
  var ypos = 90;
 NewWindow = window.open("" ,"popUp","left="+xpos+",top="+ypos+",screenX="+xpos+",screenY="+ypos+",width="+pdfwidth+",height="+pdfheight+"outerWidth="+pdfwidth+",outerHeight="+pdfheight+",toolbar=no,location=no,directories=no,status=yes,titlebar=no,menubar=no,scrollbars=yes,resizable=yes");


NewWindow.document.write("<html><title>Incorporator - Australian Company Incorporations</title>");
NewWindow.document.write("<body leftmargin='0' topmargin='0' marginwidth='0'marginheight='0'>");
  NewWindow.document.write("<embed src='"+ pdf +"' width='100%' height='100%' href='"+ pdf +"'>");
NewWindow.document.write("</embed></body></html>");

 if (!((navigator.appName == "Microsoft Internet Explorer") && (navigator.appVersion.substring(0, 3) < "3")))
        {
                NewWindow.focus();
        }
}

function openDotComCheck() {
	var width = 420;
	var height = 490;
  
	if( !( dotcomwindow == null ) && ( typeof dotcomwindow.window == "object" ) )
	{
		dotcomwindow.window.close();
		dotcomwindow = null;
	}
	dotcomwindow = new PopupNewPageWithNav("/14/loading.htm", "dotcomwindow", 375, 5, width, height);
	dotcomwindow.open();
}

function openDotComAuCheck() {
  var width = 420;
  var height = 420;

	if( !( dotcomauwindow == null ) && ( typeof dotcomauwindow.window == "object" ) )
	{
		dotcomauwindow.window.close();
		dotcomauwindow = null;
	}
	dotcomauwindow = new PopupNewPageWithNav("/14/loading.htm", "dotcomauwindow", 375, 145, width, height);
	dotcomauwindow.open();
}

// JC 10/09/2004 Ref 1317 Different way of popping up to avoid random usernam/password prompts.
// Replaces PopupRules() function.
function PopupRulesPDF() {
	var popup = new PopupWindow("/COMMON/pdfs/ReplaceableRules.pdf", "popWindow", 110, 100, 560, 430);

	popup.toolbar = true;
	popup.location = false; 
	popup.directories = false;
	popup.status = true;
	popup.titlebar = false; 
	popup.menubar = false; 
	popup.scrollbars = true;
  	popup.resizable = true;
  	popup.dependent = true;
  	popup.status = true;
  	window.guidancePopup = popup.open();
}

function PopupRules(){
        var newWindow = null;
        if (navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion > 2.0))
        {
                newWindow = window.open("", "popWindow",
                      "left=110,top=100,toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=560,height=300");
                newWindow.close();
                while(! newWindow.closed) ;
        }
        newWindow = window.open("/ReplaceableRules.asp", "popWindow",
			"left=110,top=100,toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=560,height=300");
        if (navigator.appName != "Microsoft Internet Explorer")
        {

               newWindow.focus()
        }
}
function PopupLinkedRules(){
        var newWindow2 = null;
        if (navigator.appName == "Microsoft Internet Explorer" && (navigator.appVersion > 2.0))
        {
                newWindow2 = window.open("", "popWindow2",
                      "left=200,top=200,toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=560,height=300");
                newWindow2.close();
                while(! newWindow2.closed) ;
        }
        newWindow2 = window.open("/l3/replaceable.asp", "popWindow2",
			"left=200,top=200,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=560,height=300");
        if (navigator.appName != "Microsoft Internet Explorer")
        {

               newWindow2.focus()
        }
}

function _global_onLoad() {
  MM_preloadImages('/common/images/start_incorporator_r.gif','#958434902255');
  MM_preloadImages('/common/images/faq_r.gif','#958434924136');
  MM_preloadImages('/common/images/resource_r.gif','#958434941151');
  MM_preloadImages('/common/images/view_summary_r.gif','#958434964665');
  MM_preloadImages('/common/images/terms_conditions_r.gif','#958449575585');
  MM_preloadImages('/common/images/copyright_r.gif','#958449768192');
  MM_preloadImages('/common/images/email_friend_r.gif','#958449797404');
  MM_preloadImages('/common/images/back_r.gif','#958456712527');
  MM_preloadImages('/common/images/guidance_boxleft.gif','#958456737233');
  MM_preloadImages('/common/images/guidance_boxbutton.gif','#958456737213');
  MM_preloadImages('/common/images/guidance_boxtitle.gif','#958456737223');
  MM_preloadImages('/common/images/guidance_02.gif','#958456737244');
  MM_preloadImages('/common/images/guidance_03.gif','#958456737245');
  MM_preloadImages('/common/images/guidance_04.gif','#958456737246');
  MM_preloadImages('/common/images/guide_bottom.gif','#958456737247');
var timeoutReference = setTimeout('setSessionTimeout()', '43200000' );
}

function _loib_onClick(varForm, strName, strOnClick, blnTest) {
  varForm[strName].value = '1';
  if (blnTest) {
    var blnSub;
    eval("blnSub = " + strOnClick);
    if (blnSub)
       varForm.submit();
    else
      varForm[strName].value = '';
  } else if (strOnClick == 'null') {
    varForm.submit();
  } else {
    eval(strOnClick);
  }
}

function _page_continue(form) {
  if (typeof(formSubmitted) != "undefined") {
    if (formSubmitted) {
      if (typeof(formSubmittedMessage) != "undefined") {
        alert( formSubmittedMessage );
      }
      return false;
    }
  }
  var successful = true;
  var elements = form.elements;
  for (var i = 0; successful && i < elements.length; i++) {
    if (elements[i].validate) {
      successful = elements[i].validate();
    }
  }
  if (successful) {
    if (typeof(formSubmitted) != "undefined") {
      formSubmitted = true;
    }
  }
  return successful;
}

 function BookMark() {
	if (navigator.appVersion.indexOf("Mac") != -1) 
	{ 
		alert('Please press Apple Key + D to add Incorporator to your bookmarks. ');
	} 
	else 
	{ 
		if (navigator.appName =="Microsoft Internet Explorer") 
		{ 
			window.external.addFavorite("http://www.incorporator.com.au",document.title );
		} 
		else 
		{
			if (navigator.appName =="Netscape") 
			{
				alert('Please press Crtl + D to add Incorporator to your bookmarks.');
			} 
			else 
			{
				alert('Please press Crtl + D to add Incorporator to your bookmarks.' );
			}
		}
 	}
 }