﻿

var returnLock = false;
function stopRKey(evt) { 
  var evt = (evt) ? evt : ((event) ? event : null); 
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
  if ((evt.keyCode == 13) && (node.type=="text" || node.type=="password") && !returnLock)  {return false;} 
  if (evt.keyCode == 27) {
    try { $get('ctl00_ContentPlaceHolder1_btnSearchZipCodeCancel').click(); } catch (err) {}
    try { $get('ctl00_ContentPlaceHolder1_btnSearchCommodityCodeCancel').click(); } catch (err) {}
  }
}
document.onkeypress = stopRKey;
function checkDelete() { return confirm('Selected record will be deleted. This operation can not be undone. Continue?'); }
function validateUserIDPassword(source, args) {
    if (args.Value.length == 0)
        args.IsValid = true;
    else {
        if (args.Value.length >= 6)
            args.IsValid = true;
        else  args.IsValid = false;
    }
}
function validateAccount(source, args) {
    if (!document.getElementById('ctl00_ContentPlaceHolder1_rbAccount2').checked)
        args.IsValid = true;
    else {
        if (args.Value.length > 0)
            args.IsValid = true;
        else  args.IsValid = false;
    }
}

function setCityState(div, cityObj, stateObj, city, state) {
    document.getElementById(div).style.display='none';
    document.getElementById(cityObj).value=city;
    for (var i=0; i < document.getElementById(stateObj).options.length; i++)
        if (document.getElementById(stateObj).options[i].value == state) {
            document.getElementById(stateObj).selectedIndex = i;
            break;
        }
}
function toggleCombobox(obj, cbb, open) {
    document.getElementById(cbb).selectedIndex=-1;
    if (document.getElementById(obj).style.display == 'none') {
        if (open) document.getElementById(obj).style.display = 'block';
    } else
        document.getElementById(obj).style.display = 'none';
    return false;
}

var gridcount = 0;
function gridEvent(id, serviceID, special, e) {
    if (document.getElementById('ctl00_ContentPlaceHolder1_hiddenServiceID') != null) {
        if (e == 'select') {
            for (var i=0; i<gridcount; i++) {
                if (i % 2 == 0) { document.getElementById('ctl00_ContentPlaceHolder1_td_' + i + '_1').className = 'grid_cell'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + i + '_2').className = 'grid_cell'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + i + '_3').className = 'grid_cell'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + i + '_4').className = 'grid_cell'; }
                else { document.getElementById('ctl00_ContentPlaceHolder1_td_' + i + '_1').className = 'grid_cell_alt'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + i + '_2').className = 'grid_cell_alt'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + i + '_3').className = 'grid_cell_alt'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + i + '_4').className = 'grid_cell_alt'; }
                document.getElementById('ctl00_ContentPlaceHolder1_img_' + i).style.display = 'none';
            }
            document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_1').className = 'grid_cell_s'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_2').className = 'grid_cell_s'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_3').className = 'grid_cell_s'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_4').className = 'grid_cell_s'; document.getElementById('ctl00_ContentPlaceHolder1_img_' + id).style.display = 'block';
            document.getElementById('ctl00_ContentPlaceHolder1_hiddenServiceID').value = serviceID;
            document.getElementById('ctl00_ContentPlaceHolder1_hiddenServiceSpecial').value = special;
            
        } else {
            if (document.getElementById('ctl00_ContentPlaceHolder1_hiddenServiceID').value != serviceID || document.getElementById('ctl00_ContentPlaceHolder1_hiddenServiceSpecial').value != special) {
                if (e == 'hover') { document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_1').className = 'grid_cell_h'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_2').className = 'grid_cell_h'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_3').className = 'grid_cell_h'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_4').className = 'grid_cell_h'; }
                else {
                    if (id % 2 == 0) { document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_1').className = 'grid_cell'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_2').className = 'grid_cell'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_3').className = 'grid_cell'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_4').className = 'grid_cell'; }
                    else { document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_1').className = 'grid_cell_alt'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_2').className = 'grid_cell_alt'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_3').className = 'grid_cell_alt'; document.getElementById('ctl00_ContentPlaceHolder1_td_' + id + '_4').className = 'grid_cell_alt'; }
                }
            }
        }
    }
}

