/* -- Broswer Sniff for Stylesheet Selection -- */
/* -- V4.0 -- */
/* -- Edited Last: EA May 12 2009 -- */

/* INCLUDES */
document.write('<link rel="stylesheet" type="text/css" href="/stylesheets/master.css">');
document.write('<script language="JavaScript1.2" src="/javascript/api.js" type="text/javascript"></script>');
document.write('<script language="JavaScript1.2" src="/javascript/ssdc.js" type="text/javascript"></script>');

/* GLOBAL VARIABLES */
var cssDir = "/stylesheets/";
var winNSCSS = "ns.css";
var winIECSS = "ie.css";
var macCSS = "mac_ns.css";
var corpCSS = "corp.css";

var agt=navigator.userAgent.toLowerCase();

var fileHead, styles, metaTags, att, cc, dir, lang, site;

/* BROWSER VERSIONS*/
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
            && (agt.indexOf('compatible')==-1) && (agt.indexOf('opera')==-1)
            && (agt.indexOf('webtv')==-1));
var is_nav4up = (is_nav && (is_major >= 4));
var is_nav6up = (is_nav && (is_major > 4));
var is_ie   = (agt.indexOf("msie")!=-1);
var is_ie3  = (is_ie && (is_major < 4));
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) );
var is_ie45 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4.5")!=-1));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
var is_ie4up = (document.all) ? true : false;
var is_ns4 = (document.layers)? true : false;
var is_dom = (document.getElementById && !document.all) ? true : false;

/* PLATFORMS */
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);

function ChooseSite() {

var url, urlTest, cookie, cookieTest, lnk;

lnk = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + cssDir + corpCSS + "\">";

        if(!is_ns4)
        {
                switch(site)
                {
                        case 'Corporate':
                                document.write(lnk);
                        break;
                }
        }else{
                url = /(\/corp\/|corp_home|\?Site=Corporate|corporate)/;
                urlTest = url.test(document.URL);
                cookie = /corp_home/;
                cookieTest = cookie.test(document.cookie);
                if (urlTest || cookieTest)
                {
                        document.write(lnk);
                }
        }
}

/* CSS SELECTION */
ChooseStyleSheet();
ChooseSite();
getCntry();
parseMeta();
setFont();

document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/stylesheets/print.css\" MEDIA=\"PRINT\">");

function ChooseStyleSheet()
{
  if (arguments.length > 0) {
    fileHead = cssDir + arguments[0];
  } else {
    fileHead = cssDir;
  }

 if (is_win) {
        if ((is_nav) && (is_nav6up)){
      styles = fileHead + winIECSS;
    } else if (is_nav){
      styles = fileHead + winNSCSS;
        } else {
          styles = fileHead + winIECSS;
        }
  }
  else if (((is_mac) && (is_nav)) && (!is_nav6up) )
  {
    styles = fileHead + macCSS;
  }
  else
  {
        styles = fileHead + winIECSS;
  }
        var link = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + styles + "\">";
        document.write(link);
}

function setFont()
{
        parseMeta();
        getCntry();
}

function getCntry()
{
        if (lang != "en")
        {
                switch(cc)
                {
                case 'JP':
                        ChooseStyleSheet("shift_jis/");
                break;
                case 'CN':
                        ChooseStyleSheet("GB2312/");
                break;
                case 'KR':
                        ChooseStyleSheet("euc-kr/");
                break;
                case 'TW':
                case 'HK':
                        ChooseStyleSheet("big5/");
                break;
                }
        }else{
                switch(cc)
                {
                case 'US':
                        ChooseStyleSheet(dir + "/");
                break;
                }
        }
}

function parseMeta()
{
        metaTags;
        if (is_ie4up)
        {
                metaTags=document.all.tags("meta");
        }
        else if (is_dom)
        {
                metaTags=document.getElementsByTagName("meta");
        }
        if (typeof(metaTags)!= "undefined")
        {
                for (var i=1;i<=metaTags.length;i++)
                {
                        att = metaTags.item(i-1);

                        switch(att.name)
                        {
                                case 'DCSext.pgf_Site':
                                        site = att.content;
                                        ChooseSite();
                                break;
                                case 'DCSext.pCC':
                                        cc = att.content;
                                        dir = cc.valueOf();
                                break;
                                case 'DCSext.pLL':
                                        lang = att.content;
                                break;
                        }
                }
        }
}

