/*
lib.js for DELKA

Author:			  manfred.schneiderbauer@world-direct.at
Version:      1.31
Last Changed:	2007-12-17
*/

// start functions relying on pageload
function Start(){
if(window.hasLoaded){
  // --- BEGIN function calls ---
  styleInfoBoxes();
  // --- END function calls ---
}else{window.setTimeout("Start();",250);}
}
clib_onload("Start()");

// Filialfinder image map
function turnOn(imgName) { if (document.images) { document.img11.src = eval(imgName + '_on.src'); } }
function turnOff(imgName) { if (document.images) { document.img11.src = eval(imgName + '_off.src'); } }
function initMap(thisMapSrc){
img4_on = new Image();img4_on.src="/fileadmin/user_upload/AustriaKarten/map_oberoesterreich.gif";
img5_on = new Image();img5_on.src="/fileadmin/user_upload/AustriaKarten/map_niederoesterreich.gif";
img6_on = new Image();img6_on.src="/fileadmin/user_upload/AustriaKarten/map_wien.gif";
img7_on = new Image();img7_on.src="/fileadmin/user_upload/AustriaKarten/map_burgenland.gif";
img9_on = new Image();img9_on.src="/fileadmin/user_upload/AustriaKarten/map_kaernten.gif";
img4_off = new Image();img4_off.src=thisMapSrc;
img5_off = new Image();img5_off.src=thisMapSrc;
img6_off = new Image();img6_off.src=thisMapSrc;
img7_off = new Image();img7_off.src=thisMapSrc;
img9_off = new Image();img9_off.src=thisMapSrc;
}


// Filialfinder image map cursor on non-existant countries
function mapCursor(flag){
 var im=d('imMap');
 if(flag)
  {
   if(isIE6up||isIE6up)
    {
      im.style.cursor='not-allowed';
    } else {
      im.style.cursor='default';
    }
  } else {
   im.style.cursor='auto';
  }
 }

// position the centennium birthday loop
function positionLoop(){
var corr=184;
if(isIE5up){corr=188;}
if(isIE7up){corr=184;}
d('dvLoop').style.left=((document.body.offsetWidth/2)-corr)+'px';
window.setTimeout("positionLoop();",250);
}

// open the start page popup
function openPopup(){
try{
window.setTimeout("clib_dwin.open(d('dvPopup').innerHTML,'100 Jahre DELKA','width=530,height=620,htmlmode=true');",250);
}catch(error){}
}

// style info boxes
function styleInfoBoxes(){
var allDivs=document.getElementsByTagName('div'); var d=0; var infoCell=''; var hCell=''; var textCell=''; var iCell=''; var allHeadlines=''; var allPs=''; var p=0;
for(var i=0;i<allDivs.length;i++)
  {
  if(allDivs[i].className.toLowerCase()=='dvrightinfoboxes')
    {
     allPs=allDivs[i].getElementsByTagName('p');
     for(p=0;p<allPs.length;p++)
       {
       allPs[p].style.color='#4e4e4e';
       allPs[p].style.fontSize='12px';
       }
     allHeadlines=allDivs[i].getElementsByTagName('div');
     for(d=0;d<allHeadlines.length;d++)
      {
       if(allHeadlines[d].className.toLowerCase()=='h2')
        {
        infoCell=allHeadlines[d];
        if(isIE5up)
          {
          infoCell.style.height='30px'; infoCell.style.overflow='hidden';
          }else{
          infoCell.style.height='14px';
          }
        if(!window.firstLineSkipped)
          {
          infoCell.innerHTML='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="bottom" width="18"><img src="fileadmin/dev/img/header1.gif" style="margin-left:4px;"></td><td valign="middle" style="color:#202873;font-weight:bold;font-style:italic;text-transform:none;line-height:14px;height:14px;width:237px;">'+infoCell.innerHTML+'</td></tr></table>';
          window.firstLineSkipped=true;
          }else{
          infoCell.innerHTML='<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td colspan="2"><img src="fileadmin/dev/img/separator-infoboxes.gif"></td></tr><tr><td valign="bottom" style="width:18px;"><img src="fileadmin/dev/img/header1.gif" style="margin-left:4px;"></td><td valign="middle" style="color:#202873;font-weight:bold;font-style:italic;text-transform:none;line-height:14px;height:14px;width:237px;">'+infoCell.innerHTML+'</td></tr></table>';
          }
        }
      }
    allDivs[i].innerHTML=allDivs[i].innerHTML+'<img src="fileadmin/dev/img/separator-infoboxes.gif">';
    }
  }
}

