// ****************************************************************
// *********** TOGGLE MENU ****************************************
// ****************************************************************
if (!ToggleImages) {
    var ToggleImages = true;  // Uses images by default
}
if (!ToggleImageOpen) {
    var ToggleImageOpen = "url(/images/icons/toggleClose.gif)";  // Uses this image by default for the open button
}
if (!ToggleImageClose) {
    var ToggleImageClose = "url(/images/icons/toggleOpen.gif)";  // Uses this image by default fot the close button
}
if (!ToggleCloseAll) {
    var ToggleCloseAll = true;  // By default, only one Toggle div can be opened
}

function toggleCloseAll(which, whichNotToClose) {
    // Close all Toggles
    // which = the div containing all the "ToggleContainer" classed Divs
    // l is the number of sibling "ToggleContainer"s
    l = which.childNodes.length;

    // We need to search all the siblings to close all the toggles
    for (i=0; i < l; i++) {
        // te = this element
        te = which.childNodes[i];

        if (te.className == "mToggleContainer" && te != whichNotToClose) {
            // We've found a sibbling, we need to search it for a "ToggleContent" to hide and
            // a "ToggleH2" to switch the +/- background
            // sl = number of elements in this toggleContainer
            sl = te.childNodes.length;
            for (j=0; j < sl; j++) {
            
                // tse = this sub-element
                tse = te.childNodes[j];
                if (te.childNodes[j].className) {
                    // hide this content
                    if (te.childNodes[j].className == "mToggleContent") {
                            te.childNodes[j].style.display = "none";
                    }
                    // Change this icon
                    if (te.childNodes[j].className == "mToggleH2" && ToggleImages) {
                         te.childNodes[j].style.backgroundImage = ToggleImageClose;
                    }
                }
            }               
        }
    }
}

function mtoggle(which) {
    // Close all Toggles before we open another
    if (ToggleCloseAll) {
        toggleCloseAll(which.parentNode.parentNode, which.parentNode); // Close all toggles EXCEPT this one
    }
    
    // Check all elements whithin this ToggleContainer    
    l = which.parentNode.childNodes.length;
    
    for (i = 0; i < l; i++) {
        cn = which.parentNode.childNodes[i];
        // Find the title h2 and the content div
        if (cn.className) {if (cn.className == "mToggleH2") {title = which.parentNode.childNodes[i];
		}
		if (cn.className == "mToggleContent") 
		{tcontent = which.parentNode.childNodes[i];}
		}
		}

    // Toggle them on / off
    if (tcontent.style.display != "inline") {
        tcontent.style.display = "inline";
        if (ToggleImages) {
            title.style.backgroundImage = ToggleImageOpen;
        }    
    } else {
        tcontent.style.display = "none";
        if (ToggleImages) {
            title.style.backgroundImage = ToggleImageClose;
        }
    }
}

function openToggle(which) {
    // To Open a Toggle by it's ID
    // Assign an id to the ToggleH2 classed <h2> tag
    
    findElement = document.getElementById(which);
    toggle(findElement)
}


// ****************************************************************
// *********** POPUP WINDOOW **************************************
// ****************************************************************
function popWin(theURL, winName, popW, popH, features) { 
	var winleft = (screen.width - popW) / 2;
	var winUp = (screen.height - popH) / 2;
	winProp = 'width='+popW+',height='+popH+',left='+winleft+',top='+winUp+',resizable=yes,status=yes,'+features;
	Win = window.open(theURL, winName, winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

function PrivacyWin() {
var winleft = (screen.width - 450) / 2;
var winUp = (screen.height - 450) / 2;
Win = window.open('http://www.mgmmirage.com/privacy.htm','privacy','toolbar=yes,scrollbars=yes,resizable=yes,status=yes,width=450,height=450,top='+winUp+',left='+winleft);
if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

function TermsOfUseWin() {
var winleft = (screen.width - 450) / 2;
var winUp = (screen.height - 450) / 2;
Win = window.open('http://www.mgmmirage.com/termsofuse.htm','privacy','toolbar=yes,scrollbars=yes,resizable=yes,status=yes,width=450,height=450,top='+winUp+',left='+winleft);
if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}


// ****************************************************************
// *********** DROP DOWN JUMP MENU ********************************
// ****************************************************************
function surfto(form) {
       var myindex=form.propertyJumpMenu.selectedIndex
       window.open(form.propertyJumpMenu.options[myindex].value, 
         target="_blank");
}
