function setCookie(c_name,value,expiredays)
{
	var exdate=new Date()
	exdate.setDate(exdate.getDate()+expiredays)
	document.cookie=c_name+ "=" + escape(value) + ((expiredays==null) ? "" : ";expires=" + exdate.toGMTString())
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=")
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
			return unescape(document.cookie.substring(c_start,c_end))
		}
	}
	return ""
}

// thickbox
var tb_pathToImage = "/images/loadingAnimation.gif";
var TB_SlideShowTimeout = 5000;
var e4e_lang='cz';
if(e4e_lang=='cz')
{
	var txtClose = "Zavřít";
	var txtEsc = "nebo stiskněte ESC";
	var txtPrev = "&lt; Předchozí";
	var txtNext = "Následující &gt;";
	var txtImage = "Obrázek";
	var txtOf = "z";
	var txtSlideShowStart = "Spustit slideshow";
	var txtSlideShowStop = "Zastavit slideshow";
} else if(e4e_lang=='sk') {
	var txtClose = "Zavriet";
	var txtEsc = "lebo stisknete ESC";
	var txtPrev = "&lt; Predošlé";
	var txtNext = "Následujůce &gt;";
	var txtImage = "Obrázok";
	var txtOf = "z";
	var txtSlideShowStart = "Start slideshow";
	var txtSlideShowStop = "Stop slideshow";
} else {
	var txtClose = "Close";
	var txtEsc = "or Esc key";
	var txtPrev = "&lt; Prev";
	var txtNext = "Next &gt;";
	var txtImage = "Image";
	var txtOf = "of";
	var txtSlideShowStart = "Start slideshow";
	var txtSlideShowStop = "Stop slideshow";
}
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('5 v=p;5 18=\'\';5 19=\'\';5 1u=\'\';$(o).2H(9(){1Q();1v(\'a.V, 2I.V, 2J.V\');1w=1x 1R();1w.O=2K});9 1Q(){$(\'a\').2L(9(){5 a=J.q;5 b=/\\.1g$|\\.1h$|\\.1i$|\\.1j$|\\.1k$/;5 c=a.1l().1y(b);3(c==\'.1g\'||c==\'.1h\'||c==\'.1i\'||c==\'.1j\'||c==\'.1k\'){$(J).2M(\'V\').1z(\'V\')}})}9 1v(b){$(b).r(9(){5 t=J.W||J.1A||P;5 a=J.q||J.1S;5 g=J.1T||p;v=p;1a(t,a,g);J.2N();G p})}9 1U(){3(v===p){v=Q;$(\'#1m\').R(\'<a q="#">\'+1V+\'</a>\');1W(1B,1X)}n{v=p;$(\'#1m\').R(\'<a q="#">\'+1Y+\'</a>\')}G p}9 1B(){3(v===Q){$("#8").B();$("z").s("<4 6=\'8\'></4>");1a(18,19,1u)}}9 1a(d,f,g){2O{3(1Z o.z.K.20==="21"){$("z","R").A({D:"22%",C:"22%"});$("R").A("23","2P");3(o.24("1C")===P){$("z").s("<X 6=\'1C\'></X><4 6=\'E\'></4><4 6=\'8\'></4>");$("#E").r(L)}}n{3(o.24("E")===P){$("z").s("<4 6=\'E\'></4><4 6=\'8\'></4>");$("#E").r(L)}}3(25()){$("#E").1z("2Q")}n{$("#E").1z("2R")}3(d===P){d=""}$("z").s("<4 6=\'M\'><26 O=\'"+1w.O+"\' /></4>");$(\'#M\').2S();5 h;3(f.S("?")!==-1){h=f.2T(0,f.S("?"))}n{h=f}5 i=/\\.1g$|\\.1h$|\\.1i$|\\.1j$|\\.1k$/;5 j=h.1l().1y(i);3(j==\'.1g\'||j==\'.1h\'||j==\'.1i\'||j==\'.1j\'||j==\'.1k\'){1D="";1E="";1b="";18="";19="";T="";1F="";1G=p;28=\'\';1n=\'\';3(g){1u=g;H=$("a[1T="+g+"]").2U();2a(F=0;((F<H.1o)&&(T===""));F++){5 k=H[F].q.1l().1y(i);3(!(H[F].q==f)){3(1G){18=H[F].W;19=H[F].q;T="<Y 6=\'2b\'>&1p;&1p;<a q=\'#\'>"+2V+"</a></Y>"}n{1D=H[F].W;1E=H[F].q;1b="<Y 6=\'2c\'>&1p;&1p;<a q=\'#\'>"+2W+"</a></Y>"}}n{1G=Q;1F=2X+" "+(F+1)+" "+2Y+" "+(H.1o)}}3(T==""){v=p}n{28=g;1n=\'<Y 6="1m"><a q="#">\'+(v?1V:1Y)+\'</a></Y>\'}}Z=1x 1R();Z.1q=9(){Z.1q=P;5 a=2d();5 x=a[0]-2e;5 y=a[1]-2e;5 b=Z.C;5 c=Z.D;3(b>x){c=c*(x/b);b=x;3(c>y){b=b*(y/c);c=y}}n 3(c>y){b=b*(y/c);c=y;3(b>x){c=c*(x/b);b=x}}1c=b+30;1r=c+2Z;$("#8").s("<a q=\'\' 6=\'2f\' W=\'"+11+"\'><26 6=\'31\' O=\'"+f+"\' C=\'"+b+"\' D=\'"+c+"\' 1S=\'"+d+"\'/></a>"+"<4 6=\'32\'>"+d+"<4 6=\'33\'>"+1F+1b+T+\'<34 />\'+1n+"</4></4><4 6=\'35\'><a q=\'#\' 6=\'12\' W=\'"+11+"\'>"+11+"</a> "+1H+"</4>");$("#12").r(L);3(!(1b==="")){9 1d(){v=p;3($(o).U("r",1d)){$(o).U("r",1d)}$("#8").B();$("z").s("<4 6=\'8\'></4>");1a(1D,1E,g);G p}$("#2c").r(1d)}3(!(T==="")){9 1I(){v=p;$("#8").B();$("z").s("<4 6=\'8\'></4>");1a(18,19,g);G p}$("#2b").r(1I)}3(!(1n==="")){$("#1m").r(1U)}o.1s=9(e){3(e==P){N=2g.2h}n{N=e.2i}3(N==27){L()}n 3(N==36){3(!(T=="")){o.1s="";1I()}}n 3(N==37){3(!(1b=="")){o.1s="";1d()}}};1e();$("#M").B();$("#2f").r(L);$("#8").A({13:"14"})};Z.O=f;3(v===Q){1W(1B,1X)}}n{5 l=f.2j(/^[^\\?]+\\??/,\'\');5 m=2k(l);1c=(m[\'C\']*1)+30||38;1r=(m[\'D\']*1)+39||3a;15=1c-30;16=1r-3b;3(f.S(\'2l\')!=-1){1J=f.1K(\'3c\');$("#1f").B();3(m[\'1L\']!="Q"){$("#8").s("<4 6=\'2m\'><4 6=\'1M\'>"+d+"</4><4 6=\'2n\'><a q=\'#\' 6=\'12\' W=\'"+11+"\'>"+11+"</a> "+1H+"</4></4><X 2o=\'0\' 2p=\'0\' O=\'"+1J[0]+"\' 6=\'1f\' 1A=\'1f"+1t.2q(1t.1N()*2r)+"\' 1q=\'1O()\' K=\'C:"+(15+29)+"u;D:"+(16+17)+"u;\' > </X>")}n{$("#E").U();$("#8").s("<X 2o=\'0\' 2p=\'0\' O=\'"+1J[0]+"\' 6=\'1f\' 1A=\'1f"+1t.2q(1t.1N()*2r)+"\' 1q=\'1O()\' K=\'C:"+(15+29)+"u;D:"+(16+17)+"u;\'> </X>")}}n{3($("#8").A("13")!="14"){3(m[\'1L\']!="Q"){$("#8").s("<4 6=\'2m\'><4 6=\'1M\'>"+d+"</4><4 6=\'2n\'><a q=\'#\' 6=\'12\'>"+11+"</a> "+1H+"</4></4><4 6=\'I\' K=\'C:"+15+"u;D:"+16+"u\'></4>")}n{$("#E").U();$("#8").s("<4 6=\'I\' 3d=\'3e\' K=\'C:"+15+"u;D:"+16+"u;\'></4>")}}n{$("#I")[0].K.C=15+"u";$("#I")[0].K.D=16+"u";$("#I")[0].3f=0;$("#1M").R(d)}}$("#12").r(L);3(f.S(\'3g\')!=-1){$("#I").s($(\'#\'+m[\'2s\']).2t());$("#8").2u(9(){$(\'#\'+m[\'2s\']).s($("#I").2t())});1e();$("#M").B();$("#8").A({13:"14"})}n 3(f.S(\'2l\')!=-1){1e();3($.1P.3h){$("#M").B();$("#8").A({13:"14"})}}n{$("#I").3i(f+="&1N="+(1x 3j().3k()),9(){1e();$("#M").B();1v("#I a.V");$("#8").A({13:"14"})})}}3(!m[\'1L\']){o.2v=9(e){3(e==P){N=2g.2h}n{N=e.2i}3(N==27){L()}}}}3l(e){}}9 1O(){$("#M").B();$("#8").A({13:"14"})}9 L(){v=p;$("#3m").U("r");$("#12").U("r");$("#8").3n("3o",9(){$(\'#8,#E,#1C\').3p("2u").U().B()});$("#M").B();3(1Z o.z.K.20=="21"){$("z","R").A({D:"2w",C:"2w"});$("R").A("23","")}o.1s="";o.2v="";G p}9 1e(){$("#8").A({3q:\'-\'+2x((1c/2),10)+\'u\',C:1c+\'u\'});3(!(2y.1P.3r&&2y.1P.3s<7)){$("#8").A({3t:\'-\'+2x((1r/2),10)+\'u\'})}}9 2k(a){5 b={};3(!a){G b}5 c=a.1K(/[;&]/);2a(5 i=0;i<c.1o;i++){5 d=c[i].1K(\'=\');3(!d||d.1o!=2){3u}5 e=2z(d[0]);5 f=2z(d[1]);f=f.2j(/\\+/g,\' \');b[e]=f}G b}9 2d(){5 a=o.3v;5 w=2A.2B||2C.2B||(a&&a.2D)||o.z.2D;5 h=2A.2E||2C.2E||(a&&a.2F)||o.z.2F;2G=[w,h];G 2G}9 25(){5 a=3w.3x.1l();3(a.S(\'3y\')!=-1&&a.S(\'3z\')!=-1){G Q}}',62,222,'|||if|div|var|id||TB_window|function||||||||||||||else|document|false|href|click|append||px|TB_SlideShow||||body|css|remove|width|height|TB_overlay|TB_Counter|return|TB_TempArray|TB_ajaxContent|this|style|tb_remove|TB_load|keycode|src|null|true|html|indexOf|TB_NextHTML|unbind|thickbox|title|iframe|span|imgPreloader||txtClose|TB_closeWindowButton|display|block|ajaxContentW|ajaxContentH||TB_NextCaption|TB_NextURL|tb_show|TB_PrevHTML|TB_WIDTH|goPrev|tb_position|TB_iframeContent|jpg|jpeg|png|gif|bmp|toLowerCase|TB_slideshow|TB_SlideShowHTML|length|nbsp|onload|TB_HEIGHT|onkeydown|Math|imageGroup2|tb_init|imgLoader|new|match|addClass|name|slideShow|TB_HideSelect|TB_PrevCaption|TB_PrevURL|TB_imageCount|TB_FoundURL|txtEsc|goNext|urlNoQuery|split|modal|TB_ajaxWindowTitle|random|tb_showIframe|browser|tb_add_class|Image|alt|rel|startSlideShow|txtSlideShowStop|setTimeout|TB_SlideShowTimeout|txtSlideShowStart|typeof|maxHeight|undefined|100|overflow|getElementById|tb_detectMacXFF|img||TB_SlideShowGroup||for|TB_next|TB_prev|tb_getPageSize|150|TB_ImageOff|event|keyCode|which|replace|tb_parseQuery|TB_iframe|TB_title|TB_closeAjaxWindow|frameborder|hspace|round|1000|inlineId|children|unload|onkeyup|auto|parseInt|jQuery|unescape|window|innerWidth|self|clientWidth|innerHeight|clientHeight|arrayPageSize|ready|area|input|tb_pathToImage|each|removeClass|blur|try|hidden|TB_overlayMacFFBGHack|TB_overlayBG|show|substr|get|txtNext|txtPrev|txtImage|txtOf|70||TB_Image|TB_caption|TB_secondLine|br|TB_closeWindow|190|188|630|40|440|45|TB_|class|TB_modal|scrollTop|TB_inline|safari|load|Date|getTime|catch|TB_imageOff|fadeOut|fast|trigger|marginLeft|msie|version|marginTop|continue|documentElement|navigator|userAgent|mac|firefox'.split('|'),0,{}))

