/**
*                            Orca Interactive Forum Script
*                              ---------------
*     Started             : Mon Mar 23 2006
*     Copyright           : (C) 2007 BoonEx Group
*     Website             : http://www.boonex.com
* This file is part of Orca - Interactive Forum Script
* GPL
**/


/**
 * Error handler object
 */


/**
 * constructor
 *		o - HTML Error object
 */
function BxError (o)
{
	alert(o.message + "\n" + o.description);
}

/**
 * constructor
 *		s1 - error message
 *		s2 - error description
 */
function BxError (s1, s2)
{
	alert(s1 + "\n" + s2);
}


/**
*                            Orca Interactive Forum Script
*                              ---------------
*     Started             : Mon Mar 23 2006
*     Copyright           : (C) 2007 BoonEx Group
*     Website             : http://www.boonex.com
* This file is part of Orca - Interactive Forum Script
* GPL
**/


/**
 * load xml data object
 */


/**
 * constructor
 *		url	- url with xml data to open
 *		h	- handler function
 */
function BxXmlRequest(url, h, async)
{	
	if (!url.length) return;

	/**
	 * local handler function
	 */
	var f = function (r, url, h)
	{
		if (r.readyState == 4) // only if req shows "loaded"
	    {
		    if (r.status == 200 || r.status == 304) // only if "OK"
			{
	            h (r);
		    }
			else
	        {
				var s = '';
				for (var i in r) s += i + "      ";
		        BxError("XML read failed:" + r.status, "There was a problem retrieving the XML data:\n" + url);
			}
	    }
	}

	var r;
	

	// IE
	if(window.ActiveXObject)
	{		

		try
		{			
			r = new ActiveXObject("Microsoft.XMLHTTP")

			// register handler function
			r.onreadystatechange = function(  ) 
			{
				f (r, url, h);
			}

			r.open("GET", url, async);
			r.send();  
		}
		catch(a)
		{
		}
	}
	else  if (window.XMLHttpRequest)
	{
		r = new XMLHttpRequest();
	
		// register handler function
		r.onload = function () 
		{
			f (r, url, h);
		}

		r.open("GET", url, async);
		r.send(null);  
	}	

	if (!r)
	{
		var e = new BxError("httpxml object creation failed", "please upgrade your browser");
	}
	else
	{
		this.request = r;
	}

}   





BxXmlRequest.prototype.getRetNodeValue = function (r_xml, tagname)
{
    var ret = '';

    if (r_xml.responseXML)
    {
    if (window.ActiveXObject)
	{
		var e = r_xml.responseXML.getElementsByTagName(tagname)[0];
    		if (e != undefined && e != null && e.firstChild)
		    ret = e.firstChild.nodeValue;
	}
    else
	{     
		var e = r_xml.responseXML.getElementsByTagName(tagname)[0];
		ret = e.textContent;
	}
    }

    if (ret == null || ret == undefined || !ret.length)
    {
        var r = new RegExp ('<'+tagname+'>([\\x00-\\xff]*)<\/'+tagname+'>');
        var a = r_xml.responseText.match (r);     
        if (a && a.length > 1)
            ret = a[1];
    }

	return  ret;
}
/**
*                            Orca Interactive Forum Script
*                              ---------------
*     Started             : Mon Mar 23 2006
*     Copyright           : (C) 2007 BoonEx Group
*     Website             : http://www.boonex.com
* This file is part of Orca - Interactive Forum Script
* GPL
**/


/**
 * xml/xsl transformation
 */

/**
 * constructor
 *		url_xml	- url with xml data to open
 *		url_xsl	- url with xsl data to merge with xml
 *		h		- user handler function
 */
function BxXslTransform(url_xml, url_xsl, h)
{	
	var r_xsl;
	var r_xml;
	var no_xsl = 0;

    var safari = navigator.vendor && navigator.vendor.search('Apple') > -1 ? true : false;
    var konq = navigator.vendor && navigator.vendor.search('KDE') > -1 ? true : false;

    if (xsl_mode != 'client')
    {
    	if (xsl_mode == 'server' || (!window.ActiveXObject && !window.XSLTProcessor) || window.opera || safari || konq)
	{
		if (url_xml.indexOf ("?") == -1)
			url_xml += "?trans=1";
		else
			url_xml += "&trans=1";

		no_xsl = 1;
	}
    }


	// xml load handler
	var h_xml = function (r)
	{
		if (r)  // Mozilla
		{
			r_xml = r;
		}

		if (r_xml.readyState == 4) // IE
		{
			if (200 == r_xml.status || (r_xml.parseError && !r_xml.parseError.errorCode))
			{
//				new BxError("xml load failed", r_xml.parseError.reason);
				if ((r_xsl && r_xsl.readyState == 4) || no_xsl)
					h_res (r_xml, r_xsl);
			}
		}
	}

	// xsl load handler
	var h_xsl = function (r)
	{
		if (r) // Mozilla
		{
			r_xsl = r;
		}
		
		if (r_xsl.readyState == 4) // IE
		{
			if (200 == r_xsl.status || (r_xsl.parseError && !r_xsl.parseError.errorCode))
			{
//				new BxError("xsl load failed", r_xsl.parseError.reason);
				if (r_xml && r_xml.readyState == 4) 
					h_res (r_xml, r_xsl);
			}
		}
	}


	// it fires after both (xml and xsl handlers) functions called
	var h_res = function (r_xml, r_xsl)
	{
	    var f;


        if (no_xsl)
        {
			if (window.XMLSerializer && r_xml.responseXML && r_xml.responseXML.firstChild)
			{                
    			f = ((new XMLSerializer()).serializeToString(r_xml.responseXML));                
			}
			else
            {
				f = r_xml.responseText;
            }
        }
        else
		// IE
	    if(window.ActiveXObject)
		{
			try
			{
		        f = r_xml.transformNode (r_xsl);
			}
			catch (e)
			{
				var ee = new BxError(e.message, e.description);
			}
		}
		// Mozilla
	    else if (window.XSLTProcessor)
		{
	        var x = new XSLTProcessor();
		    x.importStylesheet(r_xsl.responseXML);


	        var ff = x.transformToFragment(r_xml.responseXML, window.document);            
			if (XMLSerializer)
			{
				f = ((new XMLSerializer()).serializeToString(ff));                
			}
			else
				new BxError("xml serialization failed", "please upgrade your browser");
		}

		// call user defined handler function
		h (f);		
	}


    // other browsers
    if (no_xsl)
    {
        new BxXmlRequest (url_xml, h_xml, true);
    }
    else
	// IE
	if (window.ActiveXObject)
	{     
		var b = new ActiveXObject("MSXML2.DOMDocument");
		r_xml = b;
		b.async = true;
		b.load (url_xml);
		b.onreadystatechange = h_xml;

		b = new ActiveXObject("MSXML2.DOMDocument");
		r_xsl = b;
		b.async = true;
		b.load (url_xsl);
		b.onreadystatechange = h_xsl;
	}
	// Mozilla
	else if (window.XSLTProcessor)
	{
		new BxXmlRequest (url_xml, h_xml, true);
		new BxXmlRequest (url_xsl, h_xsl, true);
	}	


}   
/**
*                            Orca Interactive Forum Script
*                              ---------------
*     Started             : Mon Mar 23 2006
*     Copyright           : (C) 2007 BoonEx Group
*     Website             : http://www.boonex.com
* This file is part of Orca - Interactive Forum Script
* GPL
**/


function hoverEffects() {
	//get all elements (text inputs, passwords inputs, textareas)
	var elements = document.getElementsByTagName('input');
	var j = 0;
	var hovers = new Array();
	for (var i4 = 0; i4 < elements.length; i4++) {
		if((elements[i4].type=='text')||(elements[i4].type=='password')) {
			hovers[j] = elements[i4];
			++j;
		}
	}
	elements = document.getElementsByTagName('textarea');
	for (var i4 = 0; i4 < elements.length; i4++) {
		hovers[j] = elements[i4];
		++j;
	}
	
	//add focus effects
	for (var i4 = 0; i4 < hovers.length; i4++) {
		hovers[i4].onfocus = function() {this.className += "Hovered";}
		hovers[i4].onblur = function() {this.className = this.className.replace(/Hovered/g, "");}
	}
}


function correctPNG(id) 
{    
    if (!/MSIE (5\.5|6\.)/.test(navigator.userAgent)) return;

	var e = document.getElementById (id);
	if (e)
	{
		var imgName = e.style.backgroundImage
		
		imgName = imgName.substring(0, imgName.length-1)
		imgName = imgName.substring(4)
		if (imgName.substring(imgName.length-3, imgName.length).toUpperCase() == "PNG")		
		{			
			e.style.backgroundImage = 'none'
			e.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'" + imgName + "\', sizingMethod='scale')"
		}
			
	}

   for (var i=0; i<document.images.length; i++)
   {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
      {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
      }
   }

}
/**
*                            Orca Interactive Forum Script
*                              ---------------
*     Started             : Mon Mar 23 2006
*     Copyright           : (C) 2007 BoonEx Group
*     Website             : http://www.boonex.com
* This file is part of Orca - Interactive Forum Script
* GPL
**/


