function validate_form(){

	if(document.marine_insurance.assured_name.value == ""){
		alert("Enter Name of Assured.");
		document.marine_insurance.assured_name.focus();
		return false;
	}
	
	if(document.marine_insurance.email.value == ""){
		alert("Enter E-mail Address.");
		document.marine_insurance.email.focus();
		return false;
	}
	
	if(document.marine_insurance.phn.value == ""){
		alert("Enter Phone No.");
		document.marine_insurance.phn.focus();
		return false;
	}
	
	if(document.marine_insurance.commodity.selectedIndex == 0){
		alert("Select Commodity Details.");
		document.marine_insurance.commodity.focus();
		return false;
	}
	
	//Validation for cover type
/*	var cover_type_chks = document.getElementsByName('cover_type[]');
	for(i=0; i < cover_type_chks.length; i++){
		var isChecked_CoverType = false;
		if(cover_type_chks[i].checked){
			isChecked_CoverType = true;
			break;
		}
	}
	if(isChecked_CoverType == false){
		alert("Select any of the cover type");
		cover_type_chks[0].focus();
		return false;
	}  
	*/
	if(document.marine_insurance.mode_ship.selectedIndex == 0){
		alert("Select Mode of Shipment.");
		document.marine_insurance.mode_ship.focus();
		return false;
	}
	
	if(document.marine_insurance.packing.selectedIndex == 0){
		alert("Select the Packing.");
		document.marine_insurance.packing.focus();
		return false;
	}
	
/*	if(document.marine_insurance.frm_country.selectedIndex == 0){
		alert("Select the From-Country/Region.");
		return false;
	}
	
	if(document.marine_insurance.to_country.selectedIndex == 0){
		alert("Select the To-Country/Region.");
		return false;
	}
	
	
	
	if(document.marine_insurance.via_transhipment.value == ""){
		alert("Enter Via/Transhipment.");
		document.marine_insurance.via_transhipment.focus();
		return false;
	}

	if(document.marine_insurance.fromcity.value == ""){
		alert("Enter From-City.");
		document.marine_insurance.fromcity.focus();
		return false;
	}
	
	if(document.marine_insurance.tocity.value == ""){
		alert("Enter To-City.");
		document.marine_insurance.tocity.focus();
		return false;
	}
	*/	
	if(document.marine_insurance.amt_insured.value == ""){
		alert("Enter Amount Insured.");
		document.marine_insurance.amt_insured.focus();
		return false;
	}
	
	if(document.marine_insurance.lmt_consingment.value == ""){
		alert("Enter Limit Per Consingment (Rs).");
		document.marine_insurance.lmt_consingment.focus();
		return false;
	}
	
	//Validation term of cover
	/*var term_chks = document.getElementsByName('cover_terms[]');
	for(i=0; i < term_chks.length; i++){
		var isChecked_term = false;
		if(term_chks[i].checked){
			isChecked_term = true;
			break;
		}
	}
	if(isChecked_term == false){
		alert("Select any term of cover");
		term_chks[0].focus();
		return false;
	}  	
	*/
}

function show_import_export() {
	document.getElementById('export_import').style.display = 'block';
}

function hide_import_export() {
	document.getElementById('export_import').style.display = 'none';
	//unCheck_import_export();
	hide_custom_duty();
}

function show_custom_duty() {
	document.getElementById('custom_duty').style.display = 'block';
}

function hide_custom_duty() {
	document.getElementById('custom_duty').style.display = 'none';
	//unCheck_customDuty();
}

function unCheck_customDuty(){
	document.marine_insurance.cd_cover[0].checked = false;
	document.marine_insurance.cd_cover[1].checked = false;
}

function unCheck_import_export(){
	document.marine_insurance.import_export[0].checked = false;
	document.marine_insurance.import_export[1].checked = false;
}

/*
 * Limit at any Location should be only for Open and Turnover policy Only
*/
function show_hide_lmt_location(){	
		if(document.marine_insurance.cover_type[0].checked || document.marine_insurance.cover_type[2].checked){
			document.getElementById('div_lmt_location1').style.display = 'block'
			document.getElementById('div_lmt_location2').style.display = 'block'
		}
		else{
			document.getElementById('div_lmt_location1').style.display = 'none'
			document.getElementById('div_lmt_location2').style.display = 'none'
		}
}

function freeze_Via_Transhipment(chk){
	if(chk.value == "NONE"){
		document.marine_insurance.via_transhipment.disabled = true
	}
}

function unFreeze_Via_Transhipment(chk){
	if(chk.value == "VIA" || chk.value == "TRANS"){
		document.marine_insurance.via_transhipment.disabled = false
	}
}

function hideIndianStates_ShowCountry(){
	document.getElementById('div_from_cr1').style.display = 'block'
	document.getElementById('div_to_cr1').style.display = 'block'
	
	document.getElementById('div_from_cr').style.display = 'block'
	document.getElementById('div_to_cr').style.display = 'block'
}

function showIndianStates_HideCountry(){
	document.getElementById('div_from_cr1').style.display = 'none'
	document.getElementById('div_to_cr1').style.display = 'none'
	
	document.getElementById('div_from_cr').style.display = 'none'
	document.getElementById('div_to_cr').style.display = 'none'
}

function show_policyType(){
	document.getElementById('diiv_policy_type').style.display = 'block'
}

function hide_policyType(){
	document.getElementById('diiv_policy_type').style.display = 'none'
}

function loadMarineDefaults(){
	if(document.marine_insurance.transit_type[1].checked){
		show_import_export() ;
		hideIndianStates_ShowCountry();
	}
	if(document.marine_insurance.import_export[1].checked){
		show_custom_duty();
	}
	show_hide_lmt_location();
}
