// JavaScript Document

function HM_lang_Toggle() {
   var isFrench = false;
   var theurl = (location.href);
   var newUrl = "";
   langLoc = theurl.indexOf("/fr/")
   if (langLoc > -1)
     {
      newUrl = (theurl.replace("/fr/","/en/"));
      document.location.replace(newUrl); 
      window.location(newUrl); 
     }
   else 
     {
       var rootLoc = theurl.indexOf("index_f.php");
       if (rootLoc > -1)
         {
           //Check to see if you're in the root
 	    newUrl = (theurl.replace("index_f.php","index.php"));
	    document.location.replace(newUrl); 
	    window.location(newUrl);          
         
         }
       else
         {
            //Check to see if you're in the absolute root
            langLoc = theurl.indexOf("/en/");
	    if (langLoc > -1)
	     {
	       //already in english which means flip it to french
	       newUrl = (theurl.replace("/en/","/fr/"));
	       document.location.replace(newUrl); 
	       window.location(newUrl);
	     }           
            else
             {
               var rootLoc = theurl.indexOf("index.php");
	       if (rootLoc > -1)
                  {
		    newUrl = (theurl.replace("index.php","index_f.php"));
		    document.location.replace(newUrl); 
		    window.location(newUrl);               
                  }
               else
                 {
 	         newUrl = "http://www.hammondgolf.com/index_f.php";
	         document.location.replace(newUrl); 
	         window.location(newUrl);              
	         }
             
             }
            
            

	 }
     }
}
