﻿// JScript File
var GrayDiv, WrapperDiv, borderDiv
var myWidth = 0, myHeight = 0;

function alertSize() {
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myWidth;
}

function ShowBooking(guid, Size){
    var height =620;
    var width =820;
    var left =140;
    var top =90;
    
    left = (alertSize()/2) - (width/2);
    if(left<0){left=0;}
        
    if(Size=="Normal"){
        height =620;
        width =820;
        //left =140;
        top =90;

        if(myHeight - height < 0 ){
            top = 2;
        }
    }
    if(Size=="Full"){
        height = myHeight ;
        width = myWidth ;
        left = 0;
        top = 0;
        
        WrapperDiv = document.createElement('div');
        WrapperDiv.style.width = width-20;
        WrapperDiv.style.height = height-30;
        WrapperDiv.style.position = "absolute";
        WrapperDiv.style.left = left + 10;
        WrapperDiv.style.top = top + 10;
        WrapperDiv.style.border = "1px solid Gray";
        var rand = Math.floor(Math.random()*9999999);
        var html = "<iframe id='ifBooking' frameborder='0' scrolling='no' style='height:" + WrapperDiv.style.height;
        html += "; width:" + WrapperDiv.style.width + "' src='http://www.trbsoftware.com.au/BookingSelect.aspx?ty=full&gu=" + guid + "&i=" + rand + "'>";
        WrapperDiv.innerHTML = html;
        WrapperDiv.style.zIndex = 1002;
        document.body.appendChild(WrapperDiv);

    }else{
        //gray out div
        GrayDiv = document.createElement('div');
        GrayDiv.style.width = "100%";
        GrayDiv.id = "dvGrayOut";
        GrayDiv.style.height = "100%";
        GrayDiv.style.position = "absolute";
        GrayDiv.style.left = 1;
        GrayDiv.style.top = 1;
        GrayDiv.style.backgroundImage = "url(http://www.trbsoftware.com.au/Images/grayOut.png)";
        GrayDiv.style.zIndex = 1000;
        document.body.appendChild(GrayDiv);
        //wrapper div
        WrapperDiv = document.createElement('div');
        WrapperDiv.style.width = width-20;
        WrapperDiv.style.height = height-40;
        WrapperDiv.style.position = "absolute";
        WrapperDiv.style.left = left + 10;
        WrapperDiv.style.top = top + 10;
        WrapperDiv.style.border = "1px solid Gray";
        var rand = Math.floor(Math.random()*9999999);
        var html = "<iframe id='ifBooking' frameborder='0' scrolling='no' style='height:" + WrapperDiv.style.height;
        html += "; width:" + WrapperDiv.style.width + "' src='http://www.trbsoftware.com.au/BookingSelect.aspx?gu=" + guid + "&i=" + rand + "'>";
        WrapperDiv.innerHTML = html;
        WrapperDiv.style.zIndex = 1002;
        document.body.appendChild(WrapperDiv);
        //Border div
        borderDiv = document.createElement('div');
        borderDiv.style.width = width +3;
        borderDiv.style.height = height;
        borderDiv.style.position = "absolute";
        borderDiv.style.left = left;
        borderDiv.style.top = top;
        borderDiv.style.border = "1px solid Gray";
        borderDiv.style.backgroundColor = "White";
        borderDiv.innerHTML = "<table height='100%' width='100%'><tr><td valign='bottom' height='100%' width='100%' align='Center'><a style='color:black' href='javascript:HideBooking();'>Close Booking</a></td></tr></table>";
        borderDiv.style.zIndex = 1001;
        document.body.appendChild(borderDiv);
    }

    
    
}

function HideBooking(){
    GrayDiv.style.display = 'none';
    WrapperDiv.style.display = 'none';
    borderDiv.style.display = 'none';
}


