/*
  Programmer...: Michael Thomas - michael@michael-thomas.com
  Original Date: 05/11/08
  Changed Date.: 05/11/08
  
  History of Changes:
  
  
*/

/*
Set who the vendor is.  This drives the following:
  1) top banner if running from localhost or filesystem.
  2) the link that returns back to the Tutorial Home Page if running from localhost or filesystem.
*/

var strVendor = "Michael Thomas"
//var strVendor = "nTier"       

var blnTutorialHomePage_Offline_UseAlert = false; //true - shows a popup, false - goes to the online web site tutorial home page.


function fWriteLogo( strLogoFilesDirectory ) {

  var strHtmlLogo = "";

  var strLocationHost = location.host;
  var strWidth = "100%";
  var strHeight = "230";

  var strDisplayBannerFilename = ""; 
  //Options: 
  //  "logo_both.htm"
  //  "logo_ntier.htm"
  //  "logo_michael-thomas.htm"
  
  
  //*************************************
  //Start: Determine Banner to Display
  //*************************************
  
  if ( strLocationHost == "www.michael-thomas.com" ) {
	
    strDisplayBannerFilename = "logo_both.htm";
    //strDisplayBannerFilename = "logo_michael-thomas.htm";
    
  } else if ( strLocationHost == "www.ntiertraining.com" ) {

    strDisplayBannerFilename = "logo_ntier.htm" //nTier's logo only!
    
  } else {

    //Running from localhost or filesystem.
    if ( strVendor == "Michael Thomas" ) {
      strDisplayBannerFilename = "logo_both.htm"  //nTier & www.michael-thomas.com logo.
    } else if ( strVendor == "nTier" ) {
      strDisplayBannerFilename = "logo_ntier.htm" //nTier's logo only!
    } else {
      strDisplayBannerFilename = "logo_both.htm"  //nTier & www.michael-thomas.com logo.
    }
    
  }

  //*************************************
  //Stop: Determine Banner to Display
  //*************************************

  if ( strDisplayBannerFilename == "logo_both.htm" ) {

    strWidth = "100%";
    strHeight = "200";
	
    strHtmlLogo += '' + '\n' +
    '<iframe src="' + strLogoFilesDirectory + '/logo_both.htm" noResize=true scrolling=no width="' + strWidth + '" height="' + strHeight + '" align="center" valign="center" frameborder=0>' + '\n' +
    'Sponsored by: <a href="http://www.ntiertraining.com" target="_parent">NTier Training</a> and <a href="http://www.michael-thomas.com" target="_parent">Michael Thomas</a> ' + '\n' +
    '</iframe>' + '\n' +
    ''

  } else if ( strDisplayBannerFilename == "logo_michael-thomas.htm") {

    strWidth = "100%";
    strHeight = "150";

    strHtmlLogo += '' + '\n' +
    '<iframe src="' + strLogoFilesDirectory + '/logo_michael-thomas.htm" noResize=true scrolling=no width="' + strWidth + '" height="' + strHeight + '" align="center" valign="center" frameborder=0>' + '\n' +
    'Sponsored by: <a href="http://www.ntiertraining.com" target="_parent">NTier Training</a> and <a href="http://www.michael-thomas.com" target="_parent">Michael Thomas</a> ' + '\n' +
    '</iframe>' + '\n' +
    ''
  
  } else if ( strDisplayBannerFilename == "logo_ntier.htm" ) {

    strWidth = "100%";
    strHeight = "120";

    strHtmlLogo += '' + '\n' +
    '<iframe src="' + strLogoFilesDirectory + '/logo_ntier.htm" noResize=true scrolling=no width="' + strWidth + '" height="' + strHeight + '" align="center" valign="center" frameborder=0>' + '\n' +
    'Sponsored by: <a href="http://www.ntiertraining.com" target="_parent">NTier Training</a> and <a href="http://www.michael-thomas.com" target="_parent">Michael Thomas</a> ' + '\n' +
    '</iframe>' + '\n' +
    ''

  }

  document.write( strHtmlLogo );

}

function fGoToTutorialHomePage(strURL) {

  var strLocationHost = location.host;
  var strPopupAlertURL = "javascript:alert('This link is not available while you are working offline.')";
  
  //alert("Hello: " + strUrl + " - " + strLocationHost + " - " + ( strLocationHost == "" ) );
 
  if ( "|localhost|www.michael-thomas.com|www.ntiertraining.com|".indexOf("|" + strLocationHost + "|") > -1 ) {

    //Use the strURL value passed in!	

  } else {
 
    //Running on a local filesystem or a server that is not one of the valid servers.
    //FYI - Local filesystem is: strLocationHost == ""

    if ( strVendor == "Michael Thomas" ) {
      strURL = "http://www.michael-thomas.com/tech/"  //Tutorial home page at: www.michael-thomas.com
    } else if ( strVendor == "nTier" ) {
      strURL = "http://www.ntiertraining.com/resources.php" //Tutorial home page at: www.ntiertraining.com
    } else {
      strURL = strPopupAlertURL;
    }

  }	
	
  if ( blnTutorialHomePage_Offline_UseAlert ) {
    strURL = strPopupAlertURL;
  }
  
  location.href = strURL;
  
}