var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
        if (document.getElementById('skpagecommentform')){
            // Dauer der Spamsperre
            secs = 10
            StopTheClock()
            StartTheTimer()
        }
}

function StopTheClock()
{
        if(timerRunning)
                clearTimeout(timerID)
        timerRunning = false
}

function StartTheTimer()
{
        if (secs==0)
        {
                StopTheClock()
                document.getElementById('skpagecommentform').action = document.location.href + "#CommentForm"
                document.getElementById('skcommentssubmit').disabled = false
                document.getElementById('skcommentssubmit').value = "Kommentar absenden"
        }
        else
        {
                document.getElementById('skcommentssubmit').disabled = true
                document.getElementById('skcommentssubmit').value = "Warte noch " + secs + " Sekunden"
                secs = secs - 1
                timerRunning = true
                timerID = self.setTimeout("StartTheTimer()", delay)
        }
}
//InitializeTimer()
//setTimeout("InitializeTimer()", 2000);

// image write
function createkiefer (){
    
    var viewportwidth;
    var viewportheight;
    
    // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
     
    if (typeof window.innerWidth != 'undefined')
    {
        viewportwidth = window.innerWidth,
        viewportheight = window.innerHeight
    }
     
    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
    
    else if (typeof document.documentElement != 'undefined'
        && typeof document.documentElement.clientWidth !=
        'undefined' && document.documentElement.clientWidth != 0)
    {
        viewportwidth = document.documentElement.clientWidth,
        viewportheight = document.documentElement.clientHeight
    }
    
    // older versions of IE
     
    else
    {
        viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
        viewportheight = document.getElementsByTagName('body')[0].clientHeight
    }
    //document.write('<p>Your viewport width is '+viewportwidth+'x'+viewportheight+'</p>');

    if((viewportwidth >= 1440) && (viewportheight >= 650)){
        document.getElementById("kiefergfx").className = 'kiefergfx';   
    }else{
        document.getElementById("kiefergfx").className = 'dpn';
    }
}

function detectcontent(){
    
    //InitializeTimer();
    
    // call other functions
    createkiefer();

    var maxAnzahl = 45; 
    var anzahl;
    if (navigator.userAgent.indexOf('MSIE') !=-1)
    {
        anzahl = document.getElementById("bread").innerText.length
            if (anzahl >= maxAnzahl){
                repairbread();
            }
    }else{
        anzahl = document.getElementById("bread").textContent.length
            if (anzahl >= maxAnzahl){
                repairbread();
            }
    }
}

function repairbread(){
    document.getElementById("bread").style.backgroundColor = "#544021";
}

var alreadyrunflag=0 //flag to indicate whether target function has already been run

if (document.addEventListener)
  document.addEventListener("DOMContentLoaded", function(){alreadyrunflag=1; detectcontent()}, false)
else if (document.all && !window.opera){
  document.write('<script type="text/javascript" id="contentloadtag" defer="defer" src="javascript:void(0)"><\/script>')
  var contentloadtag=document.getElementById("contentloadtag")
  contentloadtag.onreadystatechange=function(){
    if (this.readyState=="complete"){
      alreadyrunflag=1
      detectcontent()
    }
  }
}

window.onload=function(){
  setTimeout("if (!alreadyrunflag) detectcontent()", 0)
}

window.onresize=function(){
    createkiefer();
}