function sendToPage(url){
	var action=confirm("Click Ok to go to view page of itinerary or click Cancel to stay on this page.")
	if(action){
		window.location=url;
	}
}
function changeCommuteTypeImage(imageName,imageId,textboxId,imageBaseUrl){
	var textboxControl=document.getElementById(textboxId);	
	var imageControl=document.getElementById(imageId);
	if(textboxControl.value==0){
		imageControl.src=imageBaseUrl+'/'+imageName+'-yes.gif';
		textboxControl.value=1;
	}
	else{
		imageControl.src=imageBaseUrl+'/'+imageName+'.gif';
		textboxControl.value=0;	
	}
}
function validateAddItinerary(msg){
	alert(msg);
}
function checkLongWord(control,wordLength){
	var inputControl=document.getElementById(control);
	var splitString = inputControl.value.split(" ");
	for (i=0; i <=splitString.length -1; i++){
		if (splitString[i].length >wordLength){
			alert("The word " + splitString[i] + " is longer than "+wordLength+" characters!");
			inputControl.value=inputControl.value.substr(0,(inputControl.value.length-1));
			//break;
		}
	} 
}
function countValidation(control,countId,maxCount){			
	var inputControl=document.getElementById(control);
	var displayCount=document.getElementById(countId);	
	if(inputControl.value.length>=(maxCount-15)){
		inputControl.value=inputControl.value.substr(0,maxCount);
		displayCount.innerHTML='<font color="red">'+(maxCount-inputControl.value.length)+'</font>';	
		checkLongWord(control,30);	
	}
	else{
		displayCount.innerHTML=maxCount-inputControl.value.length;		
		checkLongWord(control,30);
	}
}
/*function countValidation(control,countId,maxCount){			
	var inputControl=document.getElementById(control);
	var displayCount=document.getElementById(countId);
	if(inputControl.value.length>=maxCount){
		inputControl.value=inputControl.value.substr(0,maxCount);
		displayCount.innerHTML='<font color="red">'+inputControl.value.length+'</font>';		
	}
	else{
		displayCount.innerHTML=inputControl.value.length;
	}
}*/
function countCannotMissValidation(control,countId,maxCount){
	var inputControl=document.getElementById(control);
	var displayCount=document.getElementById(countId);
	if(inputControl.value.length>=(maxCount-15)){
		inputControl.value=inputControl.value.substr(0,maxCount);
		displayCount.value=(maxCount-inputControl.value.length);
		displayCount.style.color='red';
		checkLongWord(control,30);
	}
	else{
		displayCount.style.color='#6A6A6A';
		displayCount.value=(maxCount-inputControl.value.length);
		checkLongWord(control,30);		
	}
}
function disappearText(control,appearText){
    var inputControl=document.getElementById(control);
    if(inputControl.value==appearText){
        inputControl.value='';
    }
}
function btnChangeBackColor(buttonId,colorCode){
	document.getElementById(buttonId).style.backgroundColor=colorCode;
}
function testImageType(num){
	document.getElementById('imageError').innerHTML="";
	if(document.getElementById('profileImage').value==''){
		document.getElementById('imageError').innerHTML="Please select image.";		
	}
	else{
		var imageArr=(document.getElementById('profileImage').value).split('.');	
		var fileEx=imageArr[imageArr.length-1];
		if(fileEx=='jpg' || fileEx=='jpeg' || fileEx=='gif' || fileEx=='png'){
			//document.getElementById('uploadButton').disabled=false;
			//document.getElementById('imageError').innerHTML="";
			if(num==1){
				document.getElementById('save1').style.display='';
				document.getElementById('save2').style.display='none';
			}
		}
		else{
			//document.getElementById('imageError').innerHTML="Image should be of jpg, gif or png.";		
			//document.getElementById('uploadButton').disabled=true;
			if(num==1){
				document.getElementById('save1').style.display='none';
				document.getElementById('save2').style.display='';
			}
			else if(num==2){
				document.getElementById('imageError').innerHTML="Image should be of jpg, gif or png.";
			}
		}	
	}
}
function changeBack(checkNum){
	if(checkNum==1){
		document.getElementById('recentlyAskedQuestion').style.height='26px';
		document.getElementById('recentlyAskedQuestion').style.background='#CCC';
		document.getElementById('regionSpan').style.height='34px';
		document.getElementById('regionSpan').style.background='#CCE6E5';
		document.getElementById('regionSpan').style.border=0;	
	}
	else if(checkNum==2){
		document.getElementById('recentlyAskedQuestion').style.height='26px';
		document.getElementById('recentlyAskedQuestion').style.background='#CCC';
		document.getElementById('regionSpan').style.height='34px';
		document.getElementById('regionSpan').style.background='#CCE6E5';
		document.getElementById('regionSpan').style.border=0;	
		document.getElementById('countrySpan').style.height='34px';
		document.getElementById('countrySpan').style.background='#CCE6E5';
		document.getElementById('countrySpan').style.border=0;	
	}
	else if(checkNum==3){
		document.getElementById('recentlyAskedQuestion').style.height='26px';
		document.getElementById('recentlyAskedQuestion').style.background='#CCC';
		document.getElementById('regionSpan').style.height='34px';
		document.getElementById('regionSpan').style.background='#CCE6E5';
		document.getElementById('regionSpan').style.border=0;	
		document.getElementById('countrySpan').style.height='30px';
		document.getElementById('countrySpan').style.background='#CCC';
		document.getElementById('countrySpan').style.border=0;	
	}
	else if(checkNum==4){
		document.getElementById('recentlyAskedQuestion').style.height='30px';
		document.getElementById('recentlyAskedQuestion').style.background='#CCE6E5';
		document.getElementById('regionSpan').style.height='30px';
		document.getElementById('regionSpan').style.background='#CCC';
		document.getElementById('regionSpan').style.border=0;	
		document.getElementById('countrySpan').style.height='30px';
		document.getElementById('countrySpan').style.background='#CCC';
		document.getElementById('countrySpan').style.border=0;
	}
}
// functions for adding and removing con not miss items
/*function showHideDiv(parameter,dNumber,buttonId,imageBaseUrl,imageName,flag){
	var acnt=parseInt(document.getElementById(parameter+'Count'+dNumber).value);
	if(flag==1){
		if(acnt>5){
			alert("Sorry! you can add maximum 5 activity & attraction.");
		}
		else{
			document.getElementById(parameter+'div'+dNumber+acnt).style.display='';
			document.getElementById(parameter+'Show'+acnt+dNumber).value=1;
			document.getElementById(parameter+'Count'+dNumber).value=acnt+1;
			document.getElementById(buttonId).src=imageBaseUrl+'/'+imageName+'.gif';
		}
	}
	else if(flag==0){
		document.getElementById(parameter+'Count'+dNumber).value=acnt-1;
		var newAcnt=document.getElementById(parameter+'Count'+dNumber).value;
		document.getElementById(parameter+'div'+dNumber+newAcnt).style.display='none';
		document.getElementById(parameter+'Show'+newAcnt+dNumber).value=1;		
		if(document.getElementById(parameter+'Count'+dNumber).value==1){
			document.getElementById(buttonId).src=imageBaseUrl+'/'+imageName+'.gif';
		}
	}
}*/
