var toolWin="";
function openTool(url)
{

    document.getElementById("writeArea").style.height="680px";
    document.getElementById("pubContent").style.display="none";
    document.getElementById("adminContent").style.display="";
    document.getElementById("writeArea").src = url;
}


function openToolStoerer(url)
{

    document.getElementById("writeArea").style.height="60px";
    document.getElementById("adminContent").style.display="";
    document.getElementById("writeArea").src = url;

}



function openToolForList(url)
{
    document.getElementById("writeArea").style.height="680px";
    document.getElementById("pubContent").style.display="none";
    document.getElementById("adminContent").style.display="";
    document.getElementById("writeArea").src = url;
}


function showStoerer(img,x,y)
     {
            parent.document.getElementById('stoerer').src =img;
            parent.document.getElementById('stoerer').style.display="";
            parent.document.getElementById('stoerer').style.left=x+"px";
            parent.document.getElementById('stoerer').style.top=y+"px";
     }
function hideStoerer()
{
       parent.document.getElementById('stoerer').style.display="none";
}

function closeTool()
{
    document.location = document.location.href;
}



function workOnLinks(ref,target)
{
   document.getElementById(target).value = ref[ref.selectedIndex].value;
}

var slideIsActive = "";
var activeInd = 0;
var activeKat = 0;
var slides = new Array();

function registerSubSlide(katID,slideID)
{
   if(! slides[katID])
    {
        slides[katID] = new Array();
    }
   slides[katID].push(slideID);
   if(slideIsActive)
   {
       document.getElementById("slideID_"+katID+"_"+slideID).style.display="none"; 
   }
   else
   {
       slideIsActive = "slideID_"+katID+"_"+slideID;
       activeInd=0;
       activeKat = katID;
   }
}


function registerSlide(slideID)
{
   slides.push(slideID);
   if(slideIsActive)
   {
       document.getElementById(slideID).style.display="none";
   }
   else
   {
       slideIsActive = slideID;
       activeInd=0;
   }
}


function pageSlides(direction)
{
    maxInd = slides.length -1;
    document.getElementById(slides[activeInd]).style.display="none";
    if(direction == "back")
     {
          activeInd--;
     }
    if(direction == "fwd")
     {
         activeInd++;
     }
     if(activeInd < 0)
     {
          activeInd = maxInd;
     }
     if(activeInd > maxInd)
     {
          activeInd = 0;
     }
     if(document.getElementById(slides[activeInd]))
     {
       document.getElementById(slides[activeInd]).style.display="";    
       slideIsActive = slides[activeInd]; 
     }
}


function setActiveSubKat(katID)
{
    if(! slides[activeKat] )
     {
          document.getElementById("leftP").style.visibility="hidden";
          document.getElementById("rightP").style.visibility="hidden";
          return;
     }
    if( document.getElementById("slideID_"+activeKat+"_"+slides[activeKat][activeInd]))
    {
          document.getElementById("link_"+activeKat).style.color="#490000";
          document.getElementById("slideID_"+activeKat+"_"+slides[activeKat][activeInd]).style.display="none";
    }
    if(! slides[katID] )
     {
          return;
     }

    activeKat = katID;
    activeInd = 9000;
    maxInd = slides[activeKat].length -1;

    if(maxInd > 0)
    {
        document.getElementById("leftP").style.visibility="visible";
        document.getElementById("rightP").style.visibility="visible";
    }
    else
    {
        document.getElementById("leftP").style.visibility="hidden";
        document.getElementById("rightP").style.visibility="hidden";
    }
    pageSubSlides('fwd')
}

function pageSubSlides(direction)
{
    maxInd = slides[activeKat].length -1;
    if(document.getElementById("slideID_"+activeKat+"_"+slides[activeKat][activeInd]))
    {
        document.getElementById("slideID_"+activeKat+"_"+slides[activeKat][activeInd]).style.display="none";
    }
    if(direction == "back")
     {
          activeInd--;
     }
    if(direction == "fwd")
     {
         activeInd++;
     }
     if(activeInd < 0)
     {
          activeInd = maxInd;
     }
     if(activeInd > maxInd)
     {
          activeInd = 0;
     }
     if(document.getElementById("slideID_"+activeKat+"_"+slides[activeKat][activeInd]))
     {
       document.getElementById("link_"+activeKat).style.color="#a0c32d";
       document.getElementById("slideID_"+activeKat+"_"+slides[activeKat][activeInd]).style.display="";
       slideIsActive = slides[activeKat][activeInd];
     }
}


var actFontSize         = 11;
var actlineHeight       = 100;