//Include Navigation Menu Script
document.writeln("<script language=\"JavaScript\" src=\"/javascript/left_nav_global.js\" type=\"text/javascript\"></script>\n");
//TFH - 03/10/05 - Function used to hard code the banners that should be displayed for a 
//particular section or page.  
function Banner(section){
switch(section)
                {
                case 'about':
                    showBanner(0,1,1);
					break;
		        case 'contact':
                    showBanner(0,19,19);
					break;
                case 'transportation':
                    showBanner(22,25,21); 
					break;
                case 'logistics':
					showBanner(5,6,5);
					break;
                case 'international':
                    showBanner(3,21,3);
					break;
				case 'consulting':
					showBanner(0,1,0);
					break;
                case 'tools':
					showBanner(22,26,26);
					break;
//Industry Solutions Special Cases				
				case 'solutions_index':
					showBanner(0,19,0);
					break;
				case 'caseStudies':
					showBanner(1,19,1);
					break;
				case 'whitePapers':
					showBanner(0,19,0);
					break;
				case 'automotive':
					showBanner(14,5,14);
					break;
				case 'consumer':
					showBanner(9,15,9);
					break;
				case 'healthcare':
					showBanner(24,24,24);
					break;
				case 'hightech':
					showBanner(6,17,6);
					break;
				case 'retail':
					showBanner(5,10,5);
					break;
				case 'cfoResearch':
					showBanner(1,19,1);
					break;
//Landing Pages Special Cases	(landing pages 1-7)
				case 'land_1':
					showBanner(5,7,5);
					break;
				case 'land_2':
					showBanner(5,12,5);
					break;
				case 'land_3':
					showBanner(7,9);
					break;
				case 'land_4':
					showBanner(8,7,8);
					break;
				case 'land_5':
					showBanner(16,19,16);
					break;
				case 'land_6':
					showBanner(6,17,6);
					break;
				case 'land_7':
					showBanner(0,1,0);
					break;
					
                }

}

