/*
=========================================================
=========================================================
Javascript Document 
INFO BUBBLE POPUPS
Powered by Dynamic Site Design - ken@dynamicsitedesign.com
=========================================================
=========================================================*/

var rc_Timer;
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 rc_getWidgetLeft(selObj) {
	var controller = this.document.getElementById(selObj);
    var iLeft = 0;
	while(controller.tagName != "BODY") {
        iLeft += controller.offsetLeft;
        controller = controller.offsetParent; 
    }
	return iLeft;
};
function rc_getWidgetTop(selObj) {
	var controller = this.document.getElementById(selObj);
    var iTop = 0;
	while(controller.tagName != "BODY") {
        iTop += controller.offsetTop;
        controller = controller.offsetParent; 
    }
	return iTop;
};
function rc_showSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='visible';
   }
};
function rc_hideSelects(){
   var elements = document.getElementsByTagName("select");
   for (i=0;i< elements.length;i++){
      elements[i].style.visibility='hidden';
   }
};


// Begin bubble pop up Functions
function rc_posBubble(selObj,id) {
	if(!isSafari && isNS || isIE_MacOSX || isIE_Mac ){//for Netscape and IE MACs
		document.getElementById(id).style.top =(this.rc_getWidgetTop(selObj) - 124) + "px"; // used to adjust height offset of popup
		document.getElementById(id).style.left = (this.rc_getWidgetLeft(selObj) - 400) + "px"; // used to adjust left offset of popup
	}
	else if(isSafari) { // for Safari MAX OSX
		document.getElementById(id).style.top = (this.rc_getWidgetTop(selObj) - 124) + "px"; // used to adjust height offset of popup
		document.getElementById(id).style.left = (this.rc_getWidgetLeft(selObj)  - 400) + "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  - 400; // used to adjust left offset of popup
	}
};
var g_showingBubble = false;
function rc_showBubble(selObj, id, hdr, url) {
	g_showingBubble = true;
	rc_posBubble(selObj,id); // position infobubble  pop up layer
	
	// doAjax('../inc/account/'+url, '', 'rc_displayBubbleData', 'GET', '0');
	doAjax( url, '', 'rc_displayBubbleData', 'GET', '0');

	if (hdr != '') {document.getElementById('rc_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
		rc_hideSelects();  // hides any select objects that were hidden
	}

};
function rc_hideBubble(id) {

	document.getElementById(id).style.visibility='hidden';
	document.getElementById(id).style.display='none';
	document.getElementById('rc_bubble_body').innerHTML='';


	if (typeof document.body.style.maxHeight != "undefined") {
		// IE 7, mozilla, safari, opera 9
	} else {
		// IE6, older browsers
		if (g_showingBubble) {
			rc_showSelects();  // replaces any select objects that were hidden
		}
	}
	g_showingBubble = false;

};		
function rc_stopTimer() {
	clearTimeout(rc_Timer);
};
function rc_startTimer(selObj, id, vID, url) {
	rc_Timer = setTimeout("rc_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