// Parameters for the fetchValuesForLOV are as follows:
//1. Name of the  control whose value is to be set
//2. Second is the action
//3. Name of the control depending upon which values are to be fetched
function fetchValuesForLOV(strControl,mode,strMasterControl) {
	//alert('Fetching Cities ' + document.getElementById(strMasterControl).value);
	var getURL= "getValues$_?tokenMode="+mode+"&id=" + document.getElementById(strMasterControl).value;
	//alert(getURL);
	requestDynInfo(getURL,strControl,'','','','');

}

function validateFx() {
	//alert('ddd');
	var checkValidation=emptyValidation("vchUserName~vchPassword");
	if(checkValidation==true) {
		var getURL= "getValues$_?tokenMode=validate&id=" + document.getElementById("vchUserName").value + "&passwd="+document.getElementById("vchPassword").value;
		requestDynInfo(getURL,'txtMsg','memberPages.php','Y','loginProccess','Validating...');
		
	}
	return false;
}

function validatePwds() {
	var checkValidation=emptyValidation("oldPassword~newPassword~renewPassword");
	if(checkValidation==true) {
		if(document.getElementById("newPassword").value != document.getElementById("renewPassword").value) {
			alert('The new password and re-typed new password do not match. Kindly re-enter');
			document.getElementById("newPassword").value='';
			document.getElementById("renewPassword").value='';
			checkValidation=false;
		}
	}
	if(checkValidation==true) {
		var getURL= "getValues$_?tokenMode=updatePassword&pwd=" + document.getElementById("newPassword").value + "&oldPwd="+document.getElementById("oldPassword").value;
		requestDynInfo(getURL,'txtMsg','','N','','');
		
	}
	return false;
}

function validateProfileForm() {
	var checkValidation=emptyValidation("vchSuffix~vchFirstName~vchLastName~vchAddressLine1~vchAddressLine2~vchCountry~vchState~vchCity~vchZip~vchContactNo");
	if(checkValidation==true) {
		var getURL= "getValues$_?tokenMode=updateProfile&vchSuffix=" + document.getElementById("vchSuffix").value + "&vchFirstName="+document.getElementById("vchFirstName").value + "&vchLastName="+document.getElementById("vchLastName").value + "&vchAddressLine1="+document.getElementById("vchAddressLine1").value + "&vchAddressLine2="+document.getElementById("vchAddressLine2").value + "&vchCountry="+document.getElementById("vchCountry").value + "&vchState="+document.getElementById("vchState").value + "&vchCity="+document.getElementById("vchCity").value + "&vchZip="+document.getElementById("vchZip").value + "&vchContactNo="+document.getElementById("vchContactNo").value;
		//alert(getURL);
		requestDynInfo(getURL,'txtMsg','','N','','');
		
	}
	return false;
}

function validateSignupForm() {
	var checkValidation=emptyValidation("vchEmail~vchNPassword~vchRePassword");
	if(checkValidation == true) {
		checkValidation = eMailCheck(document.getElementById("vchEmail").value);
	}
	if(checkValidation==true) {
		if(document.getElementById("vchNPassword").value != document.getElementById("vchRePassword").value) {
			alert('The new password and re-typed new password do not match. Kindly re-enter');
			document.getElementById("vchNPassword").value='';
			document.getElementById("vchRePassword").value='';
			checkValidation=false;
		}
	}
	if(checkValidation==true) {
		var getURL= "getValues$_?tokenMode=register&vchEmail=" + document.getElementById("vchEmail").value + "&vchPassword="+document.getElementById("vchNPassword").value;
		requestDynInfo(getURL,'txtMsgRegistration','memberPages.php','Y','','');
		
	}
	return false;
}

function holidaySearch() {

	var getURL= "listRegionTours.inc$_?tokenMode=customSearch&strRegion=" + document.getElementById("strRegion").value + "&strCountry="+document.getElementById("strCountry").value + "&strTheme="+document.getElementById("strTheme").value + "&regN=Holiday+Search+Results";
	requestDynInfo(getURL,'showTable','','N','progressMsg','Searching please wait');
	return false;
}

function beginResetPassProc() {
	document.getElementById("forgotPass").style.visibility="visible";
}
function cancelResetPass() {
	document.getElementById("forgotPass").style.visibility="hidden";
}
function retryPassword() {
	document.getElementById("forgotPass").innerHTML= "Please Enter your Email ID<p>Email ID: <input type='text' id='forgotEmailID' value='' name='forgotEmailID'><BR><input type='button' value='Go' class='resetPassButton' onClick='resetPass()'>&nbsp;&nbsp;&nbsp;<input type='button' value='Cancel' class='cancelPassButton' onClick='cancelResetPass()'></p>";
}

