﻿// JScript File
/*
cvalenzuela
Custom Javascript Tooltips
Version .01
*/
if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
//Globals holding mouse cursor position
var intMouseX=0;
var intMouseY=0;
var intPageX=0;
var intPageY=0;
var intScrollX;
var intScrollY;

var toShowToolTip;
var toHideToolTip;
var intTODelay = 150;
var intRightEdge;
var intLeftEdge;
var intBottomEdge; 


     
var intXOffset = 20;
var intYOffset = 20;


var browser = new Browser();
//Browser Check
function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
   
}

 function CaptureMouseEvents(Capture)
  {
    if(Capture)
    {
        if(!browser)
        {
            browser = new Browser();
        }
        if (browser.isNS) 
        { 
            document.captureEvents(Event.MOUSEMOVE);
            document.onmousemove = getCursor;
           
        }
        else
        {
            document.onmousemove = getCursor;
        }
    }  
  }  

//Get Mouse Cursor position
function getCursor(e)
{
    var tempX;
    var tempY;
    if (browser.isIE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
    } else { // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
    }
    // catch possible negative values in NS4
    if (tempX < 0){tempX = 0}
    if (tempY < 0){tempY = 0}
    // draw rectangle with a pair of coordinates
    intMouseX=tempX;
    intMouseY=tempY; 
    
    //get page size
    if (browser.isIE) {
        intScrollX = document.documentElement.scrollLeft + document.body.scrollLeft;
        intScrollY = document.documentElement.scrollTop  + document.body.scrollTop;
    }else {
        intScrollX = window.scrollX;
        intScrollY = window.scrollY;
  } 
   
    if(browser.isIE)
    {
        intRightEdge = (IEWindow().clientWidth-intMouseX);
        intBottomEdge = (IEWindow().clientHeight-intMouseY);
    }
    else
    {
         intRightEdge = (window.innerWidth);
         intBottomEdge = (window.innerHeight);       
     }
  
}


function ShowToolTip(SourceObject)
{     var tDiv = document.getElementById("ToolTip");
        SourceObject.removeAttribute("title");//I Will use it later
   
    clearTimeout(toHideToolTip);
    tDiv.style.position = "absolute";       
    tDiv.style.top = intYOffset + intMouseY + "px";
    tDiv.style.left = intXOffset + intMouseX + "px";   
    trans(tDiv,90);
    toShowToolTip = setTimeout("document.getElementById('" + tDiv.id + "').style.display = 'inline';",intTODelay);
    
  

}

function PrepareToolTip(SourceObject){
    var tDiv = document.getElementById("ToolTip");
    var ParentId = SourceObject.id;
    var intObjectHeight = tDiv.offsetHeight;
    var intObjectWidth = tDiv.offsetWidth;
    var intXOffset=0;
    var intYOffset=0;     
    
   
   
    if(ParentId.indexOf("MyAzHealth") != -1)
    {
     tDiv.innerHTML = '<img src="images/myazhealthandwellnessScreen.jpg">';
    } 
    else if(ParentId.indexOf("Ahcccs") != -1)
    {
     tDiv.innerHTML = '<img src="images/myahcccsScreen.jpg">';
    }
    else if(ParentId.indexOf("healthwise") != -1)
    {
     tDiv.innerHTML = '<img src="images/healthwiseScreen.jpg">';     
    }
        
//    if(intRightEdge  <= intObjectWidth)//buggy
//    {
//        //intXOffset =  intRightEdge - intObjectWidth;//flush right  
//        intXOffset = 0 - intObjectWidth - 20; // Left of Cursor
//    }
//    else
//    {
//        intXOffset = 20;
//    }

    
    
   
}

function HideToolTip(){
    var tDiv = document.getElementById("ToolTip");
    clearTimeout(toShowToolTip);
     trans(tDiv,0);
    toHideToolTip = setTimeout("document.getElementById('" + tDiv.id + "').style.display = 'none';",intTODelay);
}


function IEWindow(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function trans(obj, opacity){
    if (browser.isNS)
        obj.style.MozOpacity=opacity/100
    else if (browser.isIE)
        
        obj.style.filter= "alpha(opacity="+opacity+")"
    else
        obj.style.opacity = opacity/100     
}

function CallPrint(strid)
{
 var prtContent = document.getElementById(strid);
 var WinPrint = window.open('','','left=0,top=0,width=550,toolbar=0,scrollbars=0,status=0');
 WinPrint.document.write(prtContent.innerHTML);
 WinPrint.document.close();
 WinPrint.focus();
 WinPrint.print();
 WinPrint.close();
}

function updateIFrame( height ) {
    var iframe = document.getElementById( 'ContentFrame' );
    iframe.setAttribute( 'height', height );
    }



function CustomAlert(TitleOfAlert, ContentOfAlert, AlertDivId)
{
   // var AlertDiv = document.getElementById(AlertDivId);
   // alert(TitleOfAlert);
   // AlertDiv.innerHTML = "Test";
    //AlertDiv.style.display = "block";

}











document.onload += CaptureMouseEvents(true);





//Effects

function InputFocus(objId)
{
    var obj= document.getElementById(objId);
    alert(objId);
    //.className="InputFocus";
    
}
function InputBlur(objId)
{
    var obj= document.getElementById(objId);
    //document.getElementById(objId).className="InputBlur";
}