// browser type

function getBrowserType() {
   // returns browserType:
   // N3 = Nescape Navigator >3
   // M4 = Mircosoft IExplorer >4
   // NN = browser unknown

   var browserVer=parseInt(navigator.appVersion);
   var browserType=navigator.appName;
   var browser = "NN";

   if (browserType == "Netscape" && browserVer >= 3) browser = "N3";
   if ((browserType.indexOf("Microsoft") != -1) && browserVer >= 4 ) browser = "M4";
   return browser;

}


function isMacIe() {
   // returns browserType:
   // N3 = Nescape Navigator >3
   // M4 = Mircosoft IExplorer >4
   // NN = browser unknown


   var is = false;

   if (navigator.userAgent.indexOf("Mac") != -1) {
      if (navigator.appName.indexOf("Microsoft") != -1) {

         is = true;
      }
   }
   return is;
}





// layer functions ////////////////////////////////////////////////////////

// init visibility
var vista = new Array();


function toggleDisplay(id) {

   vista[id] = (document.getElementById(id).style.display == 'none') ? 'block' : 'none';
   document.getElementById(id).style.display = vista[id];

}

function toggleInversDisplay(id) {
   vista[id] = (document.getElementById(id).style.display == 'block') ? 'none' : 'block';
   document.getElementById(id).style.display = vista[id];

}


function toggleVisibility(id) {

   vista[id] = (document.getElementById(id).style.visibility == 'hidden') ? 'visible' : 'hidden';
   document.getElementById(id).style.visibility = vista[id];



}

function toggleInversVisibility(id) {
   if(document.getElementById(id)) {
      vista[id] = (document.getElementById(id).style.visibility == 'visible' || document.getElementById(id).style.visibility == 'inherit' ) ?  'hidden' : 'visible';
      document.getElementById(id).style.visibility = vista[id];
   }

}




// form functions ///////////////////////////////////////////////

function selectRadio(elemId, index) {

   document.getElementsByName(elemId)[index].checked = true;


}

function selectCheckbox(elemId) {

   elem = document.getElementById(elemId);
   if(elem.checked == true) {
      elem.checked = false;
   }else {
      elem.checked = true;

   }

}


function deselectCheckbox(elemId) {

   elem = document.getElementById(elemId);
   
   if(elem.checked == true) {
      elem.checked = false;
   }

}


// naviation functions ////////////////////////////////////////

function loadPageUri(uri) {

   window.location = uri;

}



// highlight functions ////////////////////////////////////////


function highlightNav(id, event, page) {

   src = document.getElementById(id).src;

   if(event == 'over') {
      basename = src.substring(0,src.lastIndexOf('-'));
      document.getElementById(id).src = basename + '_hi.gif';
      //alert(document.getElementById(id).src);
   }

   if(event == 'out') {
      basename = src.substring(0,src.lastIndexOf('_'));
      document.getElementById(id).src = basename + '-' + page + '_norm.jpg';
      //alert(document.getElementById(id).src);
   }

}


function highlightButtonName(name, event) {

   elems = document.getElementsByName(name);

   for(i=0; i < elems.length; i++) {
      elem = elems[i];
      src = elem.src;

      basename = src.substring(0,src.lastIndexOf('_'));

      //basename = src.substring(src.lastIndexOf('/'));

      if(event == 'over') {
         elem.src = basename + '_hi.gif';
         //alert(document.getElementById(id).src);
      }

      if(event == 'out') {
         elem.src = basename + '_norm.gif';
      }

   }

}

function highlightLink(id, event) {

   elem = document.getElementById(id);

   if(event == 'over') {
      elem.style.textDecoration = 'underline';
   }

   if(event == 'out') {
      elem.style.textDecoration = '';
   }

}


function highlightLinkName(name, event) {

   elems = document.getElementsByName(name);

   for(i=0; i < elems.length; i++) {
      elem = elems[i];

      if(event == 'over') {
         elem.style.textDecoration = 'underline';
      }

      if(event == 'out') {
         elem.style.textDecoration = '';
      }

   }

}


var oldColor = '';
function highlightLinkColor(id, event) {

   elem = document.getElementById(id);

   if(event == 'over') {
      oldColor = elem.style.color;
      elem.style.color = '#222222';
      elem.style.textDecoration = 'underline';
   }

   if(event == 'out') {
      elem.style.color = oldColor;
      elem.style.textDecoration = '';
   }

}


function highlightImage(id, event) {

   src = document.getElementById(id).src;
   basename = src.substring(0,src.lastIndexOf('_'));
   ext = src.substring(src.lastIndexOf('.'),src.length);


   if(event == 'over') {
      document.getElementById(id).src = basename + '_hi' + ext;
      //alert(document.getElementById(id).src);
   }

   if(event == 'out') {
      document.getElementById(id).src = basename + '_norm'  + ext;
   }

}

// nav ///////////////////////////////////////////////