//Initial js functions to run when js document is loaded
checkBrowserWidth();

//Load when the page is ready - Using jQuery to run events
$(document).ready(function(){
$(window).resize(checkBrowserWidth);
$('div.roundbox').corner('round 9px');
$('div.anchor').corner('round bottom 9px');
$.tabs('container-1');
$.tabs('container-2');
$.tabs('container-3');
$.tabs('container-4');
$.tabs('container-5');
$.tabs('container-6');

$('#overviewBtn').click(function(){
		$('#overviewTitle').ScrollTo(800)
		if(document.getElementById('overview').style.display == "none"){$('#overview').slideDown(500);$('#toggleBtnOverview').html('-')};
		return false;
		});

$('#examplesBtn').click(function(){
		 $('#examplesTitle').ScrollTo(800);
		 if(document.getElementById('examples').style.display == "none"){$('#examples').slideDown(500);$('#toggleBtnExample').html('-')};
		 return false;
		 });

$('#qaBtn').click(function(){
	   $('#qaTitle').ScrollTo(800);
	   if(document.getElementById('qa').style.display == "none"){$('#qa').slideDown(500);$('#toggleBtnQa').html('-')};
	   return false;
	   });

$('#supportBtn').click(function(){
		$('#supportTitle').ScrollTo(800);
		if(document.getElementById('support').style.display == "none"){$('#support').slideDown(500);$('#toggleBtnSupport').html('-')};
		return false;
		});

$('#donateBtn').click(function(){
	   $('#donateTitle').ScrollTo(800);
	   if(document.getElementById('donate').style.display == "none"){$('#donate').slideDown(500);$('#toggleBtnDonate').html('-')};
	   return false;
	   });

$('.BTT').click(function(){$('#pageTop').ScrollTo(800);return false});

$(".toggleBtn").toggle(function(){
	if(document.getElementById(this.rel).style.display == "none"){$("#" + this.rel).slideDown(500);this.innerHTML = "-";return};
	this.innerHTML = "+";
	
    $("#" + this.rel).slideUp(500);
  },function(){
	 if(document.getElementById(this.rel).style.display == "block"){$("#" + this.rel).slideUp(500); this.innerHTML = "+";return};
	 this.innerHTML = "-";
    $("#" + this.rel).slideDown(500);
  });
}
);

