function checkBrowser()
{
	var isNC4, isIE4;
	isNC4 = false;
	isIE4 = false;
	if( navigator.appVersion.charAt(0) >= '4' ) 
	{
		if (navigator.appName == 'Netscape') 
		{
		isNC4 = true;
		} 
		else 
		{
		isIE4 = true;
		}
	}
	if (isNC4)
	{
	 document.layers.d1.visibility="hide";
	}
}

function newHighlite(oButton) {
	var oSel;		//Document's selection
	var rngText;	//TextRange object
	var sText,sType;
	var sTemp;
	var rULType;
	var rLIType;
	var evName = window.event.srcElement.name;

	rULType = /<(UL)>.*<\/\1>/;
	rLIType = /<LI type=("|')[a-zA-Z]{4,6}("|')>/g;
	
	oSel = document.selection;
	rngText = oSel.createRange();
	sText = new String(rngText.text);
	sTemp = new String(oButton.name)
		
	if( sText.length > 0)
	 {
		if((sTemp.indexOf("FColor")==0))
		{
			rngText.text=chTags(sText,oButton);
		}
		if((sTemp.indexOf("FSselect")==0))
		{
			rngText.text=chTags(sText,oButton);
		}
		if((sTemp.indexOf("FLITypes")==0)&(evName.indexOf("list type"))==-1) {
			if (rULType.test(sText)!=true) {
				rngText.text = "<UL><LI type=\x22"+oButton.value+"\x22>" + sText + "</LI></UL>";
				oButton.selectedIndex=0;
				}
			else {
			 	rngText.text=sText.replace(rLIType,"<LI type=\x22"+oButton.value+"\x22>");
			 	oButton.selectedIndex=0;
			 	 }
		}	

	 }
 }
  
function chTags(sText,objButton){
	var rSize,rColor,reB,rULtype,rLIType,sTmp,nfirstind,nlastind;
	
	rSize = /SIZE=("|')?\d("|')?/g;
	rColor = /COLOR=("|')?\#([0-9A-F]{1,6})("|')?/g;
	rFont = /<FONT /g;
	rFSselect=/<FONT SIZE=("|')?\d("|')?/g;
	rFColor = /<FONT COLOR=("|')?\#([0-9A-F]{1,6})("|')?/g;

	var sobjName=objButton.name;
	var evName = window.event.srcElement.name;

	if ((rColor.test(sText)) & (evName.indexOf("Color")>-1)){
		sText=sText.replace(rColor,"COLOR=\x22" + objButton.value + "\x22" );
	}
	
	if ((rSize.test(sText)) & (evName.indexOf("select")>-1))  {
		sText=sText.replace(rSize,"SIZE=\x22" + objButton.value + "\x22" );
	}
	if (rFont.test(sText)!=true)
	{
	  if ((sobjName.indexOf("Color")!=-1) & (evName.indexOf("Color")!=-1))
	  	{
		sText="<FONT COLOR=\x22" + objButton.value + "\x22 >" + sText + "</FONT>";
		}
	   if ((sobjName.indexOf("select")!=-1) & (evName.indexOf("select")!=-1))
	   	{
		sText="<FONT SIZE=\x22" + objButton.value + "\x22 >" + sText + "</FONT>";
		}
	}
	if (rFSselect.test(sText)!=true)
	{
	  if ( evName.indexOf("select")!=-1)
		{
		  var arr,i;
		  arr=sText.split(" ");
		  sText=arr[0] + " " + "SIZE=\x22" + objButton.value + "\x22" + " " +arr[1];
		  for(i=2;i<arr.length;i++)
		  {
		  	sText=sText + arr[i];
		  }
		}
	}	
	
	if ((rFont.test(sText)) & (rColor.test(sText)!=true) & (evName.indexOf("Color")))
		{
		  var arr,i;
		  arr=sText.split(" ");
		  sText=arr[0] + " " + arr[1] + " " +"COLOR=\x22" + objButton.value + "\x22" + " ";
		  for(i=2;i<arr.length;i++)
		  {
		  	sText=sText + arr[i];
		  }
		}
	return(sText);
}
  

function newHighlite_button(action) {

  var oSel;	//Document's selection
  var rngText; //TextRange object
  var sText,sType;
  var rSize,rColor,reB,rULtype,rLIType;
  
  rSize=/SIZE=("|')?\d("|')?/g;
  rColor=/COLOR=("|')?\#([0-9A-F]{1,6})("|')?/g;
  rULType=/<(UL)>.*<\/\1>/;
  rLIType=/<LI type=("|')[a-zA-Z]{4,6}("|')>/g;
  
  oSel=document.selection;
  rngText=oSel.createRange();
  sText=new String(rngText.text);
  if (sText.length >0) {
   switch(action)
  {
  case 'B':
  	   reB=/<(B)>.*<\/\1>/;
	   if(reB.test(sText)!=true)
	   {
  	   rngText.text =sText.bold();
	   }
	   break;
  case 'I':
  	   reB=/<(I)>.*<\/\1>/;
	   if(reB.test(sText)!=true)
	   {
       rngText.text =sText.italics();
	   }
	   break;
  case 'U':
  	   reB=/<(U)>.*<\/\1>/;
	   if(reB.test(sText)!=true)
	   {
  	   rngText.text = "<U>" + sText + "</U>";
	   }
	   break;
  case 'BR':
	{
  	   //reB=/<(BR)>/;
	   //if(reB.test(sText)!=true)
	   //{
  	   rngText.text = sText + "<BR>";
	   //}
  }		   
  	   
  }
  		
  }
  }
  
  
function prView( objTxtArea,strPath) {
	var infoWindow, strPath;
	var doc, strTableTop, strTableBottom;
	infoWindow=window.open('',"Preview Text","width=600,height=400,resizable=1,scrollbars=yes");
	doc=infoWindow.document;
	doc.open();
	doc.writeln("<html><head><title>YachtBroker</title><link rel=\"stylesheet\" href=\"/include/newmain.css\" type=\"text/css\"></head>");
	doc.write("<body bgcolor=white>");
	doc.write( "<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\" align=\"center\"><tr><td align=\"center\"><hr width=\"98%\" size=\"1\" noshade=\"true\" color=\"#cccccc\"><font class=\"titlepage\">Preview HTML</font><hr width=\"80%\" size=\"1\" noshade=\"true\" color=\"#cccccc\">")
	doc.write( "</td></tr></table><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"80%\" align=\"center\"><tr><td>" )
	doc.write(objTxtArea.value);
	doc.write("</td></tr></table><p align=center><a href='#' onClick='window.close()'><img border='0' src='/images_nw/buttons/btn_close.gif'></a>");
	doc.write( "<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\" align=\"center\"><tr><td align=\"center\"><hr width=\"98%\" size=\"1\" noshade=\"true\" color=\"#cccccc\">")
	doc.write( "</td></tr></table>" )
	doc.write("</body></html>");
	doc.close();
}


function advertisement_prView(objText,objTextArea) {
	var infoWindow;
	var doc, strTableTop, strTableBottom;
	infoWindow = window.open('','Preview_Text','width=600,height=400,resizable=1,scrollbars=yes');
	doc=infoWindow.document;
	doc.open();
	doc.writeln("<html><head><title>YachtBroker</title><link rel=\"stylesheet\" href=\"/include/newmain.css\" type=\"text/css\"></head>");
	doc.write("<body bgcolor=white>");
	doc.write( "<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\" align=\"center\"><tr><td align=\"center\"><hr width=\"98%\" size=\"1\" noshade=\"true\" color=\"#cccccc\"><font class=\"titlepage\">Preview</font><hr width=\"80%\" size=\"1\" noshade=\"true\" color=\"#cccccc\">")
	doc.write( "</td></tr></table><table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"80%\" align=\"center\"><tr><td><strong>Title</strong></td><td><strong>Text</strong></td></tr><tr><td>" );
	doc.write(objText.value);
	doc.write("</td><td>");
	doc.write(objTextArea.document.body.innerHTML);
	doc.write("</td></tr></table><p align=center><a href='#' onClick='window.close()'><img border='0' src='/images_nw/buttons/btn_close.gif'></a>");
	doc.write( "<table cellpadding=\"2\" cellspacing=\"2\" border=\"0\" width=\"100%\" align=\"center\"><tr><td align=\"center\"><hr width=\"98%\" size=\"1\" noshade=\"true\" color=\"#cccccc\">")
	doc.write( "</td></tr></table>" )
	doc.write("</body></html>");
	doc.close();
}



function insertTag(action, action_close, objTextArea) {

  var sel, sel1, sel2, selPos

  sel1 = objTextArea.value.substr(0, objTextArea.selectionStart);
  sel2 = objTextArea.value.substr(objTextArea.selectionEnd);
  sel = objTextArea.value.substr(objTextArea.selectionStart, objTextArea.selectionEnd - objTextArea.selectionStart);
  
  var openTag, closeTag
  openTag = "<" + action + ">"
  closeTag = "</" + action_close + ">"
  objTextArea.value = sel1 + openTag + sel + closeTag + sel2;
  
  selPos = openTag.length + sel1.length + sel.length + closeTag.length;
  objTextArea.focus();
  objTextArea.setSelectionRange(selPos, selPos);  
  objTextArea.focus();
}

function setColor( controlId )
{
	infoWindow=window.open("/include/htm/selcolor_mozilla.asp?textarea_id=" + controlId,"Set Color","width=350,height=350,resizable=1,scrollbars=no");
}

function addTableMozilla( controlId )
{
	infoWindow=window.open("/include/htm/settable_mozilla.asp?textarea_id=" + controlId,"Add Table","width=250,height=150,resizable=1,scrollbars=no");
}
function addLink( controlId )
{
	infoWindow=window.open("/include/htm/addlink_mozilla.asp?textarea_id=" + controlId,"Insert Link","width=450,height=150,resizable=1,scrollbars=no");
}

function insertOneTag(action, objTextArea) {

  var sel, sel1, sel2, selPos

  sel1 = objTextArea.value.substr(0, objTextArea.selectionStart);
  sel2 = objTextArea.value.substr(objTextArea.selectionEnd);
  sel = objTextArea.value.substr(objTextArea.selectionStart, objTextArea.selectionEnd - objTextArea.selectionStart);
  
  var opencloseTag
  opencloseTag = "<" + action + "/>"
  objTextArea.value = sel1 + sel + opencloseTag + sel2;
  
  selPos = opencloseTag.length + sel1.length + sel.length;
  objTextArea.focus();
  objTextArea.setSelectionRange(selPos, selPos);  
  objTextArea.focus();
}