function navHighlightImage(id, event) {
   //alert(id);

   if( id != nav1_activeNavId) {

      var navElemId = 'nav1_' + id + '_img';
      //      alert(navElemId);

      src = document.getElementById(navElemId).src;
      basename = src.substring(0,src.lastIndexOf('_'));

      //basename = src.substring(src.lastIndexOf('/'));

      if(event == 'over') {
         document.getElementById(navElemId).src = basename + '_hi.gif';
         //alert(document.getElementById(id).src);
      }

      if(event == 'out') {
         document.getElementById(navElemId).src = basename + '_norm.gif';
      }

   }


} // closes navHighlight


var nav3_bgColors = Array();
var nav3_colors = Array();

nav3_colors['z2'] = Array();
nav3_colors['z2']['over'] = '#586380';
nav3_colors['z2']['out']  = '#FFFFFF';
nav3_bgColors['z2'] = Array();
nav3_bgColors['z2']['over'] = '#E4F7AB';
nav3_bgColors['z2']['out']  = '#A8C844';

nav3_colors['z3'] = Array();
nav3_colors['z3']['over'] = '#586380';
nav3_colors['z3']['out']  = '#FFFFFF';
nav3_bgColors['z3'] = Array();
nav3_bgColors['z3']['over'] = '#BCC4DF';
nav3_bgColors['z3']['out']  = '#A8B0CB';



var nav4_bgColors = Array();
var nav4_colors = Array();

nav4_colors['z2'] = Array();
nav4_colors['z2']['over'] = '#586380';
nav4_colors['z2']['out']  = '#526711';
nav4_bgColors['z2'] = Array();
nav4_bgColors['z2']['over'] = '#E4F7AB';
nav4_bgColors['z2']['out']  = '#C1E15D';

nav4_colors['z3'] = Array();
nav4_colors['z3']['over'] = '#586380';
nav4_colors['z3']['out']  = '#6B7387';
nav4_bgColors['z3'] = Array();
nav4_bgColors['z3']['over'] = '#BCC4DF';
nav4_bgColors['z3']['out']  = '#C6CAD7';



var shop_bgColors = Array();
var shop_colors = Array();

shop_colors = Array();
shop_colors['over'] = '#FFFFFF';
shop_colors['out']  = '#0066B3';
shop_bgColors = Array();
shop_bgColors['over'] = '#0066B3';
shop_bgColors['out']  = '#CDE4FB';


var seminare_bgColors = Array();
var seminare_colors = Array();

seminare_colors = Array();
seminare_colors['over'] = '#FFFFFF';
seminare_colors['out']  = '#535A72';
seminare_bgColors = Array();
seminare_bgColors['over'] = '#BCC4DF';
seminare_bgColors['out']  = '#A8B0CB';


var netzwerk_bgColors = Array();
var netzwerk_colors = Array();

netzwerk_colors = Array();
netzwerk_colors['over'] = '#005CA1';
netzwerk_colors['out']  = '#FFFFFF';
netzwerk_bgColors = Array();
netzwerk_bgColors['over'] = '#DBECFD';
netzwerk_bgColors['out']  = '#4886C9';




function nav3HighlightItem(id, event) {


   //   alert (colors[nav1_activeNavId][event]);

   if( id != nav3_activeNavId) {

      var item = document.getElementById(id);
      var imgsrc = document.getElementById(id+'_img').src;
      var basename = imgsrc.substring(0,imgsrc.lastIndexOf('_'));


      document.getElementById(id).style.backgroundColor = nav3_bgColors[nav1_activeNavId][event];
      document.getElementById(id+'_link').style.color = nav3_colors[nav1_activeNavId][event];


      if(event == 'over') {
         document.getElementById(id+'_img').src = basename + '_hi.gif';
         //alert(document.getElementById(id).src);
      }

      if(event == 'out') {
         document.getElementById(id+'_img').src = basename + '_norm.gif';
      }



   }

}



function nav4HighlightItem(id, event) {


   //   alert (colors[nav1_activeNavId][event]);

   if( id != nav3_activeNavId) {

      var item = document.getElementById(id);
      var imgsrc = document.getElementById(id+'_img').src;
      var basename = imgsrc.substring(0,imgsrc.lastIndexOf('_'));

      document.getElementById(id).style.backgroundColor = nav4_bgColors[nav1_activeNavId][event];
      document.getElementById(id+'_link').style.color = nav4_colors[nav1_activeNavId][event];

      if(event == 'over') {
         //         document.getElementById(id).style.backgroundColor = '#BCC4DF';
         //         document.getElementById(id+'_link').style.color = '#FFFFFF';
         document.getElementById(id+'_img').src = basename + '_hi.gif';
         //alert(document.getElementById(id+'_img').src);
      }

      if(event == 'out') {
         //         document.getElementById(id).style.backgroundColor = '#C6CAD7';
         //         document.getElementById(id+'_link').style.color = '#6B7387';
         document.getElementById(id+'_img').src = basename + '_norm.gif';
      }



   }

}



