// JavaScript Document

/*
var childArray = new Array(0,0,0,0,0,0,0,0,0,0);
function showChildTitle() {
	var c = 0;
	var r = document.myForm.rooms[document.myForm.rooms.selectedIndex].value;
	for (var i=0;i<r;i++) {
		c = c + childArray[i];
	}
	return true;
}

function showChild(me,Span,nb) {
	var occ = me[me.selectedIndex].value;
	if (occ == '2|1') {
		alert ("When you select Double/Twin + one Kid, there is no additional bed." +\n + "The child will need to share the existing bedding." +\n + "If you want to guarantee a separate bed, please click on 'Triple (3 people)'");
		childArray[nb-1] = 1;
		document.getElementById(Span).style.display = '';
	} else {
		childArray[nb-1] = 0;
		document.getElementById(Span).style.display = 'none';
	}
	return showChildTitle();
}
*/

function showRoom() {
	var nbR = document.myForm.rooms[document.myForm.rooms.selectedIndex].value;
	var i;
	for (i=2; i<=10; i++) {
		eval("document.getElementById('r"+i+"').style.display = 'none'; ");
	}
	for (i=2; i<=nbR; i++) {
		eval("document.getElementById('r"+i+"').style.display = ''; ");
	}

	return showChildTitle();
}

/*
function buildRoomList() {
	for (var i=2;i<=10;i++) {
		document.writeln('<tr id="r'+i+'" style="display:none;">');
		document.writeln('<td width="29%" align="left" style="padding-left:23px">&nbsp; Room #'+i+'<\/td>');
		document.writeln('<td><table><tr><td><select name="roomO_'+i+'" onChange="return showChild(this,\'kid_'+i+'\','+i+');">');
		document.writeln('<script>');
		document.writeln('buildOcc();');
		document.writeln('<\/script>');
		document.writeln('<\/select><\/td><\/tr><\/table><\/td>');
		document.writeln('<td colspan="'+i+'" align="left"><span id="kid_'+i+'" style="display:none;">Child age : <select name="room_'+i+'_1">');
		document.writeln('<script>');
		document.writeln('buildOpt(childAge,childAge);');
		document.writeln('<\/script>');
		document.writeln('<\/select>');
		document.writeln('<\/span><\/td><\/tr>');
	}
	return true;
}


var childAge = '2|3|4|5|6|7|8|9|10|11';
function buildOpt(values,texts) {

	var valuesT = values.split("|");
	var textsT = texts.split("|");
	var j = parseInt(valuesT.length);
	for (var i=0;i<j;i++) {
		document.writeln('<option value="' + valuesT[i] + '">' + textsT[i] + '<\/option>');
	}
}

function updateCheckOut(checkInD,checkInM,checkInY,nbNights,printD,printM,printY){
	echoCheckOutD = document.getElementById(printD);
	echoCheckOutM = document.getElementById(printM);
	echoCheckOutY = document.getElementById(printY); 
	ScheckOut = document.getElementById(print.value);  
	if ((checkInD.value!=null) || (checkInM.value!=null) || (checkInY.value!=null)){
		var thedate = new Date(2006,02-1,16);
		thedate.setFullYear(checkInY.value, checkInM.value-1, checkInD.value);
		if (thedate.getDate() != checkInD.value) {
			checkInD.value=thedate.getDate();
			checkInM.value=thedate.getMonth()+1;
			checkInY.value=thedate.getFullYear();
		}

		thedate.setDate(thedate.getDate()+parseInt(nbNights.value));
		months = new Array("январь","‘евраль","ћарт","јпрель","ћай","»юнь","»юль","јвгуст","—ент€брь","ќкт€брь","Ќо€брь","?екабрь");
		echoCheckOutD.innerHTML = thedate.getDate();
		echoCheckOutM.innerHTML = months[thedate.getMonth()];
		echoCheckOutY.innerHTML = thedate.getFullYear();
		return 1;
	}
}

function submitNoDate(){
	checkind = document.getElementById("selectCheckInDay");
	checkinm = document.getElementById("selectCheckInMonth");
	checkiny = document.getElementById("selectCheckInYear");
	if (checkDate(checkind,checkinm,checkiny)){
		document.myForm.submit();
		return true;
	}
	else{
		return false;
	}
}

*/


function votes(ind,vote,id) {
		if(vote < 1 || vote > 10) {
			// Hide the suggestion box.
			alert('Оценка не верна!!!');
		} else {
			inputString = ind+';'+vote+';'+id;

			$.post("top.php", {vote: ""+inputString+""}, function(data){
				if(data.length >0) {
					//alert(data);
				    //$('#vote').show();
				    $('#vote').html(data);
				}
			});

		}
	}