/**
 * Enable back browser button for ajax
 */


isIE = 0;
if (document.all && !window.opera) isIE = 1;

/**
 * constructor
 */
function BxHistory ()
{
	this._hash = ""; // current hash (after #)
	this._to = 400; // timeout to check for history change
	this._hf = null; // hidden iframe
	this._en = '';
}

/**
 * go to the specified page - override this function to handle specific actions
 * @param h		hash (#)
 */
BxHistory.prototype.go = function (h)
{
	var a = h.split('&');
	if (!a.length) return;

	if (a[0] == 'action=goto')
	{
		var aa = a[1].split('=');
		switch (aa[0])
		{
			// admin functions
			case 'edit_cats':
				if (document.orca_admin) document.orca_admin.editCategories ();
				break;

			// user functions

			case 'cat_id':
				document.f.selectForumIndex (aa[1]);
				break;
			case 'forum_id':
				document.f.selectForum (aa[1], a[2]);
				break;
			case 'topic_id':
				document.f.selectTopic (aa[1]);
				break;

			case 'new_topic':
				document.f.newTopic (aa[1]);
				break;
			case 'search':
				document.f.showSearch ();
				break;
			case 'search_result':
				document.f.search (a[2], a[3], a[4], a[5], a[6]);
				break;
			case 'my_flags':
				document.f.showMyFlags ();
				break;
			case 'my_threads':
				document.f.showMyThreads ();
				break;
			case 'profile':
				document.f.showProfile (aa[1]);
				break;
		}
	}

	return;
}

/**
 * history initialization
 * @param name		hame of history object
 */
BxHistory.prototype.init = function (name)
{
	this._en = name;

	if (isIE) this._initHiddenFrame();

	this.handleHist ();
	window.setInterval(this._en + ".handleHist()", this._to);

	return true;
}

/**
 * handle history (ontimer function)
 */
BxHistory.prototype.handleHist =  function ()
{
	if (isIE)
	{
		var id = this._hf.contentDocument || this._hf.contentWindow.document;
		var h = id.getElementById('hidfr').value;

		if ( h != window.location.hash)
		{						
			this._hash = h;
			var h = this._hash.substr(1);
			//alert ('h = ' + h + "\n" + 'window.location.hash = ' + window.location.hash);
			if (h.length)
			{ 
				this.go (h);
			}
			else if (!h.length && window.location.hash.length)
			{				
				var h = window.location.hash.charAt(0) == '#' ? window.location.hash.substr(1) : window.location.hash;
				this.pushHist (h);
				this.go (h);
			}
		}
	}
	else
	{
		if ( window.location.hash != this._hash )
		{			
			this._hash = window.location.hash;
			var h = this._hash.substr(1);			
			if (h.length) this.go (h);
		}
	}
	return true;
}

/**
 * record history
 * @param h	hash
 */
BxHistory.prototype.makeHist = function (h)
{
	if (h.charAt(0) != '#') h = '#' + h;
	
	if (window.location.hash == h) return;

	if (isIE)
	{
		var id = this._hf.contentDocument || this._hf.contentWindow.document;

		var hhh = id.getElementById('hidfr').value;		

		id.getElementById('hidfr').value = h;		

		if (h != hhh)
			this.pushHist(h);

		window.location.hash = h;
	}
	else
	{
		window.location.hash = h;
		this._hash = window.location.hash;
	}


	return true;
}

/**
 * save history : IE only
 * @param h	hash
 */
BxHistory.prototype.pushHist = function (h) 
{
	if (h.charAt(0) != '#') h = '#' + h;

	var id = this._hf.contentDocument || this._hf.contentWindow.document;

	id.write ('<input id="hidfr" value="' + h + '"/>');
	id.close();

	this._hash = window.location.hash;
}

// private -------------------------------------------

/**
 * init hidden frame : IE only
 */
BxHistory.prototype._initHiddenFrame = function ()
{

	var b = document.body;
	var i = document.createElement('iframe');
	
	i.style.display = 'none';
	i.id = 'hidfr';

	b.appendChild(i);
	
	this._hf = document.getElementById('hidfr');	

    var id = null;
    if (this._hf.contentDocument)
        id = this._hf.contentDocument
    else
    if (this._hf.contentWindow && this._hf.contentWindow.document)
	    id = this._hf.contentWindow.document;

    if (id)
    {
    	id.write ('<input id="hidfr" />');
	    id.close();
    }
}



/**

*                            Orca Interactive Forum Script

*                              ---------------

*     Started             : Mon Mar 23 2006

*     Copyright           : (C) 2007 BoonEx Group

*     Website             : http://www.boonex.com

* This file is part of Orca - Interactive Forum Script

* GPL

**/





/**

 * forum functionality

 */





/**

 * constructor

 */

 

function Forum (base, min_points)

{	

	this._base = base;

	this._forum = 0;

	this._topic = 0;

	this._min_points = min_points;

}   





/**

 * edit post

 * @param id	post id 

 */

Forum.prototype.editPost = function (id)

{

	var container = document.getElementById("post_row_"+id);

	

	var node = document.getElementById(id);



	if (!node)

	{

		this.showHiddenPost(id, '$this.editPost (id);');

		return;

	}

	

	// ---------------





	var $this = this;

	

	var h = function (r)

	{		

		var html = node.innerHTML;	

		



		if (node.getElementsByTagName('form')[0]) return false;



		if (!node.parentNode.style.height || node.parentNode.style.height != 'auto')

		{

			node.parentNode._height = node.parentNode.style.height;

			node.parentNode.style.height = 'auto';

		}

	

		var div = document.createElement('div');

		

		div.innerHTML = r;

		div.style.marginTop = '10px';

	

		node.appendChild (div);

		node.style.height = '350px';

		//node.style.overflow = 'hidden';		

		

		window.orcaSetupContent = function (id, body, doc)

		{	

			body.innerHTML = html;			

			window.orcaSetupContent = function (id, body, doc) {};

		}



        if (document.getElementById('tinyEditor_'+id))

		tinyMCE.execCommand('mceAddControl', false, 'tinyEditor_'+id);



//		tinyMCE.setContent (html);

		

/*

		if (!window.ed)

		{

			window.ed = new BxEditor('edit');

			document.ed = window.ed;

			window.ed.inited = 0;

		}     

		else

		{

			document.ed = window.ed;

			window.ed.setName('edit');

			window.ed.inited = 0;



		}



		var e = div.getElementsByTagName ('iframe')[0];

		e.onload = function () 

		{ 		

			window.ed.init();

			window.ed.setText(html);		



			if (window.ed.inited) return;				

			window.ed.initMenu();	

			window.ed.inited = 1;		

		}



		e.onreadystatechange = function ()

		{	

			if (this.readyState == 'complete') 

		    {			

				window.ed.init();

				window.ed.setText(html);



				if (window.ed.inited) return;

				window.ed.initMenu();	

				window.ed.inited = 1;			

			}

		}



		e.src = "src.html";	

*/

		$this.checkHeight ();		



		return false;

	}		

	

	new BxXslTransform(this._base + "?action=edit_post_xml&post_id=" + id + "&topic_id=" + this._topic, urlXsl + "edit_post.xsl", h);



	return false;



}



/**

 * cancel post editing

 * @param id	post id 

 */

Forum.prototype.editPostCancel = function (id)

{

	var node = document.getElementById(id);

	var f = node.getElementsByTagName('form')[0];

	if (!f) return false;



	tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor_'+id);



	node.removeChild(f.parentNode);

	node.style.height = 'auto';



	if (node.parentNode._height) node.parentNode.style.height = node.parentNode._height;	



	this.checkHeight ();

}

/**

 * expand/collapse rearch result row

 * @param id	post id 

 */

Forum.prototype.expandPost = function (id)

{	

	var p = document.getElementById(id);

	var ul = p.parentNode.parentNode;

	var lis = ul.getElementsByTagName('li');

	var divs = p.parentNode.getElementsByTagName('div');

	var ll = divs.length;

	var l = lis.length;

	var n = parseInt (lis[0].style.height);

	var e = null;



	for (var i=0 ; i<ll ; ++i)

	{

		if (divs[i].className == 'colexp2') 

		{

			e =	divs[i];

			break;

		}

	}



	if (36 == n || '' == lis[0].style.height)

	{		

		for (var i=0 ; i<l ; ++i)

			lis[i].style.height = parseInt(lis[i].clientHeight) + parseInt(p.clientHeight ? p.clientHeight : p.offsetHeight) + 15 + "px";

		e.style.backgroundPosition = '0px -13px';

	}

	else

	{

		for (var i=0 ; i<l ; ++i)

			lis[i].style.height = '36px';

		e.style.backgroundPosition = '0px 0px';

	}



	this.checkHeight ();

}



