function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}
bw=new checkBrowser()


function CO_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function displayTip() {
  tipnum=document.showtips.editor.options[document.showtips.editor.selectedIndex].value;
  winName='editortips';
  features='scrollbars=yes,width=500,height=400';
  window.open('copy-paste-info/editortips_'+tipnum+'.htm',winName,features);
}

function emptyText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}
function replaceFont(thefield) {
if (thefield.value == "" || thefield.value == null)
thefield.value = thefield.defaultValue
}


function checkColor(thefield) {
	if (thefield.value == "" || thefield.value == null) {
		thefield.value = thefield.defaultValue
	} 
	else {
		fieldVal = thefield.value
	    if (fieldVal.indexOf('#') == -1) {
			isHex = checkHex(fieldVal)
		}
		else {
			fieldVal = fieldVal.substring(1, 7)
			isHex = checkHex(fieldVal)
		}
		if (!isHex) {
			alert('Please use a valid Hex Color.')
			thefield.value = thefield.defaultValue
		}
		else {
			thefield.value = "#" + fieldVal
		}
	}
}
function checkHex(hexVal){
	if (hexVal.length == 6) {
		if (hexVal.match(/[^0-9A-Fa-f]/)){
		   return 0;
		}
		else {
		   return 1;
		}
	}
	else {
		return 0;
	}
}
function GiveDec(Hex) {
   if(Hex == "A")
      Value = 10;
   else
   if(Hex == "B")
      Value = 11;
   else
   if(Hex == "C")
      Value = 12;
   else
   if(Hex == "D")
      Value = 13;
   else
   if(Hex == "E")
      Value = 14;
   else
   if(Hex == "F")
      Value = 15;
   else
      Value = eval(Hex);
   return Value;
}
function getDec(hexVal) {
   decVal = hexVal.toUpperCase();
   if (decVal.indexOf('#') == -1) { 
      a = GiveDec(decVal.substring(0, 1));
      b = GiveDec(decVal.substring(1, 2));
      c = GiveDec(decVal.substring(2, 3));
      d = GiveDec(decVal.substring(3, 4));
      e = GiveDec(decVal.substring(4, 5));
      f = GiveDec(decVal.substring(5, 6));
   }
   else {
      a = GiveDec(decVal.substring(1, 2));
      b = GiveDec(decVal.substring(2, 3));
      c = GiveDec(decVal.substring(3, 4));
      d = GiveDec(decVal.substring(4, 5));
      e = GiveDec(decVal.substring(5, 6));
      f = GiveDec(decVal.substring(6, 7));   
   }
   x = (a * 16) + b;
   y = (c * 16) + d;
   z = (e * 16) + f;
   decVal = x + ',' + y + ',' + z;
   return decVal;
}
function Preview(form) {
		usepopup=document.ScriptOptions.usepopup.options[document.ScriptOptions.usepopup.selectedIndex].value;
		chan=document.ScriptOptions.chan.value;
		webs=document.ScriptOptions.webs.value;
		pagecolor=document.ScriptOptions.pagecolor.value;
		titlecolor=document.ScriptOptions.titlecolor.value;
		bordercolor=document.ScriptOptions.bordercolor.value;
		bgcolor=document.ScriptOptions.bgcolor.value;
		fonttype=document.ScriptOptions.fonttype.value;
		
		textcolor=document.ScriptOptions.textcolor.value;
		textareabg=document.ScriptOptions.textareabg.value;
		servcmdcolor=document.ScriptOptions.servcmdcolor.value;
		serverrorcolor=document.ScriptOptions.serverrorcolor.value;
		usercmdcolor=document.ScriptOptions.usercmdcolor.value;
		actioncolor=document.ScriptOptions.actioncolor.value;
		chatfontsize=document.ScriptOptions.chatfontsize.value;
				
		RoomOwner = NickName;
		if(RoomOwner=="" || RoomOwner==null) {
			RoomOwner = "Stranger";
		}		
		if(chan==""){alert('You need to specify a channel or room name!');document.ScriptOptions.chan.focus();return false;}
		if(webs==""){webs = "Welcome to "+chan+" Java Chat!"}
		if (usepopup=="1") {
	 		bodyTag = '<body bgcolor="'+pagecolor+'" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>'
 		}
		else {
	 		bodyTag = '<body bgcolor="'+pagecolor+'">'
		}
		
		var randAd = Math.floor(Math.random() * 9);
		
		fonttype2 = 'Helvetica'
		preView = '<html><head><title>'+webs+'</title><style type="text/css">'
			+ '.tablebg {  background-color: '+bgcolor+';}'
			+ '.maintable {  background-color: '+bordercolor+';}'
			+ '.textareabg { background-color: '+textareabg+'; font-size: '+chatfontsize+';}'
			+ '.chattitle {  font-family: '+fonttype+'; color: '+titlecolor+'; font-size: 30px}'
			+ '</style></head>'+bodyTag+'<center>'
			+ '<TABLE width="590" cellpadding="0" border="0" cellspacing="4" class="maintable"><TR><TD align="left" valign="top">'
			+ '<table width="100%" border="0" class="tablebg" cellspacing="2" cellpadding="0"><tr><td height="60" align="left" valign="top">'
			+ '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="tablebg"><tr>'
			+ '<td align="left" valign="middle"><img src="../graphics/javachat/clickhereforyours.gif" width="158" height="60" border="0" align="middle">'
			+ '</td><td height="60" width="468" align="left" valign="top"><IFRAME src="http://www.chattersonline.com/ads/ads/display/chatdata-'+randAd+'.php" scrolling="no" marginwidth=0 marginheight=0 frameborder=0 vspace=0 hspace=0 WIDTH=468 HEIGHT=60></IFRAME></td>'
			+ '</tr></table></td></tr></table></TD></TR><TR><TD align="left" valign="top">' 
			+ '<table width="100%" border="0" class="tablebg" cellpadding="0" cellspacing="0" height="40">'
			+ '<tr><td align="center" valign="middle"><font class="chattitle"><b>'+webs+'</b></font></td>'
			+ '</tr></table></TD></TR><TR valign="top"><TD align="left"><table width="100%" border="0" class="tablebg" cellpadding="0" cellspacing="2">'
			+ '<tr><td align="left" valign="top"><table width="590" border="0" cellspacing="0" cellpadding="0" height="280" name="appletbg" class="tablebg">'
			+ '<tr><td align="left" valign="top"><table width="590" border="0" cellspacing="0" cellpadding="0" height="280" name="appletgrid" bgcolor="#CCCCCC">'
			+ '<tr align="left" valign="middle"><td colspan="3" height="30"><font face="'+fonttype2+'" size="3" color="#000000"><b>#'+chan+': 1 chatters, TOPIC:</b><b></b></font><b><font size="2">' 
			+ '</font></b></td></tr><tr><td align="left" valign="top"><table width="450" border="0" cellspacing="0" cellpadding="0" height="220" name="applettext" class="textareabg">'
			+ '<tr><td align="left" valign="top"><font face="'+fonttype2+'" color="'+textcolor+'">This is Standard Text color.</font><br><font face="'+fonttype2+'" color="'+servcmdcolor+'">This is Server Command color.</font><br>'
			+ '<font face="'+fonttype2+'" color="'+serverrorcolor+'">This is Server Error color.</font><br><font face="'+fonttype2+'" color="'+usercmdcolor+'">This is User Command color.</font><br>'
			+ '<font face="'+fonttype2+'" color="'+actioncolor+'">This is Action Text color.</font></td></tr></table></td>'
			+ '<td width="20" align="left" valign="top"><img src="textscroll.gif" width="20" height="220"></td>'
			+ '<td width="120" align="left" valign="top"><table width="120" border="0" cellspacing="0" cellpadding="0" height="220" name="appletnicks" class="textareabg">'
			+ '<tr><td align="left" valign="top"><font face="'+fonttype2+'" size="3" color="'+textcolor+'">@'+RoomOwner+'</font></td></tr></table></td></tr>'
			+ '<tr align="left" valign="bottom"><td colspan="3" height="30"><table width="540" border="0" cellspacing="0" cellpadding="0" height="30" name="textpannel">'
			+ '<tr><td align="left" valign="bottom" width="430"><table width="430" border="0" cellspacing="0" cellpadding="0" height="22" class="textareabg">'
			+ '<tr><td><font face="'+fonttype2+'" size="3" color="'+textcolor+'">This is the Input Area for typing.</font></td>'
			+ '</tr></table></td><td align="left" valign="bottom"><img src="previewbuttons.gif" width="160" height="30"></td>'
			+ '</tr></table></td></tr></table></td></tr></table></td><td align="right" valign="top"><table border="0" cellspacing="2" cellpadding="0">'
			+ '<tr valign="middle"><td colspan="2" align="center"><img src="../jIRC/help.gif" width="15" height="15" border="0" alt="Java Chat Help"></td>'
			+ '</tr><tr><td align="left" valign="top" width="15" class="tablebg">'
			+ '<img src="../jIRC/biggrin.gif" width="15" height="15" border="0" alt="Big Grin"><br>'
			+ '<img src="../jIRC/frown.gif" width="15" height="15" border="0" alt="Frown"><br>'
			+ '<img src="../jIRC/smile.gif" width="15" height="15" border="0" alt="Smile"><br>'
			+ '<img src="../jIRC/tongue.gif" width="15" height="15" border="0" alt="Tongue"><br>'
			+ '<img src="../jIRC/op.gif" width="15" height="15" alt="Op" border="0"><br>'
			+ '<img src="../jIRC/deop.gif" width="15" height="15" alt="Deop" border="0"><br>'
			+ '<img src="../jIRC/voice.gif" width="15" height="15" alt="Voice" border="0"><br>'
			+ '<img src="../jIRC/devoice.gif" width="15" height="15" alt="Devoice" border="0"><br>'
			+ '<img src="../jIRC/kick.gif" width="15" height="15" alt="Kick" border="0"><br>'
			+ '<img src="../jIRC/kickban.gif" width="15" height="15" alt="Kick Ban" border="0"><br>'
			+ '<img src="../jIRC/whois.gif" width="15" height="15" alt="Whois Info" border="0"></td>'
			+ '<td width="15" align="left" valign="top">'
			+ '<img src="../jIRC/cool.gif" width="15" height="15" border="0"><br>'
			+ '<img src="../jIRC/wink.gif" width="15" height="15" border="0"><br>'
			+ '<img src="../jIRC/mad.gif" width="15" height="15" border="0" alt="Mad"><br>'
			+ '<img src="../jIRC/blush.gif" width="15" height="15" border="0" alt="Blush"><br>'
			+ '<img src="../jIRC/moderate.gif" width="15" height="15" border="0" alt="Moderate"><br>'
			+ '<img src="../jIRC/unmoderate.gif" width="15" height="15" border="0" alt="UnModerate"><br>'
			+ '<img src="../jIRC/invite.gif" width="15" height="15" border="0" alt="Invite only"><br>'
			+ '<img src="../jIRC/uninvite.gif" width="15" height="15" border="0" alt="Remove invite only"><br>'
			+ '<img src="../jIRC/secret.gif" width="15" height="15" border="0" alt="Secret On"><br>'
			+ '<img src="../jIRC/unsecret.gif" width="15" height="15" border="0" alt="Secret Off"><br>'
			+ '<img src="../jIRC/join.gif" width="15" height="15" border="0" alt="Change Rooms"></td>'
			+ '</tr><tr><td align="left" valign="top" colspan="2" class="tablebg">&nbsp;</td></tr></table></td></tr></table></TD>'
			+ '</TR></table></center></body></html>'
		if (usepopup=="1") {
	  		win=window.open("","winPopup","resizable=yes,scrollbars=yes,height=415,width=645")
		}
		else {	
			win=window.open("","winRegular","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,height=350,width=670")		
		}
		win.document.write(preView)
		win.document.close()
		win.focus()
		return true
}        
	
