/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*function doBookingByAjax(url)
{
    var frm=document.priceChangedForm;
	var xmlHttp_html=GetXmlHttpObject();
	var hotelCode=frm.hotelCode.value;
    var totalRate=frm.totalRate.value;
    var roomTypeCode=frm.roomTypeCode.value;
    var ratePlanType=frm.ratePlanType.value;
    var customerFirstName=frm.customerFirstName.value;
    var customerLastName=frm.customerLastName.value;
    var customerCountryCode=frm.customerCountryCode.value;
    var customerAreaCode=frm.customerAreaCode.value;
    var customerPhoneNo=frm.customerPhoneNo.value;
    var customerEmail=frm.customerEmail.value;
    var customerAddress1=frm.customerAddress1.value;
    var customerAddress2=frm.customerAddress2.value;
    var customerCity=frm.customerCity.value;
    var customerState=frm.customerState.value;
    var customerCountry=frm.customerCountry.value;
    
	showBslLoaderAtCenter();
 
	xmlHttp_html.open("POST",url,true);
	xmlHttp_html.onreadystatechange=bookingRequest;
	xmlHttp_html.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp_html.send("hotelCode="+hotelCode+"&totalRate="+totalRate+"&roomTypeCode="+roomTypeCode+"&ratePlanType=\n\
        "+ratePlanType+"&customerFirstName="+customerFirstName+"&customerLastName="+customerLastName+"&customerCountryCode=\n\
        "+customerCountryCode+"&customerAreaCode="+customerAreaCode+"&customerPhoneNo="+customerPhoneNo+"&customerEmail=\n\
        "+customerEmail+"&customerAddress1="+customerAddress1+"&customerAddress2="+customerAddress2+"&customerCity=\n\
        "+customerCity+"&customerState="+customerState+"&customerCountry="+customerCountry);
	
    function bookingRequest()
    {
        if(xmlHttp_html.readyState==4)
        {

            if(xmlHttp_html.status==200)
            {
                responseData=xmlHttp_html.responseText;
                alert(responseData);
                var arr=new Array;
                arr=responseData.split(":");
                if(arr[0]=='PriceUpdated')
                    {
                        document.getElementById("mainDiv").style.display="block";
                        document.getElementById("priceChangedDiv").style.display="block";
                        frm.totalRate.value=arr[1];
                        document.getElementById("currentRateDiv").innerHTML=arr[1];
                    }
                    else if(arr[0]=='Unavailable')
                        {
                            document.getElementById("mainDiv").style.display="block";
                            document.getElementById("hotelUnavailableDiv").style.display="block";
                        }
                        else if(arr[0]=='Success')
                            {
                               document.getElementById('provisionalBookingId').value=arr[1];
                                alert(arr[1]);
                            }
            }            
        }
    }
  
}

function showBslLoaderAtCenter()
{

    var myHeight=0,myWidth=0,outerHeight=0,outerWidth=0,Height=0;
		myHeight=getScrolledHeight();
		Height=getInnerHeight();
		myWidth=getInnerWidth();
		var opacity='';

		var outerLoaderDiv = document.createElement("div");
        var divHeight=100;
		var divWidth=200;
		var outerDivHeight=100;
        var loaderHeight=32;
        var loaderWidth=32;
        outerLoaderDiv.setAttribute('id','outerLoaderDiv');
        if(navigator.appName == "Microsoft Internet Explorer")
		{
			var styleOuter = outerLoaderDiv.style;

			styleOuter.position='absolute';
			styleOuter.top=(myHeight+(Height-outerDivHeight)/2);

			styleOuter.left=((myWidth-divWidth-40)/2)+'px';

			styleOuter.color='#000';
			styleOuter.height=outerDivHeight+'px';
			styleOuter.width=divWidth+'px';

			outerLoaderDiv.setAttribute('style',styleOuter);

		}
		else
		{
			outerLoaderDiv.setAttribute('style','position:absolute;color: #000; top: '+(myHeight+(Height-outerDivHeight)/2)+'px; left: '+((myWidth-divWidth-40)/2)+'px;height: '+(outerDivHeight)+'px;width: '+(divWidth)+'px');

        }
		outerLoaderDiv.innerHTML='<div class="loading-box">Loading...</div>';

		document.body.appendChild(outerLoaderDiv);
}

function hideBslLoaderAtCenter()
{
    if(document.getElementById('outerLoaderDiv'))
        {
            document.body.removeChild(document.getElementById('outerLoaderDiv'));
        }
}

function getScrolledHeight()
{

	var yScrolltop;
	if (self.pageYOffset) {
		yScrolltop = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScrolltop = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScrolltop = document.body.scrollTop;
	}
	return yScrolltop;
}

