/************************************************************************************************
Name		- Tooltips
Description	- Shows tooltips using custom container and styles.
Version		- 4.0.0
Author		- Anoop Nair, Kapil Bajaj.
Company		- OASIS (part of MKCL).

# COPYRIGHT NOTICE
# Copyright (c) 2005-2010 MKCL, All rights reserved.
# This script may be used and modified free of charge for Non-profit purposes by anyone as long
# as this copyright notice and the comments above are kept in their original form.
************************************************************************************************/

if(typeof(OASIS)=='undefined')alert('Dear Developer,Please add reference to "FuncLib.js"!\r\nPlease verify version too.');OASIS.Tooltips=new function(){var messageBox;var boxHeight=0,boxWidth=0;var noMotion=0,motionTimer=new Array();this.InitAll=function(){if(!messageBox){var newDiv=document.createElement('DIV');newDiv.style.padding='1px 3px';newDiv.style.border='outset black 1px';newDiv.style.background='pink';document.body.appendChild(newDiv);OASIS.Tooltips.SetMessageBox(newDiv);}if(messageBox.parentNode)OASIS.Tooltips.SearchTooltips(document.body);};this.SearchTooltips=function(theElem){var passed=false;if(theElem.nodeType==1 && ',div,span,table,img,tr,td,a,input,'.search(','+theElem.nodeName.toLowerCase()+',')!=-1){if(theElem.tooltiptxt || theElem.getAttribute('tooltiptxt')|| theElem.tooltipfn || theElem.getAttribute('tooltipfn')){passed=true;OASIS.FuncLib.RemoveEventHandler(theElem,'mouseover',OASIS.Tooltips.Show);OASIS.FuncLib.RemoveEventHandler(theElem,'mousemove',OASIS.Tooltips.Move);OASIS.FuncLib.RemoveEventHandler(theElem,'mouseout',OASIS.Tooltips.Hide);OASIS.FuncLib.AddEventHandler(theElem,'mouseover',OASIS.Tooltips.Show);OASIS.FuncLib.AddEventHandler(theElem,'mousemove',OASIS.Tooltips.Move);OASIS.FuncLib.AddEventHandler(theElem,'mouseout',OASIS.Tooltips.Hide);}}if(!passed){var elems=theElem.childNodes;for(var i=0;i< elems.length;i++)OASIS.Tooltips.SearchTooltips(elems[i]);}};this.SetMessageBox=function(){var newBox;try{newBox=(typeof(arguments[0])=='object'? arguments[0]: document.getElementById(arguments[0]));if(!newBox)throw(0);}catch(err){alert('ArgumentException :- Parameter not found/not in expected format.'+'\r\nParameter - "MessageBox".'+'\r\nFunction - "OASIS.Tooltips.SetMessageBox".');return;}messageBox=newBox;if(OASIS.Browser.IsIe)document.body.childNodes[0].appendChild(messageBox);messageBox.style.display='none';messageBox.style.position='absolute';messageBox.style.left=0;messageBox.style.top=0;messageBox.style.zIndex=200;if(!messageBox.Body){if(messageBox.nodeName=='DIV' && messageBox.className=='ContentBox'){var divs=messageBox.getElementsByTagName('DIV'),i=0;while(divs[i].className!='InnerBodyDiv')i++;messageBox.Body=(i< divs.length? divs[i]: messageBox);}else{messageBox.Body=messageBox;}}messageBox.Settings=new function(){this.Show=true;this.SimpleTip=true;this.Width=messageBox.style.width;this.Height=messageBox.style.height;};boxHeight=0;boxWidth=0;};this.Show=function(){var evt=OASIS.FuncLib.GetEvent(arguments[0]);var source=evt.SourceElement;var type=-1;messageBox.Settings.Show=true;messageBox.Settings.SimpleTip=true;messageBox.Settings.Width=(OASIS.Browser.IsIe && OASIS.Browser.Version< 8?300:'auto');messageBox.Settings.Height='auto';while(type==-1 && source){if(source.tooltiptxt){type=0;messageBox.Body.innerHTML=source.tooltiptxt;}else if(source.getAttribute('tooltiptxt')){type=1;messageBox.Body.innerHTML=source.getAttribute('tooltiptxt');}else if(source.tooltipfn){type=2;messageBox.Body.innerHTML=(OASIS.Browser.IsIe? eval(source.tooltipfn)(source,messageBox.Settings): source.tooltipfn(source,messageBox.Settings));}else if(source.getAttribute('tooltipfn')){type=3;messageBox.Body.innerHTML=eval(source.getAttribute('tooltipfn'))(source,messageBox.Settings);}else{source=source.parentNode;}}if(type!=-1 && messageBox.Settings.Show){if(!messageBox.style.height.EndsWith('px'))messageBox.style.height=messageBox.Settings.Height;if(typeof(messageBox.SetWidth)=='function')messageBox.SetWidth(messageBox.Settings.Width);else messageBox.style.width=messageBox.Settings.Width+'px';noMotion=0;boxHeight=0;boxWidth=0;ClearTimers();if(!messageBox.Settings.SimpleTip)OASIS.FuncLib.AddEventHandler(messageBox,'mouseout',OASIS.Tooltips.Close);}};this.Move=function(){if(!messageBox.Settings.Show)return;var evt=OASIS.FuncLib.GetEvent(arguments[0]);if(noMotion==0){messageBox.style.display='none';ClearTimers();}noMotion++;motionTimer[motionTimer.length]=setTimeout('OASIS.Tooltips.DisplayBox('+noMotion+','+evt.PositionX+','+evt.PositionY+')',500);};this.Hide=function(){if(!messageBox.Settings.Show)return;var evt=OASIS.FuncLib.GetEvent(arguments[0]);if(IsChildAndParent(evt.TargetElement,messageBox))return;messageBox.Body.innerText='Tooltip';messageBox.style.display='none';ClearTimers();};this.Close=function(){var evt=OASIS.FuncLib.GetEvent(arguments[0]);if(IsChildAndParent(evt.TargetElement,messageBox))return;messageBox.Body.innerText='Tooltip';messageBox.style.display='none';ClearTimers();};this.DisplayBox=function(lastMotion,mouseX,mouseY){if(noMotion<=lastMotion){noMotion=0;messageBox.style.display='';SetPosition(mouseX,mouseY);}};function ClearTimers(){for(var i=0;i< motionTimer.length;i++)clearTimeout(motionTimer[i]);motionTimer=new Array();}function IsChildAndParent(childElem,parentElem){if(!childElem || !parentElem)return false;var parentOfChild=childElem.parentNode;while(parentOfChild!=document.body)if(parentOfChild==parentElem)return true;else parentOfChild=parentOfChild.parentNode;return false;}function SetPosition(mouseX,mouseY){var viewport=OASIS.Browser.GetViewport();if(boxHeight==0 || boxWidth==0){boxWidth=messageBox.offsetWidth;boxHeight=messageBox.offsetHeight;}if(boxWidth==0 ||(mouseX- boxWidth>0 && mouseX+1+boxWidth> viewport.Width-(OASIS.Browser.IsIe?0:15))){messageBox.style.right=(viewport.Width- mouseX+(messageBox.Settings.SimpleTip?(OASIS.Browser.IsIe?3:-8):-25))+'px';messageBox.style.left='auto';}else{messageBox.style.left=(mouseX+(messageBox.Settings.SimpleTip?3:-10))+'px';messageBox.style.right='auto';}if(boxHeight==0 ||(mouseY- boxHeight>0 && mouseY+1+boxHeight> viewport.Height-(OASIS.Browser.IsIe?0:15))){messageBox.style.bottom=(viewport.Height- mouseY+(messageBox.Settings.SimpleTip?3:-15))+'px';messageBox.style.top='auto';}else{messageBox.style.top=(mouseY+(messageBox.Settings.SimpleTip?3:-10))+'px';messageBox.style.bottom='auto';}}};OASIS.FuncLib.AddLoadEvent(OASIS.Tooltips.InitAll);