var date;
var currentDate;
var currentMonth;
var currentYear;
var currentDay;
function  timeExam()
{
	$.ajax({
		url : "http://www.ship-trader.com/control/timeTable/",
		success : function (data) {
			// $("#contentArea").html(data);
			// currentDate=data;
			//alert(data);
		}
	});
	setTimeout("timeExam()", 1000);
}
$(document).ready(function() {
	// var currentDate = date.getDate();
	//alert(currentDate);
	$.ajax({
		url : "http://www.ship-trader.com/control/timeTable/",
		success : function (data) {
			// $("#contentArea").html(data);
			currentDate=data;
			currentYear=currentDate.substr(0,4);
			currentMonth=(currentDate.substr(5,2))-1;
			currentDay=currentDate.substr(8,2);
			$('#date1').datepicker({
				minDate: new Date(currentYear, currentMonth, currentDay)
			});
			// alert(currentMonth-1);
			$('#date').datepicker({
				minDate: new Date(currentYear, currentMonth, currentDay)
			});
		}
	});
	//alert(currentYear);
	// alert(currentYear);
	$("#registrationForm").validate();
	$("#SVTrans").validate({
		rules:{
			ship_type: "required",
			sptypeHidden:{
				equalTo: "#stype"
			},
			res_ranges: "required",
			res_rangesHidden:{
				equalTo: "#res_ranges"
			},
			heavy_swl:{
				required:true,
				number: true,
				max: 999,
				min:1
			},
			space:{
				required:true,
				number: true,
				max: 999999,
				min:1
			},	
			capacity:{
				required:true,
				number: true,
				min:1
			},
			port: "required",
			ForMatchLP:{
				equalTo: "#portRange"
			},
			preportPre: "required",
			ForMatchDP:{
				equalTo: "#portRangePre"
			},
			s_date:{
				required: true,
				dateISO: true
			},
			e_date:{
				required: true,
				dateISO: true
			},
			max_draft_s:{
				required: true,
				number: true,
				max: 99.99,
				min:1
			},
			max_draft_a:{
				required: true,
				number: true,
				max: 999.99,
				min:1
			},
			// speed:{
				// required: true,
				// number: true,
				// max: 99.99,
				// min:1
			// },
			sdwt:{
				required: true,
				number: true,
				max: 999999,
				min:1
			},
			reg_country:{
			
				required:true
			},
			// loa:{
				// required: true,
				// number: true,
				// max: 999.99,
				// min:1
			// },
			// max_beam:{
				// required: true,
				// number: true,
				// max: 99.99,
				// min:1
			// },
			f_units:{
				required: true,
				number: true,
				max: 99999999,
				min:1
			}
		}
	});
	$("#DPTransForm").validate({
		rules:{
			ship_type: "required",
			sptypeHidden:{
				equalTo: "#stype"
			},
			sdwt1st:{
				required:true,
				number: true,
				min:1
			},
			sdwt2nd:{
				required:true,
				number: true,
				min:1
			},	
			ton1:{
				required:true,
				number: true,
				min:1
			},
			ton2:{
				required:true,
				number: true,
				min:2
			},
			port: "required",
			ForMatchLP:{
				equalTo: "#portRange"
			},
			preportPre: "required",
			ForMatchDP:{
				equalTo: "#portRangePre"
			},
			s_date:{
				required: true,
				dateISO: true
			},
			e_date:{
				required: true,
				dateISO: true
			},
			// loa:{
				// required: true,
				// number: true,
				// max: 999.99,
				// min:1
			// },
			// max_beam:{
				// required: true,
				// number: true,
				// max: 99.99,
				// min:1
			// },
			f_units:{
				required: true,
				number: true,
				max: 9999999999,
				min:1
			}
		}
	});
	$("#SDTransForm").validate({
		rules:{
			ship_type: "required",
			sptypeHidden:{
				equalTo: "#stype"
			},
			res_ranges: "required",
			res_rangesHidden:{
				equalTo: "#res_ranges"
			},
			heavy_swl:{
				required:true,
				number: true,
				max: 999,
				min:1
			},
			sdwt:{
				required:true,
				number: true,
				min:1
			},
			ldt:{
				required:true,
				number: true,
				min:1
			},
			space:{
				required:true,
				number: true,
				max: 999999,
				min:1
			},	
			capacity:{
				required:true,
				number: true,
				min:1
			},
			port: "required",
			ForMatchLP:{
				equalTo: "#portRange"
			},
			preportPre: "required",
			ForMatchDP:{
				equalTo: "#portRangePre"
			},
			s_date:{
				required: true,
				dateISO: true
			},
			e_date:{
				required: true,
				dateISO: true
			},
			max_draft_s:{
				required: true,
				number: true,
				max: 99.99,
				min:1
			},
			max_draft_a:{
				required: true,
				number: true,
				max: 999.99,
				min:1
			},
			speed:{
				required: true,
				number: true,
				max: 100.00,
				min:1
			},
			reg_country:{
			
				required:true
			},
			f_units:{
				required: true,
				number: true,
				max: 9999999999,
				min:1
			}
		}
	});
	$("#SRTransForm").validate({
		rules:{
			ship_type: "required",
			sptypeHidden:{
				equalTo: "#stype"
			},
			res_ranges: "required",
			res_rangesHidden:{
				equalTo: "#res_ranges"
			},
			heavy_swl:{
				required:true,
				number: true,
				max: 999,
				min:1
			},
			sdwt:{
				required:true,
				number: true,
				min:1,
				max:999999
			},
			space:{
				required:true,
				number: true,
				max: 999999,
				min:1
			},	
			capacity:{
				required:true,
				number: true,
				min:1
			},
			port: "required",
			ForMatchLP:{
				equalTo: "#portRange"
			},
			preportPre: "required",
			ForMatchDP:{
				equalTo: "#portRangePre"
			},
			s_date:{
				required: true,
				dateISO: true
			},
			e_date:{
				required: true,
				dateISO: true
			},
			max_draft_s:{
				required: true,
				number: true,
				max: 99.99,
				min:1
			},
			max_draft_a:{
				required: true,
				number: true,
				max: 999.99,
				min:1
			},
			speed:{
				required: true,
				number: true,
				max: 100.00,
				min:1
			},
			reg_country:{
			
				required:true
			},
			f_units:{
				required: true,
				number: true,
				max: 9999999999,
				min:1
			}
		}
	});
	
	$("#RPTransForm").validate({
		rules:{
			ship_type: "required",
			sptypeHidden:{
				equalTo: "#stype"
			},
			res_ranges: "required",
			res_rangesHidden:{
				equalTo: "#res_ranges"
			},
			heavy_swl:{
				required:true,
				number: true,
				max: 999,
				min:1
			},
			sdwt1st:{
				required:true,
				number: true,
				min:1
				
			},
			sdwt2nd:{
				required:true,
				number: true,
				min:1
			},
			space:{
				required:true,
				number: true,
				max: 999999,
				min:1
			},	
			capacity:{
				required:true,
				number: true,
				min:1
			},
			port: "required",
			ForMatchLP:{
				equalTo: "#portRange"
			},
			preportPre: "required",
			ForMatchDP:{
				equalTo: "#portRangePre"
			},
			s_date:{
				required: true,
				dateISO: true
			},
			e_date:{
				required: true,
				dateISO: true
			},
			max_draft_s:{
				required: true,
				number: true,
				max: 99.99,
				min:1
			},
			max_draft_a:{
				required: true,
				number: true,
				max: 999.99,
				min:1
			},
			speed:{
				required: true,
				number: true,
				max: 100.00,
				min:1
			},
			reg_country:{
			
				required:true
			},
			f_units:{
				required: true,
				number: true,
				max: 9999999999,
				min:1
			}
		}
	});
	$("#VCTrans").validate({
		rules:{
			pack_typ: "required",
			pack_typHidden:{
				equalTo: "#Packagetype"
			},
			hv_pack:{
				required:true,
				digit: true,
				max: 999,
				min:1
			},
			space:{
				required:true,
				digit: true,
				max: 999999,
				min:1
			},	
			ton:{
				required:true,
				digit: true,
				max: 999999,
				min:1
			},
			port: "required",
			ForMatchLP:{
				equalTo: "#portRange"
			},
			preportPre: "required",
			ForMatchDP:{
				equalTo: "#portRangePre"
			},
			s_date:{
				required: true,
				dateISO: true
			},
			e_date:{
				required: true,
				dateISO: true
			},
			max_draft:{
				required: true,
				number: true,
				max: 99.99,
				min:1
			},
			max_draft_a:{
				required: true,
				number: true,
				max: 99.99,
				min:1
			}
		}
	});
	$("#STTransForm").validate({
		rules:{
			ship_type: "required",
			sptypeHidden:{
				equalTo: "#stype"
			},
			res_ranges: "required",
			res_rangesHidden:{
				equalTo: "#res_ranges"
			},
			heavy_swl:{
				required:true,
				number: true,
				max: 999,
				min:1
			},
			space:{
				required:true,
				number: true,
				max: 999999,
				min:1
			},	
			capacity:{
				required:true,
				number: true,
				min:1
			},
			port: "required",
			ForMatchLP:{
				equalTo: "#portRange"
			},
			s_date:{
				required: true,
				dateISO: true
			},
			e_date:{
				required: true,
				dateISO: true
			},
			max_draft_s:{
				required: true,
				number: true,
				max: 99.99,
				min:1
			},
			max_draft_a:{
				required: true,
				number: true,
				max: 999.99,
				min:1
			},
			// speed:{
				// required: true,
				// number: true,
				// max: 99.99,
				// min:1
			// },
			sdwt:{
				required: true,
				number: true,
				max: 999999,
				min:1
			},
			reg_country:{
			
				required:true
			},
			f_units:{
				required: true,
				number: true,
				max: 9999999,
				min:1
			}
		}
	});
	$("#TCTransForm").validate({
		rules:{
			ship_type: "required",
			sptypeHidden:{
				equalTo: "#stype"
			},
			res_ranges: "required",
			res_rangesHidden:{
				equalTo: "#res_ranges"
			},
			heavy_swl:{
				required:true,
				number: true,
				max: 999,
				min:1
			},
			space:{
				required:true,
				number: true,
				max: 999999,
				min:1
			},	
			capacity:{
				required:true,
				number: true,
				min:1
			},
			port: "required",
			ForMatchLP:{
				equalTo: "#portRange"
			},
			s_date:{
				required: true,
				dateISO: true
			},
			e_date:{
				required: true,
				dateISO: true
			},
			max_draft_s:{
				required: true,
				number: true,
				max: 99.99,
				min:1
			},
			max_draft_a:{
				required: true,
				number: true,
				max: 999.99,
				min:1
			},
			// speed:{
				// required: true,
				// number: true,
				// max: 99.99,
				// min:1
			// },
			sdwt1st:{
				required: true,
				number: true,
				max: 999999,
				min:1
			},
			sdwt2nd:{
				required: true,
				number: true,
				max: 999999,
				min:1
			},
			reg_country:{
			
				required:true
			},
			// loa:{
				// required: true,
				// number: true,
				// max: 999.99,
				// min:1
			// },
			// max_beam:{
				// required: true,
				// number: true,
				// max: 99.99,
				// min:1
			// },
			f_units:{
				required: true,
				number: true,
				max: 9999999,
				min:1
			}
		}
	});
	$("a.clickablePortPre").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
		// $("#portRangeId2").val(html(portIdMain);
        //$("input#portRangeId2").val($(this).html());
		// alert(maintext);
        $("input#portRangePre").val(maintext);
        $("input#portRangeId2Pre").val(portIdMain);
        $("#RangeNamePre").html("PORT");
	    var $radios = $('input:radio[name=rangeOpenOre]');
		$radios.filter('[value=1]').attr('checked', true);
        $("input.radioPortPre:checked").val(portIdMain);
    });
	$("a.clickableCountry").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
        $("input#portRange").val(maintext);
		// alert(maintext);
        $("input#portRangeId2").val(portIdMain);
        $("#RangeName").html("Country");
	    var $radios = $('input:radio[name=rangeOpen]');
		$radios.filter('[value=2]').attr('checked', true);
        $("input.radioPort:checked").val(portIdMain);
    });
	$("a.clickableCountryPre").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
        $("input#portRangePre").val(maintext);
		// alert(maintext);
        $("input#portRangeId2Pre").val(portIdMain);
        $("#RangeNamePre").html("Country");
	    var $radios = $('input:radio[name=rangeOpenPre]');
		$radios.filter('[value=2]').attr('checked', true);
        $("input.radioPort:checked").val(portIdMain);
    });
	$("a.clickableSea").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
        $("input#portRange").val(maintext);
        $("input#portRangeId2").val(portIdMain);
        $("#RangeName").html("Sea");
	    var $radios = $('input:radio[name=rangeOpen]');
		$radios.filter('[value=3]').attr('checked', true);
        $("input.radioPort:checked").val(portIdMain);
    });
	$("a.clickableSeaPre").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
        $("input#portRangePre").val(maintext);
        $("input#portRangeId2Pre").val(portIdMain);
        $("#RangeNamePre").html("Sea");
	    var $radios = $('input:radio[name=rangeOpenPre]');
		$radios.filter('[value=3]').attr('checked', true);
        $("input.radioPort:checked").val(portIdMain);
    });
	$("a.clickableGeo").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		// alert(text);
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
		alert(maintext);
        $("input#portRange").val(maintext);
        $("input#portRangeId2").val(portIdMain);
        $("#RangeName").html("Geographic");
	    var $radios = $('input:radio[name=rangeOpen]');
		$radios.filter('[value=4]').attr('checked', true);
        $("input.radioPort:checked").val(portIdMain);
    });
	$("a.clickableGeoPre").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		// alert(text);
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
		alert(maintext);
        $("input#portRangePre").val(maintext);
        $("input#portRangeId2Pre").val(portIdMain);
        $("#RangeNamePre").html("Geographic");
	    var $radios = $('input:radio[name=rangeOpenPre]');
		$radios.filter('[value=4]').attr('checked', true);
        $("input.radioPort:checked").val(portIdMain);
    });
	$("a.clickableOcen").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		// alert(text);
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
		alert(maintext);
        $("input#portRange").val(maintext);
        $("input#portRangeId2").val(portIdMain);
        $("#RangeName").html("Ocean");
	    var $radios = $('input:radio[name=rangeOpen]');
		$radios.filter('[value=4]').attr('checked', true);
        $("input.radioPort:checked").val(portIdMain);
    });
	$("a.clickableOcenPre").click(function(event)
	{
		event.preventDefault();
		var text = $(this).text();
		// alert(text);
		var portId = text.indexOf('|');
		var strLength = text.length;
		var portIdMain = text.substring(portId+1, strLength);// to find the port id
		var maintext= text.substring(0,portId);
		alert(maintext);
        $("input#portRangePre").val(maintext);
        $("input#portRangeId2Pre").val(portIdMain);
        $("#RangeNamePre").html("Ocean");
	    var $radios = $('input:radio[name=rangeOpenPre]');
		$radios.filter('[value=4]').attr('checked', true);
        $("input.radioPort:checked").val(portIdMain);
    });	
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		if ($('#dialogNone').length>0) {
			if ($('#dialog').length>0)
			{
				$('#dialog').attr('id', 'dialogPre');
			}
			$('#dialogNone').attr('id', 'dialog');
		}
		
		// $('#dialog').attr('id', 'dialogNone');
		// $('#dialogPre').attr('id', 'dialog');
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		// $(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('top',  winH/2-$(id).height()/2+200);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	$('a[name=modal2]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		$('#dialog').attr('id', 'dialogNone');
		$('#dialogPre').attr('id', 'dialog');
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		// $(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('top',  winH/2-$(id).height()/2+200);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	$('.windowPre .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('#mask').hide();
		$('.windowPre').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
		$('.windowPre').hide();
	});	
});
function getHTTPObject(){
          if (window.ActiveXObject) 
              return new ActiveXObject("Microsoft.XMLHTTP");
          else if (window.XMLHttpRequest) 
              return new XMLHttpRequest();
          else {
              alert("Your browser does not support AJAX.");
              return null;
          }
      }
	function LoadCargoGareType(){
        httpObject = getHTTPObject();
        if (httpObject != null) {
			//alert("<?php echo base_url()?>");
			var valueoftextbox=$("#Cargo_gare_type").val();
			if(valueoftextbox.length >=2){
			var urlApu="http://www.ship-trader.com/ST_trans/LoadCargoGareType/"+valueoftextbox+"/";
            httpObject.open("POST",urlApu, true);
			// alert("Bishw");
            httpObject.send(null);
            httpObject.onreadystatechange = setOutputCargoGareType;
			}else{
				if(valueoftextbox.length <2){
					$('#ValueOfCargo_gare_type').hide();
				}
			}

        }
    }
	function setOutputCargoGareType(){
        if(httpObject.readyState == 4){
			var apu =httpObject.responseText
			$('#ValueOfCargo_gare_type').show();
			$("#ValueOfCargo_gare_type").html(apu);
        }
    }
	function setCargoGareType()
	{	
		$("a.cargogaretype").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			$("input#Cargo_gare_type").val(text);
			$("input#Cargo_gare_typeHidden").val(text);
			$('#ValueOfCargo_gare_type').hide();
		});
	}
    function LoadShipType(){
        httpObject = getHTTPObject();
        if (httpObject != null) {
			// alert("<?php echo base_url()?>");
			var valueoftextbox=$("#stype").val();
			if(valueoftextbox.length >=2){
			var urlApu="http://www.ship-trader.com/SV_trans/LoadShipType/"+valueoftextbox+"/";
            httpObject.open("POST",urlApu, true);
            httpObject.send(null);
            httpObject.onreadystatechange = setOutput;
			}else{
				if(valueoftextbox.length <2){
					$('#ValueOfShipType').hide();
				}
			}

        }
    }
	function LoadCargoType(){
        httpObject = getHTTPObject();
        if (httpObject != null) {
			// alert("<?php echo base_url()?>");
			var valueoftextbox=$("#Cargotype").val();
			if(valueoftextbox.length >=2){
			var urlApu="http://www.ship-trader.com/VC/LoadCargoType/"+valueoftextbox+"/";
            httpObject.open("POST",urlApu, true);
            httpObject.send(null);
            httpObject.onreadystatechange = setOutputCargoType;
			}else{
				if(valueoftextbox.length <2){
					$('#ValueOfCargoType').hide();
				}
			}

        }
    }
    function setOutputCargoType(){
        if(httpObject.readyState == 4){
			var apu =httpObject.responseText
			$('#ValueOfCargoType').show();
			$("#ValueOfCargoType").html(apu);
        }
    }
	function setCargoType()
	{	
		$("a.cartype").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			$("input#Cargotype").val(text);
			$("input#cargotypeHidden").val(text);
			$('#ValueOfCargoType').hide();
		});
	}
    function setOutput(){
        if(httpObject.readyState == 4){
            // alert(httpObject.responseText);
            // document.getElementById('outputText').html = httpObject.responseText;
			var apu =httpObject.responseText
			//alert(apu);
			// $("#RangeNamePre").html("Sea");
			$('#ValueOfShipType').show();
			$("#ValueOfShipType").html(apu);
        }
    }
	function setShipType()
	{	
		$("a.sstype").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			$("input#stype").val(text);
			$("input#sptypeHidden").val(text);
			$('#ValueOfShipType').hide();
		});
	}
	function setSinglePort()
	{	
		$("a.ssPort").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			$("input#res_ranges").val(text);
			$("input#res_rangesHidden").val(text);
			$('#showSinglePort').hide();
		});
	}
	function setSingleCountry()
	{	
		$("a.ssCountry").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			$("input#res_country").val(text);
			$("input#res_countryHidden").val(text);
			$('#showSingleCountry').hide();
		});
	}
	function setLoadPortType()
	{	
		$("a.PortClass").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRange").val(portName);
			$("input#ForMatchLP").val(portName);
			$("input#Openrange").val("1");
			$("input#portRangeId2").val(portIdMain);
			$("#showPCSGO").hide();
		});
		$("a.CountryClass").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRange").val(portName);
			$("input#ForMatchLP").val(portName);
			$("input#Openrange").val("2");
			$("input#portRangeId2").val(portIdMain);
			$("#showPCSGO").hide();
		});
		$("a.SeaClass").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRange").val(portName);
			$("input#ForMatchLP").val(portName);
			$("input#Openrange").val("3");
			$("input#portRangeId2").val(portIdMain);
			$("#showPCSGO").hide();
		});
		$("a.GeographicClass").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRange").val(portName);
			$("input#ForMatchLP").val(portName);
			$("input#Openrange").val("4");
			$("input#portRangeId2").val(portIdMain);
			$("#showPCSGO").hide();
		});
		$("a.OceanClass").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRange").val(portName);
			$("input#ForMatchLP").val(portName);
			$("input#Openrange").val("5");
			$("input#portRangeId2").val(portIdMain);
			$("#showPCSGO").hide();
		});
		$("a.PortClassDes").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRangePre").val(portName);
			$("input#ForMatchDP").val(portName);
			$("input#Openrangedes").val("1");
			$("input#portId2Pre").val(portIdMain);
			$("#showPCSGOdestination").hide();
		});
		$("a.CountryClassDes").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRangePre").val(portName);
			$("input#ForMatchDP").val(portName);
			$("input#Openrangedes").val("2");
			$("input#portId2Pre").val(portIdMain);
			$("#showPCSGOdestination").hide();
		});
		$("a.SeaClassDes").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRangePre").val(portName);
			$("input#ForMatchDP").val(portName);
			$("input#Openrangedes").val("3");
			$("input#portId2Pre").val(portIdMain);
			$("#showPCSGOdestination").hide();
		});
		$("a.GeographicClassDes").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRangePre").val(portName);
			$("input#ForMatchDP").val(portName);
			$("input#Openrangedes").val("4");
			$("input#portId2Pre").val(portIdMain);
			$("#showPCSGOdestination").hide();
		});
		$("a.OceanClassDes").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			var portId = text.indexOf('|');
			var strLength = text.length;
			var portIdMain = text.substring(portId+1, strLength);// to find the port id
			var portName=text.substring(0,portId);
			$("input#portRangePre").val(portName);
			$("input#ForMatchDP").val(portName);
			$("input#Openrangedes").val("5");
			$("input#portId2Pre").val(portIdMain);
			$("#showPCSGOdestination").hide();
		});
	}
	function LoadPortOnDiv(TransType){
        httpObject = getHTTPObject();
        if (httpObject != null) {
			// alert("<?php echo base_url()?>");
			var valueoftextbox=$("#portRange").val();
			if(valueoftextbox.length >=2){
			var urlApu="http://www.ship-trader.com/SV_trans/LoadPort/"+valueoftextbox+"/lp/"+TransType;
			//alert(valueoftextbox);
            httpObject.open("POST",urlApu, true);
            httpObject.send(null);
            httpObject.onreadystatechange = setOutputForPort;
			}else{
				if(valueoftextbox.length <2){
					$('#showPCSGO').hide();
				}
			}
		}
    }
	function setOutputForPort(){
        if(httpObject.readyState == 4){
			var apu =httpObject.responseText;
			$('#showPCSGOdestination').hide();
			$('#showPCSGO').show();
			$("#showPCSGO").html(apu);
        }
    }
	function LoadSinglePortOnDiv(TransType){
        httpObject = getHTTPObject();
        if (httpObject != null) {
			// alert("<?php echo base_url()?>");
			var valueoftextbox=$("#res_ranges").val();
			if(valueoftextbox.length >=2){
			var urlApu="http://www.ship-trader.com/SV_trans/LoadRestrictionPort/"+valueoftextbox+"/lp/"+TransType;
			//alert(valueoftextbox);
            httpObject.open("POST",urlApu, true);
            httpObject.send(null);
            httpObject.onreadystatechange = setOutputForSinglePort;
			}else{
				if(valueoftextbox.length <2){
					$('#showSinglePort').hide();
				}
			}
		}
    }
	function setOutputForSinglePort(){
        if(httpObject.readyState == 4){
			var apu =httpObject.responseText;
			//$('#showSinglePort').hide();
			$('#showSinglePort').show();
			$("#showSinglePort").html(apu);
        }
    }
	function LoadSingleCountryOnDiv(TransType){
        httpObject = getHTTPObject();
        if (httpObject != null) {
			//alert("<?php echo base_url()?>");
			var valueoftextbox=$("#res_country").val();
			if(valueoftextbox.length >=2){
			var urlApu="http://www.ship-trader.com/SV_trans/LoadRestrictionCountry/"+valueoftextbox+"/lp/"+TransType;
			//alert(valueoftextbox);
            httpObject.open("POST",urlApu, true);
            httpObject.send(null);
            httpObject.onreadystatechange = setOutputForSingleCountry;
			}else{
				if(valueoftextbox.length <2){
					$('#showSingleCountry').hide();
				}
			}
		}
    }
	function setOutputForSingleCountry(){
        if(httpObject.readyState == 4){
			var apu =httpObject.responseText;
			//$('#showSinglePort').hide();
			$('#showSingleCountry').show();
			$("#showSingleCountry").html(apu);
        }
    }
    function LoadDestinationPortOnDiv(TransType){
        httpObject = getHTTPObject();
        if (httpObject != null) {
			var valueoftextbox=$("#portRangePre").val();
			//alert(valueoftextbox);
			if(valueoftextbox.length >=2){
			var urlApu="http://www.ship-trader.com/SV_trans/LoadPort/"+valueoftextbox+"/ld/"+TransType;
            httpObject.open("POST",urlApu, true);
            httpObject.send(null);
            httpObject.onreadystatechange = setOutputForDestinationPort;
			}else{
				if(valueoftextbox.length <2){
					$('#showPCSGOdestination').hide();
				}
			}
        }
    }
    function setOutputForDestinationPort(){
        if(httpObject.readyState == 4){
			var apu =httpObject.responseText;
			$('#showPCSGO').hide();
			$('#showPCSGOdestination').show();
			$("#showPCSGOdestination").html(apu);
        }
    }
	//Code for to Load Package Type
	function LoadPackageType(){
        httpObject = getHTTPObject();
        if (httpObject != null) {
			// alert("<?php echo base_url()?>");
			var valueoftextbox=$("#Packagetype").val();
			if(valueoftextbox.length >=2){
			var urlApu="http://www.ship-trader.com/VC/LoadPackageType/"+valueoftextbox+"/";
            httpObject.open("POST",urlApu, true);
            httpObject.send(null);
            httpObject.onreadystatechange = setOutputPackageType;
			}else{
				if(valueoftextbox.length <2){
					$('#ValueOfPackageType').hide();
				}
			}

        }
    }
	function setOutputPackageType(){
        if(httpObject.readyState == 4){
			var apu =httpObject.responseText
			$("#ValueOfCargoType").hide();
			$("#ValueOfPackageType").show();
			$("#ValueOfPackageType").html(apu);
        }
    }
	function setPackageType()
	{	
		$("a.Packagetype").click(function(event)
		{
			event.preventDefault();
			var text = $(this).text();
			$("#ValueOfCargoType").hide();
			$("input#Packagetype").val(text);
			$("input#pack_typHidden").val(text);
			$('#ValueOfPackageType').hide();
		});
	}
	function checkDecimel(idName,maxinumvalue,type){
		if(type=="d")
		{
			var nameofID='#'+idName;
			var valueoftextbox=$(nameofID).val();
			//var value=$(this).val();
			var orignalValue=valueoftextbox;
			valueoftextbox=valueoftextbox.replace(/([^0-9].*)/g, "");
			// var text="Your Oreginal value is "+orignalValue+" I replace integer and now value is : "+valueoftextbox;
			
			$(nameofID).val(valueoftextbox);
		} 
	}
	function onlyDecimel(evt)
	{
		var e = event || evt;
		var charcode=e.which || e.keyCode;
		// alert(charcode);
		if(charcode == 46 || (charcode>47 && charcode<59)){
			return true;
		}else
		{
			return false;
		}
	}
	function onlyNumber(evt)
	{
		var e = event || evt;
		var charcode=e.which || e.keyCode;
		// alert(charcode);
		if(charcode>47 && charcode<59){
			return true;
		}
		else
		{
			return false;
		}
	}
	function withdorowCheckbox(){
		// $('input[name=max_draft_a_u]').is(':checked')
		var title = $("input[name=max_draft_a_u]").is(':checked');
		if(title == true){
			//alert(title);
			$('input[name=max_draft_a_u]').attr('checked', false);
		}
		//$('input[name=max_draft_a_u]').attr('checked')
	}
	function showCheckBox(){
		// $('input[name=max_draft_a_u]').is(':checked')
		var title = $("input[name=max_draft_a_u]").is(':checked');
		if(title == true){
			var text="";
			$("input[name=max_draft_a]").val(text);
		}
		//$('input[name=max_draft_a_u]').attr('checked')
	}
	function withdorowCheckboxAirDruft(){
		var title = $("#FRC").is(':checked');
		if(title == true){
			//alert(title);
			$('#adfasd').attr("disabled", true);
		}else{
			$('#adfasd').attr("disabled", false);
		}
	}
	function showCheckBoxAirDruft(){
		// $('input[name=max_draft_a_u]').is(':checked')
		var title = $("#FRC").is(':checked');
		if(title == true){
			//alert(title);
			$('#FRC').attr('checked', false);
			$('#adfasd').attr("active", true);
		}
		//$('input[name=max_draft_a_u]').attr('checked')
	}
	function showDestinationAny(idname,idnameOther,otherId){
		var IDname='#'+idname;
		var IDnameOther='#'+idnameOther;
		var otherIdName='#'+otherId;
		var status = $(IDname).is(':checked');
		if(status == true)
		{
			//alert(status);
			$(idname).attr('checked', false);
			$(IDnameOther).attr("disabled", true);
			$(otherIdName).attr("disabled", true);
			$(otherIdName).val("");
			$(IDnameOther).val("");
			//$(IDnameOther).hide();
		}
		else
		{
			if(status == false)
			{
				//alert(status);
				$(IDnameOther).attr("disabled", false);
				$(otherIdName).attr("disabled", false);
				//$(IDnameOther).show();
			}
		}		
	}
	function activeDependingOnValue2(idname1,idname2,idnameOther,hiddenid){
		var IDname1='#'+idname1;
		var IDname2='#'+idname2;
		var IDnameOther='#'+idnameOther;
		var HiddenId='';
		//alert(HiddenId);
		if( hiddenid!='')
		{
			HiddenId='#'+hiddenid;
		}
		var status = $(IDname1).is(':checked');
		if(status == true)
		{
			//alert(status);
			$(idname1).attr('checked', false);
			$(IDnameOther).val("");
			$(IDname2).val("");
			var apu = $(HiddenId).val();
			if(apu!='undefined')
			{
				$(HiddenId).attr("disabled", true);
			}
			//alert(HiddenId);
			$(IDnameOther).attr("disabled", true);
			$(IDname2).attr("disabled", true);
			$(otherIdName).attr("disabled", true);
			// if($(idhidden).val()!= 'undifined')
			// {
				// $(idhidden).attr("disabled", true);	
			// }
			$(otherIdName).val("");
			//$(IDnameOther).hide();
		}
		else
		{
			if(status == false)
			{
				//alert(status);
				$(IDnameOther).val("");
				$(IDnameOther).attr("disabled", false);
				$(IDname2).attr("disabled", false);
				//$(IDnameOther).show();
			}
		}
	}
	function activeDependingOnValue(idname,idnameOther){
		var IDname='#'+idname;
		var IDnameOther='#'+idnameOther;
		var status = $(IDname).is(':checked');
		if(status == true)
		{
			//alert(status);
			$(idname).attr('checked', false);
			$(IDnameOther).val("");
			$(IDnameOther).attr("disabled", true);
			$(otherIdName).attr("disabled", true);
			$(otherIdName).val("");
			//$(IDnameOther).hide();
		}
		else
		{
			if(status == false)
			{
				//alert(status);
				$(IDnameOther).val("");
				$(IDnameOther).attr("disabled", false);
				//$(IDnameOther).show();
			}
		}		
	}
	function changeMenuveringCondition()
	{
			var idname='#menoeuvring';
			var value=$('#menoeuvring').val();
			if(value=='Dead (not running)')
			{
				$('#speed').attr("disabled", true);
				//alert();
			}
			else
			{
				$('#speed').attr("disabled", false);
			}
	
	}
	/* function showCheckBoxWithId(nameField,otherFieldName){
		// $('input[name=max_draft_a_u]').is(':checked')
		
		var title = $("input[name="+nameField+"]").is(':checked');
		// alert(title);
		if(title == true){
			var text="";
			$("input[name="+otherFieldName+"]").val(text);
			$("input[name="+otherFieldName+"]").("disabled", true);
		}else{
			$("input[name="+otherFieldName+"]").("active", true);
		}
		//$('input[name=max_draft_a_u]').attr('checked')
	}
	function withdorowCheckboxWithId(nameField,otherFieldName){
		var idName1st="#"+nameField;
		var idName2nd="#"+otherFieldName;
		var title = $(idName2nd).is(':checked');
		//alert(idName1st);
		if(title == true){
			$(idName2nd).attr("checked", false);
			$(idName2nd).attr("checked", false);
		}
	} */
