   var protocol = window.location.protocol;
   var hostname = window.location.hostname;
   var host = window.location.host;
   var port = window.location.port;
   var path = window.location.pathname;
   var filename = path.substring(path.lastIndexOf('/')+1);
   var filepath = path.substring(0,path.lastIndexOf('/')+1);
   var search = window.location.search;
   var url;
   var secureUrl; 
   var adminUrl;
   
       if(host == 'lenovo.bhivesoft.com' || host == 'secure.bhivesoft.com') {
         secureUrl="https://secure.bhivesoft.com"+filepath;
         url="http://lenovo.bhivesoft.com"+filepath;
         adminUrl="https://secure.bhivesoft.com";
       } else if(port == '8080' || port == '8443') {
         secureUrl="https://"+hostname+":8443"+filepath;
         url="http://"+hostname+":8080"+filepath;
         adminUrl="https://"+hostname+":8443";
       } else if(host == 'jeevan.mentorware.com' || host == 'jeevan') {
         secureUrl="http://jeevan.mentorware.com"+filepath;  
         url="http://jeevan.mentorware.com"+filepath;
         adminUrl="http://jeevan.mentorware.com";
       } else if(host == 'sit.mentorware.com' || host == 'sitsecure.mentorware.com') {
         secureUrl="https://sitsecure.mentorware.com"+filepath;  
         url="http://sit.mentorware.com"+filepath;
         adminUrl="https://sitsecure.mentorware.com";
       } else if(host == 'sitlocal.mentorware.com' || host == 'sitlocalsecure.mentorware.com') {
         secureUrl="https://sitlocalsecure.mentorware.com"+filepath;  
         url="http://sitlocal.mentorware.com"+filepath;
         adminUrl="https://sitlocalsecure.mentorware.com";         
       } else if(host == 'uat.mentorware.com' || host == 'uatsecure.mentorware.com') {
         secureUrl="https://uatsecure.mentorware.com"+filepath;  
         url="http://uat.mentorware.com"+filepath;
         adminUrl="https://uatsecure.mentorware.com"; 
       } else if(host == 'bhiveuat.mentorware.com' || host == 'bhiveuatsecure.mentorware.com') {
         secureUrl="https://bhiveuatsecure.mentorware.com"+filepath;  
         url="http://bhiveuat.mentorware.com"+filepath;
         adminUrl="https://bhiveuatsecure.mentorware.com";          
       } else if(host == 'lu.lenovo.com' || host == 'lenovoU.lenovo.com'|| host == 'university.lenovo.com'|| host == 'lts3.lenovo.com') {
        secureUrl="https://lts3.lenovo.com"+filepath;
        url="http://university.lenovo.com"+filepath;
        adminUrl="https://lts3.lenovo.com";
      } else {
         url="http://"+host+filepath; 
         secureUrl="http://"+host+filepath;
         adminUrl="http://"+host
      }
   
    if(protocol == 'http:') {
      if(filename == 'registration_confirm.jsp' || filename == 'profile.jsp' || filename == 'update_profile.jsp') {
        if(host == 'jeevan.mentorware.com' || host == 'jeevan') {
        } else {
          window.location.href=secureUrl+filename+search;
        }
      }
    }
   
   if(protocol == 'https:') {
     if(filename != 'registration_confirm.jsp' && filename != 'profile.jsp' && filename != 'update_profile.jsp') {
      window.location.href=url+filename+search;
     }
   }
   
   
function showKeynoteAbstract(classCode) {
  target="keynote_details.jsp?content_id="+classCode
  location.href = target;
}

function showAbstract(classCode) {
  target="infocast_comments.jsp?content_id="+classCode
  location.href = target;
}

function backtoLogin() {
 location.href ="index.jsp";
}
  
