<!--@author andiriad-->

$(document).ready(
function(){
sizeLoader();
styleLoader();
printPreview();
searchfield(suggestioninput, "Suchbegriff...");
$("#contact").slideBox({width: "100%", height: "205px", position: "top"});   
$("#commentForm").validate(); 
$.datepicker.setDefaults($.datepicker.regional[datepickerregion]);
$("#Anreise").datepicker({showOn: 'both', buttonImage: 'images/calendar.png', buttonImageOnly: true});
$("#Abreise").datepicker({showOn: 'both', buttonImage: 'images/calendar.png', buttonImageOnly: true});
$("#logo *, .andiriadlogo *, #barrierefrei *, #search *").tooltip({showURL: false});
var $tabs = $("#featured").tabs({fx:{opacity: "toggle", duration: "slow"}}).tabs("rotate", 8000, true); 
     $(".ui-tabs-panel").each(function(i){
              var Size = $(".ui-tabs-panel").size();
              if (i != Size) {
                  next = i + 2;
                  $(this).append("<a href='#' class='next-tab mover' rel='" + next + "'><img src=\"images/arrow_next_right.png\" alt=\"next\" title=\"next\" width=\"20\" height=\"25\" /></a>");
              }
              if (i != 0) {
                  prev = i;
                  $(this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'><img src=\"images/arrow_next_left.png\" alt=\"previous\" title=\"previous\" width=\"20\" height=\"25\" /></a>");
              }
            });
            $('.next-tab, .prev-tab').click(function() { 
                   $tabs.tabs('select', $(this).attr("rel"));
                   return false;
             });

         preinput('#newsletterpreinput');
         preinput('#Anreise');
         preinput('#Abreise');

function preinput(id) { 
$(id).focus(function(){
        var defaultVal = $(this).attr('title');
        if($(this).val() == defaultVal)
            $(this).val('');
    });
    $(id).blur(function(){
        var defaultVal = $(this).attr('title');
        if($(this).val() == '')
            $(this).val(defaultVal);
    });
    $(id).trigger('blur');    
}             
});


Cufon.replace('.navmainStandardLevel_1', { fontFamily: 'Futura Lt BT', hover: true, fontSize: 20 });
Cufon.replace('.smallheadline', { fontFamily: 'Futura Lt BT', fontSize: 20, color: '#d9b569' });
Cufon.replace('.smallheadline.shlarge', { fontFamily: 'Futura Lt BT', fontSize: 26, color: '#d9b569' });
Cufon.replace('.smallheadline.shmedium', { fontFamily: 'Futura Lt BT', fontSize: 22, color: '#d9b569' });
Cufon.replace('.content-bottom-top-left', { fontFamily: 'Futura Lt BT' });   
Cufon.replace('h2', { fontFamily: 'Futura Lt BT', fontSize: 30 });
Cufon.replace('.angebot', { fontFamily: 'Futura Lt BT', fontSize: 15 });


function closewebReader()
{ document.getElementById('closewebReader').innerHTML = '<a href="javascript:closebr(1), closeClose();">Vorlesen lassen beenden</a>'; }
function closeClose()
{ document.getElementById('closewebReader').innerHTML = ''; }
 

<!--Cookie Reader-->
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;
}
<!--Cookie Reader end-->

<!--Print-->
function setPrintPreview (wert)
{
  createCookie("print", wert);
}

function getPrintPreview ()
{
   var wert = readCookie ('print');
   return wert;
}

function printPreview() 
{ 
      var wert = getPrintPreview(); 
      var lastknownstyle = readCookie("style");
     
      if (wert == 'true') 
         { 
           setPrintPreview('false');
           setActiveStyleSheet('printpreview'); return false; 
           createCookie ("style", 'lastknownstyle', '10');
         }
      else if (lastknownstyle == 'printpreview')
         {
           setActiveStyleSheet('default'); return false; 
           createCookie ("style", 'default', '10');
         }
}
<!--Print end-->

<!--Fontsizer-->
classarray=['container-center', 'fontsizer', 'content-bottom-below-right'];

function smallFontSize() {
     for(var i=0; i<classarray.length; i++)
     {
     document.getElementById(classarray[i]).className = 'small';
     }  
     //Werden keine days mitübergeben, bleibt das Cookie bis zum Ende der Session aktiv
     createCookie("size", "small", "10");
}

function normalFontSize() {
     for(var i=0; i<classarray.length; i++)
     {
     document.getElementById(classarray[i]).className = 'normal';
     }  
     createCookie("size", "normal", "10");
}

function largeFontSize() {
     for(var i=0; i<classarray.length; i++)
     {
     document.getElementById(classarray[i]).className = 'large';
     }  
     createCookie("size", "large", "10");  
}

function sizeLoader()
{
     if(document.cookie)
     {
     var wert = readCookie('size');
     if(wert == 'small')
     { smallFontSize();}
     else if(wert == 'normal')
     { normalFontSize(); }
     else if (wert == 'large')
     { largeFontSize(); }
     else {normalFontSize();}
     } //if Ende
}
<!--Fontsizer end-->

