/*
GLOBAL FUNCTIONS 
**********************************************/
// include the javascript 'f' on the webpage
function js(f) {
  document.write('<script type="text/javascript" src="'+ f + '"></s' + 'cript>'); 
}
//console.log without breaking IE
/*
log_debug = function() {
  if(window.console && window.console.firebug) console.log.apply(this, arguments);
}
*/
//Allow only numbers in an input-field
function isNumberKey(evt){
	var charCode = (evt.which) ? evt.which : event.keyCode
	if ((charCode > 47 && charCode < 58) || (charCode > 95 && charCode < 106) || (charCode == 8) || (charCode == 9) || (charCode == 12) || (charCode == 27) || (charCode == 37) || (charCode == 38) || (charCode == 39) || (charCode == 46)){
		return true;
	}
	return false;
}

/*
INCLUDES
**********************************************/
// specify which javascripts to include on the webpage
//js('/files/javascript/jquery.hoverIntent.minified.js');
//js('/files/javascript/jquery.form.js');
//js('/files/javascript/jquery.flash.js');
//js('/files/javascript/jquery.jfeed.js');

/*
ON LOAD
*********************************************/
// jQuery 'onReady' script - runs when the document have been loaded, but before images
$(function(){
	getCatalogue();
	
	footerReposition();
});

// popup a box with link to the newest catalogue and a adobe reader download link
function getCatalogue(){
	//$('<a id="newCataloguestar" href="http://www.albertknudsen.dk/files/Katalog%202009%20-%202010.pdf" title="Hent det nye katalog"><img src="/images/new_catalogue_star.gif" alt="nyt katalog"/></a>').appendTo('.framemain');
	
	$('#newCataloguestar').fadeOut('fast',function(){
		$(this).fadeIn('fast',function(){
			$(this).fadeOut('fast',function(){
				$(this).fadeIn('fast',function(){
					$(this).fadeOut('fast',function(){
						$(this).fadeIn('fast');
					});
				});
			});
		});
	});
	$('#newCataloguestar').click(function(){
		$this = $(this);
		$this.blur();
		var strTop = ($this.offset().top + 50) + 'px';
		var strLeft = ($this.offset().left - 10) + 'px';
		var cataloguePopup = '<div id="cataloguePopup" style="top: ' + strTop + '; left: ' + strLeft + ';"><p><a href="' + $this.attr('href') + '">Download kataloget</a></p><p>Har du ikke Adobe Reader, kan du downloade den her: <a href="http://get.adobe.com/dk/reader" target="_blank">http://get.adobe.com/dk/reader</a></p></div>';
		
		$(cataloguePopup).appendTo('body').fadeIn();
		
		$(document).one('click',function(){
			$('#cataloguePopup').fadeOut('fast',function(){ $(this).remove(); });
		});
		
		return false;
	});
}

// attach footer to the bottom of the viewport
function footerReposition(){
	$('#footer').appendTo('body').css({
		bottom: 0,
		left: 0,
		margin: 0,
		padding: '12px 0 2px',
		position: 'fixed',
		width: '100%',
		height: 'auto'
	});
	$('body').css('padding-bottom','30px');
}