function processyourTurnForm(data) {
	$("#formTurn").slideUp("slow")
	$(data.message).appendTo("#TB_ajaxContent")
}

///////////////////////////  ajax call to get code off the server for display dependent code ///////////////////////////////////////
function parseCode(o,placement){
	$.get(o,function(code){										  	   
		  code=code.replace(/&/mg,'&#38;');
		  code=code.replace(/</mg,'&#60;');
		  code=code.replace(/>/mg,'&#62;');
		  code=code.replace(/\"/mg,'&#34;');
		  code=code.replace(/\t/g,'  ');
		  code=code.replace(/\r?\n/g,'<br>');
		  code=code.replace(/<br><br>/g,'<br>');
		  code=code.replace(/ /g,'&nbsp;');
		 $('#'+placement).html(code);
	}
	);
 }


///////////////////////////  resolution dependent code ////////////////////////////////////////////////////////////////////////////////
function checkBrowserWidth(){
	var theWidth = getBrowserWidth();
	if (theWidth == 0){
		var resolutionCookie = document.cookie.match(/(^|;)tmib_res_layout[^;]*(;|$)/);

		if (resolutionCookie != null){
			setStylesheet(unescape(resolutionCookie[0].split("=")[1]));
			}
	
		$(document).load(checkBrowserWidth);
		return false;
	}

	if (theWidth > 900){
		setStylesheet("1024 x 768");
		document.cookie = "tmib_res_layout=" + escape("1024 x 768");
	}else{
		setStylesheet("");
		document.cookie = "tmib_res_layout=";
	}
	return true;
};




function getBrowserWidth(){
	if (window.innerWidth){
		return window.innerWidth;
	}else if (document.documentElement && document.documentElement.clientWidth != 0){
		return document.documentElement.clientWidth;}
	else if (document.body){
		return document.body.clientWidth;
	}
	return 0;
};




function setStylesheet(styleTitle){
	var currTag;

	if (document.getElementsByTagName){
		for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++){
			if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title")){
				currTag.disabled = true;
				if(currTag.getAttribute("title") == styleTitle){
					currTag.disabled = false;
				}
			}
		}
	}
	
	return true;
};