function getInnerHeight()
{
var myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' )
		myHeight = window.innerHeight;
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		myHeight = document.documentElement.clientHeight;
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		myHeight = document.body.clientHeight;
	return myHeight;
}

function getInnerWidth()
{
	var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' )
		myWidth = window.innerWidth;
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
		myWidth = document.documentElement.clientWidth;
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
		myWidth = document.body.clientWidth;
	return myWidth;
}

function getOuterWidth()
{
	outerWidth = window.outerWidth;
	return outerWidth;
}

function getOuterHeight()
{
	outerHeight = window.outerHeight;
	return outerHeight;
}
*/

function HS_setResult(tag,value)
{
    if(tag=='PriceUpdated')
                    {
                        document.getElementById("mainDiv").style.display="block";
                        document.getElementById("priceChangedDiv").style.display="block";
                        frm.totalRate.value=value;
                        document.getElementById("currentRateDiv").innerHTML=value;
                    }
                    else if(tag=='Unavailable')
                        {
                            document.getElementById("mainDiv").style.display="block";
                            document.getElementById("hotelUnavailableDiv").style.display="block";
                        }
                        else if(tag=='Success')
                            {
                               document.getElementById('provisionalBookingId').value=value;
                                alert(arr[1]);
                            }
}

function HS_openBigImage(bigImgSpanId,img_url)
{
  if(document.getElementById(bigImgSpanId))
	{

		document.getElementById(bigImgSpanId).innerHTML='<img src='+img_url+'>';
	}
}

function HS_showHideRoom()
{
    var noOfRooms=1;
    noOfRooms=parseInt(document.getElementById("noOfRooms").value);
    HS_appendRemoveDivs(noOfRooms);
    HS_addRemoveRoomChildDiv(noOfRooms);
}

function HS_ShowHideChildAges(roomNumber)
{
    var noOfRoomsSelected=parseInt(document.getElementById("noOfRooms").value);
    var flag=false;
    var selectedChildCount=parseInt(document.getElementById('room'+roomNumber+'Child').value);
    HS_addRemoveInnerRoomChildDiv(selectedChildCount,roomNumber);
    
    for(i=0;i<noOfRoomsSelected;++i)
        {
           
            var child=parseInt(document.getElementById('room'+i+'Child').value);
            
            if(child>0)
                {
                    flag=true;
                }
        }
        
        if(selectedChildCount>0)
            {
                document.getElementById("roomChildMainDiv").style.display="block";
                document.getElementById("room"+roomNumber+"ChildDiv").style.display="block";
            }
            else
                {
                    document.getElementById("room"+roomNumber+"ChildDiv").style.display="none";
                   
                }
            if(flag==false)
            {
                document.getElementById("roomChildMainDiv").style.display="none";
            }

    
}

function HS_appendRemoveDivs(currentSelectedRooms)
{
   for(i=1;i<currentSelectedRooms;++i)
       {
          if(document.getElementById("room"+i+"Div"))
              {

              }
          else
           {
               var innerRoomDiv=document.createElement("div");
               var str='<table width="100%" border="0" cellspacing="0" cellpadding="2">\n\
                       <tr >\n\
                        <td width="20%" >&nbsp;</td>\n\
                        <td width="20%" >Room '+(i+1)+'</td>\n\
                        <td width="27%" >\n\
                        <select name="room'+i+'Adult" class="frm3"><option value="1" selected="selected">1</option>\n\
                        <option value="2">2</option>\n\
                        <option value="3">3</option>\n\
                        <option value="4">4</option></select>\n\
                        </td>\n\
                         <td width="33%" >\n\
                         <select class="frm3" name="room'+i+'Child" id="room'+i+'Child" onchange="HS_ShowHideChildAges('+i+')">\n\
                        <option value="0" selected="selected">0</option>\n\
                        <option value="1">1</option>\n\
                        <option value="2">2</option>\n\
                        <option value="3">3</option>\n\
                        <option value="4">4</option>\n\
                        </select>\n\
                        </td>\n\
                        </tr>\n\
                        </table>';
               innerRoomDiv.setAttribute("id", "room"+i+"Div");
               innerRoomDiv.innerHTML=str;
               document.getElementById("mainRoomDiv").appendChild(innerRoomDiv);
           }
       }

    for(i=currentSelectedRooms;;++i)
        {
            if(document.getElementById("room"+i+"Div"))
                {
                    document.getElementById("mainRoomDiv").removeChild(document.getElementById("room"+i+"Div"));
                }
                else
                    {
                        break;
                    }
        }
}

