function deleteUmlaute(curText) {

 if (curText == "" || typeof(curText) != 'string' ) return "";
 var result = curText;

 result=result.replace(/ü/g, "ue");
 result=result.replace(/ö/g, "oe");
 result=result.replace(/ä/g, "ae");
 result=result.replace(/Ü/g, "Ue");
 result=result.replace(/Ö/g, "Oe");
 result=result.replace(/Ä/g, "Ae");
 result=result.replace(/ß/g, "ss");

 return result;

}

var first_run=true;

function videoivw(playerName, videoName, lineupID, referenceId) {
  p1 = '';
  p2 = '';
  p3 = '';
  p4 = '';

  // console.log("videoivw");

  if (first_run) {
    // console.log("exiting on first run");
    first_run=false;
    return;
  }
    
  /* if (document.images["ivwpx"] && (typeof _hbPageView == 'function')) { */
  if (document.images["ivwpx"]) {
    /*###### videodata ########################################*/
     p1 = deleteUmlaute(playerName.toString());
     p2 = deleteUmlaute(videoName.toString());
     if (lineupID) {
        p3 = deleteUmlaute(lineupID.toString());
     }
     if (referenceId) {
        p4 = deleteUmlaute(referenceId.toString());
     }

    /*###### parameter ########################################*/
    ivw_string = 'http://esundtri.ivwbox.de/cgi-bin/ivw/CP/1023280;80000,,Brightcove_'+ p1 +':'+ p2 +':'+ p3 +',?p='+ (Math.random()*100000);
    document.images["ivwpx"].src = ivw_string;
    //console.log("ivwstring: "+ivw_string);
    hbx_para_1 = "Brightcove_"+p1+":"+p2+"";
    hbx_para_Download = hbx_para_1+".flv";

    /*###### Videocenter ########################################*/
    if (playerName == 'Videocenter') {
      hbx_para_2 = "/videos/video-center/"+p3+"/"+p4;
      //1. IVW-Count
      //2. HBX-Count
      _hbPageView(hbx_para_1, hbx_para_2);
      // 3. HBX-Download
      _hbDownload(hbx_para_Download);
      //console.log("Videocenter:");
      //console.log("_hbPageView("+hbx_para_1+","+hbx_para_2+")");
      //console.log("_hbDownload("+hbx_para_Download+")");
  
      // 4. GA-Count
      pageTracker._trackPageview(hbx_para_2);
      //console.log("pageTracker._trackPageview("+hbx_para_2+")");
    } else {
    /*###### Rezeptvideo ########################################*/
      hbx_para_2 = "/rezept/"+p4+"/video";
      _hbDownload(hbx_para_Download);
      //pfad = '/videos/rezeptvideo/';
      // console.log("Videorezept:");
      //console.log("_hbDownload("+hbx_para_Download+")");

      // 4. GA-Count
      if (typeof pageTracker =='object') {
        // pageTracker._trackPageview("/video-dl/"+ escape(p2) + "/" +document.location.pathname+document.location.search);
        pageTracker._trackPageview("/video-dl/"+document.location.pathname+document.location.search);
      }

    }
    //console.log("Finish");
  }
}