// handle customer data change request form
function CustomerDataForm(){
  // init
d('rdWhatName').checked=false; d('rdWhatAddress').checked=false;
var allF=document.getElementsByTagName('form'); var allE=''; var e=0;
for(var i=0;i<allF.length;i++) // go thru all forms
  {
    if(allF[i].id.toString().indexOf('mailform')!=-1) // if it's a mailform form---
      {
      allF[i].id=allF[i].id+'_'+i; // temp add an index to the id
      allF[i].style.display='none'; allF[i].target='_top'; // make invisible and set target (why the heck...?)
      // find submit button and add event handler for subject field updating
      allE=document.getElementsByTagName('input');
      for(e=0;e<allE.length;e++)
        {
         if(allE[e].type=='submit')
          {
           allE[e].onclick=CustomerDataForm_fillSubject;
          }
        }
      }
  }
}
// private function, chooses one of the two forms. totally destroys the unused form.
function CustomerDataForm_toggle(){
if(d('rdWhatAddress').checked){d('mailform_0').style.display='';d('mailform_1').style.display='none';d('mailform_2').style.display='none';d('mailform_1').innerHTML='';d('mailform_2').innerHTML='';d('rdWhatName').style.display='none';d('rdWhatBoth').style.display='none';d('spWhatName').style.display='none';d('spWhatBoth').style.display='none';d('mailform_0').id='mailform';d('mailform_1').name='';d('mailform_2').name='';d('mailform_1').id='';d('mailform_2').id='';try{d('mailform_1').outerHTML='';d('mailform_2').outerHTML='';}catch(error){}}
if(d('rdWhatName').checked){d('mailform_1').style.display='';d('mailform_0').style.display='none';d('mailform_2').style.display='none';d('mailform_0').innerHTML='';d('mailform_2').innerHTML='';d('rdWhatAddress').style.display='none';d('rdWhatBoth').style.display='none';d('spWhatAddress').style.display='none';d('spWhatBoth').style.display='none';d('mailform_1').id='mailform';d('mailform_0').name='';d('mailform_2').name='';d('mailform_0').id='';d('mailform_2').id='';try{d('mailform_0').outerHTML='';d('mailform_2').outerHTML='';}catch(error){}}
if(d('rdWhatBoth').checked){d('mailform_2').style.display='';d('mailform_0').style.display='none';d('mailform_1').style.display='none';d('mailform_0').innerHTML='';d('mailform_1').innerHTML='';d('rdWhatAddress').style.display='none';d('rdWhatName').style.display='none';d('spWhatAddress').style.display='none';d('spWhatName').style.display='none';d('mailform_2').id='mailform';d('mailform_0').name='';d('mailform_1').name='';d('mailform_0').id='';d('mailform_1').id='';try{d('mailform_0').outerHTML='';d('mailform_1').outerHTML='';}catch(error){}}
}
// private function for transferring the "kundennummer" into the hidden subject field on submission
function CustomerDataForm_fillSubject(){
  d('mailformsubject').value+=' '+d('mailformkundennummer').value;
  return true;
}

//correct layout of checkboxes and radio buttons
function correctInputLayout(){
var allInps=document.getElementsByTagName('input');
for(var i=0;i<allInps.length;i++)
  {
   if(allInps[i].type=='radio'|| allInps[i].type=='checkbox')
    {
     allInps[i].style.border='none';
     allInps[i].style.backgroundColor='transparent';
    }
  }

}
clib_onload('window.setTimeout("correctInputLayout()",500)');

// restyle the Vienna Filialen page
function restyleVienna(re){
var list=getElementsByClass('ul','csc-menu csc-menu-1')[0]; // get filial list
var lis=list.getElementsByTagName('li'); // remove list item graphic from list elements
for(var i=0;i<lis.length;i++){lis[i].style.listStyleType='none';}
var as=list.getElementsByTagName('a'); // remove target from links
for(i=0;i<as.length;i++){as[i].target='';}
if(!re&&isIE55up){window.setTimeout("restyleVienna(true);",1000);} // sometimes IE bugs around
}
if(location.href.indexOf('/wien.html')!=-1){clib_onload("restyleVienna()");}
