/************************************************************************
  Source:   buildMenuMolpower.js
  Purpose:  Dropdown Menu for Molpower.com.
            This code calls the Milonic Menu.
            MOL America has purchased 3 licenses.
************************************************************************/

    ///////////////////////
    var g_script     = new Array();
    var g_abrvName   = '';
    var g_logoutHTML = '';
    var g_home_URL   = '';
    var g_LangPref0  = '';
    var g_LangPref   = '';
   // var g_MLS_Switch = '';
    var gGotFlash    = false;
    ///////////////////////   
        
    v_dir=GetCookie("JS_URL");    
    
     if (v_dir == null || v_dir.length==0){
        v_dir="http://www.molpower.com/Regusers";  
        
        if (location.href.indexOf("vlcd")!=-1) {
	    v_dir="http://vlcdev.molpower.com/vlcameudev";
        }
        if (location.href.indexOf("vlcqa")!=-1) {
	    v_dir="http://vlcqa.molpower.com/vlcameuqa";
        } 
        if (location.href.indexOf("vlcuat")!=-1) {
	    v_dir="http://vlcuat.molpower.com/vlcameuuat";
        }                         
    }
    
    //v_dir=v_dir.replace("http://","https://"); Change during special release 08-Nov-2008 (removed 15-Dec-2008)
    
    //Writes execMLS(); to the script for execution and sets g_MLS_Switch for further MLS processing
  //  document.write("<script language='JavaScript' src='"+v_dir+"/web_auth_pks.mls_switch'></script>");       
   
      
    if (navigator.plugins) {
      for (i=0;i<navigator.plugins.length;i++) {
           if (navigator.plugins[i].name.indexOf("Flash") >=0) {
               gGotFlash = true;
           }
      }
    }
    
    if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) {
        
        document.writeln('<script language="VBscript">');
        document.writeln('Function IEPluginDetect(pluginname)');
        document.writeln('  on error resume next');
        document.writeln('     IEPluginDetect = false');
        document.writeln('     IEPluginDetect = IsObject(CreateObject(pluginname))');
        document.writeln('     If (err) then');
        document.writeln('        IEPluginDetect = false');
        document.writeln('     End If');
        document.writeln('End Function');
        document.writeln('</script>');   
        
        document.write('<script language=javascript>gGotFlash='+ IEPluginDetect('ShockwaveFlash.ShockwaveFlash') + ';</script>');
    }    
            
    //executes PSP code to create menu arrays          
    document.write("<script language='JavaScript' src='"+v_dir+"/dropmenu_Molpower?pLangPref="+g_LangPref+"'></script>");      

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
	c_start=document.cookie.indexOf(c_name + "=")
	if (c_start!=-1)
	{
	c_start=c_start + c_name.length+1
	c_end=document.cookie.indexOf(";",c_start)
	if (c_end==-1) c_end=document.cookie.length
	return unescape(document.cookie.substring(c_start,c_end))
	}
	}
	return null
}

function setCookie(c_name,value,expiredays)
{
         var exdate=new Date()
         exdate.setDate(exdate.getDate() + expiredays);
      
         document.cookie=c_name+ "=" +escape(value) + ";path=/;domain=molpower.com; expires="+exdate;
      
	/**+
	((expiredays==null) ? "" : "; expires="+exdate)**/
}

