//  dw_event.js version date Apr 2008
//  basic event handling file from dyn-web.com

var dw_Event = {
  
    add: function(obj, etype, fp, cap) {
        cap = cap || false;
        if (obj.addEventListener) obj.addEventListener(etype, fp, cap);
        else if (obj.attachEvent) obj.attachEvent("on" + etype, fp);
    }, 

    remove: function(obj, etype, fp, cap) {
        cap = cap || false;
        if (obj.removeEventListener) obj.removeEventListener(etype, fp, cap);
        else if (obj.detachEvent) obj.detachEvent("on" + etype, fp);
    }, 
    
    DOMit: function(e) { 
        e = e? e: window.event; // e IS passed when using attachEvent though ...
        if (!e.target) e.target = e.srcElement;
        if (!e.preventDefault) e.preventDefault = function () { e.returnValue = false; return false; }
        if (!e.stopPropagation) e.stopPropagation = function () { e.cancelBubble = true; }
        return e;
    },
    
    getTarget: function(e) {
        e = dw_Event.DOMit(e); var tgt = e.target; 
        if (tgt.nodeType != 1) tgt = tgt.parentNode; // safari...
        return tgt;
    }
    
}

// Danny Goodman's version (DHTML def ref)
function addLoadEvent(func) {
    var oldQueue = window.onload? window.onload: function() {};
    window.onload = function() {
        oldQueue();
        func();
    }
}

// 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.asp");
       if (rootLoc > -1)
         {
           //Check to see if you're in the root
 	    newUrl = (theurl.replace("index.asp","../fr/index.asp"));
	    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.asp");
	       if (rootLoc > -1)
                  {
		    newUrl = (theurl.replace("index.asp","../fr/index.asp"));
		    document.location.replace(newUrl); 
		    window.location(newUrl);               
                  }
               else
                 {
 	         newUrl = "http://www.veloxpress.net/index.asp";
	         document.location.replace(newUrl); 
	         window.location(newUrl);              
	         }
             
             }
            
            

	 }
     }
}