function launchContent(contentId) {
  target = "/bhive/main/content/launch?id=" + contentId  
  window.open(target, "launchContent", "width=850,height=550,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=no");
}  


  var agt = navigator.userAgent.toLowerCase();
  var is_major = parseInt(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_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") == -1) && !(agt.indexOf("msie 6") == -1));
  var is_ie4up = (is_ie && (is_major >= 4));
  var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);
  var is_mac = (agt.indexOf("mac") != -1);
  var is_gecko = (agt.indexOf("gecko") != -1);
  var c_status = new Array("x","x","x","x");
  
  function grabObject (id) {
    if (is_ie4) {
      var view = eval(id);
    }
    if (is_ie5up || is_gecko) {
      var view = document.getElementById(id);
    }
    return view;
  }


  function show_hide(id) {
    if(is_ie4up || is_gecko) {

      var hdn_div = grabObject('hdn'+id);
      var shdn_span = grabObject('shdn'+id);
      var xpand_img = grabObject('img'+id);
      if(hdn_div.style.display == 'block') {
        hdn_div.style.display = 'none';
        c_status[id] = "y";
      } else {
        hdn_div.style.display = 'block';
        c_status[id] = "n";
      }

    }
  }

  function open_div(number, default_status) {
    if (is_ie4up || is_gecko) {
      document.writeln("<div id='hdn" + number + "' name='hdn" + number + "' style='display: " + default_status + ";'>");
    }
  }


  function close_div(number, default_status) {
    if (is_ie4up || is_gecko) {
      document.writeln("</div>");
    }
  }

function rssFeedLink(url) {
  escapedUrl = url.replace(/%/g,"%25");
  window.open(escapedUrl, "rss","width=840,height=480,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
}

/* Star Rating functions */

var sMax; // Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet; // Is the PreSet value onces a selection has been made
var rated;

// Rollover for image Stars //
function rating(num){
  sMax = 0; // Isthe maximum number of stars
  for(n=0; n<num.parentNode.childNodes.length; n++){
    if(num.parentNode.childNodes[n].nodeName == "A"){
      sMax++; 
    }
  }
  
  if(!rated){
    s = num.id.replace("_", ''); // Get the selected star
    a = 0;
    for(i=1; i<=sMax; i++){   
      if(i<=s){
        document.getElementById("_"+i).className = "on";
        // document.getElementById("rateStatus").innerHTML = num.title;  
        holder = a+1;
        a++;
      }else{
        document.getElementById("_"+i).className = "";
      }
    }
  }
}

// For when you roll out of the the whole thing //
function off(me){
  if(!rated){
    if(!preSet){  
      for(i=1; i<=sMax; i++){   
        document.getElementById("_"+i).className = "";
       // document.getElementById("rateStatus").innerHTML = me.parentNode.title;
      }
    }else{
      rating(preSet);
     //  document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML;
    }
  }
}

// When you actually rate something //
function rateIt(me){
  if(!rated){
   // document.getElementById("rateStatus").innerHTML = document.getElementById("ratingSaved").innerHTML + " :: "+me.title;
    preSet = me;
    rated=1;
    sendRate(me);
    rating(me);
  }
}

// Send the rating information somewhere using Ajax or something like that.
function sendRate(sel){
  url = this.location.href;
  document.rate.rating.value = sel.title;
 // alert(url);
  //this.location.href = url;
  document.rate.action.value = url;
  document.rate.submit();
}

// Clears the Comment Default text
  function clearMe() {
    if(document.commentForm.feedback.value == "Enter comment here.") {
      document.commentForm.feedback.value = "";
    }
  }

 function postComment() {
 
 var comment = document.commentForm.feedback.value;
 
     if(comment == "Enter comment here." || comment.length <= 0) {
       alert("Please enter Your Comment here.");
       document.commentForm.feedback.focus();
    } else {
      document.commentForm.submit();
    }
 }
 
  function launchRatingPage(contentId){  
    target="rating.jsp?content_id=" + contentId
    var x = 300, y = 250; // default values
    if (document.all) {
      x = window.screenTop + 175;
      y = window.screenLeft + 160;
    }
    else if (document.layers) {
      x = window.screenX + 175;
      y = window.screenY + 160;
    }
    launchwindow = window.open(target,'launchRatingPage','width=320,height=350,top='+y+',screenY='+y+',left='+x+',screenX='+x);  
    launchwindow.window.focus();
  }
  

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function showMenu(id,e){
  e = (window.event) ? window.event : e ;
  elmnt = document.getElementById(id);
  emntHeight =elmnt.clientHeight;
  elmnt.style.display="block";
  elmnt.style.left=mouseX(e) + 10;
  elmnt.style.top=mouseY(e) - 20 ;
}
function hideMenu(fileId){
    document.getElementById(fileId).style.display="none";
}
function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}