function checkCookie()
{

	NoPopupBlocker=getCookie('NoPopupBlocker');
	if (NoPopupBlocker!=null)
	  return 1;
	else
	  {
	    return 0;
	  }
	  
}
 
 
function IsPopupBlocker() {
   if (checkCookie()) return;
   var strNewURL = "Dummy.htm"
   var Strfeature = "height=0,width=0,left=0,top=0";
   var popupWin = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
   if (popupWin) {
   try
   {   
      popupWin.close();
      setCookie('NoPopupBlocker','true',1);
   }
   catch(e)
   {
      v_htm="<table width='95%' style='color:#FF0000;border:solid 1px red;' align=center border=0 cellSpacing=2 cellPadding=2>" +         
            "  <tr>" +         
            "    <td><img src='/img/warning.gif'></td>"+
            "    <td valign='middle' style='font-weight:bold;font-size:14px;'>Warning:  Pop-up Blocker Detected!</td>"+
            "  </tr>"+
            "  <tr>"+
            "    <td></td>"+
            "    <td>Operation of MOLPower.com requires that your browser be allowed to display pop-up windows.</td>"+
            "  </tr>"+
            "  <tr>"+
            "    <td></td>"+
            "    <td>For more information about pop-up blockers, and how to get your browser to work properly with MOLPower.com, click <a href='/htm/InstructionPopup.htm'>here</a></td>"+
            "  </tr>"+          
            "</table>";
      document.write(v_htm);
    }
    }
    else {
      v_htm="<table width='95%' style='color:#FF0000;border:solid 1px red;' align=center border=0 cellSpacing=2 cellPadding=2>" +         
            "  <tr>" +         
            "    <td><img src='/img/warning.gif'></td>"+
            "    <td valign='middle' style='font-weight:bold;font-size:14px;'>Warning:  Pop-up Blocker Detected!</td>"+
            "  </tr>"+
            "  <tr>"+
            "    <td></td>"+
            "    <td>Operation of MOLPower.com requires that your browser be allowed to display pop-up windows.</td>"+
            "  </tr>"+
            "  <tr>"+
            "    <td></td>"+
            "    <td>For more information about pop-up blockers, and how to get your browser to work properly with MOLPower.com, click <a href='/htm/InstructionPopup.htm'>here</a></td>"+
            "  </tr>"+          
            "</table>";
      document.write(v_htm);
    }
   
}
function winClose(WindowOpen) {
	alert("winClose");
   try
   {
      var obj = WindowOpen.name;
      WindowOpen.close();
      setCookie('NoPopupBlocker','true',1);
   }
   catch(e)
   {
      v_htm="<table width='95%' style='color:#FF0000;border:solid 1px red;' align=center border=0 cellSpacing=2 cellPadding=2>" +         
            "  <tr>" +         
            "    <td><img src='/img/warning.gif'></td>"+
            "    <td valign='middle' style='font-weight:bold;font-size:14px;'>Warning:  Pop-up Blocker Detected!</td>"+
            "  </tr>"+
            "  <tr>"+
            "    <td></td>"+
            "    <td>Operation of MOLPower.com requires that your browser be allowed to display pop-up windows.</td>"+
            "  </tr>"+
            "  <tr>"+
            "    <td></td>"+
            "    <td>For more information about pop-up blockers, and how to get your browser to work properly with MOLPower.com, click <a href='/htm/InstructionPopup.htm'>here</a></td>"+
            "  </tr>"+          
            "</table>";
      document.write(v_htm);
    }
}

