//Cross Sell random number generator
var aSeed = Math.random() + '';
var dblclk=aSeed * 1000000000000000000;

function when(anObject, anEvent, takeAction){
	if(anObject.attachEvent)
		anObject.attachEvent("on"+anEvent,takeAction);
	else if(anObject.addEventListener)
		anObject.addEventListener(anEvent,takeAction,true);
}
//POA nav method to allow for localized navigation if full path not provided
function envURL(theRelativePath){ 
    if (theRelativePath.indexOf('http://') != -1) return theRelativePath;
    return 'http://' + location.hostname + theRelativePath;
}

function createPoindexter(aParentEntity, tile, campaign, position, target){
    var thestring='';
    thestring+='<IFRAME width=\"140\" height=\"114\" scrolling=\"no\" frameborder=\"0\" src=\"http://http300.edge.ru4.com/smartserve/ad?placement='+tile+'&invocation=1000&page='+campaign+'&pos='+position+'&randomnumber='+dblclk+'&click=\">';
    thestring+='<SCRIPT src=\"http://http300.content.ru4.com/images/xp1_flash.js\"></SCRIPT>';
    thestring+='<SCRIPT src=\"http://http300.edge.ru4.com/smartserve/ad?placement='+tile+'&invocation=0&page='+campaign+'&pos='+position+'&randomnumber='+dblclk+'&click=\"></SCRIPT>';
    thestring+='<NOSCRIPT>';
    thestring+='<a href=\"http://http300.edge.ru4.com/smartserve/click?invoc=4000&placement='+tile+'&page='+campaign+'&pos='+position+'&randomnumber='+dblclk+'&rid='+dblclk+'&click=&target='+target+'\" target=\"_blank\">';
    thestring+='    <img width=\"140\" height=\"114\" src=\"http://http300.edge.ru4.com/smartserve/ad?placement='+tile+'&invocation=4000&page='+campaign+'&pos='+position+'&randomnumber='+dblclk+'&rid='+dblclk+'&click=\" alt=\"\" border=\"0\">';
    thestring+='</a>';
    thestring+='</NOSCRIPT>';
    thestring+='</IFRAME>';
    document.write(thestring);
}

function createPoindexterAlt(aParentEntity, tile){
    var thestring='';
    thestring+='<IFRAME width=\"140\" height=\"114\" scrolling=\"no\" frameborder=\"0\" src=\"http://http300.edge.ru4.com/smartserve/ad?placement='+tile+'&invocation=1000&click=\">';
    thestring+='<SCRIPT src=\"http://http300.content.ru4.com/images/xp1_flash.js\"></SCRIPT>"';
    thestring+='<SCRIPT src=\"http://http300.edge.ru4.com/smartserve/ad?placement='+tile+'&invocation=0&click=\"></SCRIPT>"';
    thestring+='<NOSCRIPT>';
    thestring+='<a href=\"http://http300.edge.ru4.com/smartserve/click?invoc=4000&placement='+tile+'&rid='+dblclk+'&click=&target=INSERT_DEFAULT_CLICKTHROUGH_URL\" target=\"_blank\">';
    thestring+='    <img width=\"140\" height=\"114\" src=\"http://http300.edge.ru4.com/smartserve/ad?placement='+tile+'&invocation=4000&rid='+dblclk+'&click=\" alt=\"\" border=\"0\">';
    thestring+='</a>';
    thestring+='</NOSCRIPT>';
    thestring+='</IFRAME>';
    document.write(thestring);
}

function LaunchDemo(theUrl, theHeight, theWidth, theScrollbar, theResize){
    var theVars='';
    
    if (theHeight!=''){theVars += "height=" + theHeight + ","}
    if (theWidth!=''){theVars += "width=" + theWidth + ","}
    if (theScrollbar!=''){theVars += "scrollbars=" + theScrollbar + ","}
    if (theResize=='1'){theVars += "resizable,"}
    theVars += "status=yes,toolbar=no,menubar=no,location=no";
    
    aHandle = window.open(theUrl, 'demo', theVars);
    return false;
}

//Used by global search to prevent postback when searching from another form
function noPostBack(sNewFormAction, functionToCallFirst){
  if ((typeof(functionToCallFirst)!='function') || functionToCallFirst()){
    document.forms[0].action = sNewFormAction;
    document.forms[0].method = 'get';
    document.forms[0]['__VIEWSTATE'].value = '';
    document.forms[0]['__VIEWSTATE'].name = 'NOVIEWSTATE';
    document.forms[0].submit();
  }
}

