﻿/*
** Blätterkatalog Script
**
*/

var _jsdebug = true;



var searchFenster = ""; //Global

	/**
	*/
	function addToCart(artno, shopsessionid)
	{
	   var destinationURL = shopBase + shopURL + shopSessionIDParameterName + shopsessionid + shopArticleIDParameterName + artno + shopURLPostfix;
	   
	   if (shopDebug) alert("ShopSessionID: "+shopsessionid+"\nArtikel "+artno+" in Detailansicht Shop aufrufen\n\nSHOP URL: "+destinationURL);	
		
	   
	   if (!shopDebug) gotoURL(destinationURL);
		
	}



////////////////////////////////////////////////////////////////////////////////

   var nOfPages=0;
   var currentPageIndex=0;

   var currentPageIDLeft = 0;
   var currentPageIDRight = 0;

   var currentPageNumberLeft = "";
   var currentPageNumberRight = "";
   var currentView = "";
   
////////////////////////////////////////////////////////////////////////////////
   function setCurrentPage(pnrLeft,pidLeft,pnrRight,pidRight,curIndex,nPages) {

       nOfPages=nPages;
       currentPageIndex=curIndex;
   
       currentPageIDLeft=pidLeft;
       currentPageIDRight=pidRight;
       
       currentPageNumberLeft = pnrLeft;
       currentPageNumberRight = pnrRight;
       if (_jsdebug) updateDebugLabel();
   }
////////////////////////////////////////////////////////////////////////////////
   function setView(viewname) {
        currentView=viewname;
        if (_jsdebug) updateDebugLabel();
   }
////////////////////////////////////////////////////////////////////////////////
   function jumpTo(type,target) {
    switch (type) {
      default:
      case "id":
        flashCommand('jump_to_id', target);
        break;
      
      case "nr":
        flashCommand('jump_to_nr', target);
        break;
      
      case "index":
        flashCommand('jump_to_index', target);
        break;
    }
  }
