function portselekt(page)
{
	if (document.getElementById("country").value!="0")

	{
	    var xmlHTTP = createXMLHttp();
	    xmlHTTP.open("GET", "/inventory/ajax/get_port.asp?country="+document.getElementById("country").value, false) ;
 	    xmlHTTP.setRequestHeader("Content-Type", "text/html; charset=utf-8" ) ;

	    xmlHTTP.send("");
	    document.getElementById("div_port").innerHTML = xmlHTTP.responseText;

        shippingcost('');
    }
}


function groupselekt(page)
{
	if (document.getElementById("automake").value!="0")

	{
	    var xmlHTTP = createXMLHttp();
	    xmlHTTP.open("GET", "/inventory/ajax/get_groups.asp?make="+document.getElementById("automake").value+"&page="+page, false) ;
 	    xmlHTTP.setRequestHeader("Content-Type", "text/html; charset=utf-8" ) ;

	    xmlHTTP.send("");
	    document.getElementById("div_make").innerHTML = xmlHTTP.responseText;
    }
}

function groupselektV2(page, status)
{
	if (document.getElementById("automake").value!="0")

	{
	    var xmlHTTP = createXMLHttp();
	    xmlHTTP.open("GET", "/inventory/ajax/get_groupsv2.asp?make="+document.getElementById("automake").value+"&page="+page +"&status="+ status, false) ;
 	    xmlHTTP.setRequestHeader("Content-Type", "text/html; charset=utf-8" ) ;

	    xmlHTTP.send("");
	    document.getElementById("div_make").innerHTML = xmlHTTP.responseText;
    }
}

function groupselektV3(page, status, group)
{
	if (document.getElementById("automake").value!="0")

	{
	    var xmlHTTP = createXMLHttp();
	    xmlHTTP.open("GET", "/inventory/ajax/get_groupsv3.asp?make="+document.getElementById("automake").value+"&group="+ group +"&page="+page +"&status="+ status, false) ;
 	    xmlHTTP.setRequestHeader("Content-Type", "text/html; charset=utf-8" ) ;

	    xmlHTTP.send("");
	    document.getElementById("div_make").innerHTML = xmlHTTP.responseText;
    }
}

function modelselekt(page)
{
	if (document.getElementById("automake").value!="0")

	{
	    var xmlHTTP = createXMLHttp();
	    xmlHTTP.open("GET", "/inventory/ajax/get_models.asp?make="+document.getElementById("automake").value+"&page="+page , false) ;
 	    xmlHTTP.setRequestHeader("Content-Type", "text/html; charset=utf-8" ) ;

	    xmlHTTP.send("");
	    document.getElementById("div_make").innerHTML = xmlHTTP.responseText;
    }
}

var ship_cost=0;

function calc_shippingcost()
{

    var tmp=document.getElementById("qty").value;
    if (tmp==999999)
        tmp=1;

     var price="$" + Number(ship_cost*tmp);
     if (price=="$0")
        price="Call";
     document.getElementById("ship_price").innerHTML = price;
}

function shippingcost(page)
{

	    var xmlHTTP = createXMLHttp();
	    xmlHTTP.open("GET", "/inventory/ajax/get_shippingcost.asp?port="+document.getElementById("port").value+"&from="+document.getElementById("from").value+"&page="+page , false) ;
 	    xmlHTTP.setRequestHeader("Content-Type", "text/html; charset=utf-8" ) ;

	    xmlHTTP.send("");
	    var tmp = xmlHTTP.responseText;
        if (!isNaN(tmp))
          ship_cost= Number(tmp);

        calc_shippingcost();

        if (document.getElementById("qty").value==999999)
            calc_TOTAL_shippingcost();
}

var ltcost=0;

function landtransportationcost(autoid)
{
	    var xmlHTTP = createXMLHttp();
	    xmlHTTP.open("GET", "/inventory/ajax/get_landtransportationcost.asp?autoid="+autoid+"&from="+document.getElementById("from").value , false) ;
 	    xmlHTTP.setRequestHeader("Content-Type", "text/html; charset=utf-8" ) ;

	    xmlHTTP.send("");
	    var tmp = xmlHTTP.responseText;
        if (!isNaN(tmp))
          ltcost= Number(tmp);

          if (ltcost==0)
             document.getElementById("land_price").innerHTML="Call"
          else
            document.getElementById("land_price").innerHTML="$" + ltcost;

          calc_TOTAL_shippingcost();

}

function calc_TOTAL_shippingcost()
{
  var msg="";
  var price='';
  if ((ltcost==0) && (ship_cost==0))
  {
      document.getElementById("total_price").innerHTML = 'N/A';
      return;
  }
  if (ltcost==0)
      {
        price=ship_cost;
        msg="* includes only Ocean Transportation.<br>Please call us for the Total Shipping Cost";
      }

   if (ship_cost==0)
      {
        price=ltcost;
        msg="* includes only Land Transportation.<br>Please call us for the Total Shipping Cost";
      }
   price=ship_cost +  ltcost;

   price="$" + price;
   if (msg!="")
        price=price + "*";

   document.getElementById("total_price").innerHTML=price;
   return;
   //document.getElementById("msg").innerHTML=msg;  
   //alert('test1');
   //return;
}

function createXMLHttp() {

    if (window.ActiveXObject) {
      var aVersions = [ "MSXML2.XMLHttp.5.0",
        "MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
        "MSXML2.XMLHttp","Microsoft.XMLHttp"
      ];

      for (var i = 0; i < aVersions.length; i++) {
        try {
            var oXmlHttp = new ActiveXObject(aVersions[i]);
            return oXmlHttp;
        } catch (oError) {
            //Do nothing
        }
      }
    }else if (typeof XMLHttpRequest != "undefined") {
        return new XMLHttpRequest();
    }
    throw new Error("XMLHttp object could be created.");
}