 /**
 * Open a connection to the specified URL, which is
 * intended to respond with an XML message.
 * 
 * @param string method The connection method; either "GET" or "POST".
 * @param string url    The URL to connect to.
 * @param string toSend The data to send to the server; must be URL encoded.
 * @param function responseHandler The function handling server response.
 */

function ajaxTags(handlerFunction, url)
{
	method = 'GET';
	toSend = '';

	if (window.XMLHttpRequest)
    {
        // browser has native support for XMLHttpRequest object
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        // try XMLHTTP ActiveX (Internet Explorer) version
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }

    if(req) {
        req.onreadystatechange = eval(handlerFunction);
        req.open(method, url, true);
        req.setRequestHeader("content-type","application/x-www-form-urlencoded");
        req.send(toSend);
    } else {
        alert('Your browser does not seem to support XMLHttpRequest.');
    }
} 

 /**
 * Handler for server's response to notes.xml request.
 * Notes are pulled from notes.xml and replace the
 * contents of the DIV with id 'notesSection'.
 */

function updateTags() {
    // Make sure the request is loaded
	//0 = uninitialized
	//1 = loading
	//2 = loaded
	//3 = interactive
	//4 = complete
    
    var swappableSection = document.getElementById('updating_tags');

	if (req.readyState < 4) {
       swappableSection.innerHTML = "<img src='http://images.advfn.com/imagesnew/2/br/spinner.gif'>";
	}

	try {
		if (req.readyState == 4) {
			// Make sure the status is "OK"

			if (req.status == 200) {
				swappableSection.innerHTML = req.responseText;
			} else {
				alert("There was a problem retrieving the AJAX data:\n" + req.statusText);
			}		
	    }
	}
	catch (e) {
		swappableSection.innerHTML = req.responseText;
	}
} 

function getTagInfo() {
    // Make sure the request is loaded
	//0 = uninitialized
	//1 = loading
	//2 = loaded
	//3 = interactive
	//4 = complete
    
    var swappableSection = document.getElementById('floating_box_content');

	try {
		if (req.readyState == 4) {
			// Make sure the status is "OK"

			if (req.status == 200) {
				swappableSection.innerHTML = req.responseText;
			} else {
				alert("There was a problem retrieving the AJAX data:\n" + req.statusText);
			}
		}
	}
	catch (e) {
		swappableSection.innerHTML = "Error. Please try again. "+req.responseText+req.readyState;
	}
}

function getIcons() {
    // Make sure the request is loaded
	//0 = uninitialized
	//1 = loading
	//2 = loaded
	//3 = interactive
	//4 = complete
    
    var swappableSection = document.getElementById('default_icons');

	try {
		if (req.readyState == 4) {
			// Make sure the status is "OK"

			if (req.status == 200) {
				swappableSection.innerHTML = req.responseText;
			} else {
				alert("There was a problem retrieving the AJAX data:\n" + req.statusText);
			}
		}
	}
	catch (e) {
		swappableSection.innerHTML = "Error. Please try again."+req.readyState;
	}
} 


// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================


function selectUnselectMatchingOptions(obj,regex,which,only){
	if(window.RegExp){
		if(which == "select"){
			var selected1=true;
			var selected2=false;
		}else if(which == "unselect"){
			var selected1=false;
			var selected2=true;
		}else{
			return;
		}
		var re = new RegExp(regex);
		if(!hasOptions(obj)){
			return;
		}
		for(var i=0;i<obj.options.length;i++){
			if(re.test(obj.options[i].text)){
				obj.options[i].selected = selected1;
			}else{
				if(only == true){
					obj.options[i].selected = selected2;
				}
			}
		}
	}
}

function hasOptions(obj){
	if(obj!=null && obj.options!=null){
		return true;
	}
	return false;
}

function moveSelectedOptions(from,to){
	if(arguments.length>3){
		var regex = arguments[3];
		if(regex != ""){
			unSelectMatchingOptions(from,regex);
		}
	}
	if(!hasOptions(from)){
		return;
	}
	for(var i=0;i<from.options.length;i++){
		var o = from.options[i];
		if(o.selected){
			if(!hasOptions(to)){
				var index = 0;
			}else{
				var index=to.options.length;
			}
			to.options[index] = new Option( o.text, o.value, false, false);
		}
	}
	for(var i=(from.options.length-1);
	i>=0;i--){
		var o = from.options[i];
		if(o.selected){
			from.options[i] = null;
		}
	}
	if((arguments.length<3) ||(arguments[2]==true)){
		sortSelect(from);
		sortSelect(to);
	}
	from.selectedIndex = -1;
	to.selectedIndex = -1;
}

