﻿function _g(x){return document.getElementById(x);}
function Setcdiv(x)
{
var i=0;
while(_g("cc_div_"+i))
{
    if(x==i)
    {
        _g("cc_div_"+i).className="tp_det_cboxs";
        _g("c_divp_"+i).className="";
        i++;
        if(_g("cc_div_"+i))
        {
             _g("cc_div_"+i).className="tp_det_cboxs";
             _g("c_divp_"+i).className="";
        }
    }
    else
    { 
        _g("cc_div_"+i).className="tp_det_cboxs_close";
        _g("c_divp_"+i).className="tp_det_sbts2";
    }
    i++;
}
}


 function ShowDivList(x){var ImgUrl="";var i=1;while(_g("TDdiv"+i)){if(_g("TDdiv"+i).style.background.toString().indexOf("url")>=0)ImgUrl=_g("TDdiv"+i).style.background;_g("DivList"+i).style.display="none"; _g("TDdiv"+i).style.background="";
i++;}_g("DivList"+x).style.display=""; _g("TDdiv"+x).style.background=ImgUrl;}
 
function SelectAdultChange(){if(_g("I_Adult").value=="0")_g("I_Children").disabled=true;else	_g("I_Children").disabled=false;SetRoomNum(true);}
function ChildCountToCheck(){var adultcount=_g("I_Adult").value;var childcount=_g("I_Children").value;
if(parseInt(adultcount)<parseInt(childcount)){alert('One adult with one child only');_g("I_Children").selectedIndex=_g("I_Adult").selectedIndex;}SetRoomNum(true);
}function SetEndDate(s){var Tday=parseInt(_g("T_TotalDays").value)-1;_g("I_StartDate").value=s;	_g("I_EndDate").value=addDate(parseDate(s),Tday);}
function parseDate(s){var reg=new RegExp("[^0-9-]","");if(s.search(reg)>=0)return "";var ss=s.split("-");if(ss.length!=3)return "";
if(isNaN(ss[0])||isNaN(ss[1])||isNaN(ss[2]))return "";
return new Date(parseFloat(ss[0]),parseFloat(ss[1])-1,parseFloat(ss[2]));}
function addDate(date,numDay){var datestr;var str;var time   =   date.getTime();var newTime   =   time   +   numDay*24*60*60*1000;
datestr= new   Date(newTime);str=datestr.getFullYear() + "-" + (datestr.getMonth()+1)+"-"+datestr.getDate();return  str;}
function CheckData(){if(_g("I_StartDate").value==""){alert("Please enter a Start Date");_g("I_StartDate").focus();	return false;}
if(_g("I_Adult").value=="0"){alert("Please select Adult number");_g("I_Adult").focus();	return false;}_g("I_Children").disabled=false;return true;}
function ShowComments(x){window.open("/Tool/CommentList.aspx?Pid="+x+"&TypeId=3",'', 'resizable=yes,scrollbars=yes;width=750,height=527');}
function SetRoomNum(y){var Ax=parseInt(_g("I_Adult").value,10);var Cx=parseInt(_g("I_Children").value,10);

if(_g("I_Rooms")!=null)
{
var RNum=parseInt(_g("I_Rooms").value,10);
Ax+=Cx;if(y){Ax=Math.floor(Ax/2)+(Ax%2);
_g("I_Rooms").selectedIndex=Ax-1;return;}
if(Ax<RNum)_g("I_Rooms").selectedIndex=Ax-1;
if(RNum*2<Ax)_g("I_Rooms").selectedIndex=(Math.floor(Ax/2)+(Ax%2))-1;}
}