//TFH - 03/10/05 - Function that randomly selects a banners and displays it on the page.
function showBanner(b1, b2, b3){
var theImages = new Array()
theImages[0] = '/img/bnrs/bnr_g_cas_stu.gif'	
theImages[1] = '/img/bnrs/bnr_g_whi_pap.gif'
theImages[2] = '/img/bnrs/bnr_g_spl_rep.gif'
theImages[3] = '/img/bnrs/bnr_g_td_streamline.gif'
theImages[4] = '/img/bnrs/bnr_g_cus_brok.gif'
theImages[5] = '/img/bnrs/bnr_g_dis_col.gif'
theImages[6] = '/img/bnrs/bnr_g_order_fulfillment.jpg'
theImages[7] = '/img/bnrs/bnr_g_air_fre.gif'
theImages[8] = '/img/bnrs/bnr_g_td_air.gif'
theImages[9] = '/img/bnrs/bnr_g_tdo.gif'
theImages[10] = '/img/bnrs/bnr_g_oce_fre.gif'
theImages[11] = '/img/bnrs/bnr_g_trans_fre.gif'
theImages[12] = '/img/bnrs/bnr_g_tdcb.gif'
theImages[13] = '/img/bnrs/bnr_g_net_man.gif'
theImages[14] = '/img/bnrs/bnr_g_honeywell.gif'
theImages[15] = '/img/bnrs/bnr_g_nikon.gif'
theImages[16] = '/img/bnrs/bnr_g_td_demo.gif'
theImages[17] = '/img/bnrs/bnr_g_toshiba.gif'
theImages[18] = '/img/bnrs/bnr_education.gif'
theImages[19] = '/img/bnrs/bnr_g_scs_glo_trd.gif'
theImages[20] = '/img/bnrs/SCS_g_freight_car.jpg'
theImages[21] = '/img/bnrs/bnr_g_incoterms.gif'
theImages[22] = '/img/bnrs/bnr_g_track_ship_ups1.jpg'
theImages[23] = '/img/bnrs/bnr_g_cvr_mr_QVw.gif'
theImages[24] = '/img/bnrs/bnr_g_healthCareCold08.gif'
theImages[25] = '/img/bnrs/bnr_g_fgvDemo_newCust.gif'
theImages[26] = '/img/bnrs/bnr_g_fgvDemo_v3.gif'


var theURLS = new Array()
theURLS[0] = '/solutions/casestudies.html'
theURLS[1] = '/solutions/whitepapers.html'
theURLS[2] = '/logistics/servicepartsreport.html'
theURLS[3] = '/transportation/tradedirect.html'
theURLS[4] = '/international/customs_broker.html'
theURLS[5] = '/logistics/distribution.html'
theURLS[6] = '/logistics/serviceparts.html'
theURLS[7] = '/transportation/air_freight.html'
theURLS[8] = '/transportation/tdair.html'
theURLS[9] = '/transportation/tdocean.html'
theURLS[10] = '/transportation/ocean_freight.html'
theURLS[11] = '/transportation/road.html'
theURLS[12] = '/transportation/tdcrossborder.html'
theURLS[13] = '/transportation/network.html'
theURLS[14] = '/solutions/case_studies/cs_honeywell.pdf'
theURLS[15] = '/solutions/case_studies/cs_nikon.pdf'
theURLS[16] = 'http://www.ups.com/tradedirect/en_us_demo.html'
theURLS[17] = 'http://pressroom.ups.com/staticfiles/audio_visual_files/106_av_lv.wmv'
theURLS[18] = '/international/education.html'
theURLS[19] = 'http://ups-scs.service.com/ups-scs/customer/tradenews/index.htm'
theURLS[20] = 'http://racing.ups.com/racing/no88_car/freight_car.html'
theURLS[21] = '/tools/incoterms.pdf'
theURLS[22] = 'http://www.ups.com/WebTracking/track?loc=en_US' 
theURLS[23] = 'http://www.ups.com/content/us/en/bussol/offering/technology/visibility/quantum_view/manage.html'
theURLS[24] = 'http://healthcare.ups.com/' 
theURLS[25] = 'http://www.ups.com/flexdemo/' 
theURLS[26] = 'http://www.ups.com/flexdemo/' 


var theALTS = new Array()
theALTS[0] = 'Case Studies'
theALTS[1] = 'White Papers'
theALTS[2] = 'Service Parts Report'
theALTS[3] = 'UPS Trade Direct'
theALTS[4] = 'Customs Brokerage'
theALTS[5] = 'Distribution'
theALTS[6] = 'Critical Parts Order Fulfillment'
theALTS[7] = 'Air Freight'
theALTS[8] = 'UPS Trade Direct Air'
theALTS[9] = 'UPS Trade Direct Ocean'
theALTS[10] = 'Ocean Freight'
theALTS[11] = 'Road Freight'
theALTS[12] = 'UPS Trade Direct Cross Border'
theALTS[13] = 'Network Management'
theALTS[14] = 'Honeywell Automotive - Case Study'
theALTS[15] = 'Nikon Consumer Goods - Case Study'
theALTS[16] = 'UPS Trade Direct Demo'
theALTS[17] = 'Toshiba Case Study'
theALTS[18] = 'Education'
theALTS[19] = 'UPS Trade Publications'
theALTS[20] = 'UPS Racing'
theALTS[21] = 'INCOTERMS'
theALTS[22] = 'Track your Freight Shipments'
theALTS[23] = 'View your Freight and Package Shipments'
theALTS[24] = 'Healthcare Logistics'
theALTS[25] = 'Flex Global View Demo'
theALTS[26] = 'Flex Global View Demo'

var myBanners = new Array()
	myBanners[0] = b1
	myBanners[1] = b2
	myBanners[2] = b3
	
	
var j = 0
var p = myBanners.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = myBanners[i]
}

var whichArrayElement = Math.round(Math.random()*(p-1));
var whichImage = myBanners[whichArrayElement]
//alert (whichImage);
//Check to see if item needs to open in a new window.....item # 17 is a WMV file and 16 in a demo...both need to open in a new window.
if (whichImage == 17 || whichImage == 16 || whichImage == 20 || whichImage == 22 || whichImage == 23 || whichImage == 24 || whichImage == 25 || whichImage == 26)
{
	document.write('<td align="left"><a href="' + theURLS[whichImage] + '" target="_blank"><img src="' + theImages[whichImage] + '" border="0" alt="' + theALTS[whichImage] + '"></a></td>');
}
else
{
	document.write('<td align="left"><a href="' + theURLS[whichImage] + '"><img src="' + theImages[whichImage] + '" border="0" alt="' + theALTS[whichImage] + '"></a></td>');
}

}

if (top.frames.length!=0)
{top.location=self.document.location;}
