// ****************************************************************
// *********** IMAGE ROLLOVERS ************************************
// ****************************************************************
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}



// ****************************************************************
// *********** DATEPICKER *****************************************
// ****************************************************************
function changeNumberNights(intNights, field, show, hide) {
	var myTextBox;
	myTextBox = document.getElementById(field);
	myTextBox.value = intNights;
	document.getElementById(hide).style.display = "none";
	if (show != ''){document.getElementById(show).style.display= "block";};
	}
function showNights(element,hide) {
document.getElementById(element).style.display="block";
//if (hide != ''){document.getElementById(hide).style.display="none";};
	}
	
function changeNumberGuests(intGuests, field, show, hide) {
	var myTextBox;
	myTextBox = document.getElementById(field);
	myTextBox.value = intGuests;
	document.getElementById(hide).style.display = "none";
	if (show != ''){document.getElementById(show).style.display= "block";};
	}
function showGuests(element,hide) {
document.getElementById(element).style.display="block";
//if (hide != ''){document.getElementById(hide).style.display="none";};
	}
	
function RoomWin(theURL,ad,nights) { 
	if (theURL == '') { theURL = '#'; }
	if (ad!=''){ theURL = theURL + "&ad=" + ad;}
	if (nights!=''){theURL = theURL + "&nights=" + nights;}
	var winleft = (screen.width - 795) / 2;
	var winUp = (screen.height - 525) / 2;
	winProp = 'width=795,height=525,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes';
	Win = window.open(theURL,'resWin',winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
	}



// ****************************************************************
// *********** 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 signupWin(email) { 
	// Change back to 'https://secure02.mgm-mirage.com/Guestbook/Guestbook.aspx?PID=CCR' once site goes live
	var URL = "https://secure02.mgm-mirage.com/Guestbook/Guestbook.aspx?PID=CCR"
	if (email != undefined){URL += "&email=" + email}
	var winleft = (screen.width - 795) / 2;
	var winUp = (screen.height - 460) / 2;
	winProp = 'width=780,height=510,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=no';
	Win = window.open(URL,'signupwin',winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

function RoomWin(theURL,ad,nights) { 
	// Change back to 'https://reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=CCR' once site goes live
	if (theURL == '') { theURL = 'https://reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=CCR'; }
	if (ad!=''){ theURL = theURL + "&ad=" + ad;}
	if (nights!=''){theURL = theURL + "&nights=" + nights;}
	var winleft = (screen.width - 795) / 2;
	var winUp = (screen.height - 460) / 2;
	winProp = 'width=795,height=460,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes';
	Win = window.open(theURL,'resWin',winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

function resWin(theURL) { 
	// Change back to 'https://reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=CCR' once site goes live
	if (theURL == null) { theURL = 'https://reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=CCR'; }
	var winleft = (screen.width - 795) / 2;
	var winUp = (screen.height - 460) / 2;
	winProp = 'width=795,height=460,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes';
	Win = window.open(theURL,'reswin',winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

function guestBook(email) { 
	// Change back to 'https://secure02.mgm-mirage.com/Guestbook/Guestbook.aspx?PID=CCR' once site goes live
	var URL = "https://secure02.mgm-mirage.com/Guestbook/Guestbook.aspx?PID=CCR"
	if (email != undefined){URL += "&email=" + email}
	var winleft = (screen.width - 795) / 2;
	var winUp = (screen.height - 460) / 2;
	winProp = 'width=780,height=510,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=no';
	Win = window.open(URL,'signupwin',winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

function golfPop() {
	var url = "http://www.bookrenotahoe.com/index.php?client[id]=43&hotel_id=5"; 
	var w = "745"; 
	var h = "500"; 
	var menu = "no"; 
	var scroll = "yes"; 
	var tool = "no"; 
	var location = "no"; 
	var resize = "no";
	var status = "yes";
	var hotkeys = "no";
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winpropsgolf = 'width='+w+', height='+h+', top='+wint+', left='+winl+', menubar='+menu+', scrollbars='+scroll+', toolbar='+tool+', location='+location+',resizable='+resize+',status='+status+',hotkeys='+hotkeys+''
	window.open(url, 'golfpop', winpropsgolf);
}

function skiPop() {
	var url = "http://www.bookrenotahoe.com/index.php?client[id]=39&hotel_id=5"; 
	var w = "745"; 
	var h = "500"; 
	var menu = "no"; 
	var scroll = "yes"; 
	var tool = "no"; 
	var location = "no"; 
	var resize = "no";
	var status = "yes";
	var hotkeys = "no";
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winpropsski = 'width='+w+', height='+h+', top='+wint+', left='+winl+', menubar='+menu+', scrollbars='+scroll+', toolbar='+tool+', location='+location+',resizable='+resize+',status='+status+',hotkeys='+hotkeys+''
	window.open(url, 'skipop', winpropsski);
}



// ****************************************************************
// *********** VERIFY - NUMBERS ONLY ******************************
// ****************************************************************
function checkNum(){
    var carCode = event.keyCode;
	if ((carCode < 48) || (carCode > 57))
	{
	alert('Please enter only numbers.');	
	event.cancelBubble = true;	
	event.returnValue = false;	
	}
}


// ****************************************************************
// *********** Submit The Form When The User Presses Enter ********
// ****************************************************************
function guestBook(email) { 
	// Change back to 'https://secure02.mgm-mirage.com/Guestbook/Guestbook.aspx?PID=CCR' once site goes live
	var URL = "https://secure02.mgm-mirage.com/Guestbook/Guestbook.aspx?PID=CCR"
	if (email != undefined){URL += "&email=" + email}
	var winleft = (screen.width - 795) / 2;
	var winUp = (screen.height - 460) / 2;
	winProp = 'width=780,height=510,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=no';
	Win = window.open(URL,'signupwin',winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}