var hTimer = null;

$(document).ready(function() {
  // $('div#logo').bind("mouseenter",function(){
    // $('div#logo').slideUp("slow", function(){
      // hTimer = window.setTimeout(function(){$('div#logo').slideDown('slow');}, 3000);
    // });
  // });
  // $('div#logo').mouseover(function(){
    // if (hTimer != null){
      // window.clearTimeout(hTimer);
      // hTimer = null;
    // }
  // });
  // $('div#logo').mouseout(function(){
    // hTimer = window.setTimeout(function(){$('div#logo').slideUp('slow');}, 3000);
  // });
  
  $('div#logo').mouseenter(function() {
	$('div#close_logo').fadeIn('slow');
});
$('div#logo').mouseleave(function() {
	$('div#close_logo').fadeOut('slow');
});
  
  $("#archiv_start").datepicker({ maxDate: '+0D', dateFormat: 'yy-mm-dd' });
  $("#archiv_stop").datepicker({ maxDate: '+0D', dateFormat: 'yy-mm-dd' });
});

function showArchiv() {
	var x = document.getElementById('archiv_start').value;
	var y = document.getElementById('archiv_stop').value;
	self.location.href = '/blog.php/archiv/'+x+'/'+y;
}
function showGutschein(Code, URL, Hash) {
	Iframe = true;
	var allElements = document.getElementsByTagName('iframe');
	var element;
	for (var i=0; (element = allElements[i]) != null; i++) {
		if (element.src == URL) Iframe = false;
	}
	document.getElementById('gts'+Hash).innerHTML = 'Gutscheincode: <a href="'+URL+'"><b>'+Code+'</b></a>';
	if (Iframe == true) document.getElementById('gtw'+Hash).innerHTML += 'Seitenvorschau: &nbsp; <img src="/img/receipt-export.png" /> <a href="'+URL+'" target="_blank">Seite in neuem Fenster öffnen</a><br /><iframe src="'+URL+'"></iframe><br /><img src="/img/cross-small.png" /><a href="javascript:void(0)" onclick="document.getElementById(\'gtw'+Hash+'\').innerHTML=\'\'">Vorschaufenster schließen</a>';

}
function show_percent() {
	var Amount = document.getElementById('percent_amount').value.replace(/,/, '.')*100;
	var Percent = document.getElementById('percent_per').value.replace(/,/, '.');
	var Sum = 0;
	if (Amount > 0 && Percent > 0) {
		Sum = Math.round(Amount - (Amount * Percent / 100)) / 100;
		if (Sum > 0) document.getElementById('percent_sum').innerHTML = '<b>'+Sum.toFixed(2).replace(/\./, ',')+'</b>';
		else document.getElementById('percent_sum').innerHTML = '...';
	} else document.getElementById('percent_sum').innerHTML = '...';
}

function close_cookie() {
	document.getElementById('logo').style.visibility='hidden';
	var ablauf = new Date();
	var infuenfTagen = ablauf.getTime() + (7 * 24 * 60 * 60 * 1000);
	ablauf.setTime(infuenfTagen);
	document.cookie = "logo_hide=true; expires=" + ablauf.toGMTString() + ",path=/;domain=empfehlungdestages.de";
}