var focusObj = null;
var focusInterval = null;
function makeFocused(objName) {
    focusObj = document.getElementById(objName);
    focusInterval = setInterval('setFocus();', 100);
}
function setFocus() {
    focusObj.onfocus = function() {
        focusObj.select();
        clearInterval(focusInterval);
        focusObj.onfocus = null;
        focusObj = null;
        focusInterval = null;
    };
    focusObj.focus();
}

function getAbsX(elt) { if (elt != null) { return (elt.x) ? elt.x : getAbsPos(elt,"Left"); } }
function getAbsY(elt) { if (elt != null) { return (elt.y) ? elt.y : getAbsPos(elt,"Top"); } }
function getAbsPos(elt,which) { iPos = 0; while (elt != null) { iPos += elt["offset" + which]; elt = elt.offsetParent; } return iPos; }
function evalJs(html_text) { var regex = /<script[^>]*>(.*?)<\/script>/ig; var result; while ((result = regex.exec(html_text)) != null) { eval(result[1]); } }
function help(display, name) { help(display, name, 'bottom'); }
function help(display, name, dir) {
    var divObj = document.getElementById('div_help_' + name); if (divObj == null) divObj = document.getElementById('ctl00_ContentPlaceHolder1_div_help_' + name);
    var handlerObj = document.getElementById('handler_help_' + name); if (handlerObj == null) handlerObj = document.getElementById('ctl00_ContentPlaceHolder1_handler_help_' + name);
    var imgObj = document.getElementById('img_help_' + name); if (imgObj == null) imgObj = document.getElementById('ctl00_ContentPlaceHolder1_img_help_' + name);
    if (display == 'block') { imgObj.src = '/Files/Assets/help_s.gif'; divObj.style.display = 'block'; divObj.style.left = (getAbsX(handlerObj) + handlerObj.offsetWidth - divObj.offsetWidth) + 'px'; if (dir == 'top') { divObj.style.top = (getAbsY(handlerObj) - imgObj.offsetHeight - divObj.offsetHeight) + 'px'; } else { divObj.style.top = (getAbsY(handlerObj) + imgObj.offsetHeight) + 'px'; } } else { imgObj.src='/Files/Assets/help.gif'; divObj.style.display='none'; } }