function HS_addRemoveRoomChildDiv(currentSelectedRooms)
{
    if(currentSelectedRooms==1)
        {
            chld=parseInt(document.getElementById('room0Child').value);
            if(chld<=0)
                {
                    document.getElementById('roomChildMainDiv').style.display="none";
                }
        }
    for(i=0;i<currentSelectedRooms;++i)
        {
            if(document.getElementById("room"+i+"ChildDiv"))
                {
                    
                }
                else
                    {
                        str='<div id="room'+i+'ChildInnerDiv" >\n\
                            <div class="htbk2">\n\
                                Room '+(i+1)+'\n\
                            </div>\n\
                            </div>\n\
                        <br>';
                        var div=document.createElement("div");
                        div.setAttribute("id", 'room'+i+'ChildDiv');
                        div.className="htbk";
                        div.style.display="none";
                        div.innerHTML=str;
                        document.getElementById('roomChildMainDiv').appendChild(div);
                    }
        }
    for(i=currentSelectedRooms;;++i)
        {
            if(document.getElementById('room'+i+'ChildDiv'))
                {
                    document.getElementById("roomChildMainDiv").removeChild(document.getElementById('room'+i+'ChildDiv'));
                }
                else
                    {
                        break;
                    }
        }
}

function HS_addRemoveInnerRoomChildDiv(selectedChildCount,roomNumber)
{
    for(i=0;i<selectedChildCount;++i)
        {
            if(document.getElementById('room'+roomNumber+'ChildInnerDiv'+i))
                {

                }
                else
                    {
                        str='<select name="room'+roomNumber+'Child'+i+'" id="room'+roomNumber+'Child'+i+'" class="frm3">\n\
                                    <option value="0" selected="selected">Age</option>\n\
                                    <option value="1">1</option>\n\
                                    <option value="2">2</option>\n\
                                    <option value="3">3</option>\n\
                                    <option value="4">4</option>\n\
                                    <option value="5">5</option>\n\
                                    <option value="6">6</option>\n\
                                    <option value="7">7</option>\n\
                                    <option value="8">8</option>\n\
                                    <option value="9">9</option>\n\
                                     <option value="10">10</option>\n\
                                </select>';
                         var childDiv=document.createElement("div");
                         childDiv.setAttribute("id", "room"+roomNumber+"ChildInnerDiv"+i);
                         childDiv.className="htbk2";
                         childDiv.innerHTML=str;
                         document.getElementById('room'+roomNumber+'ChildInnerDiv').appendChild(childDiv);
                    }
        }
    for(i=selectedChildCount;;++i)
        {
            if(document.getElementById('room'+roomNumber+'ChildInnerDiv'+i))
                {
                    document.getElementById('room'+roomNumber+'ChildInnerDiv').removeChild(document.getElementById('room'+roomNumber+'ChildInnerDiv'+i));
                }
                else
                    {
                        break;
                    }
        }
}



//********************************** SIDE Panel**********************************

function HS_showHideRoomSP()
{
    var noOfRooms=1;
    noOfRooms=parseInt(document.getElementById("noOfRooms").value);
  
    HS_appendRemoveDivsSP(noOfRooms);
    HS_addRemoveRoomChildDivSP(noOfRooms);
}
function HS_ShowHideChildAgesSP(roomNumber)
{
    var noOfRoomsSelected=parseInt(document.getElementById("noOfRooms").value);
    var flag=false;
    var selectedChildCount=parseInt(document.getElementById('room'+roomNumber+'Child').value);
    HS_addRemoveInnerRoomChildDivSP(selectedChildCount,roomNumber);

    for(i=0;i<noOfRoomsSelected;++i)
        {

            var child=parseInt(document.getElementById('room'+i+'Child').value);

            if(child>0)
                {
                    flag=true;
                }
        }

        if(selectedChildCount>0)
            {
                document.getElementById("roomChildMainDiv").style.display="block";
                document.getElementById("room"+roomNumber+"ChildDiv").style.display="block";
            }
            else
                {
                    document.getElementById("room"+roomNumber+"ChildDiv").style.display="none";

                }
            if(flag==false)
            {
                document.getElementById("roomChildMainDiv").style.display="none";
            }


}
function HS_appendRemoveDivsSP(currentSelectedRooms)
{
    var i;
   for(i=0;i<currentSelectedRooms;++i)
       {
         
         if(document.getElementById("room"+i+"Div"))
              {
               
              }
          else
           {
               HS_hotelDivStrSP(i,1,0);
           }
          
       }

    for(i=currentSelectedRooms;;++i)
        {
            if(document.getElementById("room"+i+"Div"))
                {
                    document.getElementById("mainRoomDiv").removeChild(document.getElementById("room"+i+"Div"));
                }
                else
                    {
                        break;
                    }
        }
}

