// JS 



// fungsi-fungsi //
function disHot()
{
	window.alert("Fully booked. Please book at other participating hotels.");
}

function trim(str)
{
	return str.replace(/^\s+|\s+$/g,'');
}

function cekEmail(str)
{
	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	if(reg.test(str) == false)
	{
		return false;
	}
}

function cekTlp(str)
{
	var reg = /^[\+|0][0-9]{9,}$/;
	if(reg.test(str) == false)
	{
		return false;
	}
}

function getCheckedValue(radioObj)
{
	if (!radioObj)
	{
		return "none";
	}
	
	var radioLength = radioObj.length;
	
	if (radioLength == undefined)
	{
		if(radioObj.checked)
		{
			return radioObj.value;
		}
		else
		{
			return "none";
		}
	}
	
	for(var i = 0; i < radioLength; i++)
	{
		if(radioObj[i].checked)
		{
			return radioObj[i].value;
		}
	}
	
	return "none";
}

// fungsi-fungsi //

// cek form //
function chkForm(frm)
{
	if (getCheckedValue(frm.elements['RegistrationStatus']) == 'none')
	{
		window.alert('Please select option for Registration & Accommodation Booking Status.');
		return false;
	}
	else if (trim(frm.elements['Name'].value) == '')
	{
		window.alert('Please fill out Name.');
		return false;
	}
	else if (getCheckedValue(frm.elements['RegisterAs']) == 'none')
	{
		window.alert('Please select option for Register as.');
		return false;
	}
	else if (getCheckedValue(frm.elements['Sex']) == 'none')
	{
		window.alert('Please select option for Sex.');
		return false;
	}
	else if (trim(frm.elements['Nationality'].value) == '')
	{
		window.alert('Please fill out Nationality.');
		return false;
	}
	else if (trim(frm.elements['IDPassportNo'].value) == '')
	{
		window.alert('Please fill out ID/Passport No.');
		return false;
	}
	else if (trim(frm.elements['Institution'].value) == '')
	{
		window.alert('Please fill out Institution.');
		return false;
	}
//	else if (trim(frm.elements['FaxNo'].value) != '' && cekTlp(frm.elements['FaxNo'].value) == false)
//	{
//		window.alert('Please include valid country code and area code of Fax Number.');
//		return false;
//	}
	else if (cekEmail(frm.elements['EmailAddress'].value) == false)
	{
		window.alert('Please fill out valid Email Address.');
		return false;
	}
	else if (trim(frm.elements['TelephoneNoOffice'].value) == '' && trim(frm.elements['TelephoneNoMobile'].value) == '')
	{
		window.alert('Please include valid country code and area code of Office Number or Mobile Number.');
		return false;
	}
//	else if (trim(frm.elements['TelephoneNoOffice'].value) != '' && cekTlp(frm.elements['TelephoneNoOffice'].value) == false)
//	{
//		window.alert('Please include valid country code and area code of Office Number.');
//		return false;
//	}
//	else if (trim(frm.elements['TelephoneNoMobile'].value) != '' && cekTlp(frm.elements['TelephoneNoMobile'].value) == false)
//	{
//		window.alert('Please include valid country code and area code of Mobile Number.');
//		return false;
//	}
	else if (getCheckedValue(frm.elements['CFee']) == 'none')
	{
		window.alert('Please select option for Conference Fee.');
		return false;
	}
	
	return true;
	
}
// cek form //


// cek form 2 //
function chkForm2(frm)
{
	if (getCheckedValue(frm.elements['Accommodation']) == 'none')
	{
		window.alert('Please select option for Hotel.');
		return false;
	}
	else if ((getCheckedValue(frm.elements['Accommodation']) == 'SBB_K_T_SDGV' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_K_T_DSV' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_K_T_SR' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_N_T_SDGV' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_N_T_DSV' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_N_T_SR' || getCheckedValue(frm.elements['Accommodation']) == 'SP_K_T_S' || getCheckedValue(frm.elements['Accommodation']) == 'PRS_K_T_S') && getCheckedValue(frm.elements['TwinSharePreference']) == 'none')
	{
		window.alert('Please select option for Twin Share Preference.');
		return false;
	}
	else if ((getCheckedValue(frm.elements['Accommodation']) == 'SBB_K_S_SDGV' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_K_S_DSV' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_K_S_SR' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_N_S_SDGV' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_N_S_DSV' || getCheckedValue(frm.elements['Accommodation']) == 'SBB_N_S_SR' || getCheckedValue(frm.elements['Accommodation']) == 'SP_K_S_S' || getCheckedValue(frm.elements['Accommodation']) == 'PRS_K_S_S') && getCheckedValue(frm.elements['TwinSharePreference']) != 'none')
	{
		window.alert('You are not allow to select option Twin Share Preference, because you select Single Occupancy.');
		return false;
	}
	else if (getCheckedValue(frm.elements['TwinSharePreference']) == 'enable' && (trim(frm.elements['TSWith'].value) == '' || trim(frm.elements['TSFrom'].value) == ''))
	{
		window.alert('Please fill out Twin Share With and From.');
		return false;
	}
	else if (getCheckedValue(frm.elements['PermissionData']) == 'none')
	{
		window.alert('Please select option for Permission to use Data.');
		return false;
	}
	
	return true;
	
}