/* Unipantalla: Codigo para abrir la ventana principal de unipantalla ******************************** */
var openOnePageUI = function() {
  var URLStr = "https://crs.univisit.com/OnePageCrs/OnePageUI.aspx?Code=";
  var ie = document.all;
  if (ie){
	  	   var width  = window.screen.width-9;
           var height = window.screen.height-65;
           var popUpWin=0;
 		}else{
           var width  = window.screen.width;
           var height = window.screen.height;
           var popUpWin=0;
 		 }
        if(popUpWin){
          if(!popUpWin.closed)
                  popUpWin.close();
  }
    popUpWin = open(URLStr + onePageCode, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left=0, top=0');
};

/* Booking: Codigo para integrar el booking de unipantalla  ******************************** */
var onLoadBookingScript = function (){
	var mainCnt = document.getElementById("scrContent");

	if(mainCnt && htmlBooking){
		try{
			var newSpan = document.createElement('span');
			newSpan.innerHTML = htmlBooking;			
			mainCnt.appendChild(newSpan);			
		}catch(ex){}
	}
};

var bookingRendered = 0;
var setBookingScript = function(){		
		//var url = "http://192.168.61.99/visitehotelesdemexico/WebTools/OnePageBooking/BookingEngine.aspx?Code=";
		var url = "http://www.univisit.net/WebTools/OnePageBooking/BookingEngine.aspx?code=" + onePageCode;		

		//truco para no esperar que finalize de cargar la pagina
		var scrContent = document.getElementById("scrContent");
		if(scrContent  == null){
			setTimeout("setBookingScript()",250);			
			return;
		}	
		
		if(!bookingRendered){		
			var newScript = document.createElement('script');
			newScript.type = 'text/javascript';
			//newScript.onload = onLoadBookingScript;
			newScript.src = url;			
			scrContent.appendChild(newScript);		
			bookingRendered = 1;
		}
};

setBookingScript();

// Funciones para escribir los iframes y scripts globales

//IFRAMES
var writeIframeSubscription = function(){
	document.write('<iframe src="https:\/\/crs.univisit.com\/OnePageCrs\/WebSite\/subscription.aspx?code=' + onePageCode + '" name="registrar" id="registrar" width="100%" height="20" scrolling="No" frameborder="0" allowtransparency="true"><\/iframe>');
};

var writeIframeContactUs = function(){
	document.write('<iframe src="https:\/\/crs.univisit.com\/OnePageCrs\/WebSite\/ContactUs.aspx?code=' + onePageCode + '" name="contactus" style="margin:auto" width="400" height="300" scrolling="No" frameborder="0" id="contactus" allowtransparency="true"><\/iframe>');
};

var writeIframeUnsubscribe = function(){
	document.write ('<iframe src="https:\/\/crs.univisit.com\/OnePageCrs\/WebSite\/subscriptionCancel.aspx?code=' + onePageCode + '" id="unsuscribe" name="unsuscribe" width="250" height="30" align="middle" scrolling="No" frameborder="0" allowtransparency="true"><\/iframe>');
};

//SCRIPT INCLUDE
var writeScriptGetRates = function(){
	document.write ('<script type="text\/javascript" src="https:\/\/crs.univisit.com\/wshotelUV2\/Pages\/GetRateByRoom.aspx?code=' + onePageCode + '"><\/script>');
};