///////////////////////////  round corners jquery plugin ////////////////////////////////////////////////////////////////////////////////
$.fn.corner = function(o)
{
	o = o || "";
	var width = parseInt((o.match(/(\d+)px/)||[])[1]) || 10;
	var fx = (o.match(/round|bevel|fold|notch/)||["round"])[0];
	var opts = {
		TL:		/top|tl/i.test(o), 		TR:		/top|tr/i.test(o),
		BL:		/bottom|bl/i.test(o),	BR:		/bottom|br/i.test(o)//,
	};
	if ( !opts.TL && !opts.TR && !opts.BL && !opts.BR )
		opts = { TL:1, TR:1, BL:1, BR:1 };
	var strip = document.createElement("div");
	strip.style.overflow = "hidden";
	strip.style.height = "1px";
	strip.style.backgroundColor = "transparent";
	strip.style.borderStyle = "solid";
	return this.each(function(){
		var pad = {
			T: parseInt($.css(this,"paddingTop"))||0,
			R: parseInt($.css(this,"paddingRight"))||0,
			B: parseInt($.css(this,"paddingBottom"))||0,
			L: parseInt($.css(this,"paddingLeft"))||0
		};
		strip.style.borderColor = "#ffffff";
		if ( opts.TL || opts.TR ) {
			strip.style.borderStyle = "none "+(opts.TR?"solid":"none")+" none "+(opts.TL?"solid":"none");
			var t=document.createElement("div");
			t.style.margin = "-"+pad.T+"px -"+pad.R+"px "+(pad.T-width)+"px -"+pad.L+"px";
			t.style.backgroundColor = "transparent";
			for ( var i=0; i < width; i++ ) {
				var w = fx=="round" ? Math.round(width*(1-Math.cos(Math.asin(i/width)))) : i+1;
				var e = strip.cloneNode(false);
				e.style.borderWidth = "0 "+(opts.TR?w:0)+"px 0 "+(opts.TL?w:0)+"px";
				t.insertBefore(e, t.firstChild);
			}
			this.insertBefore(t, this.firstChild);
		}
		if ( opts.BL || opts.BR ) {
			strip.style.borderStyle = "none "+(opts.BR?"solid":"none")+" none "+(opts.BL?"solid":"none");
			var b=document.createElement("div");
			b.style.margin = (pad.B-width)+"px -"+pad.R+"px -"+pad.B+"px -"+pad.L+"px";
			b.style.backgroundColor = "transparent";
			for ( var i=0; i < width; i++ ) {
				var w = fx=="round" ? Math.round(width*(1-Math.cos(Math.asin(i/width)))) : i+1;
				var e = strip.cloneNode(false);
				e.style.borderWidth = "0 "+(opts.BR?w:0)+"px 0 "+(opts.BL?w:0)+"px";
				b.appendChild(e);
			}
			this.appendChild(b);
		}
	});
};