function HS_hotelDivStrSP(roomNumber,selectedAdult,selectedChild)
{
    var i;
    var innerRoomDiv=document.createElement("div");
   var str='<table width="166" border="0" cellspacing="0" cellpadding="0">\n\
                           <tr >\n\
                            <td bgcolor="#FFFFFF">Room'+(roomNumber+1)+'</td>\n\
                            <td bgcolor="#FFFFFF">\n\
                            <select name="room'+roomNumber+'Adult" class="frm3">';
                               for(i=1;i<=4;++i)
                                   {
                                       str+='<option value="'+i+'" ';
                                       if(selectedAdult==i)
                                           {
                                               str+='selected';
                                           }
                                       str+='>'+i+'</option>';
                                   }
                            str+='</select>\n\
                            </td>\n\
                        <td align="right" bgcolor="#FFFFFF">\n\
                        <select name="room'+roomNumber+'Child" onChange="HS_ShowHideChildAgesSP('+roomNumber+')" id="room'+roomNumber+'Child" class="frm3">';
                       for(i=0;i<=4;++i)
                           {
                             str+='<option value="'+i+'" ';
                             if(selectedChild==i)
                                 {
                                     str+='selected';
                                 }
                             str+='>'+i+'</option>'
                           }
                        str+='</select></td></tr></table>';
                        innerRoomDiv.setAttribute("id", "room"+roomNumber+"Div");
               innerRoomDiv.innerHTML=str;
               document.getElementById("mainRoomDiv").appendChild(innerRoomDiv);
    return str;
}

function HS_addRemoveRoomChildDivSP(currentSelectedRooms)
{
    if(currentSelectedRooms==1)
        {
            chld=parseInt(document.getElementById('room0Child').value);
            if(chld<=0)
                {
                    document.getElementById('roomChildMainDiv').style.display="none";
                }
        }
    for(i=0;i<currentSelectedRooms;++i)
        {
            if(document.getElementById("room"+i+"ChildDiv"))
                {

                }
                else
                    {
                        str='<div id="room'+i+'ChildInnerDiv">\n\
                            <div class="htbk2">\n\
                                Room '+(i+1)+'\n\
                            </div>\n\
                            </div>\n\
                        <br>';
                        var div=document.createElement("div");
                        div.setAttribute("id", 'room'+i+'ChildDiv');
                        div.className="htbk";
                        div.style.display="none";
                        div.innerHTML=str;
                        document.getElementById('roomChildMainDiv').appendChild(div);
                    }
        }
    for(i=currentSelectedRooms;;++i)
        {
            if(document.getElementById('room'+i+'ChildDiv'))
                {
                    document.getElementById("roomChildMainDiv").removeChild(document.getElementById('room'+i+'ChildDiv'));
                }
                else
                    {
                        break;
                    }
        }
}

function HS_addRemoveInnerRoomChildDivSP(selectedChildCount,roomNumber)
{
    for(i=0;i<selectedChildCount;++i)
        {
            if(document.getElementById('room'+roomNumber+'ChildInnerDiv'+i))
                {

                }
                else
                    {
                        str='<select name="room'+roomNumber+'Child'+i+'" id="room'+roomNumber+'Child'+i+'" class="frm3">\n\
                                    <option value="0" selected="selected">Age</option>\n\
                                    <option value="1">1</option>\n\
                                    <option value="2">2</option>\n\
                                    <option value="3">3</option>\n\
                                    <option value="4">4</option>\n\
                                    <option value="5">5</option>\n\
                                    <option value="6">6</option>\n\
                                    <option value="7">7</option>\n\
                                    <option value="8">8</option>\n\
                                    <option value="9">9</option>\n\
                                     <option value="10">10</option>\n\
                                </select>';
                         var childDiv=document.createElement("div");
                         childDiv.setAttribute("id", "room"+roomNumber+"ChildInnerDiv"+i);
                         childDiv.className="htbk2";
                         childDiv.innerHTML=str;
                         document.getElementById('room'+roomNumber+'ChildInnerDiv').appendChild(childDiv);
                    }
        }
    for(i=selectedChildCount;;++i)
        {
            if(document.getElementById('room'+roomNumber+'ChildInnerDiv'+i))
                {
                    document.getElementById('room'+roomNumber+'ChildInnerDiv').removeChild(document.getElementById('room'+roomNumber+'ChildInnerDiv'+i));
                }
                else
                    {
                        break;
                    }
        }
}




