function JSONscriptRequest(fullUrl) {
    this.fullUrl = fullUrl; 
    this.noCacheIE = '&noCacheIE=' + (new Date()).getTime();
    this.headLoc = document.getElementsByTagName("head").item(0);
    this.scriptId = 'YJscriptId' + JSONscriptRequest.scriptCounter++;
}
JSONscriptRequest.scriptCounter = 1;
JSONscriptRequest.prototype.buildScriptTag = function () {
    this.scriptObj = document.createElement("script");    
    this.scriptObj.setAttribute("type", "text/javascript");
    this.scriptObj.setAttribute("src", this.fullUrl + this.noCacheIE);
    this.scriptObj.setAttribute("id", this.scriptId);
}
JSONscriptRequest.prototype.removeScriptTag = function () {
    this.headLoc.removeChild(this.scriptObj);  
}

JSONscriptRequest.prototype.addScriptTag = function () {
    this.headLoc.appendChild(this.scriptObj);
}
function generateURL(iitag,iisize,iidiv) {
	if (location.href) {
		var thistext = location.href;
		document.write("<span id='"+iidiv+"'></span>");
		request = 'http://www.tag.cx/mobile-bookmarks/ajax.php?tag='+iitag+'&isize='+iisize+'&iidiv='+iidiv+'&str='+escape(thistext)+'&callback=getBM';
		aObj = new JSONscriptRequest(request);
		aObj.buildScriptTag();
		aObj.addScriptTag();
	}
}
function toggleLayerCX( whichLayer ){
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
function getBM(jData) {
	if (jData == null) {
		alert("There was a problem parsing search results.");
		return;
	}
	var myval = jData.ResultSet;
	var mydiv = jData.xxMyDiv;
	document.getElementById(mydiv).innerHTML =  myval;
}

var xPosCX = 0;
var yPosCX = 0;

function showToolTipCX(whichLayer,evt){
	if (evt) {
		var url = evt.target;
	} else {
		evt = window.event;
		var url = evt.srcElement;
	}
	if (evt.pageX || evt.pageY) {
		xPosCX = evt.pageX;
		yPosCX = evt.pageY;
	} else if (evt.clientX || evt.clientY) {
		xPosCX = evt.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		yPosCX = evt.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	var CXtoolTip = document.getElementById(whichLayer);
	CXtoolTip.style.top = parseInt(yPosCX)+2 + "px";
	CXtoolTip.style.left = parseInt(xPosCX)+2 + "px";
	CXtoolTip.style.visibility = "visible";
}

function hideToolTipCX(whichLayer){
   var CXtoolTip = document.getElementById(whichLayer);
   CXtoolTip.style.visibility = "hidden";
}