//////////////////// tabs jquery plugin ////////////////////////////////////////////////////////////////////////////
$.tabs = function(containerId, start) {
    var ON_CLASS = 'on';
    var id = '#' + containerId;
    var i = (typeof start == "number") ? start - 1 : -1;
    if(i == -1)
    {
    	var section = getCookie('section_'+containerId);
    	if(section != '')
    	{
    		tmp = section.split('-');
    		if(tmp[1] != 'undefined')
    		{
    			i = tmp[1] - 1;
    		}
    	}
    	else
    	{
    		i = 0;
    	}
    }
    $(id + '>div:eq(' + i + ')').css({display:"block"});
    $(id + '>ul>li:nth-child(' + (i+1) + ')').addClass(ON_CLASS);
    $(id + '>ul>li>a').click(function() {
        if (!$(this.parentNode).is('.' + ON_CLASS)) {
            var re = /([_\-\w]+$)/i;
            var target = $('#' + re.exec(this.href)[1]);
            if (target.size() > 0) {
                $(id + '>div:visible').css({display:"none"});
                target.css({display:"block"});
                $(id + '>ul>li').removeClass(ON_CLASS);
                $(this.parentNode).addClass(ON_CLASS);
                setCookie('section_'+containerId, target.attr('id'));
            } else {
                alert('There is no such container.');
            }
        }
        return false;
    });
};

