var xspecialChar = new Array("'");

function specialChar(charIs){
          for (var i=0; i<xspecialChar.length;i++) {
            if(charIs==xspecialChar[i]) {
              return true;
            }
          }
          return false;
}

function replaceThis(txtstring,type){
		var look4 = ' ';
		var newLookFor = "";
		var origText = txtstring;
		var replaceWith = '_';
		var delim = "/gi";
		var resultIs = "";

          for (var i=0;i<look4.length;i++) {
            var speChar = specialChar(look4.charAt(i));
            var charToReplace = look4.charAt(i);
            if(speChar){
              newLookFor += "\\" + charToReplace;
            }else{
			  if (type != "webs") {
			    newLookFor += charToReplace;
		      }
            }
          }
          var myString = new String(newLookFor);
          var mySeparator = ',';
          var arrayName = myString.split(mySeparator);
          for (var i=0;i<arrayName.length;i++) {
            if(i==0) {
              resultIs = origText.replace(eval("/"+arrayName[i]+delim), replaceWith);
            }
		    if(i!==0) {
              resultIs = resultIs.replace(eval("/"+arrayName[i]+delim), replaceWith);
            }
		  }
          return resultIs;
}

function goChat(form) {
		nick=document.ChatNow.nick.value;
		chan=document.ChatNow.chan.value;
		webs=document.ChatNow.webs.value;
		pagecolor=document.ChatNow.pagecolor.value;
		titlecolor=document.ChatNow.titlecolor.value;
		bordercolor=document.ChatNow.bordercolor.value;
		bgcolor=document.ChatNow.bgcolor.value;
		fonttype=document.ChatNow.fonttype.value;
		textcolor=document.ChatNow.textcolor.value;
		textareabg=document.ChatNow.textareabg.value;
		servcmdcolor=document.ChatNow.servcmdcolor.value;
		serverrorcolor=document.ChatNow.serverrorcolor.value;
		usercmdcolor=document.ChatNow.usercmdcolor.value;
		actioncolor=document.ChatNow.actioncolor.value;

		chan = replaceThis(chan,'chan');
		webs = replaceThis(webs,'webs');

	 	if(nick==""){alert("You must enter a nickname.");document.ChatNow.nick.focus();return false;}
	
        win=window.open("",chan,"resizable=no,scrollbars=no,height=405,width=639")
	    win.document.write('<html><head><title>'+webs+'</title></head>\n')
	    win.document.write('<body bgcolor="#000000">\n')
		win.document.write('<FORM NAME="CHATFORM" METHOD="POST" ACTION="http://www.chattersonline.com/ads/jIRC/chatnow.cgi">\n')
        win.document.write('<input type="hidden" name="margins" value="leftmargin=0 topmargin=0 marginwidth=0 marginheight=0">\n')
        win.document.write('<input type="hidden" name="chan" value="'+chan+'">\n')
        win.document.write('<input type="hidden" name="webs" value="'+webs+'">\n')
        win.document.write('<input type="hidden" name="bgcolor" value="'+bgcolor+'">\n')
        win.document.write('<input type="hidden" name="pagecolor" value="'+pagecolor+'">\n')
        win.document.write('<input type="hidden" name="titlecolor" value="'+titlecolor+'">\n')
        win.document.write('<input type="hidden" name="bordercolor" value="'+bordercolor+'">\n')
        win.document.write('<input type="hidden" name="fonttype" value="'+fonttype+'">\n')
        win.document.write('<input type="hidden" name="nick" value="'+nick+'">\n')
        win.document.write('<input type="hidden" name="textcolor" value="'+textcolor+'">\n')
        win.document.write('<input type="hidden" name="textareabg" value="'+textareabg+'">\n')
        win.document.write('<input type="hidden" name="servcmdcolor" value="'+servcmdcolor+'">\n')
        win.document.write('<input type="hidden" name="serverrorcolor" value="'+serverrorcolor+'">\n')
        win.document.write('<input type="hidden" name="usercmdcolor" value="'+usercmdcolor+'">\n')
        win.document.write('<input type="hidden" name="actioncolor" value="'+actioncolor+'">\n')		
		win.document.write('<script language=javascript>document.CHATFORM.submit();</script>\n')
	    win.document.write('</FORM></body></html>\n')
	    win.document.close()
    	return true
}            