/*
      function execMLS()
      {
         g_MLS_Switch  = "ON"
         g_LangPref0   = GetCookie("NAVIGATOR_LANG_PREF0");
         g_LangPref    = GetCookie("NAVIGATOR_LANG_PREF");            
                  
         if(g_LangPref != null)
         {
         
         if(g_LangPref == "EN")
            {
                strPathNameBEGIN = location.pathname.toUpperCase();
                strPathNameEND   = location.pathname.toUpperCase();
              
                strPathNameEND = strPathNameEND.replace("/EN/", "/");
                strPathNameEND = strPathNameEND.replace("EN.HTM", ".HTM");
                strPathNameEND = strPathNameEND.replace("/CN/", "/");
                strPathNameEND = strPathNameEND.replace("CN.HTM", ".HTM");              
                strPathNameEND = strPathNameEND.replace("/FR/", "/");
                strPathNameEND = strPathNameEND.replace("FR.HTM", ".HTM");            
                strPathNameEND = strPathNameEND.replace("/JP/", "/");
                strPathNameEND = strPathNameEND.replace("JP.HTM", ".HTM");            
                strPathNameEND = strPathNameEND.replace("/SP/", "/");
                strPathNameEND = strPathNameEND.replace("SP.HTM", ".HTM");            
                           
                // document.write("TEST->"+strPathNameEND);
             
                //a replace occurred
                if (strPathNameBEGIN != strPathNameEND)
                {
                  location.replace(strPathNameEND);
                }
             }//end EN
         else                 
             {
         
         
         
            if(location.pathname.toLowerCase().indexOf("navihome_chngpwd")!=-1)
            {
                var strHome = "navihome_chngpwd";
                if(location.pathname.toLowerCase().indexOf("navihome_chngpwd_ptrn")!=-1)
                {
                  strHome = "navihome_chngpwd_ptrn"
                }
                if(location.pathname.toLowerCase().indexOf("navihome_chngpwd_ptst")!=-1)
                {
                  strHome = "navihome_chngpwd_ptst"
                }
                if(location.pathname.toLowerCase().indexOf("navihome_chngpwd_ameuqa")!=-1)
                {
                  strHome = "navihome_chngpwd_ameuqa"
                }
                if(location.pathname.toLowerCase().indexOf("navihome_chngpwd_proca")!=-1)
                {
                  strHome = "navihome_chngpwd_proca"
                }           
            }
            else
            {
                var strHome = "navihome";
            
                
            if(location.pathname.toLowerCase().indexOf("navihome_ptrn")!=-1)
            {
               strHome = "navihome_ptrn"
            }
            if(location.pathname.toLowerCase().indexOf("navihome_ptst")!=-1)
            {
               strHome = "navihome_ptst"
            }
            if(location.pathname.toLowerCase().indexOf("navihome_ameuqa")!=-1)
            {
               strHome = "navihome_ameuqa"
            }
            if(location.pathname.toLowerCase().indexOf("navihome_proca")!=-1)
            {
               strHome = "navihome_proca"
            }            
            
            }

          
              if (location.pathname.toLowerCase().indexOf("navihome") != -1 && 
                  location.pathname !="/htm/"+g_LangPref+"/"+strHome+g_LangPref+".htm")
              {         
                location.replace("/htm/"+g_LangPref+"/"+strHome+g_LangPref+".htm");              
              } 
            
            //is in htm directory but is not a navihome
            if (location.pathname.toLowerCase().indexOf("navihome") == -1 && location.pathname.toLowerCase().indexOf("htm") != -1)
            {
                        
              var strRedir="";
              
              if (location.pathname.toLowerCase().indexOf("/htm/jp/") != -1 && g_LangPref != "JP" && g_LangPref != "EN" && strRedir=="") {strRedir = location.pathname.toLowerCase().replace("/htm/jp/","/htm/"+g_LangPref+"/");}
              
              if (location.pathname.toLowerCase().indexOf("/htm/sp/") != -1 && g_LangPref != "SP" && g_LangPref != "EN" && strRedir=="") {strRedir = location.pathname.toLowerCase().replace("/htm/sp/","/htm/"+g_LangPref+"/");}
                
              if (location.pathname.toLowerCase().indexOf("/htm/cn/") != -1 && g_LangPref != "CN" && g_LangPref != "EN" && strRedir=="") {strRedir = location.pathname.toLowerCase().replace("/htm/cn/","/htm/"+g_LangPref+"/");}
              
              if (location.pathname.toLowerCase().indexOf("/htm/fr/") != -1 && g_LangPref != "FR" && g_LangPref != "EN" && strRedir=="") {strRedir = location.pathname.toLowerCase().replace("/htm/fr/","/htm/"+g_LangPref+"/");}
                         
              if (g_LangPref == "EN" && strRedir=="" &&
                  (location.pathname.toLowerCase().indexOf("/htm/jp/") != -1 ||
                   location.pathname.toLowerCase().indexOf("/htm/sp/") != -1 ||
                   location.pathname.toLowerCase().indexOf("/htm/cn/") != -1 ||
                   location.pathname.toLowerCase().indexOf("/htm/fr/") != -1 ))
             {
                  strRedir = location.pathname.toLowerCase().replace("/htm/","/htm/");
             }
             
             if (g_LangPref != "EN" && g_LangPref0 == "EN" && strRedir=="" &&
                  location.pathname.toLowerCase().indexOf("/htm/jp/") == -1 &&
                  location.pathname.toLowerCase().indexOf("/htm/sp/") == -1 &&
                  location.pathname.toLowerCase().indexOf("/htm/cn/") == -1 &&
                  location.pathname.toLowerCase().indexOf("/htm/fr/") == -1 )
             {
              strRedir = location.pathname.toLowerCase().replace("/htm/","/htm/"+g_LangPref+"/");
             }

              if(strRedir!="") {location.replace(strRedir);}
             }
            
           }//else EN
         }
        
       }//end execMLS()
   */

