
function bubbler(url) {
               createRequest();
			   var thisurl = String(window.location);
			   var match = thisurl.indexOf('www');
			   if(match == -1) url = string_replace('www.','',url);
               request.open("GET", url, true);
               request.onreadystatechange = doneBubbling;
               request.send(null);
}  //  end function changeflagstatus



function doneBubbling() {
	if (request.readyState == 4) {
	 if( request.status == 0 || request.status == 200 ) {
         var returnText = request.responseText;
         var explode = returnText.split("|");     //  27|HTML
		 var id = explode[0];
		 var html = explode[1].replace(/^\s+|\s+$/g, '');   //  i.e., trim
		 var a = document.getElementById('bubble' + id);
		 var newbubbleid = 'newbubble' + id;
		 if( !html ) {
		     var element = document.getElementById(newbubbleid);
			 a.parentNode.removeChild(element);
		 } else {
			var newnode = document.createElement("div");
			newnode.style.position = 'relative';
			newnode.style.zIndex = 99;
			newnode.style.textAlign = 'left';
			newnode.id = newbubbleid;
			insertAfter(newnode, a);
			newnode.innerHTML = html;
		}
		
	 } else alert("Error! Request Status is " + request.status);
	 
    }   //  request.readyState == 4

}  //  end function doneBubbling


function closebubble(idnum) {
   var newbubbleid = 'newbubble' + idnum;
   var element = document.getElementById(newbubbleid);
   var a = document.getElementById('bubble' + idnum);
   if( element) a.parentNode.removeChild(element);
}


function insertAfter(new_node, existing_node) {
	// if the existing node has a following sibling, insert the current
	// node before it. otherwise appending it to the parent node
	// will correctly place it just after the existing node.
	
	if (existing_node.nextSibling) {
	// there is a next sibling. insert before it using the mutual
	// parent's insertBefore() method.
	existing_node.parentNode.insertBefore(new_node, existing_node.nextSibling);
	} else {
	// there is no next sibling. append to the end of the parent's
	// node list.
	existing_node.parentNode.appendChild(new_node);
	}

} // insertAfter()




function bubbler2(url) {
               createRequest();
            request.open("GET", url, true);
               request.onreadystatechange = doneBubbling2;
               request.send(null);
}  //  end function changeflagstatus



function doneBubbling2() {
	if (request.readyState == 4) {
	 if( request.status == 0 || request.status == 200 ) {
         var returnText = request.responseText;
            var explode = returnText.split("|");     //  27|HTML
            var id = explode[0];
		 var html = explode[1].replace(/^\s+|\s+$/g, '');   //  i.e., trim
		 var a = document.getElementById('view' + id);
		 var newbubbleid = 'newbubble' + id;
		 if( !html ) {
		     var element = document.getElementById(newbubbleid);
			 a.parentNode.removeChild(element);
		 } else {
			var newnode = document.createElement('div');
			newnode.style.position = 'relative';
			newnode.style.zIndex = 99;
			newnode.style.textAlign = 'left';
			newnode.id = newbubbleid;
			insertAfter(newnode, a);
			newnode.innerHTML = html;
		}
		
	 } else alert("Error! Request Status is " + request.status);
	 
    }   //  request.readyState == 4

}  //  end function doneBubbling


function closebubble2(idnum) {
   var newbubbleid = 'newbubble' + idnum;
   var element = document.getElementById(newbubbleid);
   var a = document.getElementById('view' + idnum);
   if( element) a.parentNode.removeChild(element);
}

function string_replace (search, replace, subject, count) {
    // Replaces all occurrences of search in haystack with replace  
    // 
    
    var i = 0, j = 0, temp = '', repl = '', sl = 0, fl = 0,
            f = [].concat(search),
            r = [].concat(replace),
            s = subject,
            ra = r instanceof Array, sa = s instanceof Array;
    s = [].concat(s);
    if (count) {
        this.window[count] = 0;
    }

    for (i=0, sl=s.length; i < sl; i++) {
        if (s[i] === '') {
            continue;
        }
        for (j=0, fl=f.length; j < fl; j++) {
            temp = s[i]+'';
            repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
            s[i] = (temp).split(f[j]).join(repl);
            if (count && s[i] !== temp) {
                this.window[count] += (temp.length-s[i].length)/f[j].length;}
        }
    }
    return sa ? s : s[0];
}