function chngFontsize(step) {
  step = step;
  if ( (Math.abs(actFontSize + step) <= 17)  && (Math.abs(actFontSize + step) >= 8) )
  {

        tags = new Array ( "h1","p","h3","h6","li","ul","a","div","h4","td","h2" );

        actFontSize += step;
        var idn = document.getElementById('pubContent');
        idn.style.fontSize   = actFontSize+"px";
        document.getElementById('leftMenue').style.fontSize=actFontSize+"px";

        actlineHeight += step;
        for (j=0; j<tags .length; j++)
        {
             var newFontSize=0;
             var newLineHeight=0;
             var getElement = idn.getElementsByTagName(tags[j]);
             for (i=0; i<getElement.length; i++) {
                 eachElement = getElement[i];
                 switch(tags[j]) {
                       case "td" : newFontSize =  actFontSize; newLineHeight=actlineHeight;break;
                       case "a" : newFontSize =  actFontSize; newLineHeight=actlineHeight;break;
                       case "h4" : newFontSize =  actFontSize+2; newLineHeight=actlineHeight;break;
                       case "p" : newFontSize =  actFontSize; newLineHeight=actlineHeight;break;
                       case "div" : newFontSize =  actFontSize; newLineHeight=actlineHeight;break;
                       case "li" : newFontSize =  actFontSize; newLineHeight=actlineHeight;break;
                       case "ul" : newFontSize =  actFontSize; newLineHeight=actlineHeight;break;
                       case "h3": newFontSize =  actFontSize;newLineHeight=actlineHeight;break; 
                       case "h2": newFontSize =  actFontSize+1;newLineHeight=actlineHeight;break;
                       case "h1": newFontSize =  actFontSize+9;newLineHeight=actlineHeight;break;
                       break;
                       case "h6": newFontSize =  actFontSize+1;newLineHeight=actlineHeight; break;
                  }
                  eachElement.style.fontSize   = newFontSize + "px";
         //         eachElement.style.lineHeight = newLineHeight + "%";
             }
        }
  }
  if (actFontSize == 11)
  {
//      document.getElementById("spFontsizeMinus").src = "/img/fontminus_ia.jpg";
  }
  else if (actFontSize == 15)
  {
//      document.getElementById("spFontsizePlus").src = "/img/fontplus_ia.jpg";
  }
  else {
//        document.getElementById("spFontsizePlus").src = "/img/fontplus.jpg";
//        document.getElementById("spFontsizeMinus").src = "/img/fontminus.jpg";
  }
}





function AskForDel(teaserID)
{
   if(confirm("Soll der Teaser gelöscht werden ?"))
     {
           return true;
     }
    return false;
}

function showBigImage(image,aroundID,imgID)
{
     document.getElementById(imgID).src=image;
     document.getElementById(aroundID).style.display="";
}


// Die Buttondefinitionen

var win;

$(document).ready(function() {
$("#termin").click(function() {
   openTermin();
   return false;
});

$("#ultraschall").click(function() {
   openDoc('Gutschein_Ultraschallbad.pdf');
   return false;
});
$("#mikrofaser").click(function() {
   openDoc('Gutschein_Mikrofasertuch.pdf');
   return false;
});
$("#sehtest").click(function() {
   openDoc('Gutschein_Sehtest.pdf');
   return false;
});
$("#windkanal").click(function() {
   openDoc('Gutschein_Windkanal.pdf');
   return false;
});
$("#kontaktlinsen").click(function() {
   openDoc('Gutschein_Kontaktlinsen.pdf');
   return false;
});
$("#hoertest").click(function() {
   openDoc('');
   return false;
});

$("#aktuellepws").click(function() {
   openDoc('aktuellepws.pdf');
   return false;
});


});



function openDoc(file)
{
    document.location="/docs/"+file;
}

function openTermin()
{
    url = "Terminvereinbarung";
    if(win)
      {
          win.close();
          win="";
      }
     win=open(url,'Terminvereinbarung','width=550,height=550,status=no,scrollbars,resize=yes,screenx=50,screeny=50');
}


function openRecommend(katID)
{
      var url="recommend.html?katID="+katID;
      if(win)
      {
          win.close();
          win="";
      }
      win=open(url,'Weiterempfehlen','width=550,height=500,status=no,scrollbars,resize=yes,screenx=50,screeny=50');

}



function initFlowPlayer(params)
{


   flowplayer(params.playerid, "/videos/player/flowplayer-3.1.5.swf",{

   clip: {
        scaling: 'fit'
    },
    canvas: {
        backgroundColor: '#ffffff',
        backgroundGradient: [0.0, 0.0]
    },
    // some styling for the controlbar
    plugins: {
        controls: {
            backgroundColor: params.console_bgcolor,
            sliderGradient: 'none',
            backgroundGradient: [0.0, 0.1],
            bufferColor: '#445566',
            buttonOverColor: '#000000',
            progressColor: '#093055',
            tooltipColor: '#093055',
            timeColor: '#ffffff',
            tooltipTextColor: '#ffffff',
            volumeSliderColor: '#093055',
            progressGradient: 'low',
            bufferGradient: 'low',
            timeBgColor: '#093055',
            borderRadius: '0px',
            sliderColor: '#093055',
            volumeSliderGradient: 'none',
            durationColor: '#aac9e6',
            buttonColor: '#0c3e71',
            height: 28,
            opacity: 1.0
        }
    }
});

}

