// objectReference must be a relative path: e.g "test.pdf" or "downloads/test.pdf".
// A path outside the current directory is NOT allowed: e.g. "../download/test.pdf".
function trackRelative(objectReference,objectTitle){
  path = getFolder() + objectReference;
  dcsMultiTrack('DCS.dcsuri',path,'WT.ti',objectTitle);
  if (DCS.dcsref) {
    DCS.dcsref = self.location.href.substring(0,self.location.href.indexOf(self.location.pathname)) + DCS.dcsuri;
  }
}

// objectReference must be an absolute path starting from the web root directory: e.g "/com/en/downloads/test.pdf".
// The path must begin with a slash: e.g. "/".
function trackAbsolute(objectReference,objectTitle){
  path = objectReference;
  dcsMultiTrack('DCS.dcsuri',path,'WT.ti',objectTitle);
  if (DCS.dcsref) {
    DCS.dcsref = self.location.href.substring(0,self.location.href.indexOf(self.location.pathname)) + DCS.dcsuri;
  }
}

// objectReference must be a URL to an external website that is not part of your website tracking: e.g "www.microsoft.com".
// The URL protocol, e.g. "http://", is NOT allowed as part of the reference.
function trackExternal(objectReference,objectTitle){
  path = "/external/" + objectReference;
  dcsMultiTrack('DCS.dcsuri',path,'WT.ti',objectTitle);
  if (DCS.dcsref) {
    DCS.dcsref = self.location.href.substring(0,self.location.href.indexOf(self.location.pathname)) + DCS.dcsuri;
  }
}

function trackClickevent(event, target) {
    var source = (location.pathname);
	var clickevent = /*VIPURL*/"/bmwgroup_prod/common/blank_frame.html";
	switch (event) {
	  case "personal_folder":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/dokumentanablage_gb06_save.shtml";
	    break;
	  case "personal_folder07":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/dokumentanablage_gb07_save.shtml";
	    break;	
	  case "personal_folder09":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/dokumentanablage_gb09_save.shtml";
	    break;		
	  case "crosslink_download":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/crosslink_download.shtml";
	    break;
	  case "crosslink":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/crosslink.shtml";
	    break;
	  case "general":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/general.shtml";
	    break;
	  case "contentlink_download":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/contentlink_download.shtml";
	    break;
	  case "contentlink":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/contentlink.shtml";
	    break;
	  case "contentlink_audio_video":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/contentlink_audio_video.shtml";
	    break;
	  case "contentlink_external":
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/tracking_redirect/clickevent/contentlink_external.shtml";
	    break;
	  default:
	    clickevent = /*VIPURL*/"/bmwgroup_prod/common/blank_frame.html";
	    break;
	}
    if(parent.hidden_frame) {
       parent.hidden_frame.location.href = clickevent + "?source=" + escape(source) + "&target=" + escape(target);
    }
    return true;
  }

// Returns the page path starting from the web root directory.
function getFolder(){
  return thisFolder = self.location.pathname.substring(0,self.location.pathname.lastIndexOf('/')+1);
}
