var setstyled = false;

var stripe = function() {
var tables = document.getElementsByTagName("table");  
for(var x=0;x!=tables.length;x++){
	var table = tables[x];
    if (! table) { return; }
		var tbodies = table.getElementsByTagName("tbody");
		for (var h = 0; h < tbodies.length; h++) {
			var even = true;
			var trs = tbodies[h].getElementsByTagName("tr");
			for (var i = 0; i < trs.length; i++) {
				trs[i].onmouseover=function() {
					this.className += " ruled"; return false
				}
				trs[i].onmouseout=function() {
					this.className = this.className.replace("ruled", ""); return false
				}
				if(even)
					trs[i].className += " even";
			   if(!even)
					trs[i].className += " odd";
				even = !even;
			}
		}
	}
}

window.onload = stripe;

$(document).ready(function() {
	$("div.news-list-item:odd").addClass("odd");
	$("div.news-list-item:even").addClass("even");
	
	$("span.styledtags:odd").addClass("odd");
    $("span.styledtags:even").addClass("even");
	
	$("span.styledtags p:odd").addClass("odd");
    $("span.styledtags p:even").addClass("even");
  
    $("span.styledtags p:last-child").addClass("last");
    
    $(".ui-icon-info").mouseover(function() {
  		$('.preisInfoText').css("display","table");
	});
    $(".ui-icon-info").mouseout(function() {
  		$('.preisInfoText').css("display","none");
	});

	$(function(){
		if(setstyled)
			$('select.styled').customStyle();
	});

	chkFormBuchungstool();
  
});

function chkFormBuchungstool() {
		$('.tx-fbfuehrungsform-pi2 .mailformSubmit.step1').click(function() {
			var tmpUhrzeit = $('#uhrzeit_stunde').val() + ':' + $('#uhrzeit_minute').val();
			$('#uhrzeit').val( tmpUhrzeit );
		});
		$('.tx-fbfuehrungsform-pi1 .mailformSubmit.step1').click(function() {
			var tmpUhrzeit = $('#uhrzeit_stunde').val() + ':' + $('#uhrzeit_minute').val();
			$('#uhrzeit').val( tmpUhrzeit );
		});
}

(function($) {
  $.fn.fullBg = function(){
    var bgImg = $(this);
    
    bgImg.addClass('fullBg');
    
    function resizeImg() {
      var imgwidth = bgImg.width();
      var imgheight = bgImg.height();
      
      var winwidth = $(window).width();
      var winheight = $(window).height();
      
      var widthratio = winwidth / imgwidth;
      var heightratio = winheight / imgheight;
      
      var widthdiff = heightratio * imgwidth;
      var heightdiff = widthratio * imgheight;
    
      if(heightdiff>winheight) {
        bgImg.css({
          width: winwidth+'px',
          height: heightdiff+'px'
        });
      } else {
        bgImg.css({
          width: widthdiff+'px',
          height: winheight+'px'
        });   
      }
    } 
    resizeImg();
    $(window).resize(function() {
      resizeImg();
    }); 
  };
})(jQuery)

jQuery(function($) {
  $("#bgarea").fullBg();
});

function setbreite(breite){
   if (navigator.appName == "Microsoft Internet Explorer") { 
    document.getElementById("mailformangebot").style.width = breite;
  }
}

jQuery(document).ready( function() {


jQuery('map#flensburgfjord, map#flensburgfjord *').click(function(){
  jQuery.cookie('flensburgfjord_de', 'lang=set', { path: '/', expires: 30 });
  return true;
});

if(!jQuery.cookie('flensburgfjord_de')){
  //openBox();
}


});

function openBox()
{
  jQuery('body').css('overflow', 'hidden');
  jQuery('#overlayer').show();
}


jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};


