/*
=========================================================
=========================================================
Javascript Document 
INFO BUBBLE POPUPS
Powered by Dynamic Site Design - ken@dynamicsitedesign.com
=========================================================
=========================================================*/

var mTimer;
var mTimerDelay = "500"  // 1000 = 1 secound

// basic browser detection needed
var brwsr_userAgent = navigator.userAgent.toLowerCase();
var isSafari = brwsr_userAgent.indexOf('safari') != -1 ? 1 : 0; // Safari
var isIE_MacOSX = brwsr_userAgent.indexOf("msie 5.2") != -1 && brwsr_userAgent.indexOf('mac_powerpc') != -1;
var isIE_Mac = !isIE_MacOSX && brwsr_userAgent.indexOf("msie") != -1 && brwsr_userAgent.indexOf('mac') != -1;
var isNS = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 4);
var xPos,yPos;

// Begin Common Functions
function getWidgetLeft(selObj) {
	var controller = this.document.getElementById(selObj);
    var iLeft = 0;
	while(controller.tagName != "BODY") {
        iLeft += controller.offsetLeft;
        controller = controller.offsetParent; 
    }
	return iLeft;
};
function getWidgetTop(selObj) {
	var controller = this.document.getElementById(selObj);
    var iTop = 0;
	while(controller.tagName != "BODY") {
        iTop += controller.offsetTop;
        controller = controller.offsetParent; 
    }
	return iTop;
};
function showSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='visible';
   }
};
function hideSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='hidden';
   }
};


// Begin bubble pop up Functions
function posBubble(selObj,id) {
	if(!isSafari && isNS || isIE_MacOSX || isIE_Mac ){//for Netscape and IE MACs
		document.getElementById(id).style.top =(this.getWidgetTop(selObj) - 124) + "px"; // used to adjust height offset of popup
		document.getElementById(id).style.left = (this.getWidgetLeft(selObj) + 15) + "px"; // used to adjust left offset of popup
	}
	else if(isSafari) { // for Safari MAX OSX
		document.getElementById(id).style.top = (this.getWidgetTop(selObj) - 124) + "px"; // used to adjust height offset of popup
		document.getElementById(id).style.left = (this.getWidgetLeft(selObj)  + 15) + "px"; // used to adjust left offset of popup
	}
	else { // all other EI versions on PC
		xPos = xPos;
		xPos = eval(document.getElementById(selObj)).offsetLeft;
		tempEl = eval(document.getElementById(selObj)).offsetParent;
		while (tempEl != null) {
			xPos += tempEl.offsetLeft;
			tempEl = tempEl.offsetParent;
		}
		yPos = yPos;
		yPos = eval(document.getElementById(selObj)).offsetTop;
		tempEl = eval(document.getElementById(selObj)).offsetParent;
		while (tempEl != null) {
			yPos += tempEl.offsetTop;
			tempEl = tempEl.offsetParent;
		}
		xPos = xPos - 0;
		document.getElementById(id).style.top = yPos - 124; // used to adjust height offset of popup
		document.getElementById(id).style.left = xPos  + 15; // used to adjust left offset of popup
	}
};

var g_showingBubble = false;
function showBubble(selObj, id, hdr, url) {
	g_showingBubble = true;
	posBubble(selObj,id); // position infobubble  pop up layer
	
	// doAjax('../inc/account/'+url, '', 'displayBubbleData', 'GET', '0');
	doAjax( url, '', 'displayBubbleData', 'GET', '0');

	if (hdr != '') {document.getElementById('bubbleHeader').innerHTML = hdr}

	document.getElementById(id).style.visibility='visible';
	document.getElementById(id).style.display='block';
	
	if (typeof document.body.style.maxHeight != "undefined") {
		// IE 7, mozilla, safari, opera 9
	} else {
		// IE6, older browsers
		hideSelects();  // hides any select objects that were hidden
	}

};
function hideBubble(id) {

	document.getElementById(id).style.visibility='hidden';
	document.getElementById(id).style.display='none';
	document.getElementById('bubble_body').innerHTML='';


	if (typeof document.body.style.maxHeight != "undefined") {
		// IE 7, mozilla, safari, opera 9
	} else {
		// IE6, older browsers
		if (g_showingBubble) {
			showSelects();  // replaces any select objects that were hidden
		}
	}
	g_showingBubble = false;
};		
function stopTimer() {
	clearTimeout(mTimer);
};
function startTimer(selObj, id, vID, url) {
	mTimer = setTimeout("showBubble('"+selObj+"', '"+id+"', '"+vID+"', '"+url+"');", mTimerDelay);
};

function ecsBubbleUrl(uuidType, uuid) {
    var url = g_ROOT_URL + "/common/documents/cframe/bubble.htm?uuidType=" + uuidType + "&uuid=" + uuid;
    return url;
}
// End bubble pop up Functions
