function CheckAndShowPage( os_page, browser_page, jvm_page ) {
   CheckAndAct("document.location='" + os_page + "'",
               "document.location='" + browser_page + "'",
               "document.location='" + jvm_page + "'",
               "" );
}

function CheckAndAct( os_cmd, browser_cmd, jvm_cmd, ok_cmd ) {

   var agt=navigator.userAgent.toLowerCase();
   var is_major = parseInt(navigator.appVersion);
   var is_minor = parseFloat(navigator.appVersion);

   var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
   var is_ie3    = (is_ie && (is_major < 4));
   var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );

   var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);

   var is_win = (agt.indexOf("win") != -1);

   if ( !is_win ) { eval(os_cmd); }
   else if ( !is_ie5up ) { eval(browser_cmd); }
   else if ( !navigator.javaEnabled() ) { eval(jvm_cmd); }
   else { eval(ok_cmd); }
}



//
// Returned value:
//     0: ok
//     1: Machintosh.
//     2: Java not enabled.
//     3: JavaScript not enabled.  --- impossible to test here.
//
function _checkBrowser() {
   if (navigator.platform) {
      if (navigator.platform.indexOf("Mac")!=-1)  {
         return 1;
      }
   }

   if (!navigator.javaEnabled()) {
      return 2;
   }
   return 0;
}

//
// Returned value: none.
//
//

function checkBrowser_1( brand, fail_url ) {
   if ( navigator.platform ) {
      if (navigator.platform.indexOf("Mac") != -1)  {
         alert("Sorry, " + brand + " does not support Macintosh computers " +
               "for cobrowsing.");
         if ( fail_url != "" ) {
            document.location = fail_url;
         }
         return 0;
      }
   }

   if (!navigator.javaEnabled()) {
      alert("Sorry, your browser does not have Java enabled, " +
            "please enable/install Java Virtual Machine for cobrowsing.");
      if ( fail_url != "" ) {
         alert( fail_url );
         document.location = fail_url;
      }
      return 0;
   }

   if ( navigator.userAgent.indexOf( "MSIE 4."  ) != -1 ) {
      var result =  alert("Sorry, your browser is not fully " +
                          "supported for cobrowsing. ("  + 
                          brand + " supports MS IE 5.0 " +
                          "and up.)\n" +
                          "You may not share pointer and form-filling.\n" +
                          "Do you want to continue?");
      if ( !result ) {
         if ( fail_url != "" ) {
            document.location = fail_url;
         }
      }
      return 0;
   }
   return 1;
}

//
// Returned value: none.
//
function checkBrowser() {
   var result = _checkBrowser();
   if ( result == 1 ) {
         alert("Sorry, PageShare does not support Macintosh for now!");
         document.location = "http://www.pageshare.com/";
   } else if ( result == 2 ) {
         alert("Sorry, Your browser does not support Java which is required" +
               "for PageShare!");
         document.location = "http://www.pageshare.com/";
   }
}
