/* ----------------------------

     Utskriftsvänlig layout
     John Modig Productions
     
---------------------------- */

var layout="screen";
var orgLogoHTML="";
var head=document.getElementsByTagName('head')[0];
var relPath="";

var p1=document.createElement("link");
p1.setAttribute('rel','stylesheet');
p1.setAttribute('type','text/css');
p1.setAttribute('id','printStyle');
p1.setAttribute('title','printStyle');
p1.setAttribute('href','css/print.css');
p1.setAttribute('media','screen, print');
head.appendChild(p1);

var p2=document.createElement("link");
p2.setAttribute('rel','stylesheet');
p2.setAttribute('type','text/css');
p2.setAttribute('id','printStyleOverrides');
p2.setAttribute('title','printStyle');
p2.setAttribute('href','css/print_overrides.css');
p2.setAttribute('media','print');
head.appendChild(p2);

for(i=0;(a=document.getElementsByTagName("link")[i]);i++) {
  if(a.getAttribute("title")=="printStyle"){
    a.disabled=true;
  }
}

function changeStyleRelPath(rPath) {
relPath=rPath;
p1.setAttribute('href',relPath+'css/print.css');
p2.setAttribute('href',relPath+'css/print_overrides.css');
return changeStyle();
}

function changeStyle(){
var logo=document.getElementById('header');
var i, a;
switch(layout)
{
case "print":
   for(i=0;(a=document.getElementsByTagName("link")[i]);i++) {
     if(a.getAttribute("title")=="printStyle"){
       a.disabled=true;
     }
     else if(a.getAttribute("media").indexOf("screen") != -1){
       a.disabled=false;
     }
   }
document.getElementById('linkPrint').innerHTML="Print";
document.getElementById('page_body').removeChild(document.getElementById('printFooter'));
logo.innerHTML=orgLogoHTML;
layout="screen";
break
case "screen":
   for(i=0;(a=document.getElementsByTagName("link")[i]);i++) {
     if(a.getAttribute("title")=="printStyle"){
       a.disabled=false;
     }
     else if(a.getAttribute("media").indexOf("screen") != -1){
       a.disabled=true;
     }
   }
document.getElementById('linkPrint').innerHTML="Screen layout";
if(orgLogoHTML==""){orgLogoHTML=logo.innerHTML;}
logo.innerHTML="";
hrLogo = document.createElement("img");
hrLogo.setAttribute("src", relPath+"images/logos/logo_ec2009_300dpi.jpg");
hrLogo.setAttribute("alt", "Eurocities 2009 - high resolution printer friendly logotype");
hrLogo.setAttribute("title", "Eurocities 2009 - high resolution printer friendly logotype");
hrLogo.style.width="15cm";
hrLogo.style.height="4.03cm";
hrLogo.style.marginBottom="1cm";
logo.appendChild(hrLogo);

d=new Date();
mins=d.getMinutes();
if(mins<10){mins="0"+mins;}
strD=(d.getMonth()+1)+"/"+d.getDate()+"/"+d.getYear()+" "+d.getHours()+":"+mins; 
var printFooter=document.createElement("p");
printFooter.setAttribute("id", "printFooter");
printFooter.innerHTML="Printed date: "+strD+".<br />Url: "+location.href+"<br /><br />";
printFooter.style.fontSize="7pt";
printFooter.style.lineHeight="9pt";

footerLogo1 = document.createElement("img");
footerLogo1.setAttribute("src", relPath+"images/logos/logo_ec_300dpi.jpg");
footerLogo1.setAttribute("alt", "Eurocities - high resolution printer friendly logotype");
footerLogo1.setAttribute("title", "Eurocities - high resolution printer friendly logotype");
footerLogo1.style.width="1.0cm";
footerLogo1.style.height="2cm";
footerLogo1.style.marginRight="0.5cm";
printFooter.appendChild(footerLogo1);

footerLogo2 = document.createElement("img");
footerLogo2.setAttribute("src", relPath+"images/logos/logo_sterik_300dpi.jpg");
footerLogo2.setAttribute("alt", "The City of Stockholm - high resolution printer friendly logotype");
footerLogo2.setAttribute("title", "The City of Stockholm - high resolution printer friendly logotype");
footerLogo2.style.width="2cm";
footerLogo2.style.height="2cm";
printFooter.appendChild(footerLogo2);

document.getElementById('page_body').insertBefore(printFooter, document.getElementById('page_menu'));

layout="print";
break
}
return false;
}