	var lastday = 1;
	var max_day = 30;	
	
	function showNextDay(itin_num, itin_dir){
		var day_num = this.lastday + 1;
		
		if(day_num > max_day){
			this.lastday = max_day;
		} else {
			this.lastday = day_num;
			showItinDay(itin_num, day_num, itin_dir)
		}
	}
	
	
	function showPrevDay(itin_num, itin_dir){
		var day_num = this.lastday - 1;
		
		if(day_num < 0){
			this.lastday = 0;
		} else {
			this.lastday = day_num;
			showItinDay(itin_num, day_num, itin_dir)
		}	
	}
	
	function showItinDay(itin_num, day_num, itin_dir){
			var frm = frames['day_frame'];   
			var frm_loc = itin_dir + "days/" + "day" + day_num + ".html"
			frm.location.href = frm_loc;
			
			this.lastday = day_num;
			//alert(this.lastday);
		}
		
		function resizeItin(){
			//var frm = frames['day_frame']; //MUST BE REFERRED AS FRAME TO ACCESS frm.document.height			
			var frm_e = document.getElementById('day_view'); // MUST BE REFERRED AS ELEMENT TO ACCESS frm_e.style.height	
			var prevHeight = document.getElementById('day_view').offsetHeight; //offset height works for ff and IE			
			//alert(prevHeight);
			//if(prevHeight < 785){
				//var heightDiff = 785 - prevHeight;
			//alert(navigator.appName);
			var y = 785;
			if(navigator.appName=='Netscape'){
				y = 685;
			}
			if(prevHeight < y){
				var heightDiff = y - prevHeight;
				var newHeight = heightDiff + prevHeight;
				frm_e.style.height = (newHeight) + "px";//792 is letter size papaer height	
			}
			else{
				frm_e.style.height = (prevHeight + 50) + "px";
			}
		}
		
		function getItinVarSwitch(href){
			var hrefId = document.getElementById(href);			
			var checkbox = document.getElementsByTagName('input');	
			hrefId.href = window.location.href;	
			for(i=0; i<checkbox.length; i++){
				if(checkbox[i].checked){			
					hrefId.href += '&'+checkbox[i].name+'='+checkbox[i].value;			
				}
				else{
					hrefId.href += '';
				}
			}	
			hrefId.href += '&checkout=1';
		}
		
		function itinValidate(href){
			var hrefId = document.getElementById(href);
			/*var urlString = window.location;
			var checkbox = document.getElementsByTagName('input');
			if((hrefId.href=='')||(hrefId.href==window.location.href+'&checkout=1')){
				alert('please select an add-on');
				hrefId.href = window.location.href;
			}*/
			var checkbox = document.getElementsByTagName('input');	
			var count = 0;
			for(i=0; i<checkbox.length; i++){
				if(checkbox[i].checked){			
					count++;
				}
			}
			if(count==0){
				alert('please select an add-on');
			}
			else{
				hrefId.href = window.location.href+'&checkout=1';
			}
		}
		
		function countPeople(adultId, childId, areaId){	
			var adultNumber = "<?php echo $_GET['adults']; ?>";
			//parseInt(document.getElementById(adultId).value);
			var childNumber = "<?php echo $_GET['children']; ?>";
			//document.getElementById(childId).value;
			
			adultNumber = parseInt(adultNumber);
			
			var txtArea = document.getElementById(areaId).value;
			var peopleArray = new Array();
			var peopleInfoArray = new Array();
			
			if((childNumber=='')||(childNumber==null)){
				childNumber = 0;
			}
			else{
				childNumber = parseInt(childNumber);
			}
			
			/* get actual inputs */
			var totalPeople = adultNumber + childNumber;		
			
			/* eliminate trailing ';' if any */
			var areaLength = txtArea.length;
			var lastChar = txtArea.charAt(areaLength-1);
			if(lastChar == ';'){
				txtArea = txtArea.substring(0,areaLength-2);
			}
			
			/* split string as array */
			peopleArray = txtArea.split(';');
			
			/* theoretical amount of people and data of people for comparison */
			var totalSemi = totalPeople;
			var totalComma = totalPeople * 3;
			
			var peopleArrayCount = peopleArray.length;	
			var peopleInfoArrayCount = 0;
			
			/* if there is only one tourist */
			for(i=0; i<peopleArrayCount; i++){
				peopleInfoArray = peopleArray[i].split(',');		
				for(k=0; k<peopleInfoArray.length; k++){
					peopleInfoArrayCount++;
				}		
			}	
				
			if((peopleArrayCount==totalSemi) && (peopleInfoArrayCount==totalComma)){		
				document.tourinfo.submit();		
			}
			else{
				alert('Please input the information in the correct format in the \'Names, Nationalities and Passprot Numbers of all Tourists\' field.  Check if all the people you are willing to take with you in the tour have their information inputted in the field.');
				return false;
			}
		}
		
		function foldOut(id){
			var id = document.getElementById(id);
			if(id.style.display == ''){
				id.style.display = 'none';
			}
			else{
				id.style.display = '';
			}	
		}		


function phoneAlert(id1, id2, id3){
	var phone_1 = document.getElementById(id1).value;
	var phone_2 = document.getElementById(id2).value;
	var phone_3 = document.getElementById(id3).value;
	var count = 0;
	var message = "Please input your phone number correctly.  Fill in the 1st box with your 3 digit area code, then fill in the 2nd box with the 1st 3 digits of your phone number, the remaining 4 digits will be filled in the last box.  Please remember that '#', '-', '+' and are not necessary and any sort of letter and special character is invalid.";
			
	if((/^-?\d+$/.test(phone_1) == false) || (phone_1.length < 3)){
		alert(message); 
	}
	else if((/^-?\d+$/.test(phone_2) == false) || (phone_2.length < 3)){
		alert(message); 
	}
	else if((/^-?\d+$/.test(phone_3) == false) || (phone_3.length < 4)){
		alert(message); 
	}
	else{
		document.tourinfo.submit();
	}
}

function check_tos(id){
	var tos = document.getElementById(id);
	if(tos.checked){
		document.tosubmit.submit();
		//alert('submit');
	}
	else{
		alert('Please agree to the Terms of Service by checking its box.');
	}
}

function checkNumber(id){
	var selectOp = document.getElementById(id);		
	if(selectOp.name =='adults'){
		if(selectOp.value == 17){
			alert('for more number of people and larger tours, please contact us at 1-877-china-77 or e-mail us at tourgiude@marcopolosolo.com');
			selectOp.value = "1";
		}
		else{
			return true;
		}		
	}else{
		if(selectOp.value == 9){
			alert('for more number of people and larger tours, please contact us at 1-877-china-77 or e-mail us at tourgiude@marcopolosolo.com');
			selectOp.value = "0";
		}
		else{
			return true;
		}
	}
}