function removeSelectedOptions(from){
	if(!hasOptions(from)){
		return;
	}
	for(var i=(from.options.length-1); i>=0;i--){
		var o = from.options[i];
		if(o.selected){
			from.options[i] = null;
		}
	}
	from.selectedIndex = -1;
}

function sortSelect(obj){
	var o = new Array();
	if(!hasOptions(obj)){
		return;
	}
	for(var i=0;i<obj.options.length;i++){
		o[o.length] = new Option(obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;
	}
	if(o.length==0){
		return;
	}
	o = o.sort(function(a,b){
		if((a.text+"") <(b.text+"")){
			return -1;
		}
		if((a.text+"") >(b.text+"")){
			return 1;
		}
		return 0;
	});
	for(var i=0;i<o.length;i++){
		obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);
	}
}





///// THIS IS THE JAVASCRIPT FOR SHOWING CONTENT ON TAGS/USERNAMES/THREADS

<!-- Copyright 2006,2007 Bontrager Connection, LLC
// http://bontragerconnection.com/ and http://willmaster.com/
// Version: July 28, 2007
var cX = 0; var cY = 0; var rX = 0; var rY = 0;

function ShowContent(d, url, alt) {

  document.getElementById('floating_box_content').innerHTML = "<img src='http://images.advfn.com/imagesnew/2/br/spinner.gif'>";
  ajaxTags('getTagInfo', url);

  if(d.length < 1) {
    return;
  }

  var dd = document.getElementById(d);
  AssignPosition(dd,alt);
  dd.style.display = "block";
}

var timer = 0;

function lookup(inputString, url, displayBox, contentBox) {
  clearTimeout (timer);
  timer = setTimeout("load('"+inputString+"', '"+url+"', '"+displayBox+"', '"+contentBox+"')",300);
}

function load(inputString, url, displayBox, contentBox) {
  if(inputString.length == 0) {
  } else {
    $('#'+contentBox).html('<img src="http://images.advfn.com/imagesnew/2/br/spinner.gif" width="16" height="16">');
    $.post(url, {value: ""+inputString+""}, function(data){
    	if(data.length >0) {
      	box_on = true;
      	$('#'+contentBox).html(data);
    	}
  	});
	}
}

function UpdateCursorPosition(e){ 
	cX = e.pageX; 
	cY = e.pageY;
}

function UpdateCursorPositionDocAll(e){ 
	cX = event.clientX; 
	cY = event.clientY;
}

if(document.all) { 
	document.onmousemove = UpdateCursorPositionDocAll; 
} else { 
	document.onmousemove = UpdateCursorPosition; 
}

function AssignPosition(d,alt) {
	if(self.pageYOffset) {
		rX = self.pageXOffset;
		rY = self.pageYOffset;
	} else if(document.documentElement && document.documentElement.scrollTop) {
		rX = document.documentElement.scrollLeft;
		rY = document.documentElement.scrollTop;
	} else if(document.body) {
		rX = document.body.scrollLeft;
		rY = document.body.scrollTop;
	}
	if(document.all) {
		cX += rX; 
		cY += rY;
	}

	if (alt) {
		d.style.left = (cX-200) + "px";
	} else {
		d.style.left = (cX+10) + "px";
	} 
	d.style.top = (cY+10) + "px";
}

function HideContent(d) {
	if(d.length < 1) { 
		return; 
	}
	document.getElementById(d).style.display = "none";
}

function UpdateContent(d, url) {

	document.getElementById('floating_box_content').innerHTML = "<img src='http://images.advfn.com/imagesnew/2/br/spinner.gif'>";
	ajaxTags('getTagInfo', url);

	if(d.length < 1) { 
		return; 
	}
	var dd = document.getElementById(d);
	dd.style.display = "block";
}





//// GET BB ICONS WHEN CREATING A COMMUNITY

function GetIcons(d, url) {

	document.getElementById(d).innerHTML = "<img src='http://images.advfn.com/imagesnew/2/br/spinner.gif'>";
	ajaxTags('getIcons', url);

	if(d.length < 1) { 
		return; 
	}
}

//-->