//Used by global search
function SWS(sw) {
    sw = sw.replace(/^[\s]+/,"");
    document.forms[0].q.value = sw;
    if(sw==""){
        alert("Please enter a word or phrase for the search query.")
        document.forms[0].q.focus();
        return false;
    }
    else {
        document.forms[0].submit();
        return true;
    }
}

//Flash Detection

var requiredVersion = 6;
var useRedirect = false;

// System globals
var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;    // boolean. true if flash 3 is installed
var flash4Installed = false;    // boolean. true if flash 4 is installed
var flash5Installed = false;    // boolean. true if flash 5 is installed
var flash6Installed = false;    // boolean. true if flash 6 is installed
var maxVersion = 6;             // highest version we can actually detect
var actualVersion = 0;          // version the user really has
var hasRightVersion = false;    // boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;            // the version of javascript supported


var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows

jsVersion = 1.1;

// JavaScript plugins array detection.
if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

function detectFlash() {  
  if (navigator.plugins) {
    if (navigator.plugins["Shockwave Flash 2.0"]
        || navigator.plugins["Shockwave Flash"]) {

      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;

      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
     
      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion >= 6;
    }
  }
  
  for (var i = 2; i <= maxVersion; i++) {  
    if (eval("flash" + i + "Installed") == true) actualVersion = i;
  }
  
  if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 3;  
  
  if (actualVersion >= requiredVersion) {
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace(flashPage);  
      } else {
        window.location = flashPage;
      }
    }
    
    hasRightVersion = true;                
  } else {  
    if (useRedirect) {
      if(jsVersion > 1.0) {
        window.location.replace((actualVersion >= 2) ? upgradePage : noFlashPage);
      } else {
        window.location = (actualVersion >= 2) ? upgradePage : noFlashPage;
      }
    }
  }
}
function JumpTo(thisguy)
{
    switch(thisguy){
      case 'redir1':
        document.interest.action='/corporateservices/bt/booking_plat/small/';
      break;
      case 'redir2':
        document.interest.action='/corporateservices/bt/booking_plat/medium/';
      break;
      case 'redir3':
        document.interest.action='/corporateservices/bt/booking_plat/large/';
      break;
      case 'redir4':
        document.interest.action='/corporateservices/ms/';
      break;

    }
  
  document.interest.submit();
}
detectFlash();  // call our detector now that it's safely loaded.

//For the Nav POA
function ChangeImage(ImgElement,ImgPath)
{
  if (ImgPath.toLowerCase() != "http://www10.americanexpress.com/images" && ImgPath != "" && ImgElement.src != ImgPath)
    ImgElement.src = ImgPath;
}

//Table striping, compliments ALA: http://www.alistapart.com/articles/zebratables
//page usage (after this file is included): <script>stripe('playlist', '#fff', '#edf3fe');</script>
  function hasClass(obj) {
    // this function is needed to work around 
    // a bug in IE related to element attributes
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {
    var even = false;
    // if arguments are provided to specify the colours of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#DFE9F5";
    var table = document.getElementById(id);
    if (! table) { return; }
    var tbodies = table.getElementsByTagName("tbody");
    for (var h = 0; h < tbodies.length; h++) {
      var trs = tbodies[h].getElementsByTagName("tr");
      for (var i = 0; i < trs.length; i++) {
        // avoid rows that have a class attribute or backgroundColor style
        if (! hasClass(trs[i]) && ! trs[i].style.backgroundColor) {
          var tds = trs[i].getElementsByTagName("td");
          for (var j = 0; j < tds.length; j++) {
            var mytd = tds[j];
            // avoid cells that have a class attribute or backgroundColor style
            if (! hasClass(mytd) && ! mytd.style.backgroundColor) {
              mytd.style.backgroundColor = even ? evenColor : oddColor;
            }
          }
        }
        //if a row only has TH, don't treat it as the first row
        if(tds && tds.length>0) {even =  ! even};
      }
    }
  }

//687x387
//553x186
function internalHeaderExpand(){ 
    var sbHead = document.getElementById('sbHeader');
	var startHeight=sbHead.height;
	for(i=startHeight; i < 387; i++) {
		sbHead.height = i;
	}    
}
function internalHeaderContract(){ 
    var sbHead = document.getElementById('sbHeader');
	var startHeight=sbHead.height;
	for(i=startHeight; i > 186; i--) {
		sbHead.height = i;
	}    
}