var submenuList = new Array();

submenuList[0] = "imprints";
submenuList[1] = "newTitles";
submenuList[2] = "libNTeacher";
submenuList[3] = "purchasing";
submenuList[4] = "aboutUs";


var sub2menuList = new Array();

sub2menuList[0] = "printOrderForm";
sub2menuList[1] = "myProfile";


var menuItemArrayId = new Array();

menuItemArrayId[0] = "home";
menuItemArrayId[1] = "imprints";
menuItemArrayId[2] = "newTitles";
menuItemArrayId[3] = "libNTeacher";
menuItemArrayId[4] = "purchasing";
menuItemArrayId[5] = "aboutUs";


function closeSubmenu(){
   for(i=0; i< menuItemArrayId.length; i++)
      document.getElementById(menuItemArrayId[i] + "Img").style.backgroundImage = "url(" + ext_path +"images/" + menuItemArrayId[i] + "Hover.gif)";

   for(i=0; i< submenuList.length; i++){
         document.getElementById(submenuList[i]).className = "subMenuBoxHide";
   }

   //for(i=0; i< sub2menuList.length; i++){
   //         document.getElementById(sub2menuList[i]).className = "sub2MenuBoxHide";
   //}

   document.getElementById("search").className = "searchSubMenuBoxHide";
}

function chgMainMenuItemColor(mainMenuItem, movement, submenu){
   if(movement == "in"){
      for(i=0; i< submenuList.length; i++){
         document.getElementById(submenuList[i]).className = "subMenuBoxHide";
      }

      for(i=0; i< menuItemArrayId.length; i++)
         document.getElementById(menuItemArrayId[i] + "Img").style.backgroundImage = "url(" + ext_path +"images/" + menuItemArrayId[i] + ".gif)";

      document.getElementById("search").className = "searchSubMenuBoxHide";

      document.getElementById(submenu + "Img").style.backgroundImage = "url(" + ext_path +"images/" + submenu + "Hover.gif)";

      if(!(submenu == "home")){
         document.getElementById(submenu).className = "subMenuBoxShow";

         var tempLeft = (document.documentElement.clientWidth - 780) / 2;

         if(tempLeft < 15)
            tempLeft = 15;

         document.getElementById(submenu).style.left = tempLeft + "px";
      }
   }
   else{
      for(i=0; i< menuItemArrayId.length; i++)
         document.getElementById(menuItemArrayId[i] + "Img").style.backgroundImage = "url(" + ext_path +"images/" + menuItemArrayId[i] + "Hover.gif)";

//      if(!(submenu == "home"))
//         document.getElementById(submenu).className = "subMenuBoxHide";
   }
}

function chgSub2MenuBox(movement, submenu, a){
   if(movement == "in"){
      for(i=0; i< sub2menuList.length; i++){
         document.getElementById(sub2menuList[i]).className = "sub2MenuBoxHide";
         //document.getElementById(sub2menuList[i] + "A").style.color = "";
      }

      document.getElementById(submenu).className = "sub2MenuBoxShow";
      document.getElementById(a).style.color = "#f15922";
   }
   else{
      //document.getElementById(submenu).className = "sub2MenuBoxHide";
      document.getElementById(a).style.color = "";
   }
}

function goPage(url){
   window.location.href = url;
}


function viewCart()
{
   window.location.href = "/marshallcavendish-us/cart.xml?submitB=1";
}

function clearSearchBox(obj){
   if(obj.value == "Search"){
      obj.value = "";
   }
}

function chgSearchMenu(){
   for(i=0; i< submenuList.length; i++){
      document.getElementById(submenuList[i]).className = "subMenuBoxHide";
   }

   for(i=0; i< menuItemArrayId.length; i++)
      document.getElementById(menuItemArrayId[i] + "Img").style.backgroundImage = "url(" + ext_path +"images/" + menuItemArrayId[i] + "Hover.gif)";

   document.getElementById("search").className = "searchSubMenuBoxShow";
}

function processPath( newPath, dest )
   {
      var path = window.location.href;
      path = path.substring(path.indexOf("//") + 2);
      var domain = path.substring(0, path.indexOf("/"));
      if (domain.indexOf(":") != -1 )
      {
         domain = domain.substring(0, domain.indexOf(":"));
      }

      if( newPath.length == 0 )
      {
         if( dest.length == 0 )
         {
            path = path.substring( path.indexOf("/") + 1, path.lastIndexOf("/")) + "/login.xml";
         }
         else
         {
            path = path.substring( path.indexOf("/") + 1, path.lastIndexOf("/")) + "/" + dest;
         }
         path = "http://" + domain + "/" + path;
      }
      else
      {
         if( newPath.indexOf("http") != -1 )
         {
            newPath = newPath.substring(newPath.indexOf("//") + 2);
            newPath = newPath.substring(newPath.indexOf("/"));
         }

         path = "http://" + domain + newPath;
      }

      return path;
   }