function writeHeader(parAlign,parAppName) {

  var v_html="";
  var strAlign=parAlign;
  var strFlashGlobe="";
  var strFlashShip="";
  
  
  if (strAlign=="") {
      strAlign="center";
  }
  
  if (gGotFlash) {
     if (navigator.appName=='Netscape') {
         strFlashGlobe="<embed width='490' height='70' src='/Img/rotatingglobe2.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>";
         strFlashShip ="<embed width='226' height='70' src='/Img/Ships2.swf' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>";
     }
     else {
         strFlashGlobe="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='490' height='70'>" +
                       "  <param name='movie' value='/Img/rotatingglobe2.swf'>" +
                       "  <param name='quality' value='high'>" +
                       "  <param name='wmode' value='transparent' >" +                       
                       "</object>";
         strFlashShip ="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='226' height='70'>" +
                       "  <param name='movie' value='/Img/Ships2.swf'>" +
                       "  <param name='quality' value='high'>" +
                       "  <param name='wmode' value='transparent' >" +                                              
                       "</object>";
     }
  }
  
  /*
    if(g_MLS_Switch == "ON" )
    {  
      var vMLS = "<select disabled=true id='cboMLS' class='fld' onChange='setCookie(\"NAVIGATOR_LANG_PREF0\",g_LangPref,1);setCookie(\"NAVIGATOR_LANG_PREF\",this.value,1);location.href=location.pathname;'>" +
                 "  <option value='EN'>English</option>" +  
             //  "  <option value='FR'>Français</option>" +              
             //  "  <option value='SP'>Español</option>" +
             //  "  <option value='JP'>日本語</option>" +               
             //  "  <option value='CN'>简体中文</option>" +
               "</select>";
    }
    else
    {  
      var vMLS = "";
    }    
      */         

  v_html="<table width='100%' height='99' cellpadding='0' cellspacing='0' border='0' background='/Img/hdrBack.gif'>" +
         "  <tr height='70'>" +
         "    <td valign='top' align='left'><img src='/Img/molLogo.gif' style='cursor:pointer' onclick='location.href=\""+g_home_URL+"\"'></td>" +
         "    <td valign='top' align='center'>" +      
                strFlashGlobe +
         "    </td>" +        
         "    <td valign='top' align='right' height='70' width='244'>" +
                strFlashShip +
         "    </td>" +
         "  </tr>" +         
         "  <tr height='29'>" +
         //"    <td colspan='3' align='right'>"+vMLS+"&nbsp;&nbsp;"+g_abrvName+g_logoutHTML+"&nbsp;&nbsp;</td>" +         
         "    <td colspan='3' align='right'>"+g_abrvName+g_logoutHTML+"&nbsp;&nbsp;</td>" +         
         "  </tr>" +         
         "</table>";

   document.write(v_html);
  /*
  if(g_MLS_Switch == "ON" )
    { 
        for(x=0;x<document.getElementById("cboMLS").length;x++)
        {
          if (document.getElementById("cboMLS")[x].value==g_LangPref)
          {
             document.getElementById("cboMLS")[x].selected=true;
          }
        }     
    }  
    */
   IsPopupBlocker(); 
   
 v_html="";
 if (typeof(parAppName) != 'undefined') {
  v_html+="<table bgcolor='#FFFFFF' width='95%' align=center border=0 cellSpacing=0 cellPadding=0>" +
         "  <tr>" +
         "   <td style='color:#284279;font-family:verdana,tahoma,arial,helvetica;font-size:12px;font-weight:bold;' height='25' valign='center' align='left'>"+parAppName+"</td>" +
         "  </tr>" +  
         "  <tr>" +
         "   <td height='1' bgcolor='#999999'></td>" +
         "  </tr>" +
         "</table>";         
 }         
    
  v_html+="<table bgcolor='#FFFFFF' width='95%' height=435 align=center border=0 cellSpacing=2 cellPadding=2>" +         
         "  <tr>" +         
         "<td class='txt' valign='top' align='" +strAlign + "' height='100%'>";
                 
   document.write(v_html);

} 

function writeFooter() {

  var v_html="";
  var d = new Date();
  

  v_html="    </td>" +
         "  </tr>" +
         "</table>" +
         "<table width='100%' height='25' border='0' class='ftrText' cellpadding='3' cellspacing='0'>" +
         "  <tr class='boxFtr' style='background-color:#528dd1;color:white;font-family:arial,verdana,tahoma,helvetica;font-size:11px;font-weight:bold;'>" +
         "    <td>&nbsp;&nbsp;&copy;&nbsp;" + d.getYear() + " MOL Inc.</td>" +
         "    <td align='right'>" +
         "      <span style='cursor:pointer' onclick='location.href=\"/VLCWeb/UIStatic/about/sitemap.aspx\"'>Sitemap</span>&nbsp;|" +
         "      <span style='cursor:pointer' onclick='location.href=\"/VLCWeb/UIStatic/about/termsofuse.aspx\"'>Terms of Use</span>&nbsp;|" +
         "      <span style='cursor:pointer' onclick='location.href=\"/VLCWeb/UIStatic/about/privacy.aspx\"'>Privacy Policy</span>&nbsp;" +
         "    </td>" +
         "  </tr>" +
         "</table>";     
                  
   document.write(v_html);
} 
    
function GetCookie(name) {
      var result = null;
      var siteCookie = " " + document.cookie + ";";
      var searchName = " " + name + "=";
      var startOfCookie = siteCookie.indexOf(searchName);
      var endOfCookie;
      if (startOfCookie != -1) {
         startOfCookie += searchName.length; //skip past cookie name
         endOfCookie = siteCookie.indexOf(";",startOfCookie);
         result = unescape(siteCookie.substring(startOfCookie,endOfCookie));
      }
      return result;
    }    
 

function writeScriptArray() {

   v_html=""
   for (x=0;x<g_script.length;x++) {
        v_html+=g_script[x];
   }
   eval(v_html);
   dumpmenus();
}