function toggleLeftMenu(id) {
    if (document.getElementById('menu' + id).style.display == 'none') {
        document.getElementById('menu' + id).style.display = 'block';
        document.getElementById('menuimg' + id).src = '/Files/Assets/bullet_collapse.gif';
    } else {
        document.getElementById('menu' + id).style.display = 'none';
        document.getElementById('menuimg' + id).src = '/Files/Assets/bullet_expand.gif';
    }
}
function openHelpWindow(name, url) {
    var windowObj = window.open(url, name, "width=500,height=500,top=200,left=200,toolbars=no,scrollbars=yes,status=no,resizable=no");
    windowObj.focus();
    return false;
}
function openHelpWindowWithSize(name, url, width, height) {
    var windowObj = window.open(url, name, "width=" + width + ",height=" + height + ",top=200,left=200,toolbars=no,scrollbars=yes,status=no,resizable=no");
    windowObj.focus();
    return false;
}
function openHelp_GroundLTL_Hazardous() {
    openHelpWindowWithSize('groundltl_hazardous', '/help/groundltl_hazardous.htm', 500, 300);
}
function openHelp_GroundLTL_InsidePickup() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_inside_pickup.htm', 500, 300);
}
function openHelp_GroundLTL_LiftGateService() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_lift_gate_service.htm', 500, 300);
}
function openHelp_GroundLTL_ResidentialPickup() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_residential_pickup.htm', 500, 300);
}
function openHelp_GroundLTL_WeekendPickup() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_weekend_pickup.htm', 500, 300);
}
function openHelp_GroundLTL_HolidayPickup() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_holiday_pickup.htm', 500, 300);
}
function openHelp_GroundLTL_TradeShowPickup() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_trade_show_pickup.htm', 500, 300);
}
function openHelp_GroundLTL_COD() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_cod.htm', 500, 300);
}
function openHelp_GroundLTL_InsideDelivery() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_inside_delivery.htm', 500, 300);
}
function openHelp_GroundLTL_DeliveryLiftGateService() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_delivery_lift_gate_service.htm', 500, 300);
}
function openHelp_GroundLTL_ResidentialDelivery() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_residential_delivery.htm', 500, 300);
}
function openHelp_GroundLTL_WeekendDelivery() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_weekend_delivery.htm', 500, 300);
}
function openHelp_GroundLTL_HolidayDelivery() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_holiday_delivery.htm', 500, 300);
}
function openHelp_GroundLTL_TradeShowDelivery() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_trade_show_delivery.htm', 500, 300);
}
function openHelp_GroundLTL_LimitedAccessLocationsDelivery() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_limited_access_locations_delivery.htm', 500, 300);
}
function openHelp_GroundLTL_CallBeforeDelivery() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_call_before_delivery.htm', 500, 300);
}
function openHelp_GroundLTL_SortingAndSegregatingPieces() {
    openHelpWindowWithSize('groundltl', '/help/groundltl_sorting_and_segregating_pieces.htm', 500, 300);
}
function openHelp_Truckload_Hazardous() {
    openHelpWindowWithSize('truckload', '/help/truckload_hazardous.htm', 500, 300);
}
function openHelp_OceanLCL_Hazardous() {
    openHelpWindowWithSize('oceanlcl', '/help/oceanlcl_hazardous.htm', 500, 300);
}
function openHelp_OceanFCL_Hazardous() {
    openHelpWindowWithSize('oceanfcl', '/help/oceanfcl_hazardous.htm', 500, 300);
}
function openHelp_Air_Pickup() {
    openHelpWindowWithSize('air', '/help/air_pickup.htm', 500, 300);
}
function openHelp_Air_Delivery() {
    openHelpWindowWithSize('air', '/help/air_delivery.htm', 500, 300);
}
function openHelp_Air_LiftGateService() {
    openHelpWindowWithSize('air', '/help/air_lift_gate_service.htm', 500, 300);
}
function openHelp_Air_DeliveryDutiesPaid() {
    openHelpWindowWithSize('air', '/help/air_delivery_duties_paid.htm', 500, 300);
}
function openHelp_Air_DeliveryDutiesUnpaid() {
    openHelpWindowWithSize('air', '/help/air_delivery_duties_unpaid.htm', 500, 300);
}
function barCode(barString) {
	var myCode = new Array();
	var grow = "";
	for (var i = 0; i != barString.length; i++) {
		var myChar = barString.charAt(i);
		if (myChar == "*")
		    myCode[i] = "bc_star.gif";
		else 
		    myCode[i] = "bc_" + myChar + ".gif";
	}

	for (var i=0; i != myCode.length; i++)
        grow = grow + '<img width="14" height="60" src="http://iconnection.tnt.com:81/Shipper/barcode/' + myCode[i] + '" />';

	return grow;
}
var focusclientid;
function fnSetFocus(txtClientId) {
    focusclientid=txtClientId;
    setTimeout("fnFocus()",100);
}
function fnFocus() {
    eval("document.getElementById('"+focusclientid+"').focus()");
}
var valueclientid;
var valueclientval;
function fnSetValue(txtClientId, clientVal) {
    valueclientid=txtClientId;
    valueclientval=clientVal;
    setTimeout("fnValue()",100);
    return false;
}
function fnValue() {
    eval("document.getElementById('"+valueclientid+"').value='" + valueclientval + "'");
}
function toggle(obj) {
    if (document.getElementById(obj).style.display == 'block')
        document.getElementById(obj).style.display = 'none'
    else
        document.getElementById(obj).style.display = 'block';
}
function convertToKg(obj1, obj2) {
    document.getElementById(obj2).value = '';
    if (!isNaN(parseFloat(document.getElementById(obj1).value))) {
        val = parseFloat(document.getElementById(obj1).value);
        document.getElementById(obj2).value = val * 0.4536;
    }
}
function convertToLb(obj1, obj2) {
    document.getElementById(obj2).value = '';
    if (!isNaN(parseFloat(document.getElementById(obj1).value))) {
        val = parseFloat(document.getElementById(obj1).value);
        document.getElementById(obj2).value = val * 2.2046;
    }
}