function GetCode(form){
		usepopup=document.ScriptOptions.usepopup.options[document.ScriptOptions.usepopup.selectedIndex].value;
		chan=document.ScriptOptions.chan.value;
		webs=document.ScriptOptions.webs.value;
		pagecolor=document.ScriptOptions.pagecolor.value;
		titlecolor=document.ScriptOptions.titlecolor.value;
		bordercolor=document.ScriptOptions.bordercolor.value;
		bgcolor=document.ScriptOptions.bgcolor.value;
		fonttype=document.ScriptOptions.fonttype.value;
		
		textcolor=document.ScriptOptions.textcolor.value;
		textareabg=document.ScriptOptions.textareabg.value;
		servcmdcolor=document.ScriptOptions.servcmdcolor.value;
		serverrorcolor=document.ScriptOptions.serverrorcolor.value;
		usercmdcolor=document.ScriptOptions.usercmdcolor.value;
		actioncolor=document.ScriptOptions.actioncolor.value;		
		chatfontsize=document.ScriptOptions.chatfontsize.value;
		
		if(chan==""){alert('You need to specify a channel or room name!');document.ScriptOptions.chan.focus();return false;}
		if(webs==""){webs = "Welcome to "+chan+" Java Chat!"}
		bgnum = 0;
		for (i=0; i<document.ScriptOptions.radiobg.length; i++) {
			if (document.ScriptOptions.radiobg[i].checked) {
				bgnum = i + 1;
			}
		}
		
		textcolor = getDec(textcolor)
		textareabg = getDec(textareabg)
		servcmdcolor = getDec(servcmdcolor)
		serverrorcolor = getDec(serverrorcolor)
		usercmdcolor = getDec(usercmdcolor)
		actioncolor = getDec(actioncolor)
				
		if (NickName != "" && NickName != null) {
			chatLink='http://www.chattersonline.com/ads/jIRC/chatnow.cgi?directstart=false&chan=' + escape(chan) + '&webs=' + escape(webs) + '&pagecolor='
			+ escape(pagecolor) + '&titlecolor=' + escape(titlecolor) + '&bordercolor=' + escape(bordercolor) + '&bgcolor='
			+ escape(bgcolor) + '&chatfontsize=' + escape(chatfontsize) + '&fonttype=' + escape(fonttype) + '&margins=' + escape("leftmargin=0 topmargin=0 marginwidth=0 marginheight=0") + '&textcolor='
			+ escape(textcolor) + '&servcmdcolor=' + escape(servcmdcolor) + '&usercmdcolor=' + escape(usercmdcolor) + '&textareabg=' + escape(textareabg) + '&serverrorcolor='
			+ escape(serverrorcolor) + '&actioncolor=' + escape(actioncolor) + ''
			linkCode='<a href="#" onClick="window.open(\''+chatLink+'\',\'ChatNow\',\'height=405,width=639\'); return false;">Click to Chat!</a>'
			if (usepopup=="1") {
				ChatCode='\r\n\r\n'
				+ '<!-- ChatRoom code created for '+NickName+' by ChattersOnline.com -->\r\n'
				+ '<script language="JavaScript" src="http://www.chattersonline.com/ads/jIRC/popupcreater3.js"></script>\r\n'
				+ '<form name="ChatNow">\r\n'
				+ '<table width="380" border="0" cellspacing="0" cellpadding="0" height="60" background="http://www.chattersonline.com/ads/graphics/javachat/javachatlogin'+bgnum+'.gif">\r\n'
				+ '<tr align="right"><td height="58">\r\n'
				+ '<input type="hidden" name="chan" value="' +chan+ '">\r\n'
				+ '<input type="hidden" name="webs" value="' +webs+ '">\r\n'
				+ '<input type="hidden" name="bgcolor" value="' +bgcolor+ '">\r\n'
				+ '<input type="hidden" name="pagecolor" value="' +pagecolor+ '">\r\n'
				+ '<input type="hidden" name="titlecolor" value="' +titlecolor+ '">\r\n'
				+ '<input type="hidden" name="bordercolor" value="' +bordercolor+ '">\r\n'
				+ '<input type="hidden" name="fonttype" value="' +fonttype+ '">\r\n'
				+ '<input type="hidden" name="chatfontsize" value="' +chatfontsize+ '">\r\n'
				+ '<input type="hidden" name="textcolor" value="' +textcolor+ '"><input type="hidden" name="textareabg" value="' +textareabg+ '">\r\n'
				+ '<input type="hidden" name="servcmdcolor" value="' +servcmdcolor+ '"><input type="hidden" name="serverrorcolor" value="' +serverrorcolor+ '">\r\n'
				+ '<input type="hidden" name="usercmdcolor" value="' +usercmdcolor+ '"><input type="hidden" name="actioncolor" value="' +actioncolor+ '">\r\n'				
				+ '<input type="TEXT" name="nick" size="12">\r\n'
				+ '<input type="button" value="Chat Now!" onClick="goChat();">\r\n'
				+ '&nbsp;&nbsp;&nbsp;</td></tr></table></form>\r\n'
				+ '<br />Hosted by <a href="http://www.chattersonline.com" title="Get a free chat room for your website!">ChattersOnline.com</a>\r\n'
				+ '<!-- ChatRoom created on '+JavaDate+'. -->\r\n\r\n'
			}
			else {
				ChatCode='\r\n\r\n'
				+ '<!-- ChatRoom code created for '+NickName+' by ChattersOnline.com -->\r\n'
				+ '<FORM METHOD="POST" ACTION="http://www.chattersonline.com/ads/jIRC/chatnow.cgi">\r\n'
				+ '<table width="380" border="0" cellspacing="0" cellpadding="0" height="60" background="http://www.chattersonline.com/ads/graphics/javachat/javachatlogin'+bgnum+'.gif">\r\n'
				+ '<tr align="right"><td height="58">\r\n'
				+ '<input type="hidden" name="chan" value="' +chan+ '">\r\n'
				+ '<input type="hidden" name="webs" value="' +webs+ '">\r\n'
				+ '<input type="hidden" name="bgcolor" value="' +bgcolor+ '">\r\n'
				+ '<input type="hidden" name="pagecolor" value="' +pagecolor+ '">\r\n'
				+ '<input type="hidden" name="titlecolor" value="' +titlecolor+ '">\r\n'
				+ '<input type="hidden" name="bordercolor" value="' +bordercolor+ '">\r\n'
				+ '<input type="hidden" name="fonttype" value="' +fonttype+ '">\r\n'
				+ '<input type="hidden" name="chatfontsize" value="' +chatfontsize+ '">\r\n'
				+ '<input type="hidden" name="textcolor" value="' +textcolor+ '"><input type="hidden" name="textareabg" value="' +textareabg+ '">\r\n'
				+ '<input type="hidden" name="servcmdcolor" value="' +servcmdcolor+ '"><input type="hidden" name="serverrorcolor" value="' +serverrorcolor+ '">\r\n'
				+ '<input type="hidden" name="usercmdcolor" value="' +usercmdcolor+ '"><input type="hidden" name="actioncolor" value="' +actioncolor+ '">\r\n'				
				+ '<input type="TEXT" name="nick" size="12">\r\n'
				+ '<input type="submit" value="Chat Now!" name="submit">\r\n'
				+ '&nbsp;&nbsp;&nbsp;</td></tr></table></form>\r\n'
				+ '<!-- ChatRoom created on '+JavaDate+'. -->\r\n\r\n'
			}
		}
		else {
		linkCode=''
		ChatCode='Hello Stranger =)\r\n'
			+ '\r\n'
			+ 'Welcome to ChattersOnline.com! We are very happy to see that\r\n'
			+ 'you are interested in having your own chat room for your\r\n'
			+ 'website but we would like you to become a member first.\r\n'
			+ 'Move your mouse over the "menu" tab and select "new user" and\r\n'
			+ 'complete the membership form. It is a very quick process\r\n'
			+ 'and should not take more than a few minutes. Please return\r\n'
			+ 'here after you have logged in with your password and let us\r\n'
			+ 'help you finish creating your java chat room. =)\r\n'
			+ '\r\n'
			+ 'Thank You,\r\n'
			+ 'ChattersOnline Staff.\r\n'
		}
		document.ScriptOptions.javachat_code_section.value=ChatCode;
		document.ScriptOptions.javachat_link_code.value=linkCode;
		document.ScriptOptions.javachat_code_section.focus()
}

function highlight(x){
document.forms[x].elements[0].focus()
document.forms[x].elements[0].select()
}



