// use the most friendly method possible (try to reduce the possibility of throwing errors)
createTryHandler = function(){
  if(document.createTryHandler_init) return;
  document.createTryHandler_init = true;

  var sHTML = ''
  +'<SC'+'RIPT LANGUAGE="JavaSc'+'ript1.5">'
  +'document.j15TryHandler = function(){'
  +'  try{'
  +'    window.opener.document.ivanUrlSubmit.submit()'
  +'  }'
  +'  catch(err){}'
  +'}'
  +'</SC'+'RIPT>'
  document.write(sHTML)
}
createTryHandler()


function signupsubmit(type) {
	var query = "";
	if (document.location.search){
		query=document.location.search;
	}
  if ((type=="")||(type==null)||(type=="unknown")) {
		if (window.opener&&!window.opener.closed){

      // see if the opener has a special form for passing query string variables forward
      if(document.j15TryHandler) document.j15TryHandler()
      else{
        if(window.opener.document && window.opener.document.ivanUrlSubmit){ 
          //for Nate, allows pass of link_id or refer_id
          window.opener.document.ivanUrlSubmit.submit()
      		window.close();
        }
        else{
    			window.opener.document.location="/cgi-bin/path/signup";
      		window.opener.focus();
      		window.close();
        }
      }

		} else {
			if (window.name=="BHTOUR"){
				signupwin=window.open("","BizhostingSignup","");
				window.close();
			    signupwin.document.location="/cgi-bin/path/signup";
			} else {
				signupwin=window.window
			    signupwin.document.location="/cgi-bin/path/signup";
			}
		}
	} else {

    var which_redir = 'BH_FREE_SIGNUP'
    if(type.indexOf('comhost3')!=-1) which_redir='BH_PROFESSIONAL_SIGNUP'
    if(type.indexOf('comhost2')!=-1) which_redir='BH_VALUE_SIGNUP'

		signupcontents="<HTML>\n<BODY BGCOLOR=white>\n<FORM NAME=signup METHOD=POST ACTION=/cgi-bin/redirect?id="+which_redir+""+query+">\n<INPUT TYPE=hidden NAME=do_step VALUE=main_options>\n<INPUT TYPE=hidden NAME=account_type VALUE='"+type+"'>\n</FORM>\n<SCRIPT>\ndocument.signup.submit();\n</SCRIPT></BODY>\n</HTML>\n\n";
		if (window.opener&&!window.opener.closed){
			window.close();
			window.opener.document.writeln(signupcontents);
		} else {
			if (window.name=="BHTOUR"){
				signupwin=window.open("","BizhostingSignup","");
				window.close();
				signupwin.document.writeln(signupcontents);
			} else {
				signupwin=window.window
				signupwin.document.writeln(signupcontents);
			}
		}
	}
}