function resetPass() {
	//alert('REsetting');

	var checkValidation=emptyValidation("forgotEmailID");
	if(checkValidation == true) {
		checkValidation = eMailCheck(document.getElementById("forgotEmailID").value);
	}
	if(checkValidation == true) {
		var getURL= "getValues$_?tokenMode=forgotPass&forgotEmailID=" + document.getElementById("forgotEmailID").value;
		requestDynInfo(getURL,'forgotPass','','N','','');
	}
	return false;
}
//Parameters are as follows:
// 1. divID: The divID to display/hide
// 2. controlID: The name of the Control for which the value is to be read
// 3. fetchWhat: Parameter specifying what has to be fetched.
// 4. dependentDivs: Name of the child div's which have to be disabled if the value of control (passed as Parameter2) is blank 
function showDivs(divID,controlID,fetchWhat,dependentDivs) {
	if(document.getElementById(controlID).value != "") {
		document.getElementById(divID).style.visibility="visible";
		if(fetchWhat == "CTR") {
			fetchValuesForLOV('intCountryID','listCountries',controlID);
		}
		if(fetchWhat == "CTY") {
				//1. Name of the  control whose value is to be set
				//2. Second is the action
				//3. Name of the control depending upon which values are to be fetched
			fetchValuesForLOV('cityList','listCitiesTR',controlID);
		}

	} else {
		//Check if the any of the top level are selected blank, then disable all the underlying Divs
		var divsArr=new Array();
		divsArr=dependentDivs.split("~");
		for(i=0;i<divsArr.length;i++) {
			document.getElementById(divsArr[i]).style.visibility="hidden";
		}//end of for of DIVS
	}//end of Else
}

//Used to navigate to the next div
function navigateDiv(divNo,validationDivs) {

	var checkValidation = emptyValidation(validationDivs);
	if(checkValidation == true) {
		
		var getURL= "setValues$_?tokenMode=saveSession&";
		var divsArr=new Array();
		divsArr=validationDivs.split("~");

		for(i=0;i<divsArr.length;i++) {
			getURL= getURL + divsArr[i] + '=' + document.getElementById(divsArr[i]).value + '&';
		}//end of for of divsArr.validationDivs
		//alert(getURL);
		requestDynInfo(getURL,'countrydivcontainer','','','','');
		countries.expandit((divNo*1));
	}
}

function setValue(controlID) {
	//alert(controlID.value + ' : ' + controlID.checked);
	selectCities = document.getElementById("intCityID").value;
	var valsArr=new Array();
	valsArr=selectCities.split("~");
	newCityVals='';
	selectedVal=controlID.value;
	for(i=0;i<valsArr.length;i++) {
		//if checked is false, then remove the value from the String, else retain the existing values
		if(valsArr[i] == selectedVal && controlID.checked == false) {
		} else {
			if(newCityVals != "") {
				newCityVals = newCityVals  + '~' + valsArr[i];
			} else {
				newCityVals = valsArr[i];
			}
		}
	}
	if(controlID.checked == true) {
		newCityVals = newCityVals  + '~' + selectedVal;
	} //else {
	//	newCityVals = selectedVal;
	//}

	document.getElementById("intCityID").value = newCityVals;
}

function  toggleDisp(divno) {
	var me = document.getElementById(divno);
me.style.top="-10";
me.style.position="relative";

	me.style.visibility="visible";
	me.style.width="450";
	me.style.height="150";
}

function hideDetailsDiv(divno) {
	//alert('dd123');
	var me = document.getElementById(divno);
me.style.position="absolute";
	me.style.width="1";
	me.style.height="1";
	me.style.visibility="hidden";


}

function selectAllLoc() {
	alert('select all');
}

function downLoadBroc(varBrochID,varBrochName,varBrochLoc) {
//alert(varBrochID+varBrochName+varBrochLoc);
	document.getElementById("downLoadBrochDiv").style.visibility="visible";
	document.getElementById("intBrochureID").value = varBrochID;
	document.getElementById("varBrochName").value = varBrochName;
	document.getElementById("varBrochLoc").value = varBrochLoc;
}
function cancelDownLoad() {
	document.getElementById("downLoadBrochDiv").style.visibility="hidden";
}

function startBrochDownLoad() {
	var checkValidation=emptyValidation("downloadBrochFName~downloadBrochLName~downloadBrochEmail~downloadBrochPhoneNo");
	if(checkValidation == true) {
		checkValidation = eMailCheck(document.getElementById("downloadBrochEmail").value);
	}

	if(checkValidation == true) {
		var getURL= "getValues$_?tokenMode=downLoadBrochRequest&downloadBrochFName=" + document.getElementById("downloadBrochFName").value + "&downloadBrochLName="+document.getElementById("downloadBrochLName").value + "&downloadBrochEmail="+document.getElementById("downloadBrochEmail").value + "&downloadBrochPhoneNo="+document.getElementById("downloadBrochPhoneNo").value + "&intBrochureID="+document.getElementById("intBrochureID").value;
		requestDynInfo(getURL,'dwnMsg','','N','brochDwnProg','Downloading please wait');
		document.getElementById("downLoadBrochDiv").style.visibility="hidden";
		var downLoadURL='downLoadBroc.php?varBrochName='+escape(document.getElementById("varBrochName").value)+'&varBrochLoc='+escape(document.getElementById("varBrochLoc").value);
		//alert(downLoadURL);
		window.open(downLoadURL,'downloadWin', 'width=10,height=10,resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no');
	}
	return false;
}