function shopnavHighlightItem(id,event) {

   //alert(id);

   //alert (shop_bgColors[event]);
   //alert (shop_bgColors[event]);

   if( id != nav3_activeNavId) {

      var item = document.getElementById(id);
      var imgsrc = document.getElementById(id+'_img').src;
      var basename = imgsrc.substring(0,imgsrc.lastIndexOf('_'));


      document.getElementById(id).style.backgroundColor = shop_bgColors[event];
      document.getElementById(id+'_link').style.color = shop_colors[event];


      if(event == 'over') {
         document.getElementById(id+'_img').src = basename + '_hi.gif';
         //alert(document.getElementById(id).src);
      }

      if(event == 'out') {
         document.getElementById(id+'_img').src = basename + '_norm.gif';
      }



   }

}


function netzwerknavHighlightItem(id,event) {

   //alert(id);

   //alert (shop_bgColors[event]);
   //alert (shop_bgColors[event]);

   if( id != nav3_activeNavId) {

      var item = document.getElementById(id);
      var imgsrc = document.getElementById(id+'_img').src;
      var basename = imgsrc.substring(0,imgsrc.lastIndexOf('_'));


      document.getElementById(id).style.backgroundColor = netzwerk_bgColors[event];
      document.getElementById(id+'_link').style.color = netzwerk_colors[event];


      if(event == 'over') {
         document.getElementById(id+'_img').src = basename + '_hi.gif';
         //alert(document.getElementById(id).src);
      }

      if(event == 'out') {
         document.getElementById(id+'_img').src = basename + '_norm.gif';
      }



   }

}




function seminarnavHighlightItem(id,event) {

   //alert(id);

   //alert (shop_bgColors[event]);
   //alert (shop_bgColors[event]);

   if( id != nav3_activeNavId) {

      var item = document.getElementById(id);
      //var imgsrc = document.getElementById(id+'_img').src;
      //var basename = imgsrc.substring(0,imgsrc.lastIndexOf('_'));

      document.getElementById(id).style.backgroundColor = seminare_bgColors[event];

      //document.getElementById(id+'_link').style.color = seminare_colors[event];
      if(document.getElementById(id+'_termin')) {
         document.getElementById(id+'_termin').style.color = seminare_colors[event];
      }


      if(event == 'over') {
         //document.getElementById(id+'_img').src = basename + '_hi.gif';
         //alert(document.getElementById(id).src);
      }

      if(event == 'out') {
         //document.getElementById(id+'_img').src = basename + '_norm.gif';
      }



   }

}





function highlightHomenav(id, event) {

   highlightImage('homenav_' + id, event);


   var homeEinblickImgs = Array();

   homeEinblickImgs['z1'] = '/cms_forumschule_inter/bilder/global/home_einblick_z1.gif';
   homeEinblickImgs['z2'] = '/cms_forumschule_inter/bilder/global/home_einblick_z2.jpg';
   homeEinblickImgs['z3'] = '/cms_forumschule_inter/bilder/global/home_einblick_z3.jpg';

   if(event == 'over') {
      document.getElementById('homeEinblickImg').src = homeEinblickImgs[id];
      //      alert(document.getElementById('homeEinblickImg').src);
   }

   if(event == 'out') {
      document.getElementById('homeEinblickImg').src = '/cms_forumschule_inter/bilder/global/home_einblick_titel.jpg';
   }


}



function formFocus(id) {

   document.getElementById(id).style.backgroundColor = '#FFFFFF';

}

function formFocus2(id) {

   document.getElementById(id).style.backgroundColor = '#DBECFD';

}


function formFocus3(id) {

   document.getElementById(id).style.backgroundColor = '#CDE4FB';

}



// selectnav ///////////////////////////////////////////////


function selectnav(pagenum) {

   if(selectnavCurrent >0 ) {
      document.getElementById('selectnav'+selectnavCurrent).style.visibility = 'hidden';

   }

   selectnavCurrent = pagenum;
   document.getElementById('selectnav'+pagenum).style.visibility = 'visible';

}


// popup functions
var popupnum = 0;

function popupSizedCentered(location, width, height) {

   popupnum++;
   LeftPosition = (screen.width) ? (screen.width-width)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-height)/2 : 0;

   if(window.screenLeft) {
      LeftPosition  = LeftPosition + window.screenLeft
   }

   ref = window.open(location, 'lewpopup'+popupnum, "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width="+width+",height="+height+",top="+TopPosition+",left="+LeftPosition);

   ref.focus();

   //return false;

}



function popupAGB(location) {

   popupSizedCentered(location, 400,650);
   
}


function shopLieferung() {

   deselectCheckbox('feAbholung');
   
}

function shopAbholung() {

   deselectCheckbox('feLieferadresse');
   
}


function shopFormFocus(id) {

   document.getElementById(id).style.backgroundColor = '#FFFFFF';

}

function shopFormFocus2(id) {

   document.getElementById(id).style.backgroundColor = '#CDE4FB';

}




function z3FormFocus(id) {

   document.getElementById(id).style.backgroundColor = '#FFFFFF';

}

function z3FormFocus2(id) {

   document.getElementById(id).style.backgroundColor = '#EEEFF5';

}
