// JavaScript MGM MIRAGE (c)2009

// DW Image Hover
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];}
}

// ---- Book Gui ----
// -- Calendar
window.addEvent('domready', function() {
	myCal5 = new Calendar({ date1: 'n/j/Y'}, { classes: ['bookgui'], direction: 1, tweak: {x: 3, y: -3} });
});
// -- Nights
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 ResWin(dateIn,stayLength) {

	// date coming in as "01/01/2010", needs to be 010110
	var dateSplit = dateIn.split("/");
	var month = dateSplit[0].length == 1 ? "0" + dateSplit[0] : dateSplit[0];
	var day = dateSplit[1].length == 1 ? "0" + dateSplit[1] : dateSplit[1];
	var year = dateSplit[2].substr(2);
	var formattedDate = month + day + year;
	//alert(formattedDate);

	//if (theURL == '') { theURL = 'https://booking.ihotelier.com/istay/istay.jsp?Rooms=1&HotelID=73133&LanguageID=1'; }
	//if (theURL == '') { theURL = 'http://test-reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=710'; }
	//var theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP%28A2560%29:;myti;?/';
	var theURL = 'https://app.streamsend.com/public/IKGY/asC/subscribe';
	theURL = theURL + formattedDate + ";"; 		// 010110;
	theURL = theURL + (stayLength.length == 1 ? "0" + stayLength : stayLength) + ";?/";

	// redirect mobile visitors to differnt url
	if(isMobile())
		theURL = 'http://be.genares.net/8428/Mobile?ArrivalDateDay=' + day + '&ArrivalDateMonth=' + month + '&ArrivalDateYear=' + dateSplit[2] + '&Nights=' + stayLength;

	var urlWithTracking = pageTracker._getLinkerUrl(theURL);
	//alert(urlWithTracking);

	var winleft = (screen.width - 1000) / 2;
	var winUp = (screen.height - 700) / 2;
	winProp = 'width=1000,height=700,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes';
	Win = window.open(urlWithTracking,'resWin',winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
	void(0);
}

function ResWinInt(dateIn,stayLength) {

	// date coming in as "01/01/2010", needs to be 010110
	var dateSplit = dateIn.split("/");
	var month = dateSplit[0].length == 1 ? "0" + dateSplit[0] : dateSplit[0];
	var day = dateSplit[1].length == 1 ? "0" + dateSplit[1] : dateSplit[1];
	var year = dateSplit[2].substr(2);
	var formattedDate = month + day + year;
	//alert(formattedDate);

	//if (theURL == '') { theURL = 'https://booking.ihotelier.com/istay/istay.jsp?Rooms=1&HotelID=73133&LanguageID=1'; }
	//if (theURL == '') { theURL = 'http://test-reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=710'; }
	//var theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP%28A2560%29:;myti;?/';
	var theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP%28A2560%29:;myti;';
	theURL = theURL + formattedDate + ";"; 		// 010110;
	theURL = theURL + (stayLength.length == 1 ? "0" + stayLength : stayLength) + ";?/";

	// redirect mobile visitors to differnt url
	if(isMobile())
		theURL = 'http://be.genares.net/8428/Mobile?ArrivalDateDay=' + day + '&ArrivalDateMonth=' + month + '&ArrivalDateYear=' + dateSplit[2] + '&Nights=' + stayLength;

	var urlWithTracking = pageTracker._getLinkerUrl(theURL);
	//alert(urlWithTracking);

	var winleft = (screen.width - 1000) / 2;
	var winUp = (screen.height - 700) / 2;
	winProp = 'width=1000,height=700,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes';
	Win = window.open(urlWithTracking,'resWin',winProp);
	if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
	void(0);
}

function ResWinInt2(theURL,ad,nights) {
if (theURL == '') { theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP%28A2560%29:;MYTI;?/'; }
//if (theURL == '') { theURL = 'http://test-reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=710&lang=es'; }
if (ad!=''){ theURL = theURL + "&ad=" + ad;}
if (nights!=''){theURL = theURL + "&nights=" + nights;}
var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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 ResWinES(theURL,ad,nights) {
if (theURL == '') { theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP(A2560):;myti;07142010;01;?/&__utma=1.2122100068.1264524606.1279127924.1279131542.684&__utmb=1.1.10.1279131542&__utmc=1&__utmx=-&__utmz=1.1278619948.661.7.utmcsr=dcoupons|utmccn=hotelDC|utmcmd=link&__utmv=-&__utmk=153773240'; }
//if (theURL == '') { theURL = 'http://test-reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=710&lang=es'; }
if (ad!=''){ theURL = theURL + "&ad=" + ad;}
if (nights!=''){theURL = theURL + "&nights=" + nights;}
var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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 ResWinDE(theURL,ad,nights) {
if (theURL == '') { theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP(A2560):;myti;07142010;01;?/&__utma=1.2122100068.1264524606.1279127924.1279131542.684&__utmb=1.1.10.1279131542&__utmc=1&__utmx=-&__utmz=1.1278619948.661.7.utmcsr=dcoupons|utmccn=hotelDC|utmcmd=link&__utmv=-&__utmk=153773240'; }
//if (theURL == '') { theURL = 'http://test-reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=710&lang=de'; }
if (ad!=''){ theURL = theURL + "&ad=" + ad;}
if (nights!=''){theURL = theURL + "&nights=" + nights;}
var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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 PromoWin(theURL,promo) {
if (theURL == '') { theURL = 'https://booking.ihotelier.com/istay/istay.jsp?hotelid=73133'; }
if (promo!=''){ theURL = theURL + "&host=promo&code=" + promo;}
var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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 RoomWin(theURL) {
//if (theURL == null) { theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP%28A2560%29:;myti;?/'; }
if (theURL == null) { theURL = 'https://app.streamsend.com/public/IKGY/asC/subscribe'; }
// redirect mobile visitors to differnt url
if(isMobile())
	theURL = 'http://be.genares.net/8428/Mobile';

var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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 ViewWin(theURL) {
if (theURL == null) { theURL = 'https://reservations.treasureisland.com/cgi-bin/lansaweb?procfun+inquiry+icpin04+res'; }

// redirect mobile visitors to differnt url
if(isMobile())
	theURL = 'http://be.genares.net/8428/Mobile';

var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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 RoomWinInt(theURL) {
if (theURL == null) { theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP%28A2560%29:;MYTI;?/'; }
//if (theURL == null) { theURL = 'https://reservations.treasureisland.com/cgi-bin/LANSAWEB?procfun+rn+resnet+res+funcparms+UP%28A2560%29:;tiplz1;?/'; }
var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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 RoomWinDE(theURL) {
if (theURL == null) { theURL = 'https://booking.ihotelier.com/istay/istay.jsp?hotelid=73133'; }
//if (theURL == null) { theURL = 'http://test-reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=710&lang=de'; }
var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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 RoomWinES(theURL) {
if (theURL == null) { theURL = 'https://booking.ihotelier.com/istay/istay.jsp?hotelid=73133'; }
//if (theURL == null) { theURL = 'http://test-reservations.mgmmirage.com/bookingengine.aspx?host=hotel&pid=710&lang=es'; }
var winleft = (screen.width - 1000) / 2;
var winUp = (screen.height - 700) / 2;
winProp = 'width=1000,height=700,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(); }
}

// WetSpa
function WetspaWin(theURL) {
if (theURL == null) { theURL = 'http://www.wetspati.com/'; }
var winleft = (screen.width - 1024) / 2;
var winUp = (screen.height - 768) / 2;
winProp = 'width=1024,height=768,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes';
Win = window.open(theURL,'spaWin',winProp);
if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

// Dining
function DinnerWin(Restaurant) {
var winleft = (screen.width - 800) / 2;
var winUp = (screen.height - 525) / 2;
winProp = 'width=800,height=525,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes';
if (Restaurant==null){
window.open('https://reservations.mgmmirage.com/bookingengine.aspx?host=dining&pid=170','dinner',winProp);
//window.open('http://test-reservations.mgmmirage.com/bookingengine.aspx?host=dining&pid=710','dinner',winProp);
} else {
window.open('https://reservations.mgmmirage.com/bookingengine.aspx?host=dining&pid=170&code='+Restaurant,'dinner',winProp);
//window.open('http://test-reservations.mgmmirage.com/bookingengine.aspx?host=dining&pid=710&code='+Restaurant,'dinner',winProp);
}

}

// Tickets
function TicketWin() {
var winleft = (screen.width - 800) / 2;
var winUp = (screen.height - 520) / 2;
winProp = 'width=800,height=520,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=no,status=yes';
Win = window.open('http://ti.admission.com','ticket',winProp);
if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}


// Plan a Meeting
function Meeting(theURL) {
if (theURL == null) { theURL = 'http://rfp.treasureisland.com/'; }
var winleft = (screen.width - 1024) / 2;
var winUp = (screen.height - 768) / 2;
winProp = 'width=1024,height=768,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=yes,toolbar=yes,status=yes';
Win = window.open(theURL,'spaWin',winProp);
if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

// Guestbook - MPE
function GuestBook(email) {
var URL = "https://secure02.mgm-mirage.com/Guestbook/Guestbook.aspx?PID=170"
//var URL = "http://test-secure02.mgm-mirage.com/MPE/Guestbook/Guestbook.aspx?PID=170"
var winleft = (screen.width - 920) / 2;
var winUp = (screen.height - 600) / 2;
if (email != undefined){
	URL += "&email=" + email
}
winProp = 'width=920,height=600,left='+winleft+',top='+winUp+',scrollbars=yes,resizable=yes,menubar=no,toolbar=yes,status=yes';
Win = window.open(URL,'go',winProp);
if (parseInt(navigator.appVersion) >= 4) { Win.focus(); }
}

function openCalendar(FormElement){
	var calendarwindow;
	url = "calendar.html?formname=iform&formelement=" + FormElement;
	calendarwindow = window.open(url,"thewindow","toolbar=no,LEFT=700,TOP=400,WIDTH=170,HEIGHT=140,status=no,scrollbars=no,resize=no,menubar=no");
	calendarwindow.focus();
}

window.addEvent('domready', function(){
	$('drop_down_menu').getElements('li.menu').each( function( elem ){
		var list = elem.getElement('ul.links');
		var myFx = new Fx.Slide(list).hide();
		elem.addEvents({
			'mouseenter' : function(){
				myFx.cancel();
				$('drop_down_menu').getElements('li.menu ul li').setStyle('visibility', 'visible');
				myFx.slideIn();
			},
			'mouseleave' : function(){
				myFx.cancel();
				myFx.slideOut();
			}
		});
	})
});


function isMobile()
{
	var a = navigator.userAgent||navigator.vendor||window.opera;
	return (/android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)));

}


/*
window.fbAsyncInit = function() {
  FB.init({appId: 'your app id', status: true, cookie: true,
           xfbml: true});
};

(function() {
  var e = document.createElement('script'); e.async = true;
  e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
  document.getElementById('fb-root').appendChild(e);
}());
*/


