﻿function css() {
	
	$('.link-print').bind('click',function(){ window.print(); });
	
    $('#content .page').jScrollPane({
    	showArrows: true,
    	reinitialiseOnImageLoad: true,
        verticalDragMinHeight: 34,
        verticalDragMaxHeight: 34,
        horizontalDragMinWidth: 20,
        horizontalDragMaxWidth: 20
    });	
}

function ie() {
	/* go on for IE in generall */
	if($.browser.msie){
		
		if($.browser.version <= 7) {
			/* take care IE 7 & lower */
		
			$('input').ieClass('type');
			$('table + table').addClass('sib');
		
		}
		if($.browser.version <= 8) {
			/* take care IE 8 & lower */
				
			$('div:last-child, li:last-child, td:last-child').addClass('last-child');
			$('tr:odd').addClass('odd');
			$('tr:even').addClass('even');
					
		
			function beforePrint(){
				$('nav, footer ul, aside').wrap('<div class="hide"></div>');
				$('header').wrap('<div class="header"></div>');
				$('aside').wrap('<div class="aside"></div>');
				$('article').wrap('<div class="article"></div>');
				$('footer').wrap('<div class="footer"></div>');
				
			}
			function afterPrint(){
				$('nav, footer ul, aside').unwrap();
				$('header, aside, article, footer, .mod-frm').unwrap();
			}
			
			window.attachEvent('onbeforeprint', beforePrint);
			window.attachEvent('onafterprint', afterPrint);
		}
	}
	
}

	/* 
	 * Load HTML5 IE set 
	 * before DOM is ready
	 */
if($.browser.msie){
	var html5Set = "abbr,article,aside,nav,canvas,footer,header,section,time,mark,figure,figcaption".split(','),i=html5Set.length;
	while (i--){
		document.createElement(html5Set[i])
	}
}

	/* 
	 * Load jQuery sets
	 */
$(document).ready(css);
$(document).ready(ie);


	/* 
	 * jQuery extras
	 */
$.fn.extend({
	ieClass: function(ieAttr) {
		return this.each(function(){
			$(this).addClass($(this).attr(ieAttr));
		});
	}, // ieClass	
	unwrap: function() {
		this.parent(':not(body)').each(function(){
			$(this).replaceWith( this.childNodes );
		});
		return this;
	}, // unwrap
	iePseudoElem: function(type,html) {
		return this.each(function(){
			htmlElem = type == 'after' ? document.createElement('after') : document.createElement('before');
				
			$(htmlElem).html(html);
			if(type == 'after')
				$(this).append(htmlElem);
			else
				$(this).prepend(htmlElem);
		});
	} // iePseudoElem
});	