/**

 * search the forum

 */

Forum.prototype.search = function (text, type, forum, u, disp)

{	

	this.loading ('SEARCHING');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	var $this = this;



	var h = function (r)

	{		

		var m = document.getElementById('main');		



		m.innerHTML = r;



        $this.setWindowTitle(null); 



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=search&text=" + text + "&type=" + type + "&forum=" + forum + "&u=" + u + "&disp=" + disp, urlXsl + "search.xsl", h);



	document.h.makeHist('action=goto&search_result=1&' + text + '&' + type + '&' + forum + '&' + u + '&' + disp);



	return false;

}

	



/**

 * returns new topic page XML

 */

Forum.prototype.selectCat = function (cat, id)

{		

	var e = document.getElementById(id);



	if (!e) 

	{

		new BxError("category id is not defined", "please set category ids");

		return false;

	}



	// determine next forum sibling 

	var et = e.nextSibling;	

	while (et && !(et.tagName == 'DIV' || et.tagName == 'UL'))

		et = et.nextSibling;

	if (et && et.tagName != 'DIV') et = null;



	// determine next cat sibling 

	var en = e.nextSibling;	

	while (en && en.tagName != 'UL' && en.id && !en.id.match(/^cat/))

		en = en.nextSibling;



	var ei = e.getElementsByTagName('div')[0];



	if (et)

	{

		ei.style.backgroundPosition = '0px 0px';

		e.parentNode.removeChild (et);

		return false;

	}



	this.loading ('LOADING FORUMS');



	var $this = this;



	var h = function (r)

	{		

		var d = document.createElement("div");		

		d.innerHTML = r;



		if (et)

			e.parentNode.replaceChild (d, et);

		else

			e.parentNode.insertBefore (d, en);		



        $this.setWindowTitle(null);



		ei.style.backgroundPosition = '0px 0px';



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=list_forums&cat=" + cat, urlXsl + "cat_forums.xsl", h);



	document.h.makeHist('action=goto&cat_id=' + cat);



	return false;

}



/**

 * select forum

 *	@param id	forum id

 */

Forum.prototype.selectForum = function (id, start)

{

	this.loading ('LOADING FORUM TOPICS');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	this._forum = id;



	var $this = this;



	var h = function (r)

	{		

		var m = document.getElementById('main');		



		m.innerHTML = r;



        $this.setWindowTitle(null);



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=list_topics&forum=" + this._forum + "&start=" + start, urlXsl + "forum_topics.xsl", h);



	document.h.makeHist('action=goto&forum_id=' + this._forum + "&" + start);



	return false;

}





/**

 * select forum

 *	@param id	forum id

 */

Forum.prototype.selectForumIndex = function (cat)

{

	this.loading ('LOADING FORUM INDEX');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	var $this = this;



	var h = function (r)

	{		

		m.innerHTML = r;



        $this.setWindowTitle(null);



		$this.stopLoading ();



		$this.checkHeight ();



		var ec = document.getElementById('cat' + cat);	

		if (ec) ec.blur();



		correctPNG('live_fade');

	}



	new BxXslTransform(this._base + "?action=forum_index" + (cat ? ("&cat=" + cat) : ''), urlXsl + "home.xsl", h);



	document.h.makeHist('action=goto&cat_id=' + cat);



	return false;

}







/**

 * show profile page

 *	@param user	usrname to show 

 */

Forum.prototype.showProfile = function (user)

{

	this.loading ('LOADING PROFILE PAGE');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	var $this = this;



	var h = function (r)

	{		

		m.innerHTML = r;



        $this.setWindowTitle(null);



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=profile&user=" + user, urlXsl + "profile.xsl", h);



	document.h.makeHist('action=goto&profile=' + user);



	return false;

}





/**

 * select topic

 *	@param id	topic id

 */

Forum.prototype.selectTopic = function (id)

{

	this.loading ('LOADING TOPIC POSTS');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	this._topic = id;



	var $this = this;



	var h = function (r)

	{		

		m.innerHTML = r;



        $this.setWindowTitle(null);



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=list_posts&topic=" + this._topic, urlXsl + "forum_posts.xsl", h);



	document.h.makeHist('action=goto&topic_id=' + this._topic);



	return false;

}





/**

 * open new 'post new topic' page

 *	@param id	forum id

 */

Forum.prototype.newTopic = function (id)

{

	this.loading ('LOADING POST TOPIC PAGE');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	this._forum = id;



	var $this = this;



	var h = function (r)

	{		

		var m = document.getElementById('main');



		m.innerHTML = r;



        $this.setWindowTitle(null);



        if (document.getElementById('tinyEditor'))

		tinyMCE.execCommand('mceAddControl', false, 'tinyEditor'); 



		$this.stopLoading ();

/*

        if (!window.ed)

        {

            window.ed = new BxEditor('edit');

            document.ed = window.ed;

            window.ed.init();

            window.ed.initMenu();

        } 

        

        else

        {

            document.ed = window.ed;

            window.ed.setName('edit');

            window.ed.init();

            window.ed.initMenu();

        }

*/		



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=new_topic&forum=" + this._forum, urlXsl + "new_topic.xsl", h);



	document.h.makeHist('action=goto&new_topic=' + this._forum);



	return false;

}





/**

 * cancel new topic submission

 */

Forum.prototype.cancelNewTopic = function (forum_id, start)

{

	if (document.getElementById('tinyEditor'))

		tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor');



	return this.selectForum (forum_id, start);

}



/**

 * my threads page

 */

Forum.prototype.showMyThreads = function ()

{

    if (!isLoggedIn)

    {

        alert('Please login to view topics you participate in');

        return;

    }



	this.loading ('LOADING');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	var $this = this;



	var h = function (r)

	{		

		var m = document.getElementById('main');



		m.innerHTML = r;



        $this.setWindowTitle(null);



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=show_my_threads", urlXsl + "forum_topics.xsl", h);



	document.h.makeHist('action=goto&my_threads=1');



	return false;

}





/**

 * my flags page

 */

Forum.prototype.showMyFlags = function ()

{

    if (!isLoggedIn)

    {

        alert('Please login to view flagged topics');

        return;

    }



	this.loading ('LOADING');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	var $this = this;



	var h = function (r)

	{		

		var m = document.getElementById('main');



		m.innerHTML = r;



        $this.setWindowTitle(null);



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=show_my_flags", urlXsl + "forum_topics.xsl", h);



	document.h.makeHist('action=goto&my_flags=1');



	return false;

}



/**

 * open new 'search' page

 */

Forum.prototype.showSearch = function ()

{

	this.loading ('LOADING SEARCH PAGE');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	var $this = this;



	var h = function (r)

	{		

		var m = document.getElementById('main');



		m.innerHTML = r;



        $this.setWindowTitle(null);



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=show_search", urlXsl + "search_form.xsl", h);



	document.h.makeHist('action=goto&search=1');



	return false;

}









/**

 * open new 'post reply' page

 *	@param id_f	forum id

 *	@param id_t	topic id

 */

Forum.prototype.postReply = function (id_f, id_t)

{

	this.loading ('LOADING POST REPLY PAGE');



	var m = document.getElementById('reply_container');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	if (document.getElementById('tinyEditor'))

	{

		tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor'); 

	}



	this._forum = id_f;

	this._topic = id_t;



	var $this = this;



	var h = function (r)

	{		

/*

		var bt = document.getElementById('reply_button');

		if (!bt) 

		{

			new BxError("reply_button div is not defined", "please name it");

		}

		bt.style.display = 'none';

*/

		m.innerHTML = r;

        m.style.display='block';



        if (document.getElementById('tinyEditor'))

		tinyMCE.execCommand('mceAddControl', false, 'tinyEditor'); 



		$this.stopLoading ();

/*

		if (!window.ed)

		{

			window.ed = new BxEditor('edit');

			document.ed = window.ed;

			window.ed.init();

			window.ed.initMenu();

		}



		else

		{

			document.ed = window.ed;

			window.ed.setName('edit');

			window.ed.init();

			window.ed.initMenu();

		}

*/

		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=reply&forum=" + this._forum + "&topic=" + this._topic, urlXsl + "post_reply.xsl", h);



	return false;

}







/**

 * open new 'post reply' page

 *	@param id_f	forum id

 *	@param id_t	topic id

 */

Forum.prototype.postReplyWithQuote = function (id_f, id_t, p_id)

{

	this.loading ('LOADING POST REPLY PAGE');



	var m = document.getElementById('reply_container');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	if (document.getElementById('tinyEditor'))

	{

		tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor'); 

	}



	this._forum = id_f;

	this._topic = id_t;



	var $this = this;



	var h = function (r)

	{		

		m.innerHTML = r;		

        m.style.display='block';



		var post = $this.getPostText(p_id);



		post = post.replace (/<text>/ig, '')

		post = post.replace (/<\/text>/ig, '')

		post =  '<p>&#160;</p><div class="quote_post">' + post + '</div> <p>&#160;</p>';



		window.orcaSetupContent = function (id, body, doc)

		{	

			body.innerHTML = post;			

			window.orcaSetupContent = function (id, body, doc) {};

		}



        if (document.getElementById('tinyEditor'))

		tinyMCE.execCommand('mceAddControl', false, 'tinyEditor'); 



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=reply&forum=" + this._forum + "&topic=" + this._topic, urlXsl + "post_reply.xsl", h);



	return false;

}



/**

 * cancel reply

 */

Forum.prototype.cancelReply = function ()

{

/*

	var bt = document.getElementById('reply_button');

	if (!bt) 

	{

		new BxError("reply_button div is not defined", "please name it");

	}

	bt.style.display = 'inline';

*/



	if (document.getElementById('tinyEditor'))

	{

		tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor'); 

	}



	var m = document.getElementById('reply_container');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}

	m.innerHTML = '&#160;';

    m.style.display='none';

}



/**

 * show access denied page

 */

Forum.prototype.accessDenied = function ()

{

	this.loading ('LOADING PAGE');



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	var $this = this;



	var h = function (r)

	{		

		var m = document.getElementById('main');



		m.innerHTML = r;



        $this.setWindowTitle(null);



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=access_denied", urlXsl + "default_access_denied.xsl", h);



	return false;

}



/**

 * show new topic successfully created  page

 *	@param forum_id	forum id

 */

Forum.prototype.postSuccess = function (forum_id)

{

	this.loading ('LOADING PAGE');	



	var m = document.getElementById('main');

	if (!m) 

	{

		new BxError("main div is not defined", "please name main content container");

	}



	if (document.getElementById('tinyEditor'))

	{

		tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor'); 

	}



	this._forum = forum_id;



	var $this = this;



	var h = function (r)

	{		

		var m = document.getElementById('main');



		m.innerHTML = r;



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=post_success&forum=" + forum_id, urlXsl + "default_post_success.xsl", h);



	return false;

}





/**

 * show reply success page

 *	@param f_id	forum id

 *	@param t_id	topic id

 */

Forum.prototype.replySuccess = function (f_id, t_id)

{

	tinyMCE.execCommand('mceRemoveControl', false, 'tinyEditor');

	return this.selectTopic(t_id);

}





/**

 * delete post

 *	@param p	post id

 *	@param f	forum id

 *	@param t	topic id

 *	@param ask	conform deletetion

 */

Forum.prototype.deletePost = function (p, f, t, ask)

{

	if (ask) if (!confirm('Are you sure ?')) return false;



	var form = document.getElementById('tmp_del_form');



	if (!form) 

	{

		form = document.createElement('form');

		form.style.display = 'none';

		form.id = 'tmp_del_form';

		form.method = 'post';

		form.target = 'post_actions';

		document.body.appendChild(form);

	}



	if (!form) return;



	form.action = 'index.php?action=delete_post&post_id=' + p + '&forum_id=' + f + '&topic_id=' + t;

	form.submit();



	return false;

}



/**

 * show delete success page

 *	@param forum_id	forum id

 */

Forum.prototype.deleteSuccess = function (f_id, t_id, t_exists)

{

	if (f_id)

	{

		if (t_exists)

			this.selectTopic (t_id);

		else

			this.selectForum (f_id, 0);

	}

	else if (0 == f_id && 0 == t_id)

	{

		orca_admin.reportedPosts();

	}



	if (t_exists)

		this.showModalMsg ("Post was successfully deleted");

	else

		this.showModalMsg ("Topic and post were successfully deleted");



	return false;

}



/**

 * show edit success page

 *	@param forum_id	forum id

 */

Forum.prototype.editSuccess = function (t_id)

{

	this.selectTopic(t_id);



	this.showModalMsg ("Post was successfully edited");



	return false;

}



/**

 * show compose message form

 */

Forum.prototype.composeMessage = function (to, mid)

{

	this.loading ('LOADING COMPOSE MESSAGE PAGE');



	var $this = this;



	var h = function (r)

	{

	    var e = document.getElementById('messages');

		e.innerHTML = r;



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform (this._url + "&compose=1&to=" + to + "&mID=" + mid, urlXsl + "mailbox_compose.xsl", h);

}







/**

 * show compose message form

 */

Forum.prototype.composeComplete = function (ret)

{

	this.loading ('SENDING MESSAGE');



	var $this = this;



	var h = function (r)

	{

	    var e = document.getElementById('messages');

		e.innerHTML = r;



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform (this._url + "&compose_complete=1&ret=" + ret, urlXsl + "mailbox_compose_complete.xsl", h);

}



/**

 * validate compose message form

 */

Forum.prototype.validateForm = function (f)

{

	if (f['mText'].value.length == 0 )

	{

		alert('Message body empty');

		return false;

	}



	this.loading ('SENDING MESSAGE');



	return true;

}



/**

 * show valid charachters

 */

Forum.prototype.showValidChars = function (a)

{

	alert("Valid chars:\r\n A-Z a-z 0-9 ! @ # $ % ^ & * ( ) < > _ = + { } ' \" ? . : , | / \\ [] -");

}



/**

 * check string value

 */

Forum.prototype.checkSubject = function (s)

{

	//if (!s.match (/^[\sA-Za-z0-9\!@#\$%\^&\*\(\)_\=\+\{\}'\"\?\.:,\|/\\\[\]\-]{5,50}$/))	

	if (s.length < 5 || s.length > 200)

		return false;

	return true;

}



/**

 * check string value

 */

Forum.prototype.checkText = function (s)

{

	return ((s.length > 4 && s.length < 64000) ? true : false);

}



/**

 * check form values

 */

Forum.prototype.checkPostTopicValues = function (s, t, n)

{	
	var ret1 = false;

	var ret2 = false;

	var e;



	if (true == n)

	{

		e = document.getElementById('err_' + s.name);	

		if (!this.checkSubject(s.value)) 

		{		

			if (e) e.style.display = "inline";

			s.style.backgroundColor = "#ffaaaa";

			s.focus();

		}

		else

		{

			if (e) e.style.display = "none";

			s.style.backgroundColor = "#ffffff";

			ret1 = true;

		}

	}



	e = document.getElementById('err_' + t.name);	

	if (!this.checkText(t.value)) 

	{

		if (e) e.style.display = "inline";

		t.style.backgroundColor = "#ffaaaa";

//		if (!ret1) t.focus ();

	}

	else

	{

		if (e) e.style.display = "none";

		t.style.backgroundColor = "#ffffff";

		ret2 = true;

	}



	return (n ? (ret1 && ret2) : ret2);

}







/**

 * create and display loading message

 */

Forum.prototype.hideModalMsg = function ()

{

	var e = document.body;

	var l = document.getElementById ("modal_msg");

	e.removeChild(l);

}



/**

 * create and display loading message

 */

Forum.prototype.showModalMsg = function (str)

{

	var e = document.body;

	var t = document.createTextNode(str);

	var d = document.createElement("div");

	var s = document.createElement("div");

	var br = document.createElement("br");

	var i = document.createElement("input");		



	e.appendChild (d);



	d.id = "modal_msg";

	d.style.position = "absolute";

	d.style.zIndex = "50001";

	d.style.textAlign = "center";

	d.style.width = e.clientWidth + "px";

	d.style.height = (window.innerHeight ? (window.innerHeight + 30) : screen.height) + "px";			

	d.style.top = getScroll() - 30 + "px";

	d.style.left = 0 + "px";

	d.style.display = "inline";

	d.style.backgroundImage = "url(/img/loading_bg.gif)";





	s.style.border = "1px solid #B5B5B5";

	s.style.backgroundColor = "#F3F3F3";

	s.style.color = "#333333";

	s.style.padding = "20px";

	s.style.marginTop = (parseInt(d.style.height) / 2 - 20) + "px";

	s.style.marginLeft = "auto";

	s.style.marginRight = "auto";

	s.style.width = "300px";

	s.style.fontWeight = "bold";

	s.style.lineHeight = "30px";



	i.type = "reset";

	i.value = " OK ";

	i.style.marginTop = "15px";

	i.onclick = function () {

		document.f.hideModalMsg ();

		return false;

	}



	d.appendChild(s);



	s.appendChild(t);

	s.appendChild(br);

	s.appendChild(i);



}



/**

 * create and display loading message

 */

Forum.prototype.stopLoading = function ()

{

	var l = document.getElementById ("loading");

	if (l)

	{

		l.style.display = "none";

	}

}



/**

 * create and display loading message

 */

Forum.prototype.loading = function (sid)

{

	var d = document.getElementById ("loading");

	var e = document.body; // getElementById('content');



	if (d)

	{

		d.firstChild.innerHTML = sid + "...";

		d.style.top = getScroll() - 30 + "px";

		d.style.left = 0 + "px";

		d.style.display = "inline";

	}

	else

	{

		var t = document.createTextNode(sid + "...");

		var d = document.createElement("div");

		var s = document.createElement("span");



		e.appendChild (d);



		d.id = "loading";

		d.style.position = "absolute";

		d.style.zIndex = "50000";

		d.style.textAlign = "center";

		d.style.width = e.clientWidth + "px";

		d.style.height = (window.innerHeight ? (window.innerHeight + 30) : screen.height) + "px";			

		d.style.top = getScroll() - 30 + "px";

		d.style.left = 0 + "px";

		d.style.display = "inline";

		d.style.backgroundImage = "url(img/loading_bg.gif)";		



		s.style.border = "1px solid #B5B5B5";

		s.style.backgroundColor = "#F3F3F3";

		s.style.color = "#333333";

		s.style.padding = "20px";

		s.style.fontWeight = "bold";

		s.style.lineHeight = d.style.height;



		d.appendChild(s);

		s.appendChild(t);

	}

}







/**

 * create and display loading message

 */

Forum.prototype.hideHTML = function (w, h, html)

{

	var l = document.getElementById ("show_html");

	

	if (l)

	{

		document.body.removeChild(l);

	}

}



/**

 * create and display loading message

 */

Forum.prototype.showHTML = function (html, w, h)

{

	var d = document.getElementById ("show_html");

	var e = document.body; 



	if (d)

	{

		var div = d.firstChild;

		div.innerHTML = html;

		d.style.top = getScroll() - 30 + "px";

		d.style.left = 0 + "px";

		d.style.display = "block";

		if (w) div.style.width = w + 'px';

		if (h) div.style.height = h + 'px';

		div.style.top = parseInt(d.style.height)/2 - h/2 + 'px';

		div.style.width = parseInt(d.style.width)/2 - w/2 + 'px';

	}

	else

	{

		var d = document.createElement("div");

		var div = document.createElement("div");



		e.appendChild (d);



		d.id = "show_html";

		d.style.position = "absolute";

		d.style.zIndex = "49000";

		d.style.textAlign = "center";

		d.style.width = e.clientWidth + "px";

		d.style.height = (window.innerHeight ? (window.innerHeight + 30) : screen.height) + "px";			

		d.style.top = getScroll() - 30 + "px";

		d.style.left = 0 + "px";

		d.style.display = "inline";

		d.style.backgroundImage = "url(img/loading_bg.gif)";		



		div.innerHTML = html;

		div.style.position = "absolute";

		if (w) div.style.width = w + 'px';

		if (h) div.style.height = h + 'px';

		div.style.top = parseInt(d.style.height)/2 - h/2 + 'px';

		div.style.left = parseInt(d.style.width)/2 - w/2 + 'px';



		d.appendChild(div);

	}

}





/*

 * correct auto height in explorer

 */

Forum.prototype.checkHeight = function ()

{

//	e_c = document.getElementById('content');

//	if (!e_c) return;

//	e_c.style.height = "100px";

//	e_c.style.height = "auto";

}





Forum.prototype.hideHiddenPost = function (id)

{

	this.loading ('POST IS LOADING');



	var m = document.getElementById('post_row_'+id);

	if (!m) 

	{

		return false;

	}	



	var $this = this;



	var h = function (r)

	{		

		m.innerHTML = r;



		$this.stopLoading ();



		$this.checkHeight ();

	}



	new BxXslTransform(this._base + "?action=hide_hidden_post&post_id=" + id, urlXsl + "forum_posts.xsl", h);



	//document.h.makeHist('action=goto&forum_id=' + this._forum + "&" + start);



	return false;		

}



Forum.prototype.showHiddenPost = function (id, run)

{

	this.loading ('POST IS LOADING');



	var m = document.getElementById('post_row_'+id);

	if (!m) 

	{

		return false;

	}	



	var $this = this;



	var h = function (r)

	{		

		m.innerHTML = r;



		$this.stopLoading ();



		$this.checkHeight ();



		if (run) eval (run);

	}



	new BxXslTransform(this._base + "?action=show_hidden_post&post_id=" + id, urlXsl + "forum_posts.xsl", h);



	//document.h.makeHist('action=goto&forum_id=' + this._forum + "&" + start);



	return false;	

}



/*

 * align the post, after the avatar load

 */

Forum.prototype.alignPost = function (img, points)

{

	if (img.parentNode && points >= this._min_points)

	{

		var d = img.parentNode.parentNode.parentNode; 

		var y = 35;//img.parentNode.y | img.parentNode.offsetTop; 

		if ((img.clientHeight + y ) > d.clientHeight) 

			d.style.height = img.clientHeight + 5 + "px"; 

		document.f.checkHeight(); 

	}

}



/*

 * good vote post 

 */

Forum.prototype.voteGood = function (post_id)

{				

	var $this = this;



	var h = function (r)

	{		

		var o = new BxXmlRequest('','','');			

		var ret = o.getRetNodeValue (r, 'ret');

		if ('1' == ret)

		{

			var e = document.getElementById ('points_'+post_id);

			e.innerHTML = parseInt(e.innerHTML) + 1;

			$this.hideVoteButtons (post_id);

			$this.hideReportButton  (post_id);

			return false;

		}



		alert ('Vote error');

		return false;

	}



	new BxXmlRequest (this._base + "?action=vote_post_good&post_id="+post_id, h, true);



	return false;		

}



/*

 * flag/unflag 

 */

Forum.prototype.flag = function (topic_id)

{				

	var $this = this;



	var h = function (r)

	{		

		var o = new BxXmlRequest('','','');			

		var ret = o.getRetNodeValue (r, 'ret');

		if ('1' == ret)

		{

			alert ('Topic has been successfully added to your flagged topics');

			return false;

		}

		if ('-1' == ret)

		{

			alert ('Topic has been successfully removed from your flagged topics');

			return false;

		}



		alert ('Please login to flag topics');

		return false;

	}



	new BxXmlRequest (this._base + "?action=flag_topic&topic_id="+topic_id, h, true);



	return false;

}



/*

 * report post 

 */

Forum.prototype.report = function (post_id)

{				

	var $this = this;



	var h = function (r)

	{		

		var o = new BxXmlRequest('','','');			

		var ret = o.getRetNodeValue (r, 'ret');

		if ('1' == ret)

		{

			alert ('Post has been reported');

			return false;

		}



		alert ('Report error');

		return false;

	}



	new BxXmlRequest (this._base + "?action=report_post&post_id="+post_id, h, true);



	return false;		

}



/*

 * place -1 vote for post

 */

Forum.prototype.voteBad = function (post_id)

{

	var $this = this;



	var h = function (r)

	{		

		var o = new BxXmlRequest('','','');			

		var ret = o.getRetNodeValue (r, 'ret');

		if ('1' == ret)

		{

			var e = document.getElementById ('points_'+post_id);

			e.innerHTML = parseInt(e.innerHTML) - 1;

			$this.hideHiddenPost (post_id);

			return false;

		}



		alert ('Vote error');

		return false;

	}



	new BxXmlRequest (this._base + "?action=vote_post_bad&post_id="+post_id, h, true);



	return false;				

}



/*

 * make vote buttons inactive

 */

Forum.prototype.hideVoteButtons = function (post_id)

{

	var e = document.getElementById('rate_'+post_id);

	var a = e.getElementsByTagName('img');

	if (a[0]) 

	{

		a[0].src = urlImg + 'vote_good_gray.gif';

		a[0].parentNode.onclick = function () {};

	}

	if (a[1]) 

	{

		a[1].src = urlImg + 'vote_bad_gray.gif';

		a[1].parentNode.onclick = function () {};

	}	

}



/*

 * make report button inactive

 */

Forum.prototype.hideReportButton = function (post_id)

{

	var e = document.getElementById('report_'+post_id);

	var a = e.getElementsByTagName('img');

	if (a[0]) 

	{

		a[0].src = urlImg + 'report_gray.gif';

		a[0].parentNode.onclick = function () {};

	}

}



Forum.prototype.getPostText = function (post_id)

{

	var e = document.getElementById(post_id);

	if (!e) return '';



	return e.innerHTML;

}



function getScroll()

{

	if (navigator.appName == "Microsoft Internet Explorer")

	{

//		return document.body.scrollTop;

		return document.documentElement.scrollTop

	}

	else

	{

		return window.pageYOffset;

	}

}





Forum.prototype.livePost = function (ts)

{

	var to = 1000;  // timeout

	var $this = this;



	var lt = document.getElementById('live_tracker');



	var h = function (r)

	{		

		var o = new BxXmlRequest('','','');			

		var ret = o.getRetNodeValue (r, 'ret');

		//ret = parseInt(ret);

		if (ret > 0)

		{			

			// get new post and insert it 



			var hh = function (r)			

			{			

				if (!lt) return;



				// delete oldest



				var ln = lt.lastChild;

				while (ln.className != 'live_post')

				{

					ln = ln.previousSibling;

					if (!ln) break;

				}



				lt.removeChild (ln);



				// insert new



				lt.innerHTML = r + lt.innerHTML;

	

				// watch latest post

				setTimeout('f.livePost('+ret+')', to);



				// super effect, get new inserted item

				var fn = lt.firstChild;

				while (fn.className != 'live_post')

				{

					fn = fn.nextSibling;

					if (!fn) break;

				}

				setTimeout('f.fade(\'' + fn.id + '\',1,1,1)', 100);

			}



			new BxXslTransform ($this._base + "?action=get_new_post&ts=" + ts +"&now=" + (new Date()), urlXsl + "live_tracker.xsl",hh);

		

			return false;

		}	



		// watch latest post	

		setTimeout('f.livePost('+ts+')', to);



		return false;

	}



	

	if (lt)

		new BxXmlRequest (this._base + "?action=is_new_post&ts=" + ts +"&now=" + (new Date()), h, true);	



	return false;		

}





Forum.prototype.fade = function (id, r, g, b)

{

	r += 5;

	g += 5;

	b += 5;



	if (r > 59) r = 59;

	if (g > 59) g = 59;

	if (b > 59) b = 59;



	var e = document.getElementById (id);

	e.style.height = b + 'px';



	if (r < 59 || g < 59 || b < 59) 

		setTimeout('f.fade(\'' + id + '\','+r+','+g+','+b+')', 100);

}



Forum.prototype.setWindowTitle = function (s)

{

    if ((!s || !s.length) && document.getElementById('forum_title'))

            s = document.getElementById('forum_title').innerHTML;



	var defTitle = 'Internet Marketing Forum';

    if (!s || !s.length)

        window.document.title = defTitle;

    else

    window.document.title = s + ' - Internet Marketing Forum';

}





/**
*                            Orca Interactive Forum Script
*                              ---------------
*     Started             : Mon Mar 23 2006
*     Copyright           : (C) 2007 BoonEx Group
*     Website             : http://www.boonex.com
* This file is part of Orca - Interactive Forum Script
* GPL
**/


/**
 * admin functionality
 */


/**
 * constructor
 */
function Admin (base, forum)
{	
	this._base = base;
	this._forum = forum;
}   



/**
 * edit categories admin page
 */
Admin.prototype.editCategories = function ()
{
	this._forum.loading ('LOADING');

	var $this = this;

	var h = function (r)
	{		
		var m = document.getElementById('main');		

		m.innerHTML = r;

		$this._forum.stopLoading ();

		$this._forum.checkHeight ();
	}

	new BxXslTransform(this._base + "?action=edit_categories", urlXsl + "edit_categories.xsl", h);

	document.h.makeHist('action=goto&edit_cats=1');

	return false;
}

/**
 * edit categories admin page
 */
Admin.prototype.reportedPosts = function ()
{
	this._forum.loading ('LOADING');

	var $this = this;

	var h = function (r)
	{		
		var m = document.getElementById('main');		

		m.innerHTML = r;

		$this._forum.stopLoading ();

		$this._forum.checkHeight ();
	}

	new BxXslTransform(this._base + "?action=reported_posts", urlXsl + "forum_posts.xsl", h);

//	document.h.makeHist('action=goto&edit_cats=1');

	return false;
}

/**
 * move category up or down
 *	@param id	category id
*	@param dir	direction (up|down)
 */
Admin.prototype.moveCat = function (cat_id, dir)
{
	var $this = this;

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'ret');
		if ('1' == ret)
		{			
			$this.editCategories();		
		}		
	}

	new BxXmlRequest (this._base + "?action=edit_category_move&cat_id="+cat_id+"&dir="+dir, h, true);

	return true;
}

/**
 * delete category
 *	@param id	category id
 */
Admin.prototype.delCat = function (cat_id)
{
	if (!confirm ('Are you sure to delete category with all forums, topics and post')) return false;

	var $this = this;

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'ret');
		if ('1' == ret)
		{
			alert ('Category has been successfully deleted');
			$this.editCategories();
			return;
		}

		alert ('Can not delete category');
	}

	new BxXmlRequest (this._base + "?action=edit_category_del&cat_id="+cat_id, h, true);

	return true;
}

/**
 * delete forum
 *	@param forum_id	forum id
 */
Admin.prototype.delForum = function (forum_id)
{
	if (!confirm ('Are you sure to delete forum with topics and posts')) return false;

	var $this = this;

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'ret');
		if (ret > 0)
		{
			alert ('Forum has been successfully deleted');			
			$this.selectCat(ret, 'cat'+ret, true, true);
			return;
		}

		alert ('Can not delete forum');
	}

	new BxXmlRequest (this._base + "?action=edit_forum_del&forum_id="+forum_id, h, true);

	return true;
}

/**
 * edit category
 *	@param id	category id
 */
Admin.prototype.editCat = function (cat_id)
{	
	var $this = this;

	var h = function (r)
	{			
		$this._forum.showHTML (r, 300, 200);
	}

	new BxXslTransform(this._base + "?action=edit_category&cat_id="+cat_id, urlXsl + "edit_cat_form.xsl", h);

	return true;
}

/**
 * new group
 */
Admin.prototype.newCat = function ()
{	
	var $this = this;

	var h = function (r)
	{			
		$this._forum.showHTML (r, 300, 200);
	}

	new BxXslTransform(this._base + "?action=edit_category&cat_id="+0, urlXsl + "edit_cat_form.xsl", h);

	return true;
}

/**
 * edit category
 *	@param cat_name	new group name
 *	@param cat_id	category id 
 */
Admin.prototype.editCatSubmit = function (cat_id, cat_name)
{
	var $this = this;

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'ret');
		if ('1' == ret)
		{
			if (cat_id > 0)
				alert ('Group has been successfully modified');
			else
				alert ('New group has been successfully added');
			$this._forum.hideHTML();
			$this.editCategories();
			return false;
		}

		if (cat_id > 0)
			alert ('Can not modify group');
		else
			alert ('Can not add new group');
		return false;
	}

    cat_name = escape (cat_name); 

	new BxXmlRequest (this._base + "?action=edit_category_submit&cat_id="+cat_id+"&cat_name="+cat_name, h, true);

	return false;
}


/**
 * edit forum
 *	@param id	category id
 */
Admin.prototype.editForum = function (forum_id)
{	
	var $this = this;

	var h = function (r)
	{			
		$this._forum.showHTML (r, 400, 200);
	}

	new BxXslTransform(this._base + "?action=edit_forum&forum_id="+forum_id, urlXsl + "edit_forum_form.xsl", h);

	return true;
}


/**
 * new category
 */
Admin.prototype.newForum = function (cat_id)
{	
	var $this = this;

	var h = function (r)
	{			
		$this._forum.showHTML (r, 400, 200);
	}
	
	new BxXslTransform (this._base + "?action=edit_forum&forum_id=0&cat_id="+cat_id, urlXsl + "edit_forum_form.xsl", h);

	return true;
}


/**
 * edit forum
 *	@param forum_id	forum id
 *	@param title 	forum title
 *	@param desc 	forum description
 *	@param type 	forum type
 */
Admin.prototype.editForumSubmit = function (cat_id, forum_id, title, desc, type)
{
	var $this = this;

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'ret');
		if ('1' == ret)
		{
			if (forum_id > 0)
				alert ('Forum has been successfully modified');
			else
				alert ('New forum has been successfully added');
			$this._forum.hideHTML();
			$this.selectCat (cat_id, 'cat'+cat_id, true, true);			
			return false;
		}

		if (forum_id > 0)
			alert ('Can not modify forum');
		else
			alert ('Can not add new forum');
		return false;
	}

    title = escape(title); 
    desc = escape(desc); 

	new BxXmlRequest (this._base + "?action=edit_forum_submit&cat_id="+cat_id+"&forum_id="+forum_id+"&title="+title+"&desc="+desc+"&type="+type, h, true);

	return false;
}


/**
 * returns new topic page XML
 */
Admin.prototype.selectCat = function (cat, id, force_show, force_reload)
{	
	var e = document.getElementById(id);

	if (!e) 
	{
		new BxError("category id is not defined", "please set category ids");
		return false;
	}

	// determine next forum sibling 
	var et = e.nextSibling;	
	while (et && !(et.tagName == 'DIV' || et.tagName == 'UL'))
		et = et.nextSibling;
	if (et && et.tagName != 'DIV') et = null;

	// determine next cat sibling 
	var en = e.nextSibling;	
	while (en && en.tagName != 'UL' && en.id && !en.id.match(/^cat/))
		en = en.nextSibling;

	var ei = e.getElementsByTagName('div')[0];

	if (et && !force_show)
	{
		ei.style.backgroundPosition = '0px 0px';
		e.parentNode.removeChild (et);
		if (!force_reload) return false;
	}

	this._forum.loading ('LOADING FORUMS');

	var $this = this;

	this._cat = cat;
	
	var h = function (r)
	{	
		var d = document.createElement("div");		
		d.innerHTML = r;

		if (et)
			e.parentNode.replaceChild (d, et);
		else
			e.parentNode.insertBefore (d, en);		

		ei.style.backgroundPosition = '0px 0px';

		$this._forum.stopLoading ();

		$this._forum.checkHeight ();

		return false;
	}

	new BxXslTransform(this._base + "?action=list_forums_admin&cat=" + cat, urlXsl + "edit_cat_forums.xsl", h);

	//document.h.makeHist('action=goto&cat_id=' + cat);

	return false;
}

/*
 * lock/unlock
 */
Admin.prototype.lock = function (topic_id, locked)
{				
	var $this = this;

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');
		var ret = o.getRetNodeValue (r, 'ret');
        var eImg = document.getElementById('btn_lock_topic');
		if ('1' == ret)
		{                   
			alert ('Topic has been successfully locked');            
            if (eImg) 
            {
                eImg.src = eImg.src.replace(/unlocked/,'locked');
                var eB = eImg.nextSibling;
                if (eB.tagName != 'B') eB = eB.nextSibling;
                //if (eB.tagName == 'B') eB.innerHTML = eB.innerHTML.replace(/Lock/,'Unlock');
            }
			return false;
		}
		if ('-1' == ret)
		{         
			alert ('Topic has been successfully unlocked');
            if (eImg) 
            {
                eImg.src = eImg.src.replace(/locked/,'unlocked');
                var eB = eImg.nextSibling;
                if (eB.tagName != 'B') eB = eB.nextSibling;
                //if (eB.tagName == 'B') eB.innerHTML = eB.innerHTML.replace(/Unlock/,'Lock');
            }
			return false;
		}

		alert ('Only admin can lock/unlock topics');
		return false;
	}

	new BxXmlRequest (this._base + "?action=lock_topic&topic_id=" + topic_id + "&ts=" + (new Date()), h, true);

	return false;
}
/**
*                            Orca Interactive Forum Script
*                              ---------------
*     Started             : Mon Mar 23 2006
*     Copyright           : (C) 2007 BoonEx Group
*     Website             : http://www.boonex.com
* This file is part of Orca - Interactive Forum Script
* GPL
**/


/**
 * login/join functionality
 */


/**
 * constructor
 */
function Login (base, forum)
{	
	this._base = base;
	this._forum = forum;
}   


/**
 * show login form
 *	@param id	forum id
 */
Login.prototype.showLoginForm = function ()
{
	this._forum.loading ('LOADING LOGIN FORM');

	var $this = this;

	var h = function (r)
	{		
		$this._forum.showHTML (r, 400, 200);
		
		$this._forum.stopLoading ();
	}

	new BxXslTransform(this._base + "?action=login_form", urlXsl + "login_form.xsl", h);    

	return false;
}


/**
 * show join form
 */
Login.prototype.showJoinForm = function ()
{
	this._forum.loading ('LOADING JOIN FORM');

	var $this = this;

	var h = function (r)
	{		
		$this._forum.showHTML (r, 400, 200);
		
		$this._forum.stopLoading ();
	}

	new BxXslTransform(this._base + "?action=join_form", urlXsl + "join_form.xsl", h);

	return false;
}


/**
 * submit join form
 *	@param username	new username
 *	@param email	new email
 */
Login.prototype.joinFormSubmit = function (username, email)
{
	var $this = this;

	var h = function (r)
	{		
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'js');		
		if (!ret || !ret.length)
		{			
			alert ("Thank you! You Joined!\nYour login and password have been sent to your email.");
			$this._forum.hideHTML();
			return false;
		}
		
		alert ('Join failed');
		
		eval (ret);
		
		return false;
	}

	new BxXmlRequest (this._base + "?action=join_submit&username="+username+"&email="+email, h, true);

	return false;
}

/**
 * submit login form
 *	@param username	login username
 *	@param pwd		login password
 */
Login.prototype.loginFormSubmit = function (username, pwd)
{
	var $this = this;

	var h = function (r)
	{			
		var o = new BxXmlRequest('','','');			
		var ret = o.getRetNodeValue (r, 'js');
		if (!ret || !ret.length)
		{			
			document.location = $this._base + "?refresh=1";
			return false;
		}
		
		alert ('Login failed');
		
		eval (ret);
		
		return false;
	}	

	new BxXmlRequest (this._base + "?action=login_submit&username="+username+"&pwd="+pwd, h, true);

	return false;
}


/**
 * logout
 */
Login.prototype.logout = function ()
{	
	$this = this;

	var h = function (r)
	{
		document.location = $this._base + "?refresh=1";
		return false;
	}

	new BxXmlRequest (this._base + "?action=logout", h, true);

	return false;

	document.cookie = 'orca_pwd=; orca_user=; expires=Fri, 02-Jan-1970 00:00:00 GMT';	
	document.location = this._base + "?refresh=1";
	return false;
}
/**
*                            Orca Interactive Forum Script
*                              ---------------
*     Started             : Mon Mar 23 2006
*     Copyright           : (C) 2007 BoonEx Group
*     Website             : http://www.boonex.com
* This file is part of Orca - Interactive Forum Script
* GPL
**/


/**
 * html editor
 */

BxEditor = function (i)
{
	// this._el
	// this._moz
	// this._doc
	this._name = i;
}

BxEditor.prototype.setName = function (i)
{
	this._name = i;
}

BxEditor.prototype.init = function ()
{
	this._el = document.getElementById (this._name);
	if (!this._el.contentDocument)
	{
		this._el = window[this._name];
	}

	this._doc = this._el.document ? this._el.document : this._el.contentDocument;

	if (!this._doc.designMode)
	{
		alert('please upgrade your browser');
		return;
	}
	
	this._doc.designMode = 'on';

}


BxEditor.prototype.initMenu = function ()
{
	var a = { 
				0:{'left':0, 'make':'Bold'}, 
				1:{'left':-18, 'make':'Italic'}, 
				2:{'left':-36, 'make':'Underline'},
				3:{'left':-216, 'make':'Code'},
				4:{'left':-162, 'make':'BulletedList'},
				5:{'left':-144, 'make':'NumberedList'},
				6:{'left':-180, 'make':'Outdent'},
				7:{'left':-198, 'make':'Indent'},
				8:{'left':-288, 'make':'RemoveFormat'}
			}
	var len = 9;
	var ul = document.createElement ('ul');
	var img = document.createElement ('img');
	var $this = this;
	

	img.src = "sp.gif";
	img.style.width = '18px';
	img.style.height = '18px';
	img.style.border = 'none';

	ul.style.listStyle = 'none';
	ul.style.margin = '0';
	ul.style.marginTop = '5px';
	ul.style.marginBottom = '5px';
	ul.style.padding = '0';
	ul.style.clear = 'both';
	ul.style.height = '20px';
	ul.style.width = (len*20) + 'px';
	ul.style.backgroundColor = '#999999';
	ul.style.overflow = 'hidden';

	for (var r in a)
	{
		var li = document.createElement('li');
		var img2 = img.cloneNode(false);
		li._func = a[r].make;

		li.style.width = '18px';
		li.style.height = '18px';
		li.style.border = '1px solid #999999';
		li.style.backgroundImage = 'url(toolbar.gif)';
		li.style.backgroundPosition = a[r].left + 'px 0px';
		li.style.overflow = 'hidden';
		li.style.styleFloat = 'left';
		li.style.cssFloat = 'left';
		li.title = a[r].make;

		li.onmouseover = function () { this.style.border = '1px solid #ffffff'; }
		li.onmouseout = function ()  { this.style.border = '1px solid #999999'; this.style.backgroundColor = 'transparent'; }
		li.onmousedown = function () { this.style.backgroundColor = '#bbbbbb'; }
		li.onmouseup = function ()   { this.style.backgroundColor = 'transparent'; }
		li.onclick = function () { eval ('$this.make' + this._func + '()'); }

		li.appendChild (img2);

		ul.appendChild(li);
	}

	if (this._el.frameElement)
		this._el.frameElement.parentNode.insertBefore (ul, this._el.frameElement);
	else
		this._el.parentNode.insertBefore (ul, this._el);
}


BxEditor.prototype.makeBold = function ()
{
	this._el.focus();
	this._doc.execCommand('bold', false, null);
}

BxEditor.prototype.makeItalic = function ()
{
	this._el.focus();
	this._doc.execCommand('italic', false, null);
}

BxEditor.prototype.makeUnderline = function ()
{
	this._el.focus();
	this._doc.execCommand('underline', false, null);
}

BxEditor.prototype.makeBulletedList = function ()
{
	this._el.focus();
	this._doc.execCommand('InsertUnorderedList', false, null);
}

BxEditor.prototype.makeNumberedList = function ()
{
	this._el.focus();
	this._doc.execCommand('InsertOrderedList', false, null);
}

BxEditor.prototype.makeOutdent = function ()
{
	this._el.focus();
	this._doc.execCommand('outdent', false, null);
}

BxEditor.prototype.makeIndent = function ()
{
	this._el.focus();
	this._doc.execCommand('indent', false, null);
}


BxEditor.prototype.makeRemoveFormat = function ()
{
	this._el.focus();
//	this._clean_nodes(this._get_selected_tags(this._el.contentWindow, 'pre'), 'code')
	this._doc.execCommand('RemoveFormat', false, true);
}

BxEditor.prototype.makeCode = function ()
{
	var r = this._doc.execCommand('FormatBlock', false, 'blockquote');
	if (!r)
	{
		this._doc.execCommand('FormatBlock', false, 'Definition');
		this._format_pre_ie();
	}
	else
	{
		this._format_pre_moz ();
	}
	this._el.focus();
}


/*
Formatted = pre
Address = address
Heading 1 = h1
Heading 6 = h6
Numbered List = ol li
Bulleted List = ul li
Directory List = dir li
Menu List = menu li
Definition Term = dl dt
Definition = dl dd

*/

BxEditor.prototype.makeFont = function ()
{
	this._el.focus();
	this._doc.execCommand('FontName', false, 'Arial');
}

BxEditor.prototype.makeHeading = function (h)
{
	this._el.focus();
	if (!this._doc.execCommand('FormatBlock', false, 'h' + h))
		this._doc.execCommand('FormatBlock', false, 'Heading ' + h);
}

BxEditor.prototype.getText = function ()
{
	if (this._el.contentDocument)
	{
		return this._el.contentDocument.body.innerHTML;
	}
	else
	{
		return this._el.document.body.innerHTML;
	}
}

BxEditor.prototype.setText = function (s)
{
	if (this._el.contentDocument)
	{
		this._el.contentDocument.body.innerHTML = s;
	}
	else
	{
		if (this._el.document && this._el.document.body)
			this._el.document.body.innerHTML = s;
	}
}

// private functions -----------------------------------------------------------


BxEditor.prototype._get_selection_bounds = function (editor_window){

   var range, root, start, end

   if(editor_window.getSelection){ // Gecko, Opera
      var selection = editor_window.getSelection()

      range = selection.getRangeAt(0)
      
      start = range.startContainer
      end = range.endContainer
      root = range.commonAncestorContainer
      if(start == end) root = start

      if(start.nodeName.toLowerCase() == "body") return null

      if(start.nodeName == "#text") start = start.parentNode
      if(end.nodeName == "#text") end = end.parentNode
      
      return {
         root: root,
         start: start,
         end: end
      }

   }else if(editor_window.document.selection){ // MSIE
      range = editor_window.document.selection.createRange()
      if(!range.duplicate) return null
      
      var r1 = range.duplicate()
      var r2 = range.duplicate()
      r1.collapse(true)
      r2.moveToElementText(r1.parentElement())
      r2.setEndPoint("EndToStart", r1)
      start = r1.parentElement()
      
      r1 = range.duplicate()
      r2 = range.duplicate()
      r2.collapse(false)
      r1.moveToElementText(r2.parentElement())
      r1.setEndPoint("StartToEnd", r2)
      end = r2.parentElement()
      
      root = range.parentElement()
      if(start == end) root = start
      
      return {
         root: root,
         start: start,
         end: end
      }
   }
   return null // browser not supported
}


// bounds - array [root, start, end]
// tag_name - tag name
BxEditor.prototype._find_tags_in_subtree = function (bounds, tag_name, stage, second){

   var root = bounds['root']
   var start = bounds['start']
   var end = bounds['end']

   if(start == end) return [start]

   if(!second) this._global_stage=stage

   if(this._global_stage == 2) return []
   if(!this._global_stage) this._global_stage = 0

   tag_name = tag_name.toLowerCase()

   var nodes=[]
   for(var node = root.firstChild; node; node = node.nextSibling){
      if(node==start && this._global_stage==0){
         this._global_stage = 1
      }
      if(node.nodeName.toLowerCase() == tag_name && node.nodeName != '#text' || tag_name == ''){
         if(this._global_stage == 1){
            nodes.push(node)
         }
      }
      if(node==end && this._global_stage==1){
         this._global_stage = 2
      }
      nodes=nodes.concat(this._find_tags_in_subtree({root:node, start:start, end:end}, tag_name, this._global_stage, true))
   }
   return nodes
}


BxEditor.prototype._closest_parent_by_tag_name = function (node, tag_name) {

   tag_name = tag_name.toLowerCase()
   var p = node
   do{
      if(tag_name == '' || p.nodeName.toLowerCase() == tag_name) return p
   }while(p = p.parentNode)

   return node
}

BxEditor.prototype._get_selected_tags = function (editor_window, tag_name){

   if(tag_name){
      tag_name = tag_name.toLowerCase()
   }else{
      tag_name = ''
   }
   var bounds = this._get_selection_bounds(editor_window)
   if(!bounds) return null

   bounds['start'] = this._closest_parent_by_tag_name(bounds['start'], tag_name)
   bounds['end'] = this._closest_parent_by_tag_name(bounds['end'], tag_name)
   return this._find_tags_in_subtree(bounds, tag_name)
}

BxEditor.prototype._clean_nodes = function (nodes, class_name){	
   if(!nodes) return
   var l = nodes.length - 1
   var p;
   var html = '';
   for(var i = l ; i >= 0 ; i--){
//      if(!class_name || nodes[i].className == class_name){
         html += '<p>' + nodes[i].innerHTML + '</p>';
         p = nodes[i].parentNode;
         p.removeChild(nodes[i]);

//      }
//      else
//     {
//         html += nodes[i].innerHTML;
//     }
   }

   if (p) p.innerHTML = html;
}


BxEditor.prototype._format_pre_moz = function (){

	var iframe = this._el;
	var wysiwyg = this._doc;

	wysiwyg.execCommand('RemoveFormat', false, true)

	var nodes=this._get_selected_tags(iframe.contentWindow, 'blockquote')
	var new_node
	for(var i=0;i<nodes.length;i++)
	{
		new_node = wysiwyg.createElement('pre')
//		new_node.className = 'code';
		new_node.innerHTML = nodes[i].innerHTML
		nodes[i].parentNode.replaceChild(new_node, nodes[i])
	}
}


BxEditor.prototype._format_pre_ie = function (){

	var iframe = this._el;
	var wysiwyg = this._doc;

	wysiwyg.execCommand('RemoveFormat', false, true)

	this._clean_nodes(this._get_selected_tags(iframe, 'dd'))

	var nodes=this._get_selected_tags(iframe, 'dl')
	var new_node
	for(var i=0;i<nodes.length;i++)
	{
		new_node = wysiwyg.createElement('pre')
//		new_node.className = 'code';
		new_node.innerHTML = nodes[i].innerHTML
		nodes[i].parentNode.replaceChild(new_node, nodes[i])
	}
}

BxEditor.prototype._format_inline = function (tag_name, class_name){

   this._magic_unusual_color='#00f001';

   var iframe = this._el;//document.getElementById(iframe_id)
   var wysiwyg = this._doc;//iframe.contentWindow.document

   wysiwyg.execCommand('RemoveFormat', false, true)

   this._clean_nodes(this._get_selected_tags(iframe.contentWindow, 'span'))

   if(tag_name!=''){
      
		wysiwyg.execCommand('ForeColor', false, this._magic_unusual_color)

      var nodes=this._get_selected_tags(iframe.contentWindow, 'font')
      var new_node
      for(var i=0;i<nodes.length;i++){
         if(nodes[i].getAttribute('color') != this._magic_unusual_color) continue
         new_node = wysiwyg.createElement(tag_name)
//         if(class_name) new_node.className = class_name
         new_node.innerHTML = nodes[i].innerHTML
         nodes[i].parentNode.replaceChild(new_node, nodes[i])
      }
   }
   iframe.focus()
}

BxEditor.prototype._wysiwyg_format_block = function (class_name){

   var tag_name = 'h1';
   var iframe = this._el;//document.getElementById(iframe_id)
   var wysiwyg = this._doc;//iframe.contentWindow.document

//   wysiwyg.execCommand('formatblock', false, tag_name)
   if (!this._doc.execCommand('FormatBlock', false, tag_name))
      this._doc.execCommand('FormatBlock', false, 'Heading 1');

   // asign class for tag
   var nodes = this._get_selected_tags(iframe.contentWindow, tag_name)
   for(var i = 0; i < nodes.length; i++){
      if(class_name)
      {
         nodes[i].className = class_name
      }
      else
      {
         nodes[i].removeAttribute('class')
         nodes[i].removeAttribute('className')
      }
   }
   iframe.focus()
}
