if(window.location.hostname){
	var COOKIE_NAME = 'ageVerified';
	$go = $.cookie(COOKIE_NAME);
	var url = window.location.pathname;
	var urlfull = window.location.href;
	var verify = "/altersabfrage/";
/*
*/

	if ($go == null && url != verify) {
		$.cookie('redir', urlfull,{ path: '/', _domain: window.location.hostname});
		window.location.href = verify;
	}
	function grantAccess(){
		var redir = $.cookie('redir');
		if(redir == verify || redir == null){
			redir = '/';
		}
		$.cookie('redir', null);
		$.cookie('ageVerified', 'yes',{ path: '/', _domain: window.location.hostname});
		window.location.href = redir;
	};
	}
/*------------------------------------------------*/
function fbs_click(){
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
/*------------------------------------------------*/

var t = document.title;
//tt = t.split("– Verrückt nach Leben");
tt = t.split("- Verrückt nach Leben");
//tt = t.split("Verrückt nach Leben");
t=tt[0];
function titlebar(val){
	var msg  = "Verrückt nach Leben";
	var speed = 100;
	var pos = val;

	msg = ""+msg+"";
	var le = msg.length;
		if(pos < le){
		pos = pos+1;
		s = msg.substr(0,pos);
		document.title = t + s;
		timer = window.setTimeout("titlebar("+pos+")",speed);
		}
}
//titlebar(-5);
/*------------------------------------------------*/

var pos = 2;
function titleFun(){
//	var spacer = " »";
	var spacer = " -";
	var time_length = 2000;
	var msg = "Verrückt nach Leben";
/*
	document.title = t + msg.substring(pos, msg.length) + spacer + msg.substring(0, pos);
	pos++;
	if (pos > msg.length) pos=0;
	window.setTimeout("titleFun()",time_length);
*/
/*
	*/
//	if (pos == 2){	pos=0;	p1=" ";	p2="«";	} else {p1="";	p2=" «";}
	if (pos == 2){	pos=0;	p1=" ";	p2="«";	} else {p1="";	p2=" «";}
	document.title = t + spacer + p1 + msg + p2;
	pos++;
	window.setTimeout("titleFun()",time_length);
}
titleFun();

/*------------------------------------------------*/
$(function() {
	$(".box_shadow_abs").each(function() {
		if(!$(this).hasClass('no')){
			var p = $(this).parent().find('.teaser_pic');
			if(p.length == 0){p = $(this).parent().find('.box_size');}
			if ($(this).css('width') == "0px" || $(this).css('width') == "3px") $(this).css('width',p.width()+'px');
			if ($(this).css('height') == "0px" || $(this).css('height') == "3px" || $(this).css('height') == "17px") $(this).css('height',p.height()+'px');
			if(p.css('bottom') == "0px"){
				if ( $.browser.msie && parseInt($.browser.version) == 7) {
					$(this).css('bottom','-3px');
				}
			}
		}
	});
});
/*------------------------------------------------*/
$(function() {
	//$("#left_nav").hide();
//	$(".small_nav_teaser").each(function() {
	$("#left_nav > div").each(function() {
		var id = $(this).attr("id");
		if(id == "home_icon"){$('#home_icon').show();return;}
		var clone = $(this).clone();
			$(this).css({'top':$(this).position().top * 0.2,
						'left':$(this).position().left * 0.2});
			$(this).addClass("left_nav_small_teaser");
			var a = $(this).find('.teaser_pic');
			a.css('margin','1px');
			var b = $(this).find('.teaser_pic img');
			b.css({	'width': parseInt(b.width() * 0.2)+'px', 
					'height': parseInt(b.height() * 0.2)+'px'});

//			if(p.length == 0){p = $(this).find('.box_size');}
			var p = $(this).find('.box_shadow_abs');
			p.removeClass('box_shadow_abs');
			p.addClass('box_white_abs');
			p.css({'border':'1px solid #ffffff', 
					'top':parseInt(p.position().top * 0.2)+'px', 
					'width':parseInt(p.width() * 0.2)+'px', 
					'height':parseInt(p.height() * 0.2)+'px'});

			var p = $(this).find('.teaser_text_w');
			if(p.length){
				p.css({'font-size':2.2+'px',
					'line-height':2.5+'px',
					'width':p.width() * 0.2,
					'top':p.position().top * 0.2,
					'left':p.position().left * 0.2});
				if($(this).parent().hasClass('small_nav_teaser')){return;}
			}
			var p = $(this).find('.teaser_text_b');
			if(p.length){
			p.css({'font-size':2.2+'px',
					'line-height':2.5+'px',
					'width':p.width() * 0.2,
					'top':p.position().top * 0.2,
					'left':p.position().left * 0.2});
			}
			//$(this).find('.frost').removeClass('frost');


			if($(this).hasClass('notactive') || $(this).hasClass('frostblueactive')){
				$(this).find('a').removeAttr("href");
				//$(this).find('.frosty').css('cursor','default');

			}else{
				$(this).hover(
					function() {
						$('.wrapper').find('.left_nav_big_teaser').hide();
						$("#" + id + "_big").show();
					},
					function(){
					}
				);
			}
		$("#left_nav").css({"visibility":"visible"});
		//clone.removeClass("small_nav_teaser");
		clone.addClass("left_nav_big_teaser");
		clone.removeClass("frostblueactive");
		clone.attr("id", id+"_big");
		clone.css({"z-index":'2000',
					'cursor':'pointer',
					'position':'absolute',
					'top':$(this).position().top,
					'left':$(this).position().left
		});
		var ins = clone.prependTo($(this).parent());
		ins.click(
			function(e) {

				var attr = $(this).find("a").attr('target');
				if (typeof attr !== 'undefined' && attr !== false) {
					// ...
				} else {
					e.preventDefault();
					var u = $(this).find("a").attr("href");
					window.location.href=u;
				}
			}
		);
		ins.hover(
			function() {},function(){$(this).hide();}
		);

		ins.hide();
	});
});

/*------------------------------------------------*/
$(function() {
	var frosty_div = '<div class="frosty" style="overflow:hidden;"><img class="frosty_iefix" src="/wp-content/themes/aperol/img/frosty.png" width="309" height="315" border="0" alt=""></div>';
	var frostyblue_div = '<div class="frosty" style="overflow:hidden;margin:1px"><img class="frostyblue_iefix" src="/wp-content/themes/aperol/img/frosty_blue.png" border="0" alt=""></div>';

	function makeFrost(me,p,dd){
			p.find('.frosty').remove();
			//p.prepend('<div class="frosty" style="overflow:hidden;"><img class="frosty_iefix" src="/wp-content/themes/aperol/img/frosty.png" width="309" height="315" border="0" alt=""></div>');
			p.prepend(dd);
			var getfrom = me;
			var f = p.find('.frosty');
			if(p.find('.frostsize').length){
				getfrom = p.find('.frostsize');
			}
			if($(getfrom).css('top') != "auto"){
				f.css('top',$(getfrom).css('top'));
			}
			if($(getfrom).css('bottom') == "0px" || $(getfrom).css('bottom') == "-3px"){
				f.css('bottom',$(getfrom).css('bottom'));
			}
			f.css('width',$(getfrom).width());
			f.css('height',$(getfrom).height());
			//f.find('img').css('width',$(getfrom).width());
			//f.find('img').css('height',$(getfrom).height());
/*
	if(!p.hasClass('frostactive')){
			var a = $('<a/>').attr('href', p.find("a").attr("href"));
			p.find('.frosty > img').wrap(a);
	} else {
		p.css('cursor','default');
		p.find('.frosty').css('cursor','default');
	}
*/

	if(p.hasClass('frostactive') || p.hasClass('frostblueactive')){
		p.find('a').removeAttr("href");
		p.css('cursor','default');
		p.find('.frosty').css('cursor','default');
	} else {
			var a = $('<a/>').attr('href', p.find("a").attr("href"));
			var tar = p.find("a").attr("target");
			p.find('.frosty > img').wrap(a);
			if(tar){
				p.find('.frosty a').attr('target', tar);
			}
	}



			/*f.click(
				function() {
					var u = p.find("a").attr("href");
					window.location.href=u;
				}
			);*/
	};
/*------------------------------------------------*/
	$(".frostactive").each(function() {
		//$(this).hover(function() {},function(){}	);
		makeFrost($(this).find('.frost'),$(this),frosty_div);
	});

	$(".frostblueactive").each(function() {
		makeFrost($(this).find('.frost'),$(this),frostyblue_div);
	});

	$("body").hover(
		function() {
			//$(this).find('.frosty').remove();
			$(".wrapper").find('.frostover').stop().remove();
			$(this).find('.left_nav_big_teaser').hide();
		}
	);
/*------------------------------------------------*/
	$(".frost").hover(
		function() {
		//return;
			if($(this).parent().hasClass('small_nav_teaser')){return;}
			if($(this).parent().hasClass('left_nav_small_teaser')){return;}
			if($(this).parent().hasClass('frostactive')){
				//.removeAttr("href");
				return;
			}
			//$("body").find('.frostover').remove();
			$("body").find('.frostover').stop().fadeOut(200);
			var p = $(this).parent();
		makeFrost($(this),p,frosty_div);
			var f = $(this).parent().find('.frosty');
			f.addClass('frostover');
			f.hide();
			f.fadeIn('slow');
			/*f.click(
				function() {
					var u = $(this).parent().find("a").attr("href");
					window.location.href=u;
				}
			);*/
			f.mouseout(
				function() {
					$(this).stop().fadeOut(200, function(){$(this).remove();});
				}
			);
			/*var i = $(this).parent().find('.teaser_pic');
			i.mouseout(
				function() {
					$(this).parent().find('.frosty').fadeOut(200, function(){$(this).remove();});
				}
			);*/
		},
		function(){
			//$("#frost").remove();
		}
	);
});

/*------------------------------------------------*/
$(function() {
/*
	$('#social-bar').hover(function() {
		$(this).removeClass("social-bar-clip");
		$(this).stop().animate({'width' : '238px'}, 200);
		var fb = '<iframe src="http://www.facebook.com/plugins/likebox.php?href=http%3A%2F%2Fwww.facebook.com%2Faperol.de&amp;width=200&amp;colorscheme=light&amp;show_faces=true&amp;border_color&amp;stream=false&amp;header=false&amp;height=300" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:200px; height:300px;" allowTransparency="true"></iframe>';
		$('.social-bar-item-content').html(fb);

		var timg_Facebook_Button = new Image();
		timg_Facebook_Button.src = "http://ad3.adfarm1.adition.com/track?tid=4121&sid=9794&type=image&orderid=&itemno=&descr=&quantity=&price=0.00&total=0.00";

	}, function(){
		$(this).stop().animate({'width' : '38px'}, 200, function() {$(this).addClass("social-bar-clip")});
	});
*/
	jQuery.fn.centerV = function () {
		//this.css("position","absolute");
//		this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
		var topY = (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() - 105;
		if(topY<10){topY=10;}
//		this.css("margin-top", topY + "px");
		this.css("top", topY + "px");
		//this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
		return this;
	}
	jQuery.fn.centerH = function () {
		var w = (($(window).width() - this.outerWidth()) / 2);
		//alert(w);
		if(w<220){
			w=220;
		}
		this.css("margin-left", w + "px");
//		this.css("left", w + "px");
		return this;
	}

	function centerIT(){
		$('.content_home').centerV();
		$('.content_holder_sub').centerH();
		//$('.content_sub').centerV();
	}

	if($('#contentwidth').width()){
		var w=$('#contentwidth').width();
		$('.content_sub').css('width', w + "px");
		$('.content_holder_sub').css('width', w + "px");
	}

	$(window).resize(function() {
	  centerIT();
	});
	centerIT();
	$('#left_nav').show();

//	$('#ft_teaser_2').css('left',$('#ft_teaser_1 .footer_teaser').width() + 10 + "px");

//alert($('.content_sub').width());
//alert($('.content_holder_sub').width());

});

/*------------------------------------------------*/
function showVideoJS(m,w,h,id){
	var t = "nonver";//flow|nonver
	var out="";
	out+="\n"+'<video id="'+id+'" class="video-js" width="'+w+'" height="'+h+'" controls preload autoplay poster="'+m+'.png">';
	out+="\n"+'<source src="'+m+'.mp4" type=\'video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"\' />';

    out+="\n"+'  <object id="flash_fallback_1" class="vjs-flash-fallback" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" data="/wp-content/themes/aperol/img/NonverBlaster.swf">';
    out+="\n"+'    <param name="movie" value="/wp-content/themes/aperol/img/NonverBlaster.swf" />';
    out+="\n"+'    <param name="flashvars" value=\'videoURL='+m+'.mp4&teaserURL='+m+'.png&allowSmoothing=true&autoplay=false&buffer=3&showTimecode=true&loop=false&controlColour=0xffffff&scaleIfFullScreen=true&showScalingButton=true\' />';

	out+="\n"+'    <param name="allowfullscreen" value="true" />';
    out+="\n"+'    <img src="'+m+'.png" width="'+w+'" height="'+h+'" alt="Poster Image" title="No video playback capabilities." />';
    out+="\n"+'  </object>';
    out+="\n"+'</video>';
	document.write(out);
}

/*------------------------------------------------*/
$(function(){
	$.fn.supersized.options = {  
		startwidth: 1255,  
		startheight: 876,
		minsize: .5
	};
	$('#supersize').supersized(); 
});

/*------------------------------------------------*/
function isValidDateF(d) {
  if ( Object.prototype.toString.call(d) !== "[object Date]" )
    return false;
  return !isNaN(d.getTime());
}

function isValidDate(s) {
    // format D(D)/M(M)/(YY)YY

    var dateFormat = /^\d{1,4}[\.|\/|-]\d{1,2}[\.|\/|-]\d{1,4}$/;

    if (dateFormat.test(s)) {
        s = s.replace(/0*(\d*)/gi,"$1");
        var dateArray = s.split(/[\.|\/|-]/);

		if (dateArray[1] < 1 || dateArray[1] > 12) {
			return false;
		}
		if (dateArray[0] < 1 || dateArray[0] > 31) {
			return false;
		}

		if ((dateArray[1]==4 || dateArray[1]==6 || dateArray[1]==9 || dateArray[1]==11) && dateArray[0]==31) {
			return false
		}

        dateArray[1] = dateArray[1]-1;

        if (dateArray[2].length<4) {
            dateArray[2] = (parseInt(dateArray[2]) < 50) ? 2000 + parseInt(dateArray[2]) : 1900 + parseInt(dateArray[2]);
        }

        var testDate = new Date(dateArray[2], dateArray[1], dateArray[0]);
        if (testDate.getDate()!=dateArray[0] || testDate.getMonth()!=dateArray[1] || testDate.getFullYear()!=dateArray[2]) {
            return false;
        } else {
            return true;
        }
    } else {
        return false;
    }
}/*------------------------------------------------*/

function launchWindow(id,t) {
	$('.window .close, .window.close').click(function () {
		$('#mask').hide();
		$('.window').hide();
	});		
	
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});



	$('body').append($('#mask'));
	$('body').append($('#boxes'));
	$('#modaltext').html(t);

		var maskHeight = $(window).height();
		var maskWidth = $(window).width();
	
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//$('#mask').fadeIn(1000);	
		$('#mask').stop().fadeTo(300,0.3);	
	
		var winH = $(window).height();
		var winW = $(window).width();
              
		$(id).css('top',  winH/2-$(id).height());
		$(id).css('left', winW/2-$(id).width()/2);
	
		$(id).stop().fadeIn(500); 
	
	$(window).resize(function() {
		$('#mask').css({'width':$(window).width(),'height':$(window).height()});
	});

}

function track_facebook(){
	var timg_Facebook_Button = new Image();
	timg_Facebook_Button.src = "http://ad3.adfarm1.adition.com/track?tid=4121&sid=9794&type=image&orderid=&itemno=&descr=&quantity=&price=0.00&total=0.00";
	return true;
}




