﻿var first = true;
function calcHeight(sclientId)
{
  //find the height of the internal page
  var the_height=
    document.getElementById(sclientId + '_ifrBooking').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById(sclientId + '_ifrBooking').height=
      the_height;
}

function fnSetLoaderStyle()
{
    var top = (jQuery("#beIframe").offset().top + ( jQuery("#beIframe").height()/2)) - (jQuery("#contentLoading").height()/2);
    var left = (jQuery("#beIframe").offset().left + (jQuery("#beIframe").width()/2)) - (jQuery("#contentLoading").width()/2);
    
    document.getElementById("contentLoading").style.display = 'block';
    document.getElementById("contentLoading").style.top = top + 'px';
    document.getElementById("contentLoading").style.left = left + 'px';
}

/*Modified By Ruchir Patel om 21-04-2010.. Functions provided by Parkingbrain team.*/
function ResizeIframe(dialogHeight)     
{   
    if(first)
    {
        HideParentWaitImage();
        first = false;
    }
    var iFrames = document.getElementsByTagName("iframe");
    if (typeof dialogHeight == "undefined") 
    {
        dialogHeight = 0;
    }
    for (var i = 0, j = iFrames.length; i < j; i++) 
    {
        if (iFrames[i].id == "beIframe") 
        {
            if (dialogHeight < iFrames[i].contentWindow.document.body.offsetHeight) 
            {
                dialogHeight = iFrames[i].contentWindow.document.body.offsetHeight;
            }
            iFrames[i].style.height = dialogHeight + 'px';
            setTimeout('TempResizeIframe(' + dialogHeight + ');', 100);
        }
    }
}
 
function TempResizeIframe(dialogHeight)
{
    var iFrames = document.getElementsByTagName("iframe");
    if (typeof dialogHeight == "undefined") 
    {
        dialogHeight = 0;
    }
    for (var i = 0, j = iFrames.length; i < j; i++) 
    {
    if (iFrames[i].id == "beIframe") 
    {
        if (dialogHeight < iFrames[i].contentWindow.document.body.offsetHeight) 
        {
            dialogHeight = iFrames[i].contentWindow.document.body.offsetHeight;
        }
        jQuery(iFrames[i].contentWindow.document.body).children().each(function () {if (dialogHeight < jQuery(this).outerHeight()) {dialogHeight = jQuery(this).outerHeight();}});
        iFrames[i].style.height = dialogHeight + "px";
    }
    }
}

function fnClearImages()
{   
	//This Loop remove all the Images and tables from CMS Home Page
    for(i=0;i<=25;i++)
		{
			if(document.getElementById("ElementToRemoveByBE"+i) != null)
			{
				document.getElementById("ElementToRemoveByBE"+i).style.display = 'none';
			} 
		}
	
	//This finction Set 100% width of TD above Iframe
	jQuery(".FrameFix-Width").css("width","100%");
}

//Added by Anil Patel Dt. 29/10/2009
function fnShowImages()
{   
	//This function set Menu Iframe src from Booking Engine
    var menuIframe = document.getElementById('menuIframe');
    menuIframe.src = menuIframe.src ;
    
	
	//This Loop Reset Hiden Images and Tables
	for(i=0;i<=25;i++)
    {
        if(document.getElementById("ElementToRemoveByBE"+i) != null)
        {
            document.getElementById("ElementToRemoveByBE"+i).style.display = '';
        } 
    }
    
	if(typeof setFlash != 'undefined')
	{
		flashInterval = setInterval('setFlash()', 100);
	}
	
	//This finction Set 0% width of TD above Iframe
	jQuery(".FrameFix-Width").css("width","");
}

/* START - Added By: Mahesh on 03/12/2009. As per Jaydeep Parekh's email on 03/12/2009 Sub: reg: Loading issue */
function ShowParentWaitImage()
{
    var oWaitDiv = jQuery("#contentLoading");
    var topPosition='';
    var leftPosition='';
    topPosition = jQuery(document).scrollTop()+ (jQuery(window).height()-oWaitDiv.height()) / 2 +'px';
    leftPosition = jQuery(document).scrollLeft()+ (jQuery(window).width()-oWaitDiv.width()) / 2 +'px';
    oWaitDiv.css({top :topPosition ,left : leftPosition });
    oWaitDiv.show();
    jQuery('#divModalBack').show();
    // $("#contentLoading").dialog({ height: 530,width:530,position:[0,0],bgiframe:false});
}

function HideParentWaitImage()
{
    jQuery("#contentLoading").hide(); 
    jQuery('#divModalBack').hide();
}
/* END - Added By: Mahesh on 03/12/2009. As per Jaydeep Parekh's email on 03/12/2009 Sub: reg: Loading issue */


//Added by Ruchir Patel. To add label, which contains booking engine content, into module DIV tag.
function SetBEHtml(sDvClientID)
{ 
    var oDv = jQuery('#' + sDvClientID);
    var oLt = jQuery('#lblBEContent');
    oLt.appendTo(oDv);
    oLt.show();
}