//////////////////// Unobtrustive Code Highlighter By Dan Webb ////////////////////////////////////////////////////////////////////////////
var CodeHighlighter = { styleSets : new Array };

CodeHighlighter.addStyle = function(name, rules) {
	// using push test to disallow older browsers from adding styleSets
	if ([].push) this.styleSets.push({
		name : name, 
		rules : rules,
		ignoreCase : arguments[2] || false
	})
	
	function setEvent() {
		setTimeout('$(document).ready(function(){CodeHighlighter.init()})',1000)
	}
	
	// only set the event when the first style is added
	if (this.styleSets.length==1) setEvent();
}

CodeHighlighter.init = function() {
	if (!document.getElementsByTagName) return; 
	if ("a".replace(/a/, function() {return "b"}) != "b") return; // throw out Safari versions that don't support replace function
	// throw out older browsers
	
	var codeEls = document.getElementsByTagName("CODE");
	// collect array of all pre elements
	codeEls.filter = function(f) {
		var a =  new Array;
		for (var i = 0; i < this.length; i++) if (f(this[i])) a[a.length] = this[i];
		return a;
	} 
	
	var rules = new Array;
	rules.toString = function() {
		// joins regexes into one big parallel regex
		var exps = new Array;
		for (var i = 0; i < this.length; i++) exps.push(this[i].exp);
		return exps.join("|");
	}
	
	function addRule(className, rule) {
		// add a replace rule
		var exp = (typeof rule.exp != "string")?String(rule.exp).substr(1, String(rule.exp).length-2):rule.exp;
		// converts regex rules to strings and chops of the slashes
		rules.push({
			className : className,
			exp : "(" + exp + ")",
			length : (exp.match(/(^|[^\\])\([^?]/g) || "").length + 1, // number of subexps in rule
			replacement : rule.replacement || null 
		});
	}
	
	function parse(text, ignoreCase) {
		// main text parsing and replacement
		return text.replace(new RegExp(rules, (ignoreCase)?"gi":"g"), function() {
			var i = 0, j = 1, rule;
			while (rule = rules[i++]) {
				if (arguments[j]) {
					// if no custom replacement defined do the simple replacement
					if (!rule.replacement) return "<span class=\"" + rule.className + "\">" + arguments[0] + "</span>";
					else {
						// replace $0 with the className then do normal replaces
						var str = rule.replacement.replace("$0", rule.className);
						for (var k = 1; k <= rule.length - 1; k++) str = str.replace("$" + k, arguments[j + k]);
						return str;
					}
				} else j+= rule.length;
			}
		});
	}
	
	function highlightCode(styleSet) {
		// clear rules array
		var parsed;
		rules.length = 0;
		
		// get stylable elements by filtering out all code elements without the correct className	
		var stylableEls = codeEls.filter(function(item) {return (item.className.indexOf(styleSet.name)>=0)});
		
		// add style rules to parser
		for (var className in styleSet.rules) addRule(className, styleSet.rules[className]);
		
			
		// replace for all elements
		for (var i = 0; i < stylableEls.length; i++) {
			// EVIL hack to fix IE whitespace badness if it's inside a <pre>
			if (/MSIE/.test(navigator.appVersion) && stylableEls[i].parentNode.nodeName == 'PRE') {
				stylableEls[i] = stylableEls[i].parentNode;
				
				parsed = stylableEls[i].innerHTML.replace(/(<code[^>]*>)([^<]*)<\/code>/i, function() {
					return arguments[1] + parse(arguments[2], styleSet.ignoreCase) + "</code>"
				});
				parsed = parsed.replace(/\n( *)/g, function() { 
					var spaces = "";
					for (var i = 0; i < arguments[1].length; i++) spaces+= "&nbsp;";
					return "\n" + spaces;  
				});
				parsed = parsed.replace(/\t/g, "&nbsp;&nbsp;&nbsp;&nbsp;");
				parsed = parsed.replace(/\n(<\/\w+>)?/g, "<br />$1").replace(/<br \/>[\n\r\s]*<br \/>/g, "<p><br></p>");
				
			} else parsed = parse(stylableEls[i].innerHTML, styleSet.ignoreCase);
			
			stylableEls[i].innerHTML = parsed;
		}
	}
	
	// run highlighter on all stylesets
	for (var i in this.styleSets) highlightCode(this.styleSets[i]);
}

CodeHighlighter.addStyle("javascript",{
	comment : {
		exp  : /(\/\/[^\n]*\n)|(\/\*[^*]*\*+([^\/][^*]*\*+)*\/)/
	},
	brackets : {
		exp  : /\(|\)/
	},
	string : {
		exp  : /'[^']*'|"[^"]*"/
	},
	keywords : {
		exp  : /\b(arguments|break|case|continue|default|delete|do|else|false|for|function|if|in|instanceof|new|null|return|switch|this|true|typeof|var|void|while|with)\b/
	},
	global : {
		exp  : /\b(toString|valueOf|window|element|prototype|constructor|document|escape|unescape|parseInt|parseFloat|setTimeout|clearTimeout|setInterval|clearInterval|NaN|isNaN|Infinity)\b/
	}
});

