var Print = { init: function() { }, addPrintButton: function(){ $('
').appendTo('div[@id=print_btm]'); }, removePrintButton: function(){ $('div[@class=printButtons]').remove(); }, disabled: [], added: [], swithToPrintLayout: function(){ window.switchLayout = false; var s = document.getElementsByTagName('style'); var l = document.getElementsByTagName('link'); var a = []; for ( var i = 0; i < s.length; i++ ) a[a.length] = s[i]; for ( var i = 0; i < l.length; i++ ) if (l[i].rel.indexOf("stylesheet") >= 0) a[a.length] = l[i]; for ( var i = 0; i < a.length; i++ ) { if (a[i].media == "print") { var o = a[i].cloneNode(false); o.media = "screen"; this.added[this.added.length] = o; a[i].parentNode.insertBefore(o, a[i]); } if (!a[i].disabled && a[i].media != "print") { a[i].disabled = true; this.disabled[this.disabled.length] = a[i]; } } this.addPrintButton(); }, swithToNormalLayout: function(){ window.switchLayout = true; for ( var i = 0; i < this.disabled.length; i++ ) this.disabled[i].disabled = false; for ( var i = 0; i < this.added.length; i++ ) { this.added[i].disabled = true; this.added[i].parentNode.removeChild(this.added[i]); } this.disabled = []; this.added = []; this.removePrintButton(); } }; Print.init();