function emailThisPage()
{
  var u = "http://shop.lenovo.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/seutil.workflow:ShowEmailPage?width=500&Email.PageUrl=";
  u += escape(document.location.href);
  window.open(u, "taf_win", "width=500,height=560,top=0,left=0,status,scrollbars,resizable");
}

  
  
  function SetCookie (name, value, expires) {
  // alert("SetCookie for "+ name +" "+ value +"  "+ expires);
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + value +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
  } 

        function getCookieVal (offset) {
          var endstr = document.cookie.indexOf (";", offset);
          if (endstr == -1)
          endstr = document.cookie.length;
          return unescape(document.cookie.substring(offset, endstr));
        }
  
        function GetCookie (name) {
          var arg = name + "=";
          var alen = arg.length;
          var clen = document.cookie.length;
          var i = 0;
          while (i < clen) {
           var j = i + alen;
           if (document.cookie.substring(i, j) == arg)
             return getCookieVal (j);
           i = document.cookie.indexOf(" ", i) + 1;
           if (i == 0)
            break; 
          }
          return null;
        }
  
        function Login_onsubmit() 
         {
         // alert("submit login form");
          var chk = false;
          var username = document.bpLogin.login.value;
          var userpassword = document.bpLogin.password.value;
          var expdate = new Date ();
          expdate.setTime (expdate.getTime() + (1000 * 60 * 60 * 24 * 90));
          if (document.bpLogin.rememberUser.checked)
           {
             chk = true;
             // alert("setting cookie "+username);
             SetCookie('bhiveLoginId',username,expdate);
             // SetCookie('bhivePassword',userpassword,expdate);
             SetCookie('chked','true',expdate);
            } else {
             SetCookie('bhiveLoginId','',expdate);
             // SetCookie('bhivePassword','',expdate);
             SetCookie('chked','false',expdate);
            }
             document.bpLogin.action=secureUrl+filename+search;
            document.bpLogin.submit();
         }

  function loadUsername()
  {
    var getuser=GetCookie("bhiveLoginId");
    var chked=GetCookie("chked");
    if(getuser)
    {
      document.bpLogin.login.value = getuser;
    }
    //alert(chked);
    if(chked == 'true')
    {
      document.bpLogin.rememberUser.checked= "true";    
    } else {
      document.bpLogin.rememberUser.checked= ""; 
    }
  }    
  
  function LeftTrim(String) {
    String = "" + String
    var Count = 0
    if(String.length == 0)
      return(String)
    for(Count = 0;Count < String.length;Count++) {
      if(!(String.charAt(Count) == " "))
        return(String.substring(Count,String.length))
    }
    return("")
  }

  function RightTrim(String) {
    String = "" + String
    var Count = 0
    if(String.length == 0)
      return(String)
    for(Count = String.length -1;Count >= 0;Count--)
    {
      if(!(String.charAt(Count) == " "))
        return(String.substring(0,Count + 1))
    }
    return("")
  }

  function AllTrim(String) {
    String = "" + String
    return(RightTrim(LeftTrim(String)))
  }

  function goto(fileName) {
   goto(fileName,'');
  }

  function goto(fileName,windowName) {
   if(fileName.indexOf('www.') == -1 &&  fileName.indexOf('http://') == -1 && fileName.indexOf('https://') == -1) {
     if(fileName.indexOf('registration_confirm.jsp') >= 0 || fileName.indexOf('profile.jsp') >= 0 || fileName.indexOf('update_profile.jsp') >= 0) {
       target = secureUrl + fileName;
     } else {
       target = url + fileName;
     }
     window.location.href=target;    
   } else {
      target = fileName;
      window.open(target,windowName,'');
   }
   
 }

  function validateKeyword(act) {
    var keyword=AllTrim(document.searchForm.keyword.value);
    document.searchForm.action = url + act + "?keyword="+keyword;
    if(keyword.length==0 || keyword =="")
    {
      document.searchForm.keyword.value="";
      document.searchForm.keyword.focus();
      return false;
    }
    else if(keyword =="Search Catalog" || keyword == "Search Infocast")
    {
      return false;
    }    
    else {
      document.searchForm.keyword.value= keyword;
      return true;
    }
  }
  function loadCourse(id)
      {   
        target ="course_launch_frame.jsp?id="+id;
        window.open(target,'launchWindow', 'height=650,toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes');
    }
    
  function changelanguage() {
    document.languageForm.submit();
  }
  function launchPCourse(id)
  { 
    var x = 300, y = 250; // default values
    if (document.all) {
      x = window.screenTop + 175;
      y = window.screenLeft + 160;
    }
    else if (document.layers) {
      x = window.screenX + 175;
      y = window.screenY + 160;
    }
    target ="launch_course.jsp?id="+id;
    window.open(target,'launchWindow', 'height=650,toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=yes');
    // window.open(target,'spam', 'height=290,width=400,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,top='+y+',screenY='+y+',left='+x+',screenX='+x);
  }