
function setTravelerDetail(select,pax,room,adult,child,infant,edit,max,adults,roomtype,title)
{
num = select-pax;
html = "";
if(num>0)
{
for(i=0;i<num;i++)
{
html += "			<div class='data t_data' id='data"+room+"_"+(parseInt(pax)+parseInt(i))+"'>";
html += "				<div class='t_title'><select name='title["+room+"]["+(parseInt(pax)+parseInt(i))+"]' id='title["+room+"]["+(parseInt(pax)+parseInt(i))+"]'>";
for(j=0;j<title.length;j++)
{
html += "<option value='"+title[j]+"'>"+title[j]+"</option>";
}
html += "				</select></div>";
html += "				<div class='t_lname'><input type='text' name='fname["+room+"]["+(parseInt(pax)+parseInt(i))+"]' id='fname["+room+"]["+(parseInt(pax)+parseInt(i))+"]'></div>";
html += "				<div class='t_fname'><input type='text' name='lname["+room+"]["+(parseInt(pax)+parseInt(i))+"]' id='lname["+room+"]["+(parseInt(pax)+parseInt(i))+"]'></div>";
html += "					<div class='t_type'><select name='paxtype["+room+"]["+(parseInt(pax)+parseInt(i))+"]' id='paxtype["+room+"]["+(parseInt(pax)+parseInt(i))+"]'>";
if(adults > 0)
html += "						<option value='A' SELECTED='selected'>Adult</option>";
else
html += "						<option value='A' >Adult</option>";
if(child=='Y')
{
if(adults < 1)
html += "						<option value='C' SELECTED='selected'>Child</option>";
else
html += "						<option value='C'>Child</option>";
}
if(infant=='Y')
html += "						<option value='I'>Infant</option>";
html += "					</select></div>";
html += "			</div>";
adults--;
if(i == (max-1))
{
break;
}
}
if(edit==1)
{
$("#travelerDetail"+room).html('');
option_num = document.getElementById("pax"+room).getElementsByTagName("option").length;
roomtype_num = document.getElementById("roomtype["+room+"]").getElementsByTagName("option").length;
for(i=option_num;i<max;i++)
{
if(i==max)
$("#pax"+room).append("<option value='"+(i+1)+"' selected='selected'>"+(i+1)+"</option>");
else
$("#pax"+room).append("<option value='"+(i+1)+"'>"+(i+1)+"</option>");
}
for(i=0;i<roomtype_num;i++)
{
if(document.getElementById("roomtype["+room+"]").options[i].value == roomtype)
document.getElementById("roomtype["+room+"]").options.item(i).selected = true;
}
}
$("#travelerDetail"+room).append(html);
}
else
{
num = pax-select;
j=1;
for(i=num;i>0;i--)
{
$('#data'+room+'_'+(pax-j)).remove();
j++;
}
}
$("#paxcheck"+room).val(select);
document.getElementById("pax"+room).options.item((select-1)).selected = true;
}
function changeRoom(select,room,sg,sg_a_max,sg_max,tw,tw_a_max,tw_max,db,db_a_max,db_max,tr,tr_a_max,tr_max,qd,qd_a_max,qd_max,adult,child,infant,all,max,title)
{
num = select-room;
html = "";
if(num>0)
{
for(i=0;i<num;i++)
{
html += "<div class='optionparams' id='optionparams"+(parseInt(room)+parseInt(i))+"'>";
html += "			<div class='data' >";
html += "				<div>";
html += "					Room "+((parseInt(room)+parseInt(i))+1);
html += "				</div>";
html += "				<div>";
html += "					Pax:<select name='pax["+(parseInt(room)+parseInt(i))+"]' id='pax"+(parseInt(room)+parseInt(i))+"' onChange='setTravelerDetail(this.value,document.getElementById(\"paxcheck"+(parseInt(room)+parseInt(i))+"\").value,"+(parseInt(room)+parseInt(i))+",\""+adult+"\",\""+child+"\",\""+infant+"\",\"\",\"\",\"\",\"\",titleArray);'>";
if(sg == 'Y')
{
count = sg_max;
count_a = sg_a_max;
}
else if(tw == 'Y')
{
count = tw_max;
count_a = tw_a_max;
}
else if(db == 'Y')
{
count = db_max;
count_a = db_a_max;
}
else if(tr == 'Y')
{
count = tr_max;
count_a = tr_a_max;
}
else if(qd == 'Y')
{
count = qd_max;
count_a = qd_a_max;
}
all = parseInt(all);
max = parseInt(max);
for(j=1;j<=count;j++)
{
if(all > max)
{
if(j==max)
html +=						"<option value='"+j+"' selected='selected'>"+j+"</option>";
else
html +=						"<option value='"+j+"'>"+j+"</option>";
}
else
{
if(j==Math.abs(all))
html +=						"<option value='"+j+"' selected='selected'>"+j+"</option>";
else if(j==count)
html +=						"<option value='"+j+"' selected='selected'>"+j+"</option>";
else
html +=						"<option value='"+j+"'>"+j+"</option>";
}
}
html += "					</select><input type='hidden' id='paxcheck"+(parseInt(room)+parseInt(i))+"' value='"+count+"'>";
all = all-max;
html += "					Room type:<select id='roomtype["+(parseInt(room)+parseInt(i))+"]' name='roomtype["+(parseInt(room)+parseInt(i))+"]' onChange='";
if(sg=='Y')
html += " if(this.value==\"SG\"){changeRoomtype("+sg_a_max+","+sg_max+",document.getElementById(\"paxcheck"+(parseInt(room)+parseInt(i))+"\").value,"+(parseInt(room)+parseInt(i))+",\""+adult+"\",\""+child+"\",\""+infant+"\",titleArray);}";
if(tw=='Y')
html += " if(this.value==\"TW\"){changeRoomtype("+tw_a_max+","+tw_max+",document.getElementById(\"paxcheck"+(parseInt(room)+parseInt(i))+"\").value,"+(parseInt(room)+parseInt(i))+",\""+adult+"\",\""+child+"\",\""+infant+"\",titleArray);}";
if(tr=='Y')
html += " if(this.value==\"TR\"){changeRoomtype("+tr_a_max+","+tr_max+",document.getElementById(\"paxcheck"+(parseInt(room)+parseInt(i))+"\").value,"+(parseInt(room)+parseInt(i))+",\""+adult+"\",\""+child+"\",\""+infant+"\",titleArray);}";
if(db=='Y')
html += " if(this.value==\"DB\"){changeRoomtype("+db_a_max+","+db_max+",document.getElementById(\"paxcheck"+(parseInt(room)+parseInt(i))+"\").value,"+(parseInt(room)+parseInt(i))+",\""+adult+"\",\""+child+"\",\""+infant+"\",titleArray);}";
if(qd=='Y')
html += " if(this.value==\"QD\"){changeRoomtype("+qd_a_max+","+qd_max+",document.getElementById(\"paxcheck"+(parseInt(room)+parseInt(i))+"\").value,"+(parseInt(room)+parseInt(i))+",\""+adult+"\",\""+child+"\",\""+infant+"\",titleArray);}";
html += "'>";
if(sg=='Y')
html += "					<OPTION VALUE='SG'>Single</OPTION>";
if(tw=='Y')
html += "					<OPTION VALUE='TW' selected='selected'>Twin</OPTION>";
if(db=='Y')
html += "					<OPTION VALUE='DB'>Double</OPTION>";
if(tr=='Y')
html += "					<OPTION VALUE='TR'>Triple</OPTION>";
if(qd=='Y')
html += "					<OPTION VALUE='QD'>Quad</OPTION>";
html += "					</select>";
html += "					<span id='textMax"+(parseInt(room)+parseInt(i))+"'> Max adults:"+count_a+"  Max adults+children:"+count+" </span>";
html += "				</div>";
html += "			</div>";
html += "				<div class='data_titles'>";
html += "					<div class='t_title'>Title</div>";
html += "					<div class='t_fname'>Firstname</div>";
html += "					<div class='t_lname'>Lastname</div>";
html += "					<div class='t_type'>Paxtype</div>";
html += "				</div>";
html += "           <div id='travelerDetail"+(parseInt(room)+parseInt(i))+"' class='travelerDetail'>";
for(j=0;j<count;j++)
{
html += "				<div class='data t_data' id='data"+(parseInt(room)+parseInt(i))+"_"+j+"'>";
html += "				<div class='t_title'><select name='title["+(parseInt(room)+parseInt(i))+"]["+j+"]' id='title["+(parseInt(room)+parseInt(i))+"]["+j+"]'>";
for(k=0;k<title.length;k++)
{
html += "<option value='"+title[k]+"'>"+title[k]+"</option>";
}
html += "				</select></div>";
html += "					<div class='t_fname'><input type='text' name='fname["+(parseInt(room)+parseInt(i))+"]["+j+"]' id='fname["+(parseInt(room)+parseInt(i))+"]["+j+"]'></div>";
html += "					<div class='t_lname'><input type='text' name='lname["+(parseInt(room)+parseInt(i))+"]["+j+"]' id='lname["+(parseInt(room)+parseInt(i))+"]["+j+"]'></div>";
html += "					<div class='t_type'><select name='paxtype["+(parseInt(room)+parseInt(i))+"]["+j+"]' id='paxtype["+(parseInt(room)+parseInt(i))+"]["+j+"]'>";
if(adult=='Y')
html += "						<option value='A'>Adult</option>";
if(child=='Y')
html += "						<option value='C' >Child</option>";
if(infant=='Y')
html += "						<option value='I'>Infant</option>";
html += "					</select></div>";
html += "				</div>";
}
html += "           </div>";
html += "		</div>";
}
$("#traveler").append(html);
}
else
{
num = room-select;
j=1;
for(i=num;i>0;i--)
{
$('#optionparams'+(room-j)).remove();
j++;
}
}
$("#roomcheck").val(select);
}
function changeRoomtype(adultmax,roommax,pax,room,adult,child,infant,title)
{
$("#pax"+room+" option").remove();
for(i=1;i<=roommax;i++)
{
if(i==roommax)
$("#pax"+room).append('<option value="'+i+'" selected="selected">'+i+'</option>');
else
$("#pax"+room).append('<option value="'+i+'">'+i+'</option>');
}
$("#textMax"+room).html("Max adults:"+adultmax+"  Max adults+children:"+roommax+"");
setTravelerDetail(roommax,pax,room,adult,child,infant,'','','','',title);
}
function setMouseOver(r,c,opt)
{
document.getElementById('r['+opt+']['+r+']['+c+']').style.backgroundColor="#E5E5E5";
}
function setMouseOut(r,c,opt)
{
document.getElementById('r['+opt+']['+r+']['+c+']').style.backgroundColor="";
}
function setMouseClick(r,c,day,opt)
{
click = document.getElementById('inputClick['+opt+']').value;
document.getElementById('inputClick['+opt+']').value = 'r['+opt+']['+r+']['+c+']';
document.getElementById('d['+opt+']').value = day;
document.getElementById('optval').value = opt;
document.getElementById('r['+opt+']['+r+']['+c+']').className='selectday';
document.getElementById(click).className='';
}
function showCalendar(opt)
{
$("div .calendar").hide();
$("#"+opt).show();
optval = parseInt(document.getElementById('optval').value);
document.getElementById('optval').value = (optval+1)%2;
}
function setName(room,index,title,name,lastname,paxtype)
{
document.getElementById('title['+room+']['+index+']').value = title;
document.getElementById('fname['+room+']['+index+']').value = name;
document.getElementById('lname['+room+']['+index+']').value = lastname;
if(paxtype == 'A')
select = 0;
if(paxtype == 'C')
select = 1;
if(paxtype == 'I')
select = 2;
document.getElementById("paxtype["+room+"]["+index+"]").options.item(select).selected = true;
}

