function matchcolumns(){
     var divs,childDivs,contDivs,maxHeight,totalChildHeight,divHeight,childDivHeight,d,e;
	
     // get all <div> elements in the document 
     divs=document.getElementsByTagName('div');
     contDivs=[];

     // initialize maximum height value 
     maxHeight=0; 
     totalChildHeight=0;
     childDivHeight=0;

     // iterate over all <div> elements in the document 
     for(var i=0;i<divs.length;i++){ 
    
          // make collection with <div> elements with class attribute 'container' 
          if(/\bcolumn\b/.test(divs[i].className)){ 
                totalChildHeight=0;
                d=divs[i];
                childDivs=d.getElementsByTagName('div');
                contDivs[contDivs.length]=d;

                // determine height for <div> element 
                if(d.offsetHeight){ 
                     divHeight=d.offsetHeight; 					
                }
                else if(d.style.pixelHeight){ 
                     divHeight=d.style.pixelHeight;					 
                }

                for(var j=0;j<childDivs.length;j++){
                    if(/\bsubcolumn\b/.test(childDivs[j].className)){
                        e=childDivs[j];
                        if(e.offsetHeight){ 
                             childDivHeight=e.offsetHeight; 					
                        }
                        else if(e.style.pixelHeight){
                            childDivHeight=e.style.pixelHeight;
                        }
                        totalChildHeight += childDivHeight;
                    }
                }

                //divHeight=Math.max(totalChildHeight,divHeight);
                if (maxHeight != 0 && totalChildHeight != 0)
                {
                    if (totalChildHeight < maxHeight)
                    {
                        if (document.getElementById('teaserleft') != undefined)
                        {
                            var teaserleft, teaserleftnewheight;
                            teaserleftnewheight = (maxHeight-totalChildHeight)+childDivHeight-10;
                            teaserleft = document.getElementById('teaserleft');
                            teaserleft.style.height=teaserleftnewheight + "px";
                        }
                        if (document.getElementById('teaser2') != undefined)
                        {
                            var teaser2, teaser2newheight;
                            teaser2newheight = (maxHeight-totalChildHeight)+childDivHeight-10;
                            teaser2 = document.getElementById('teaser2');
                            teaser2.style.height=teaser2newheight + "px";
                        }
                    }
                }

                // calculate maximum height
                maxHeight=Math.max(maxHeight,divHeight);
          } 
     }

     // assign maximum height value to all of container <div> elements 
     for(var i=0;i<contDivs.length;i++){ 
          contDivs[i].style.height=maxHeight + "px"; 
     }
}

function matchteasercolumns(){
    var teaserleft, teaserright, leftHeight, rightHeight, maxHeight;
    teaserleft = document.getElementById('teaserleft');
    teaserright = document.getElementById('teaserright');

    maxHeight=0;
    leftHeight=0;
    rightHeight=0;
    
    if(teaserleft.offsetHeight){
         leftHeight=teaserleft.offsetHeight;
    } 
    else if(teaserleft.style.pixelHeight){ 
         leftHeight=teaserleft.style.pixelHeight;					 
    }

    if(teaserright.offsetHeight){
         rightHeight=teaserright.offsetHeight;
    } 
    else if(teaserright.style.pixelHeight){ 
         rightHeight=teaserright.style.pixelHeight;					 
    }

    maxHeight=Math.max(leftHeight,rightHeight);

    teaserleft.style.height=maxHeight + "px";
    teaserright.style.height=maxHeight + "px";
}

function fixteaserheight(){
    if(document.getElementById){
        // First match the teaser columns
        matchteasercolumns();
    }
}

function fixheight(){
    if(document.getElementsByTagName){
        // First match the teaser columns
        matchcolumns();
    }
}

function printview()
{
    document.getElementById('side').style.display = 'none';
    document.getElementById('headermain').style.display = 'none';
    document.getElementById('footer').style.display = 'none';
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