<!--Styleswitcher-->
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}


<!--changed by andiriad-->
  function styleLoader(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

<!--Styleswitcher end-->


<!--Readspeaker-->
function readpage(br_url,br_post) {
  brcall=escape(br_url);
  br_player="<table style='border:1px solid #aeaeae;'><tr><td>"+"<object type='application/x-shockwave-flash'  classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' height='20' width='250'><param name='movie' value='http://media.readspeaker.com/flash/rplayerpro.swf?mp3="+brcall+"&bgcolor=FFFFFF&autoplay=1'><param name='quality' value='high'><param name='SCALE' value='exactfit'><param name='wmode' value='transparent'><embed wmode='transparent' src='http://media.readspeaker.com/flash/rplayerpro.swf?mp3="+brcall+"&autoplay=1' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwaveflash' autostart='true' scale='exactfit' height='20' width='250'></embed></object>";
  br_html="<br><span style='font-size: 10px; font-face: verdana,arial;'><a target='rs' href='"+br_url+"'>Play mp3</a> | Speech-enabled by <a target='rs' href='http://www.readspeaker.com'>ReadSpeaker</a></span>";
  br_html+="<br><span style='font-size: 10px; font-face: verdana,arial;'><a href='"+br_url+"&save=1"+"'>Save mp3</a></span></td>";
  ad_html="<tr><td colspan='2'><a href='http://app.readspeaker.com/adserver/adserver.php?cid=7506UCM9CJBU0JU3VXFGRWT6D6W1RPEP&t=2&l=de_de&c=18&r=AT&p=200' target='_blank'><img border=0 src='http://app.readspeaker.com/adserver/adserver.php?cid=7506UCM9CJBU0JU3VXFGRWT6D6W1RPEP&t=1&l=de_de&c=18&r=AT&p=200'></td></tr>";
  c_html="<td style='vertical-align: top;' ><a href='javascript:closebr("+br_post+");'><img id='closebr' src='http://media.readspeaker.com/images/webreader/close.gif' border=0 alt='x'></a></td></tr>";
  if (br_post!='') {
    WR="WR_"+br_post;
  }
  else {
    WR="WR";
  }
  var x=document.getElementById(WR);
  if (x) {
    x.innerHTML=br_player+br_html+c_html+ad_html+"</table>";
  }
}

function closebr(br_post) {
  if (br_post!='') {
    WR="WR_"+br_post;
  }
  else {
    WR="WR";
  }
  var x=document.getElementById(WR);
  if (x) {
    x.innerHTML="";
  }
}
<!--Readspeaker end-->

<!--Fastinit-->
var FastInit = {
    onload : function() {
        if (FastInit.done) { return; }
        FastInit.done = true;
        for(var x = 0, al = FastInit.f.length; x < al; x++) {
            FastInit.f[x]();
        }
    },
    addOnLoad : function() {
        var a = arguments;
        for(var x = 0, al = a.length; x < al; x++) {
            if(typeof a[x] === 'function') {
                if (FastInit.done ) {
                    a[x]();
                } else {
                    FastInit.f.push(a[x]);
                }
            }
        }
    },
    listen : function() {
        if (/WebKit|khtml/i.test(navigator.userAgent)) {
            FastInit.timer = setInterval(function() {
                if (/loaded|complete/.test(document.readyState)) {
                    clearInterval(FastInit.timer);
                    delete FastInit.timer;
                    FastInit.onload();
                }}, 10);
        } else if (document.addEventListener) {
            document.addEventListener('DOMContentLoaded', FastInit.onload, false);
        } else if(!FastInit.iew32) {
            if(window.addEventListener) {
                window.addEventListener('load', FastInit.onload, false);
            } else if (window.attachEvent) {
                return window.attachEvent('onload', FastInit.onload);
            }
        }
    },
    f:[],done:false,timer:null,iew32:false
};
/*@cc_on @*/
/*@if (@_win32)
FastInit.iew32 = true;
document.write('<script id="__ie_onload" defer src="' + ((location.protocol == 'https:') ? '//0' : 'javascript:void(0)') + '"><\/script>');
document.getElementById('__ie_onload').onreadystatechange = function(){if (this.readyState == 'complete') { FastInit.onload(); }};
/*@end @*/
FastInit.listen();
<!--Fastinit end-->

<!--Searchfield-->
/* 

    SearchField 
    written by Alen Grakalic, provided by Css Globe (cssglobe.com)
    please visit http://cssglobe.com/post/1202/style-your-websites-search-field-with-jscss/ for more info

    changed by Andiriad 
*/

searchfield = function(suggestioninput, defaultText){
    
    // CONFIG 
    
    // this is id of the search field you want to add this script to. 
    // You can use your own id just make sure that it matches the search field in your html file.
    var id = "searchterm";
    
    // Text you want to set as a default value of your search field.
    //var defaultText = "Seite durchsuchen..";  
    
    // set to either true or false
    // when set to true it will generate search suggestions list for search field based on content of variable below
    var suggestion = true;
    
    // static list of suggestion options, separated by comma
    // replace with your own
    var suggestionText = suggestioninput; 
    
    // END CONFIG (do not edit below this line, well unless you really, really want to change something :) )
    
    // Peace, 
    // Alen

    var field = document.getElementById(id);    
    var classInactive = "sf_inactive";
    var classActive = "sf_active";
    var classText = "sf_text";
    var classSuggestion = "sf_suggestion";
    this.safari = ((parseInt(navigator.productSub)>=20020000)&&(navigator.vendor.indexOf("Apple Computer")!=-1));
    if(field){
        field.value = defaultText;
        field.c = field.className;      
        field.className = field.c + " " + classInactive;
        field.onfocus = function(){
            this.className = this.c + " "  + classActive;
            this.value = (this.value == "" || this.value == defaultText) ?  "" : this.value;
        };
        field.onblur = function(){
            this.className = (this.value != "" && this.value != defaultText) ? this.c + " " +  classText : this.c + " " +  classInactive;
            this.value = (this.value != "" && this.value != defaultText) ?  this.value : defaultText;
            clearList();
        };
        if (suggestion){
            
            var selectedIndex = 0;
                        
            field.setAttribute("autocomplete", "off");
            var div = document.createElement("div");
            var list = document.createElement("ul");
            list.style.display = "none";
            div.className = classSuggestion;
            list.style.width = field.offsetWidth + "px";
            div.appendChild(list);
            field.parentNode.appendChild(div);  

            field.onkeypress = function(e){
                
                var key = getKeyCode(e);
        
                if(key == 13){ // enter
                    selectList();
                    selectedIndex = 0;
                    return false;
                };  
            };
                
            field.onkeyup = function(e){
            
                var key = getKeyCode(e);
        
                switch(key){
                case 13:
                    return false;
                    break;          
                case 27:  // esc
                    field.value = "";
                    selectedIndex = 0;
                    clearList();
                    break;              
                case 38: // up
                    navList("up");
                    break;
                case 40: // down
                    navList("down");        
                    break;
                default:
                    startList();            
                    break;
                };
            };
            
            this.startList = function(){
                var arr = getListItems(field.value);
                if(field.value.length > 0){
                    createList(arr);
                } else {
                    clearList();
                };  
            };
            
            this.getListItems = function(value){
                var arr = new Array();
                var src = suggestionText;
                var src = src.replace(/, /g, ",");
                var arrSrc = src.split(",");
                for(i=0;i<arrSrc.length;i++){
                    if(arrSrc[i].substring(0,value.length).toLowerCase() == value.toLowerCase()){
                        arr.push(arrSrc[i]);
                    };
                };              
                return arr;
            };
            
            this.createList = function(arr){                
                resetList();            
                if(arr.length > 0) {
                    for(i=0;i<arr.length;i++){              
                        li = document.createElement("li");
                        a = document.createElement("a");
                        a.href = "javascript:void(0);";
                        a.i = i+1;
                        a.innerHTML = arr[i];
                        li.i = i+1;
                        li.onmouseover = function(){
                            navListItem(this.i);
                        };
                        a.onmousedown = function(){
                            selectedIndex = this.i;
                            selectList(this.i);     
                            return false;
                        };                  
                        li.appendChild(a);
                        list.setAttribute("tabindex", "-1");
                        list.appendChild(li);   
                    };  
                    list.style.display = "block";               
                } else {
                    clearList();
                };
            };  
            
            this.resetList = function(){
                var li = list.getElementsByTagName("li");
                var len = li.length;
                for(var i=0;i<len;i++){
                    list.removeChild(li[0]);
                };
            };
            
            this.navList = function(dir){           
                selectedIndex += (dir == "down") ? 1 : -1;
                li = list.getElementsByTagName("li");
                if (selectedIndex < 1) selectedIndex =  li.length;
                if (selectedIndex > li.length) selectedIndex =  1;
                navListItem(selectedIndex);
            };
            
            this.navListItem = function(index){ 
                selectedIndex = index;
                li = list.getElementsByTagName("li");
                for(var i=0;i<li.length;i++){
                    li[i].className = (i==(selectedIndex-1)) ? "selected" : "";
                };
            };
            
            this.selectList = function(){
                li = list.getElementsByTagName("li");   
                a = li[selectedIndex-1].getElementsByTagName("a")[0];
                field.value = a.innerHTML;
                clearList();
            };          
            
        };
    };
    
    this.clearList = function(){
        if(list){
            list.style.display = "none";
            selectedIndex = 0;
        };
    };      
    this.getKeyCode = function(e){
        var code;
        if (!e) var e = window.event;
        if (e.keyCode) code = e.keyCode;
        return code;
    };
    
};

// script initiates on page load. 

//this.addEvent = function(obj,type,fn){
//  if(obj.attachEvent){
//      obj['e'+type+fn] = fn;
//      obj[type+fn] = function(){obj['e'+type+fn](window.event );}
//      obj.attachEvent('on'+type, obj[type+fn]);
//  } else {
//      obj.addEventListener(type,fn,false);
//  };
//};
//addEvent(window,"load",searchfield);
<!--Searchfield end-->