////////////////////////////////////////////////////////////////////////////////
   function updateDebugLabel() {
   
    //document.getElementById("l1").className="unselected";
    //document.getElementById("l2").className="unselected";
    //document.getElementById("l3").className="unselected";

    //document.getElementById("viewlabel").innerHTML=currentView;
    
    switch (currentView) {
      default:
      case "catalog":
        //document.getElementById("l1").className="selected";
        break;
      
      case "detail":
        //document.getElementById("l2").className="selected";
        break;
      
      case "thumb":
        //document.getElementById("l3").className="selected";
        break;
    }
    //-------------------------

      var pageIndexRight=parseInt(currentPageIndex)+1;
      var tx1="";
      var tx2="";
       if (currentView=="catalog") {
        // Katalogansicht
        if (currentPageIndex==0) {
           // Wenn die erste Seite aufgeschlagen ist
           tx1="Nr: " + currentPageNumberRight + 
           "<br\>ID: "+currentPageIDRight;
           tx2="Index: " + currentPageIndex;
        } else if (currentPageIndex==nOfPages-1) {
           // Wenn die letzte Seite aufgeschlagen ist
           tx1="Nr: " + currentPageNumberLeft + 
           "<br\>ID: "+currentPageIDLeft;
           tx2="Index: " + pageIndexRight;
        } else {
         tx1="Nr: " + currentPageNumberLeft + " / " + currentPageNumberRight +
         "<br\>ID: "+currentPageIDLeft + " / " + currentPageIDRight;
         tx2="Index: " + currentPageIndex + " / " + pageIndexRight;
         }
       } else {
        // Jede andere Ansicht
         tx1="Nr: " + currentPageNumberLeft + 
         "<br\>ID: "+currentPageIDLeft;
         tx2="Index: " + currentPageIndex;
       }
       tx2+="<br/>Anzahl: " + nOfPages;
       //document.getElementById("pagelabel1").innerHTML=tx1;
       //document.getElementById("pagelabel2").innerHTML=tx2;
}
////////////////////////////////////////////////////////////////////////////////

	/**
	*  blättert auf die entsprechende seite um
	*  setzt voraus, dass der blätterkatalog in
	*  dem fenster noch geladen ist
	*/
	function blaetterkatalogflip(newPage)
	{
		 flashCommand('jump_to_id', newPage)                 
		 // jumpTo('id', newPage);
	}


        //Fehler vom BK-Flash?
        function gotourl( myURL )  	
          {
           gotoURL(myURL); 
          }

        function fnGetSign(TValue)
		  {
			var TSign= "?";    
			if (TValue.indexOf("?") >= 0) TSign = "&"; 
			return TSign; 
		  }
	/**
	* sprint zu einer URL
	* Ziel: Shop-Fenster
	*/ 
	function gotoURL( myURL ) 
	{
          //get page		  
          var progname = "index.html";
          var progpath = window.location.href; 
		  var progurl = progpath; 
		  var progsubcat = "x"; 
          var pageid = "1"; 
		  var progfolder = ""; 
          var win_parameter = "resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes"; 
	  	  var win_width = "300"; 
	  	  var win_height = "500";
	  	  var win_title = "_blank"; 
	  	  var win_url = ""; 
	  	  var bnDoPopup = false; 		  
	  	  var strEmail = "mailto:info@aaaedv.ch?subject=Blaetterkatalog";
	  	  var searchword = "";                  
                  var strSessId = shopSessionIDParameterName; 
                  var searchtyp = "1"; 
                  var progfunct = "1"; 
                  var bnDoFree = false;

         if (strSessId.indexOf("?") >= 0) strSessId = strSessId.replace("?", "&"); 
         var strSessOId = strSessId.substr(1, strSessId.length); 		 
		 
          //Pfad ausfindig machen: 
          var temp = progpath.toLowerCase(); 
          var temp2; 
          // Hat es Parameter ?xxx Zuerst entfernen
          if (temp.indexOf("?") > 1) {
            temp2  = temp.substr(temp.indexOf("?"));
            temp = temp.replace(temp2, ''); 
			progurl = temp; 
            }
          progurl = progurl.replace("#", ""); 
		  
          if (temp.lastIndexOf("/") > 1)
            {
             progname = temp.substr(temp.lastIndexOf("/")+1); 
            }                     
          
		  
		  progfolder = temp.replace(progname, '');
          temp = temp.replace('/blaetterkatalog/' + progname, '');
          //Untersuchen ob Subkatalog-Nr. vorhanden?
          temp2 = temp.substr(temp.length - 4, 1);
		  
          if (temp2.toLowerCase() == "x") {
			progsubcat = temp.substr(temp.length-3, 3); 
			//alert(progsubcat); 
            temp2 = temp.substr(0, (temp.length -4 )); 
            temp = temp2; 
           }   
          progpath = temp;                

          var destinationURL = shopBase + shopURL + shopSessionIDParameterName + shopsession  + shopURLPostfix
          
          //Spezielle Pfade für ePaper-Funktionen
          var Default_Path = 'blaetterkatalog/actions/showbox.htm';
          if (BK_TOP_URL == '')  BK_TOP_URL = Default_Path; 
          if (BK_BAG_URL == '')  BK_BAG_URL = Default_Path;
          if (BK_EX1_URL == '')  BK_EX1_URL = Default_Path; 
          if (BK_BKM_URL == '')  BK_BKM_URL = Default_Path;
          if (BK_ZU1_URL == '')  BK_ZU2_URL = Default_Path;
          if (BK_ZU2_URL == '')  BK_ZU2_URL = Default_Path;
          if (BK_DET_BKM_URL == '')  BK_DET_BKM_URL = Default_Path;
          if (BK_DET_PR2_URL == '')  BK_DET_PR2_URL = Default_Path;
          if (BK_DET_SA2_URL == '')  BK_DET_SA2_URL = Default_Path;
          if (BK_DET_ART_URL == '')  BK_DET_ART_URL = Default_Path;
          if (BK_DET_SMA_URL == '')  BK_DET_SMA_URL = Default_Path;
          if (BK_DET_RE1_URL == '')  BK_DET_RE1_URL = Default_Path;        
          if (BK_DET_RE2_URL == '')  BK_DET_RE2_URL = Default_Path;   
          
          var ExtParameter = ""; 
          if (shopUserID == ' ') shopUserID = ''; 
          if (shopKey1ID == ' ') shopKey1ID = '';
          if (shopPar1ID == ' ') shopPar1ID = ''; 
          if (shopTempID == ' ') shopTempID = ''; 
          if (shopUserID != '')  ExtParameter += "&userid=" + shopUserID;
          if (shopKey1ID != '')  ExtParameter += "&key1id=" + shopKey1ID;
          if (shopPar1ID != '')  ExtParameter += "&par1id=" + shopPar1ID;
          if (shopTempID != '')  ExtParameter += "&tempid=" + shopTempID;         

          var sZusatz = ""; 
          if (shopSessionIDParameterName != '?SessionId=')
            {
              sZusatz = "&SessionId=" + shopsession;
              ExtParameter += sZusatz;
            }
          
          var TopURL1 = BK_TOP_URL + fnGetSign(BK_TOP_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var ExtUrl1 = BK_EX1_URL + fnGetSign(BK_EX1_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var BAGUrl1 = BK_BAG_URL + fnGetSign(BK_BAG_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var BKMUrl1 = BK_BKM_URL + fnGetSign(BK_BKM_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var ZU1Url1 = BK_ZU1_URL + fnGetSign(BK_ZU1_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var ZU2Url1 = BK_ZU2_URL + fnGetSign(BK_ZU2_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var DetUrl3 = BK_DET_BKM_URL + fnGetSign(BK_DET_BKM_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var DetUrl5 = BK_DET_PR2_URL + fnGetSign(BK_DET_PR2_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var DetUrl6 = BK_DET_SA2_URL + fnGetSign(BK_DET_SA2_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var DetUrl7 = BK_DET_ART_URL + fnGetSign(BK_DET_ART_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var DetUrl8 = BK_DET_SMA_URL + fnGetSign(BK_DET_SMA_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var DetUrl9 = BK_DET_RE1_URL + fnGetSign(BK_DET_RE1_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
          var DetUrl0 = BK_DET_RE2_URL + fnGetSign(BK_DET_RE2_URL) +  strSessOId + shopsession  + shopURLPostfix + ExtParameter;
            
          var showTyp = "1"; 
          var AccTyp =  -1; 
		  
          try { shopAccess = BKShowAccess; }
          catch (Exception) { shopAccess = '2';}	                      
          if (shopAccess == "1") bnDoFree = true; 

          var eFahaPara = ""; 
          try { eFahaPara = eFahaParameter; }
          catch (Exception) { eFahaPara = '';}	 

          var strURL = myURL;
          if (strURL.indexOf("&strArtikelNr=") > 1) showTyp = "2"; 
          if (strURL.indexOf("&image=true") > 1) showTyp = "3"; 
          if (strURL.indexOf("&color=") > 1) showTyp = "4";
          if (strURL.indexOf("&subcat=") > 1) showTyp = "5"; 
          if (myURL == "HOME") showTyp = "5"; 
          if (myURL == "SEARCH") showTyp = "6";
          if (myURL == "BAG") showTyp = "7";
          if (myURL == "ARCHIV") showTyp = "8";
          if (myURL == "BOOKMARK") showTyp = "9";
          if (myURL == "SEARCHWEO") showTyp = "10";
          if (myURL == "BAGWEO") showTyp = "11";
          if (myURL.indexOf("OOKMARK=") > 0) showTyp = "12"; 
          if (myURL.indexOf("O_BOOKVERW=") > 0) showTyp = "9";
          if (myURL.indexOf("O_MAIL=") > 0) showTyp = "13"; 
          if (myURL.indexOf("O_SEND=") > 0) showTyp = "14";
          if (myURL.indexOf("O_PRINT=") > 0) showTyp = "15";
          if (myURL.indexOf("O_SAVE=") > 0) showTyp = "16";
	  if (myURL.indexOf("O_LIST=") > 0) showTyp = "17";
          if (myURL == "ZUSATZ1") showTyp = "18";
	  if (myURL == "ZUSATZ2") showTyp = "19";
	  if (myURL == "CART") showTyp = "20";	
	  if (myURL == "OFFERT") showTyp = "21";	
	  if (myURL == "BESTELL") showTyp = "22";
          if (myURL.indexOf("O_RESERVE1=") > 0)  showTyp = "23";
	  if (myURL.indexOf("O_RESERVE2=") > 0)  showTyp = "24";
	  if (myURL == "SWK") showTyp = "25";	
          if (myURL.indexOf("O_QUICK=") > 0) showTyp = "26";
          if (myURL.indexOf("_POPUP_") > 0) showTyp = "27";
          if (myURL.indexOf("O_CHAPTER=") > 0) showTyp = "28";
          if (myURL.indexOf("O_QUICKARTICLE=") > 0) showTyp = "29";
          if (myURL == "SEARCHFAHA") showTyp = "30";
	  if (myURL.indexOf("O_QUICKFAHA=") > 0) showTyp = "31";
          if (myURL.indexOf("O_MAILFAHA=") > 0) showTyp = "32";
          if (myURL.indexOf("O_FUNCTION_") > 0) showTyp = "33";
          if (myURL.indexOf("O_QUICKWORD=") > 0) showTyp = "34";
          if (myURL.indexOf("O_DOWNLOAD=") > 0) showTyp = "35";
          if (myURL.indexOf("O_JUMP=") > 0) showTyp = "36";
          if (myURL.indexOf("O_REDIRECT=") > 0) showTyp = "37";
          if (myURL.indexOf("_POPUPPROZ_") > 0) showTyp = "38";
		  
	  if (showTyp == 13 || showTyp == 14)
	    {			  			  
	      if (ProgLang == "D") strEmail = BKMail_D; 
              if (ProgLang == "F") strEmail = BKMail_F;
              if (ProgLang == "I") strEmail = BKMail_I;
              if (ProgLang == "E") strEmail = BKMail_E;			  
              if (ProgLang == "S") strEmail = BKMail_S;		
	      strEmail = strEmail.replace('[URL]', progurl);
	      strEmail = strEmail.replace('[URL]', progurl);              
	    }
           
          //alert("Typ= " + showTyp + "\n\nURL= " + strURL + "\n\nLang=" + lang + "\n\nProgName= " + progname + "\n\nSubcat = " + progsubcat + "\n\nPath = " + progpath + "\n\nFolder = " + progfolder + "\n\n\myURL = " + myURL); 
          
          if (showTyp == "1")
            { 
             var shopFenster = window.open(myURL);
             shopFenster.focus(); 
             return;
            }

          if (showTyp == "2")
            { 			   
              win_width = XPopWH[49];   //"580"; 
              win_height = XPopWH[50];   //"400"; 
	      win_title = "_Cart"; 	     
              win_url = myURL; 
              
              var WOpener = false; 
              try
                {
                  WOpener = BKOpener; 
                 }
              catch( Exception )
                 {WOpener = false; }
              
              //alert(WOpener);  
              if (WOpener)
                {
                  try
	    	    {
                     if (window.opener.closed == true)
                       {
                        bnDoPopup = true;
                        //alert("OPENER.CLOSED"); 
                       }
                  else
                       {
                        //alert("ES KLAPPT"); 
                        window.opener.location.href =win_url;

                        window.opener.focus();
                        return true; 
                       }
	            }
	         catch( Exception )
                   {    
                    //alert("CATCH ERROR");       
                    bnDoPopup = true; 
	           }
                }

	      bnDoPopup = true; 
              AccTyp =  36;		  			   
             }

          if (showTyp == "3")
            { 
     	     win_width = XPopWH[52];   // "480"; 
	     win_height = XPopWH[53];   // "200"; 
	     win_title = "_Picture"; 
	     win_url = myURL; 
	     bnDoPopup = true; 	
             AccTyp =  37;		  
            }
          
          if (showTyp == "4")
            { 
     	     win_width = XPopWH[55];   // "300"; 
	     win_height = XPopWH[56];   // "300"; 
	     win_title = "_Color"; 
	     win_url = myURL; 
	     bnDoPopup = true;	
             AccTyp =  37;		
            }

 
          if (showTyp == "5")
            {
	     bnDoFree = false;		 
             var myNewURL = "";
             var myNewParameter = ""; 
             var myNewSubCat = "000";  


             if (myURL.indexOf("&") > 1) {
                myNewParameter  = "?" + myURL.substr(myURL.indexOf("&")+1);
             }
             else { 
               myNewParameter = "?startpage=" + epaperStartPage + "&pcode=1_1_1_0&subcat=000";  // Standard
               if (myURL == "HOME") myNewParameter = "?startpage=" + epaperStartPage  + "&subcat=000";
               }

             if (myNewParameter.indexOf("&subcat=") > 1) {
                myNewSubCat = myNewParameter.substr(myNewParameter.indexOf("&subcat=") +8, 3); 
               } 
             
             if (myNewSubCat == '000') {
               myNewSubCat = "";    // Nichts zum AnhÃ¤ngen 
              }
             else {
               myNewSubCat = "x" + myNewSubCat; 
              }  
             //alert("PROBLEM? " + myURL + "\n\n - " + myNewParameter + " - " + myNewSubCat);
                    
             myNewURL = progpath + myNewSubCat + "/blaetterkatalog/" + progname + myNewParameter; 
             //alert(myNewURL); 
             myNewURL = myNewURL + ExtParameter; 
             document.location.href = myNewURL
            }	  


          if (showTyp == "34")
            { 
              searchword = myURL.replace('DO_QUICKWORD=', '') 
              searchword = escape(searchword); 
              showTyp = "6";
              searchtyp = "1"
	      AccTyp =  4;
            }

          if (showTyp == "29")
            { 
              searchword = myURL.replace('DO_QUICKARTICLE=', '') 
              searchword = escape(searchword); 
              showTyp = "6";
              searchtyp = "3"
			  AccTyp =  4;
            }

          if (showTyp == "26")
            { 
              searchword = myURL.replace('DO_QUICK=', '') 
              searchword = escape(searchword); 
              showTyp = "6";
              searchtyp = "4"
			  AccTyp =  4;
            }          

          if (showTyp == "6")
            { 
    	     win_width = XPopWH[34];   // "1500"; 
	     win_height = XPopWH[35];   // "800"; 
	     win_title = "_Search"; 
             win_url = epaperSearch; 
             AccTyp =  4;
             if (searchword != "")
               {
                if (win_url.indexOf("?") > 1)
                  {
                   win_url = win_url + "&txtSearch=" + searchword + "&typSearch=" + searchtyp;
                  }
                else
                  {
                   win_url = win_url + "?txtSearch=" + searchword + "&typSearch=" + searchtyp;
                  }
                }
              temp = shopSessionIDParameterName; 
              if (win_url.indexOf("?") > 1)
                {temp = strSessId;}
              else
                {if (temp.indexOf("?") < 0) {temp = "?dummyz=Y" +  temp;}}
              win_url = win_url + temp + shopsession;  
              win_url = win_url + ExtParameter + "&dialog=" +  ProgLang +  eFahaPara;              
	      win_parameter = win_parameter + ",width=" + win_width + ",height=" + win_height;				  
     		   		  
              try 
                {
                 if (searchFenster.closed)
                   {                    
                    searchFenster = WinPopup(win_url, win_title, win_parameter);	
                    searchFenster.focus(); 
                    return;
                   }
                 else
                   {   
                    if (searchword != '')
                      {
                       searchFenster = WinPopup(win_url, win_title, win_parameter);	
                       searchFenster.focus(); 
                       return;
                      }               
                    else
                      {
                       searchFenster.focus(); 
                       return;
                      } 
                   } 
                }
             catch ( Exception )
		       {                 
                 searchFenster = WinPopup(win_url, win_title, win_parameter);	
                 searchFenster.focus(); 
                 return;
                }
            }

          if (showTyp == "31")
            { 
              searchword = myURL.replace('DO_QUICKFAHA=', '') 
              searchword = escape(searchword); 
              showTyp = "30";
              searchtyp = "4"
			  AccTyp =  25;
            } 

          if (showTyp == "30")
            { 
    	      win_width = XPopWH[34];   // "1500"; 
	          win_height = XPopWH[35];   // "800"; 
	          win_title = "_Search"; 
	          win_url = eFahaSearch; 
              AccTyp =  25;
              if (searchword != "")
               {
                if (win_url.indexOf("?") > 1)
                  {
                   win_url = win_url + "&txtSearch=" + searchword + "&typSearch=" + searchtyp;
                  }
                else
                  {
                   win_url = win_url + "?txtSearch=" + searchword + "&typSearch=" + searchtyp;
                  }
                }             

              temp = shopSessionIDParameterName; 
              if (win_url.indexOf("?") > 1)
                {temp = strSessId;}
              else
                {if (temp.indexOf("?") < 0) {temp = "?dummyz=Y" + temp;}}
              win_url = win_url + temp + shopsession; 
		  win_url = win_url + "&fahapbid=" + eFahaPBID  + "&fahatyp=" + eFahaTyp + "&dialog=" + ProgLang +  "&fahaurl=" + eFahaURL + sZusatz;
	          win_parameter = win_parameter + ",width=" + win_width + ",height=" + win_height;				  
     		   		  
              try 
                {
                 if (searchFenster.closed)
                   {                    
                    searchFenster = WinPopup(win_url, win_title, win_parameter);	
                    searchFenster.focus(); 
                    return;
                   }
                 else
                   { 
                    if (searchword != '')
                      {
                       searchFenster = WinPopup(win_url, win_title, win_parameter);	
                       searchFenster.focus(); 
                       return;
                      }               
                    else
                      {
                       searchFenster.focus(); 
                       return;
                      }                 
                   } 
                }
             catch ( Exception )
		       {                 
                 searchFenster = WinPopup(win_url, win_title, win_parameter);	
                 searchFenster.focus(); 
                 return;
                }
            }


          if (showTyp == "7")
            { 
              //destinationURL = destinationURL + "&task=bag";
              destinationURL = BAGUrl1 + "&task=bag"
              win_width = XPopWH[22];    //"800"; 
              win_height = XPopWH[23];   //"700"; 	
	      win_title = "_Bag"; 
	      win_url = destinationURL; 
	      bnDoPopup = true; 			                 
    		  AccTyp =  27;
           }

          if (showTyp == "8")
            {
	      //destinationURL = destinationURL + "&task=archiv";
              destinationURL = ExtUrl1+ "&task=archiv";
              win_width = XPopWH[37];   // "800"; 
	      win_height = XPopWH[38];   // "700"; 
	      win_title = "_Archiv"; 
	      win_url = destinationURL;  
	      bnDoPopup = true;	  
		  AccTyp =  21;
           }

          if (showTyp == "9")
            { 
              //destinationURL = destinationURL + "&task=bookmark&sub_cat=" + progsubcat;
              destinationURL = BKMUrl1 + "&task=bookmark&sub_cat=" + progsubcat;
              if (myURL.indexOf("OOKVERW=") > 0)
               {
                pageid = myURL.replace('DO_BOOKVERW=', '');
                destinationURL += "&pageid="  + pageid;
               }
              destinationURL += "&dialog=" +  ProgLang +  eFahaPara; 
              win_width = XPopWH[1];   // "800"; 
	      win_height = XPopWH[2];   // "700"; 
	      win_title = "_Bookmark"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;	 
		  AccTyp =  22;
            }

          if (showTyp == "10")
            { 
              destinationURL = destinationURL + "&task=search";
              win_width = XPopWH[31];   // "800"; 
	      win_height = XPopWH[32];   // "700"; 
	      win_title = "_WEOSEARCH"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;	
		  AccTyp =  3;
           }

          if (showTyp == "11")
            { 
              destinationURL = destinationURL + "&task=bag";   
    	      win_width = XPopWH[22];   // "800"; 
	      win_height = XPopWH[23];   // "700"; 
	      win_title = "_Bag"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;
		  AccTyp =  27;
            }

          if (showTyp == "12")
            { 
              //Bsp/Book:  destinationURL = destinationURL + "&task=bookmark";
              pageid = myURL.replace('BOOKMARK=', '')        
              //destinationURL = destinationURL + "&task=addbookmark&sub_cat=" + progsubcat + "&page_nr=" + pageid;
              destinationURL =  DetUrl3 + "&task=addbookmark&sub_cat=" + progsubcat + "&page_nr=" + pageid;
              destinationURL += "&dialog=" +  ProgLang +  eFahaPara; 
    	      win_width = XPopWH[25];   // "800"; 
	      win_height = XPopWH[26];   // "700"; 
	      win_title = "_AddBookmark"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;		
		  AccTyp =  13;
            }

          if (showTyp == "13")
            { 
             AccTyp =  14;
             pageid = myURL.replace('DO_MAIL=', '') 
             destinationURL = destinationURL + "&task=mail&page_nr=" + pageid;             			 
	     strEmail = strEmail.replace('[PAGE]', pageid );
             strEmail = strEmail.replace('[PAGE]', pageid );	
	     if (shopPar1ID != '' && shopPar1ID.indexOf("@") != -1)
               {
                if (strEmail.lastIndexOf("?") > 1)
                  {
                   temp = "mailto:" + shopPar1ID + "?" + strEmail.substr(strEmail.lastIndexOf("?")+1); 
                   strEmail = temp; 
                  }
               }	 
             window.location.href = strEmail;             //"mailto:info@aaaedv.ch"; 
             return;                
           }

          if (showTyp == "32")
            {
             AccTyp =  25;            				
             pageid = myURL.replace('DO_MAILFAHA=', '') 
             destinationURL = destinationURL + "&task=mail&page_nr=" + pageid;             			 
	     eFahaEmail = eFahaEmail.replace('[PAGE]', pageid );
             eFahaEmail = eFahaEmail.replace('[PAGE]', pageid );	
             eFahaEmail = eFahaEmail.replace('[URL]', progurl);     		 
             window.location.href = eFahaEmail;             //"mailto:info@aaaedv.ch"; 
             return;
            }

          if (showTyp == "14")
            { 
              pageid = myURL.replace('DO_SEND=', '') 
              //destinationURL = destinationURL + "&task=send&page_nr=" + pageid;              
              destinationURL = DetUrl8 + "&task=send&page_nr=" + pageid;    
              strEmail = strEmail.replace('[PAGE]', pageid );
	      strEmail = strEmail.replace('[PAGE]', pageid );	
              var new_progurl = progurl.replace("http://", "http_"); 
              destinationURL = destinationURL +	"&bkpath=" + new_progurl;  	  
              destinationURL = destinationURL + "&lang=" + ProgLang + "&url=" + strEmail;      //"mailto:info@aaaedv.ch";			  
    	      win_width = XPopWH[13];   // "800"; 
	      win_height = XPopWH[14];   // "700"; 
	      win_title = "_Send"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;	             
              AccTyp =  18;		  
            }
		   
          if (showTyp == "15")
            { 
             pageid = myURL.replace('DO_PRINT=', '') 
             //destinationURL = destinationURL + "&task=print&page_nr=" + pageid + "&gourl=" + progfolder + "blaetterkatalog/pdf/save/bk_" + pageid + ".pdf";
             destinationURL = DetUrl5 + "&task=print&page_nr=" + pageid + "&gourl=" + progfolder + "blaetterkatalog/pdf/save/bk_" + pageid + ".pdf";
    	     win_width = XPopWH[4];   // "800"; 
	     win_height = XPopWH[5];   // "700"; 
	     win_title = "_Print"; 
	     win_url = destinationURL; 
			 AccTyp =  15;
	     bnDoPopup = true;               
           }	
		   
          if (showTyp == "16")
            { 
             pageid = myURL.replace('DO_SAVE=', '') 
             //destinationURL = destinationURL + "&task=save&page_nr=" + pageid + "&gourl=" + progfolder + "blaetterkatalog/pdf/save/bk_" + pageid + ".pdf";
             destinationURL = DetUrl6 + "&task=save&page_nr=" + pageid + "&gourl=" + progfolder + "blaetterkatalog/pdf/save/bk_" + pageid + ".pdf";
    	     win_width = XPopWH[7];   // "800"; 
	     win_height = XPopWH[8];   // "700"; 
	     win_title = "_Save"; 
	     win_url = destinationURL; 
	     bnDoPopup = true; 
			 AccTyp =  16;		 
            }
			
          if (showTyp == "17")
            { 
              pageid = myURL.replace('DO_LIST=', '') 
              //destinationURL = destinationURL + "&task=list&page_nr=" + pageid ;
              destinationURL = DetUrl7 + "&task=list&page_nr=" + pageid ;
              win_width = XPopWH[10];   // "800"; 
	      win_height = XPopWH[11];   // "700"; 
	      win_title = "_List"; 
	      win_url = destinationURL; 
	      bnDoPopup = true; 
			 AccTyp =  17;		  
           }		   

          if (showTyp == "18")
            { 
              //destinationURL = destinationURL + "&task=zusatz1";   
              destinationURL = ZU1Url1 + "&task=zusatz1";
              win_width = XPopWH[58];   // "800"; 
    	      win_height = XPopWH[59];   // "700"; 
	      win_title = "_Zusatz1"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;                
 			 AccTyp =  9;
           }
		   
          if (showTyp == "19")
            { 
              //destinationURL = destinationURL + "&task=zusatz2"; 
              destinationURL = ZU2Url1 + "&task=zusatz2";  
              win_width = XPopWH[61];   // "800"; 
	      win_height = XPopWH[62];   // "700"; 
	      win_title = "_Zusatz2"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;    
			 AccTyp =  10;		  
           }

          if (showTyp == "20")
            { 
              //destinationURL = destinationURL + "&task=rapidcart";  
              destinationURL = ExtUrl1+ "&task=rapidcart"; 
              win_width = XPopWH[28];   // "800"; 
	      win_height = XPopWH[29];   // "700"; 
	      win_title = "_RapidCart"; 
	      win_url = destinationURL; 
	      bnDoPopup = true; 
            AccTyp =  24;		  
           }
		   
          if (showTyp == "21")
            { 
              //destinationURL = destinationURL + "&task=offert";  
              destinationURL = ExtUrl1+ "&task=offert"; 
    	      win_width = XPopWH[40];   // "800"; 
	      win_height = XPopWH[41];   // "700"; 
	      win_title = "_Offert"; 
	      win_url = destinationURL; 
	      bnDoPopup = true; 
            AccTyp =  21;		  
           }	
          if (showTyp == "22")
            { 
              //destinationURL = destinationURL + "&task=bestell";  
              destinationURL = ExtUrl1+ "&task=bestell"; 
    	      win_width = XPopWH[43];   // "800"; 
	      win_height = XPopWH[44];   // "700"; 
	      win_title = "_Bestell"; 
	      win_url = destinationURL; 
	      bnDoPopup = true; 
            AccTyp =  21;		  
           }		   

          if (showTyp == "23")
            { 
              pageid = myURL.replace('DO_RESERVE1=', '') 
              //destinationURL = destinationURL + "&task=reserve1&page_nr=" + pageid ;
              destinationURL = DetUrl9 + "&task=reserve1&page_nr=" + pageid ;
  	      win_width = XPopWH[16];   // "800"; 
	      win_height = XPopWH[17];   // "700"; 
	      win_title = "_List"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;
            AccTyp =  19;		  
           }

          if (showTyp == "24")
            { 
              pageid = myURL.replace('DO_RESERVE2=', '') 
              //destinationURL = destinationURL + "&task=reserve2&page_nr=" + pageid ;
              destinationURL = DetUrl0 + "&task=reserve2&page_nr=" + pageid ; 
    	      win_width = XPopWH[19];   // "800"; 
	      win_height = XPopWH[20];   // "700"; 
	      win_title = "_List"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;      
            AccTyp =  20;		  
           }

          if (showTyp == "25")
            { 
              //destinationURL = destinationURL + "&task=swk";   
              destinationURL = ExtUrl1+ "&task=swk";
              win_width = XPopWH[46];   // "800"; 
	      win_height = XPopWH[47];   // "700"; 
	      win_title = "_SWK"; 
	      win_url = destinationURL; 
	      bnDoPopup = true;  
            AccTyp =  21;		  
            }
          

  
          if (showTyp == "27")
            {
              win_width= 400;
              win_height = 400;
              win_title = "_blank";
              temp = myURL;
              if (temp.indexOf("_POPUP_") > 1) {
                temp2  = temp.substr(temp.indexOf("_POPUP_"));
                temp = temp.replace(temp2, '');
                myURL = temp;
                temp2 = temp2.replace('_POPUP_', '');
                temp2 += "_";
                var brokenstring=temp2.split('_');
                if (brokenstring[0] != '' && !isNaN(brokenstring[0])) {win_width = brokenstring[0];}
                if (brokenstring[1] != '' && !isNaN(brokenstring[1])) {win_height = brokenstring[1];}
                if (brokenstring.length > 2 && brokenstring[2] !='') {win_title = brokenstring[2];}
              }
              win_url = myURL;
      	      //alert("myURL = " + myURL +"\ntemp=" +temp + "\ntemp2 = " +temp2 +"\nWidth=" +win_width +"\nHeight="+win_height+"\nTitle:" +win_title+"\nbrokenstring.length= " +brokenstring.length);
	            bnDoPopup = true;
                AccTyp =  26;				
            }


          if (showTyp == "28")
            { 
             pageid = myURL.replace('DO_CHAPTER=', '') 
             //destinationURL = destinationURL + "&task=print&page_nr=" + pageid + "&gourl=" + progfolder + "blaetterkatalog/pdf/save/bk_" + pageid + ".pdf";
             destinationURL = DetUrl5 + "&task=chapter&page_nr=" + pageid + "&gourl=" + progfolder + "blaetterkatalog/pdf/save/bk_" + pageid + ".pdf";
    	     win_width = XPopWH[4];   // "800"; 
	     win_height = XPopWH[5];   // "700"; 
	     win_title = "_Print"; 
	     win_url = destinationURL; 
	     bnDoPopup = true;
            AccTyp =  23;		 
           }
		

          if (showTyp == "33")
            { 
  	     win_width = XPopWH[16];   // "800 Res 1"; 
             win_height = XPopWH[17];   // "700 Res 1";
 
             if (myURL.indexOf("O_FUNCTION_1") > 0) {
                progfunct = BK_CMD_FKT1; 
                win_title = "_FUNCT1";
                AccTyp =  31;				
               }
             if (myURL.indexOf("O_FUNCTION_2") > 0) {
                progfunct = BK_CMD_FKT2;  
                win_title = "_FUNCT2";
                AccTyp =  32;				
               }
             if (myURL.indexOf("O_FUNCTION_3") > 0)  {
                progfunct = BK_CMD_FKT3; 
                win_width = XPopWH[19];   // "800 Res 2"; 
                win_height = XPopWH[20];   // "700 Res 2";
                win_title = "_FUNCT3";
                AccTyp =  33;				
              }  
             if (myURL.indexOf("O_FUNCTION_4") > 0)  {
                progfunct = BK_CMD_FKT4; 
                win_width = XPopWH[19];   // "800 Res 2"; 
                win_height = XPopWH[20];   // "700 Res 2";
                win_title = "_FUNCT4";
                AccTyp =  34;				
              }   
			  
             temp = shopSessionIDParameterName; 
              if (progfunct.indexOf("?") > 1)
                {temp = strSessId;}
              else
                {if (temp.indexOf("?") < 0) {temp = "?dummyz=Y" +  temp;}}
             progfunct = progfunct + temp + shopsession; 

     	     progfunct = progfunct + ExtParameter; 
	         win_url = progfunct; 
	         bnDoPopup = true;  
            }
			
        if (showTyp == "35")
          { 
		  
          var IE7Downlink = "";
          try { IE7Downlink = PDFDownLink; }
          catch (Exception) { IE7Downlink = 'blaetterkatalog/actions/download.htm';}
          destinationURL = IE7Downlink;
	  if (destinationURL.indexOf("?") <= 1) {destinationURL += "?xyz=abc"}
	  destinationURL += ExtParameter + "&dialog=" +  ProgLang; // + "&downpath=" + IE7DownPath;
            if (XPopWH.length > 64)  {
              win_width = XPopWH[64];
              win_height = XPopWH[65];    }
            else {
              win_width = 300;
	            win_height = 250;   }
	  win_title = "_DOWN";
	  win_url = destinationURL;
	  bnDoPopup = true;
          AccTyp =  35;		  
         }			

        if (showTyp == "36")
          {
           pageid = myURL.replace('DO_JUMP=', '')
           var bnFound = true;
           var JumpURL = "";
           try { JumpURL = BKJumpURL; }
           catch (Exception) { JumpURL = 'blaetterkatalog/actions/jumpto.htm'; bnFound = false;}
           if (JumpURL.indexOf("?") <= 1) {JumpURL += "?xyz=abc"}
           var JumpTyp = "1";
           var JumpName = "name" ;
           if (bnFound)   {
               JumpTyp = BKJumpTyp;
               JumpName = BKJumpName; }
             
           destinationURL =  JumpURL + "&page_nr=" + pageid + "&dialog=" +  ProgLang;
            if (XPopWH.length > 66)  {
              win_width = XPopWH[67];
              win_height = XPopWH[68];    }
            else {
    	        win_width = XPopWH[34];   // "800";
	            win_height = XPopWH[35];   // "700";
               }
	         win_title = "_Jump";
	         win_url = destinationURL;
	         
	         if (JumpTyp == "1") bnDoPopup = true;
	         if (JumpTyp == "2") {
                  try
	    	           {
                     if (window.opener.closed == true)
                       {
                        bnDoPopup = true;
                        //alert("OPENER.CLOSED");
                       }
                     else
                       {
                        //alert("ES KLAPPT");
                        window.opener.location.href =win_url;
                        window.opener.focus();
                        return true;
                       }
	                  }
	                catch( Exception )
                    {
                    //alert("CATCH ERROR");
                    bnDoPopup = true;
	                  }
              }
           if (JumpTyp == "3") {
               //Manuell anpassen
               parent.main_3.location.href = win_url;
               bnDoPopup = false;
             }
           
           AccTyp = 36;
         }


          if (showTyp == "37")
            { 
	     win_url = myURL.replace('DO_REDIRECT=', '');
	     bnDoPopup = false;
             document.location.href = win_url;
            AccTyp =  37;		 
           }


          if (showTyp == "38") 
            {
              
              var win_proz = 80; 
              win_width= 400;
              win_height = 400;
              win_title = "_blank";
              temp = myURL;
            
              if (temp.indexOf("_POPUPPROZ_") > 1) {
                temp2  = temp.substr(temp.indexOf("_POPUPPROZ_"));
                temp = temp.replace(temp2, '');
                myURL = temp;
                if (shopsession != '')
                  {
                    if (myURL.indexOf("?") > 1)
                      {
                        myURL += "&sid=" + shopsession; 
                      }
                    else 
                      {
                       myURL += "?sid="  +shopsession;   
                      }
                  }
                if (ExtParameter != '') 
                   {
                    if (myURL.indexOf("?") > 1)
                      {
                       //Nothing
                      }
                    else 
                      {
                       myURL += "?xshow=true";   
                      }
                    myURL += ExtParameter;
                   }

                temp2 = temp2.replace('_POPUPPROZ_', '');
                temp2 += "_";
                var brokenstring=temp2.split('_');
                if (brokenstring[0] != '' && !isNaN(brokenstring[0])) {win_proz = brokenstring[0];}                
                if (brokenstring.length > 1 && brokenstring[1] !='') {win_title = brokenstring[1];}
                //Prozent ausrechnen in Breite und Höhe
                //alert("Proz = " + win_proz + "Name = " + win_title);
                if (win_proz > 0) 
                  {
	           var w_per = (screen.width/100)*(win_proz);
	           var h_per = (screen.height/100)*(win_proz);
	           var left = (screen.width/2)-(w_per/2);
	           var top = (screen.height/2)-(h_per/2);
                   //alert("Vor Aufruf: w_per = " + w_per + " h_per = " + h_per + " left= " + left + " top = " + top); 
	           var targetWin = window.open (myURL, win_title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width='+w_per+', height='+h_per+', top='+top+', left='+left);
                   targetWin.focus();
                   return; 
                  }
              }
              win_url = myURL;
      	      //alert("myURL = " + myURL +"\ntemp=" +temp + "\ntemp2 = " +temp2 +"\nWidth=" +win_width +"\nHeight="+win_height+"\nTitle:" +win_title+"\nbrokenstring.length= " +brokenstring.length);
	        
                bnDoPopup = true;
                AccTyp =  26;

            }

	   if (bnDoPopup == true) 
	     {
                  win_url = win_url.replace('[LANG]', ProgLang);
		  var strNoFree = 'N';		 
	      win_parameter = win_parameter + ",width=" + win_width + ",height=" + win_height;	
	      //alert(win_parameter);               
			  var shopFenster = ""; 
			  
			  if (bnDoFree == true) 
			    {				  
				 if (AccTyp == -1) 
				   {
					 bnDoFree = false;   
				   }
				 else
				   { 
				    AccTyp = AccTyp - 1; 	
                                    try {strNoFree = arrAcc[AccTyp]}
                                    catch (Exception) { strNoFree = 'N';}  
				    //alert("Typ (-1) = " + AccTyp + " -> " + strNoFree + " Test =" + arrAcc[AccTyp]);
				    if (strNoFree == 'N') bnDoFree = false; 
			    	}
		        }
				
              if (bnDoFree == true)
                {                 
                 var AccReplace = "_f=x_"; 
                 try { AccReplace = BKReplaceAccess; }
                 catch (Exception) { AccReplace = "_f=x_";}    
                 
				 var newURL = "blaetterkatalog/actions/checkaccess.htm?XURL=";
                 temp = win_url.replace("?", AccReplace); 
                 win_url = newURL + temp; 
                }
                             
     	      var shopFenster = WinPopup(win_url, win_title, win_parameter);

              shopFenster.focus(); 
              return;
	     }

             //Vorläufig ausgesetzt
             if (1==2)
               {
                 try {
			if ( typeof( opener ) == "undefined" || typeof( opener ) == "unknown" ||
			    	typeof( opener.name ) == "undefined" || typeof( opener.name ) == "unknown" )
			{
				if ( shopFenster.closed )	
				{
					shopFenster = window.open( myURL, "shop", "" );
					shopFenster.focus();
				}
				else 
				{
					shopFenster.location.href=myURL;
					shopFenster.focus();	
				}
			} 
			else 
			{
				opener.location.href = myURL;
				opener.blatterkatalogPopup = window;
				opener.focus();
			}
		} 
		catch ( Exception )
		{
			if( opener && !opener.closed )
			{
				opener.location.href = myURL;
				opener.focus();
			}
			else 
			{
				try {
					if ( shopFenster.closed )	
					{
						shopFenster = window.open( myURL, "shop", "" );
						shopFenster.focus();
					}
					else 
					{
						shopFenster.location.href = myURL;
						shopFenster.focus();	
					}
				} 
				catch ( Exception )
				{
						shopFenster = window.open( myURL, "shop", "" );
						shopFenster.focus();
				}
			}
		}
             }  
	}

	/**
	 * getFlashPath() ermittelt das Flash-Objekt
	 */
	function getFlashPath() 
	{
    	if ( document.all ) 
    	{
	        //ie
	        return document.bkflash;
    	}
    	else 
    	{
	        //safari
	        var ffilm = document.getElementById( "bkflash" );
	        try 
	        {
	            flashfilm.SetVariable( "tst", "1" );
	       	} 
	       	catch ( Exception ) 
	       	{
	            //firefox
            	ffilm = document.embeds["bkflash"];
            }
            return ffilm;
	    }
	}
	
	

	/////////////////////////////////////
	// Funktion zum externen Aufruf der Flash-Commands
	// id => 'jump_to_id'
	// par => pageid
	// aufruf mit z.b. flashCommand('jump_to_id', 5)
	/////////////////////////////////////
	function flashCommand( id, par ) 
	{
		try
		{
		    var movie = getFlashPath();
		    movie.SetVariable( "jscommand", id + "|" + par );
		}   
	    catch( Exception )
	    {
	      	document.getElementById("bkflash").SetVariable( "jscommand", id + "|" + par );		
	    }	
	}
	
	
	function getURLParam( strParamName ) 
	{
	var strReturn = " ";
	var strHref = window.location.href;
	
	var i = strHref.indexOf( strParamName );
	
	if ( i > 0 )
	{
		var j = strHref.indexOf( "=", i + 1 );
		if ( j > 0 )
		{
			var endPos = strHref.length;
			var k = strHref.indexOf( "?", j + 1 );
			var l = strHref.indexOf( "&", j + 1 );
			if ( k > 0 && l > 0 )
			{
			   	if ( k < l ) 
			   	{
			   		endPos = k;
			   	}	
				else 
				{
					endPos = l;
				}	
			} 
			else if ( k > 0 )
			{
			  endPos = k;
			} 
			else if ( l > 0 )
			{
			  endPos = l;
			}
			
			strReturn = strHref.substring( j + 1 , endPos );
		}	
	}
	return strReturn;
	}	
    
	function WinPopup(TUrl, TName, TFeature)
	  {
		return window.open(TUrl, TName, TFeature);  
	  }

	window.onerror = stoperror;

	function stoperror( a )
	{
  	return false;
	}