CodeHighlighter.addStyle("html", {
	comment : {
		exp: /&lt;!\s*(--([^-]|[\r\n]|-[^-])*--\s*)&gt;/
	},
	tag : {
		exp: /(&lt;\/?)([a-zA-Z]+\s?)/, 
		replacement: "$1<span class=\"$0\">$2</span>"
	},
	string : {
		exp  : /'[^']*'|"[^"]*"/
	},
	attribute : {
		exp: /\b([a-zA-Z-:]+)(=)/, 
		replacement: "<span class=\"$0\">$1</span>$2"
	},
	doctype : {
		exp: /&lt;!DOCTYPE([^&]|&[^g]|&g[^t])*&gt;/
	}
});

CodeHighlighter.addStyle("css", {
	comment : {
		exp  : /\/\*[^*]*\*+([^\/][^*]*\*+)*\//
	},
	keywords : {
		exp  : /@\w[\w\s]*/
	},
	selectors : {
		exp  : "([\\w-:\\[.#][^{};>]*)(?={)"
	},
	properties : {
		exp  : "([\\w-]+)(?=\\s*:)"
	},
	units : {
		exp  : /([0-9])(em|en|px|%|pt)\b/,
		replacement : "$1<span class=\"$0\">$2</span>"
	},
	urls : {
		exp  : /url\([^\)]*\)/
	}
 });

//////////////////// scroll ////////////////////////////////////////////////////////////////////////////
jQuery.getPos = function (e)
{
	var l = 0;
	var t  = 0;
	var w = jQuery.intval(jQuery.css(e,'width'));
	var h = jQuery.intval(jQuery.css(e,'height'));
	var wb = e.offsetWidth;
	var hb = e.offsetHeight;
	while (e.offsetParent){
		l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
		t += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
		e = e.offsetParent;
	}
	l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
	t  += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
};
jQuery.getClient = function(e)
{
	if (e) {
		w = e.clientWidth;
		h = e.clientHeight;
	} else {
		w = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
		h = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
	}
	return {w:w,h:h};
};
jQuery.getScroll = function (e) 
{
	if (e) {
		t = e.scrollTop;
		l = e.scrollLeft;
		w = e.scrollWidth;
		h = e.scrollHeight;
	} else  {
		if (document.documentElement && document.documentElement.scrollTop) {
			t = document.documentElement.scrollTop;
			l = document.documentElement.scrollLeft;
			w = document.documentElement.scrollWidth;
			h = document.documentElement.scrollHeight;
		} else if (document.body) {
			t = document.body.scrollTop;
			l = document.body.scrollLeft;
			w = document.body.scrollWidth;
			h = document.body.scrollHeight;
		}
	}
	return { t: t, l: l, w: w, h: h };
};

jQuery.intval = function (v)
{
	v = parseInt(v);
	return isNaN(v) ? 0 : v;
};

jQuery.fn.ScrollTo = function(s) {
	o = jQuery.speed(s);
	return this.each(function(){
		new jQuery.fx.ScrollTo(this, o);
	});
};

jQuery.fx.ScrollTo = function (e, o)
{
	var z = this;
	z.o = o;
	z.e = e;
	z.p = jQuery.getPos(e);
	z.s = jQuery.getScroll();
	z.clear = function(){clearInterval(z.timer);z.timer=null};
	z.t=(new Date).getTime();
	z.step = function(){
		var t = (new Date).getTime();
		var p = (t - z.t) / z.o.duration;
		if (t >= z.o.duration+z.t) {
			z.clear();
			setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
		} else {
			st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
			sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t)};
	z.timer=setInterval(function(){z.step();},13);
};

