var ie = (document.all) ? 1:0 // detects ie
var dom = (document.getElementById && !document.all) ? 1:0 //detects mozilla browsers like NS6 & 7

// Helps Setup SubNavDropDown Kill for MacIE
function BrowserDetectVeryLite(){
    var ua = navigator.userAgent.toLowerCase(); 
    this.isMac   = (ua.indexOf('mac') != -1);
    this.isIE    = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) ); 
    this.isNS        = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );
    
        
    // browser version
    n = ua.indexOf('netscape')
    NSversion = ua.substring(n+8,n+9)

    this.versionMinor = parseFloat(navigator.appVersion); 
    this.versionMajor = parseInt(this.versionMinor); 
    // correct version number
    if (this.isIE && this.versionMinor >= 4) {
        this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );}
    }
var browser = new BrowserDetectVeryLite();



getVer = browser.versionMinor.toString()
isIE50 = (getVer.indexOf('5.0')!=-1?true:false)

var killRollouts;
if(browser.isMac && browser.isIE){killRollouts = true} 
if(isIE50){killRollouts = true} 
if(NSversion == "6"){killRollouts = true} 
// ******************************************


// Search Submit
function HeaderSearchButton_Click() {
    if(ie){
        if(document.forms[0]._headerSearch.value != null && document.forms[0]._headerSearch.value != ''){
            window.location.href = "/CWS/Search.aspx?state=SearchQuery&Criteria="+escape(document.forms[0]._headerSearch.value) ;
            return false;
            }
        else {
            window.location.href = "/CWS/Search.aspx?state=NoTextEntered";
            return false;}}
    if(dom){
        if(document.forms[0]._headerSearch.value != null && document.forms[0]._headerSearch.value != ''){
            window.location.href = "/CWS/Search.aspx?state=SearchQuery&Criteria="+escape(document.forms[0]._headerSearch.value) ;
            return false;}
        else {
            window.location.href = "/CWS/Search.aspx?state=NoTextEntered";
            return false;}}
}
// ********************************************************************************************

//For launching Maps and Directions
function launchPopup(page){
    var width
    var height
    var leftdist
    var topdist
    width = screen.width;
    height = screen.height;
    leftdist = Math.round((width - 700) / 2);
    topdist = Math.round((height - 500) / 2);
    window.open(page,'mappopup','width=700,height=500,top=10,left='+leftdist+',resizable=1,menubar=1,location=1,scrollbars=1,toolbar,status=1')
}
// *******************************************************************************************
// For hitting enter to submit search
function entsub() {
var Key=event.keyCode
if(Key==13)
{
   
    HeaderSearchButton_Click()
    return false ;
}
else
{   
    return true;
}
}
// **********************************


// Right Mouse Click Disable
var message="Copyright 2003 Tenet Healthcare Corporation. All Rights Reserved.";

function rightClickDisable(){
    if(ie){
        if (event.button==2){
            alert(message);
            return false;}
    }
    if(dom){
        oncontextmenu=new Function("alert(message);return false")}
}
// ******************************************************************

// Begin SR 32809  - CWS: Add RAD editor to existing templates
function HideDefinition()
{
    hideddrivetip();
}
function ShowDefinition(elementId,titleText,descText)
{
    ddrivetip(unescape(titleText),unescape(descText))   
}

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
document.write("<div id='dhtmltooltip'></div>");
var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(theTitle, theDesc){
if (ns6||ie){
tipobj.innerHTML="<table class='toolTipTable' cellpadding='0' cellspacing='0'><tr class='toolTipTitle'><td>" + theTitle + "</td></tr><tr class='toolTipDesc'><td>" + theDesc + "</td></tr></table>";
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip && tipobj.style.visibility!="visible"){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip
//End SR 32809

// ******************************************************************
// Return the browser window size.
//
// The following method should work on all supported browsers:
// If window.innerHeight/Width is provided, that is fully trustworthy, use that. 
// Else if document.documentElement.clientHeight/Width is provided and either one is greater than 0, use that. 
// Else use document.body.clientHeight/Width

function getWindowSize()
{
    var myWidth = 0, myHeight = 0;
    if( typeof( window.innerWidth ) == 'number' )
    {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    }
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
    {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    }
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
    {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    
    var windowSize = new Object();
    windowSize.width = myWidth;
    windowSize.height = myHeight;
    
    return windowSize;
}
