var ship_cat258 = new Array();
ship_cat258[0] = "121,Oil/Bulk Carrier";
ship_cat258[1] = "123,Oil/Bulk/Ore Carrier";
ship_cat258[2] = "221,ULCC ";
ship_cat258[3] = "222,VLCC";
ship_cat258[4] = "223,Oil Tanker";
ship_cat258[5] = "224,Product Tanker";
ship_cat258[6] = "150,Gas Carrier";
ship_cat258[7] = "151,LPG Tanker";
ship_cat258[8] = "152,LNG Tanker";
ship_cat258[9] = "225,Chemical Tanker";

var ship_cat7 = new Array();
ship_cat7[0] = "190,Passenger Ship";
ship_cat7[1] = "191,Passenger/Cargo Ship";
ship_cat7[2] = "192,RO-RO Passenger Ferry";
ship_cat7[3] = "194,Ferry";
ship_cat7[4] = "195,Hovercraft";
ship_cat7[5] = "196,Hydrofoil";


function chk_Class(strAction, strRegistrationTypeCodeID, intSpecialRegistrationTypeCodeID){
	var i;
	var objForm = document.theForm;
	var shipSubTypeObject = objForm.ShipSubTypeCodeID;
	var ShipSubTypeSelected = shipSubTypeObject.options[shipSubTypeObject.selectedIndex].value

	var objCertificationType = objForm.CertificationType;
	var CertificationTypeSelected = objCertificationType.options[objCertificationType.selectedIndex].value;
	
	var grt = _Trim(objForm.GTonnage.value);
	
	var strCertificationType = "TVR";
	
	var objRegistrationType = eval("objForm." + strRegistrationTypeCodeID);
	var strTypeRegistrationType = objRegistrationType.type;
	var intRegistrationType;

	if (strTypeRegistrationType == "select-one"){
		intRegistrationType = objRegistrationType.options[objRegistrationType.selectedIndex].value;
	}
	else{
		intRegistrationType = objRegistrationType.value;
	}
	
	for(i=0; i<ship_cat258.length; i++){
		var separator = ",";
		var strArray = new Array();
		strArray = ship_cat258[i].split(separator);
		if (ShipSubTypeSelected == strArray[0]){
			if(grt > 1000 && CertificationTypeSelected == strCertificationType && intRegistrationType != intSpecialRegistrationTypeCodeID){
				alert(strArray[1]+" exceeding 1000 gross tonnage has the option of registering with the Registry (with approval on a case-by-case basis) or failing which, you may register with Certified Classification Society, but not with Special Registration.");
				objForm.submit();
			}
		}
	}
	
	for(i=0; i<ship_cat7.length; i++){
		var separator = ",";
		var strArray = new Array();
		strArray = ship_cat7[i].split(separator);
		if (ShipSubTypeSelected == strArray[0] && CertificationTypeSelected == strCertificationType){
			alert(strArray[1]+" can only be certified by Classification Society.");
			objForm.action = strAction;
			objForm.NewCertificationType.value = "CLASS";
			objForm.submit();
		}
	}
	return false;
}

function IsClass(strAction, strRegistrationTypeCodeID, intSpecialRegistrationTypeCodeID){
	var objForm = document.theForm;

	if (!chk_Class(strAction, strRegistrationTypeCodeID, intSpecialRegistrationTypeCodeID)){
		objForm.action = strAction;
		objForm.submit();
	}else{
		return false;
	}
}

function CheckForm(strAction){
	if ( formChecker() ) {
		return true;
	}
	return false;
}

function SaveForLater(strAction, strUserName, strLoginLink){
	var objForm = document.theForm;

	if ( CheckForm(strAction) ){
		objForm.next_action.value = "Save";
		if (strUserName == ""){
			var strForm = _GetFormInputs(objForm);
			loginGoTo(strLoginLink, strForm, objForm.action);
		}else{
			objForm.submit();
		}
	}
}

function ActionNextPage(strAction){
	var objForm = document.theForm;
	if ( CheckForm(strAction) ){
		objForm.next_action.value = "Next";
		objForm.submit();
	}
}

function reservedName_OnChange()
{
	var objForm;
	objForm = document.theForm;
	objForm.ShipName.value = objForm.reserved_name.options[objForm.reserved_name.selectedIndex].value;
}

function onloadFocus(){
	var objForm = document.theForm;
	_FocusElement(objForm.ShipName);
}

function IsRefresh(strAction){
	var objForm = document.theForm;
	objForm.action = strAction;
	objForm.Refresh.value = "Y";
	objForm.submit();
}

function CheckIsOtherHullMaterial(){
	var objForm = document.theForm;
	var HullMaterialCodeID = objForm.HullMaterialCodeID.options[objForm.HullMaterialCodeID.selectedIndex].value;
	if ( HullMaterialCodeID == 255 && _Trim(objForm.HullMaterialOther.value) == "" ){
		return false;
	}
	else if ( HullMaterialCodeID != 255 && objForm.HullMaterialOther.value != "" ) {
		objForm.HullMaterialOther.value = "";
	}
	return true;
}


