//DEFAULT
//Menu
var timeout = 250;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open() {
	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').css({ visibility: 'visible' });
}

function jsddm_close() {
	if(ddmenuitem) ddmenuitem.css({ visibility: 'hidden' });
}

function jsddm_timer() {
	closetimer = window.setTimeout(jsddm_close, timeout);
}

function jsddm_canceltimer() {
	if(closetimer) {
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

//AUTO LOAD MODAL
function loadModal(h) {
	setTimeout(function() {
		h = h.replace('#','');
		$('a[href*=' + h + ']').trigger('click');
	}, 750);
}

// jQuery Start
jQuery(document).ready(function() {

	//Hash
	var hash = location.hash;
	if (hash != '') {
		loadModal(hash);
	}


	//Png Fix
	if($.browser.msie && $.browser.version <= 6 ) pngFix();

	//Menu
	$('ul#nav > li').bind('mouseover', jsddm_open);
	$('ul#nav > li').bind('mouseout',  jsddm_timer);

	//Home
	$('.home').each( function() {
		$('#carousel').insertBefore('#content');
		$('#footer').insertBefore('#content');
		$('#news li').each( function(e) {
			var url = $(this).find('a').attr('href'),
					target = $(this).find('a').attr('target');
			$(this).find('a').remove();
			$(this).wrapInner('<a href="'+url+'" target="'+target+'"></a>');
		});
	});
	$('#news li').click( function(){
		var txt = $(this).find('img').attr('alt');
		ga.track('/elmachips/home/clique/'+txt);
	});

	//timeline
	$('.linha-do-tempo').each( function() { $('#timeline').insertAfter('#content'); } );
	
	//FLIR
	FLIR.init({ path: 'http://www.elmachips.com.br/scripts/library/flir/' });
	//Verifing height
	$('.home #news h3').each(function() {
		var chars = $(this).text();
		chars = chars.split('').length;
		var tipo = (chars > 25 ? 'bigger' : (chars >= 18 ? 'big' : 'small'));
		$(this).addClass(tipo);
	});
	$('.home h2, .nossa-historia h2, .linha-do-tempo h2, .sua-saude h2, .sua-saude h3').each(function() { FLIR.replace(this, new FLIRStyle({ mode: 'static' }))});
	$('.home #news h3, .sua-saude h4').each(function() { FLIR.replace(this, new FLIRStyle({ mode: 'wrap' }))});
	
	//Fancybox
	$('.bTable, .bTables, .bOthers, .sProdutos').fancybox({
		'overlayOpacity': 0.75, 'frameHeight': 300, 'frameWidth': 565, 'overlayShow': true, 'padding': 0, 'hideOnContentClick': false, 'callbackOnShow': appear
	});
	$('.bSAC').fancybox({
		'overlayOpacity': 0.75, 'frameHeight': 520, 'frameWidth': 550, 'overlayShow': true, 'hideOnContentClick': false
	});

	// SWF embed
	$('#hottestFlash').each(function() {
		swfobject.embedSWF("http://www.elmachips.com.br/swf/Banner.swf", "hottestFlash", "95%", "100%", "9.0.0", false, false, {bgcolor: "#ffffff", wmode: 'transparent', allowScriptAccess: 'always', flashvars: 'url=http://www.elmachips.com.br/xml/bannerfiles.xml&produto='+$('body').attr('class')}, {id:'hottestFlash', name:'hottestFlash'});
	});
	$('#footerFlash').each(function() {
		swfobject.embedSWF("http://www.elmachips.com.br/swf/Footer.swf", "footerFlash", "100%", "100%", "9.0.0", false, false, {bgcolor: "#ffffff", wmode: 'transparent', allowScriptAccess: 'always', flashvars: 'url=http://www.elmachips.com.br/xml/homecarrousel.xml&produto='+$('body').attr('class')}, {id:'footerFlash', name:'footerFlash'});
	});
	$('#carouselFlash').each(function() {
		swfobject.embedSWF("http://www.elmachips.com.br/swf/Carrousselbase.swf", "carouselFlash", "100%", "100%", "9.0.0", false, false, {bgcolor: "#ffffff", wmode: 'transparent', allowScriptAccess: 'always', flashvars: 'url=http://www.elmachips.com.br/xml/carrousel.xml&produto='+$('body').attr('class')}, {id:'carouselFlash', name:'carouselFlash'});
	});
	$('#timeFlash').each(function() {
		swfobject.embedSWF("http://www.elmachips.com.br/swf/linhaTempo.swf", "timeFlash", "100%", "100%", "9.0.0", false, false, {bgcolor: "#ffffff", wmode: 'transparent', allowScriptAccess: 'always', flashvars: 'SRVPATH=http://www.elmachips.com.br/'}, {id:'timeFlash', name:'timeFlash'});
	});
	
	//Rel Blank
	$('a[rel="blank"]').attr({ target: '_blank' });

	//GA Tracker
	$('a.bSite, a.bAbout').bind('mouseup',function(){
		var newRev = $(this).attr('rev');
		newRev = newRev.replace(/\-/g,'/');
		ga.track(newRev);
	});

// jQuery End
});

//Png Fix
function pngFix() {
	var caminho = $('ul#nav a span').css('backgroundImage').match(/url\(\"(.*)\"\)/);
	$('ul#nav a span').css({
		backgroundImage: 'none',
		filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod="scale", src="'+caminho[1]+'", left="0")'
	});
}

//Appear
function appear() {
	$('#title h1, #modal h3').each(function() { FLIR.replace(this, new FLIRStyle({ mode: 'static', output:'gif' }))});
	$('#modal h1.saude, #modal h2.saude, #title h2').each(function() { FLIR.replace(this, new FLIRStyle({ mode: 'wrap', output:'gif' }))});
	if ($('#modal table').hasClass('tabela')) {
		$('#modal .tabela').each(function(){
			$(this).find('tr:odd').addClass('odd')
		});
	}

	if ($('#modal').hasClass("valor") && $.browser.msie && $.browser.version <= 6 ) {
		$('#valor').addClass('ie6');
	}

	$('#modal #scroll').each(function(){
		$(this).parent('div').css({ paddingRight: '0' });
		$(this).addClass('scroll-pane');
		$('.scroll-pane').jScrollPane({ showArrows: true, scrollbarWidth: 19 });
	});

	var altura = $('#modal').height(),
			toper = ($('#wrap').height()+$(window).scrollTop()-altura)/2;
	$('#fancy_outer').animate({ height: (altura), top: toper }, 10, function() {
		altura = $('#modal').height();
		altura = $('#modal').hasClass("valor") ? altura+85 : altura+20;
		toper = ($('#wrap').height()+$(window).scrollTop()-altura)/2;
		$('#fancy_outer').animate({ height: (altura), top: toper }, 100 );
		$('#fancy_outer').animate({ top: toper }, 10, function() {
			$(window).scrollTop(($(window).scrollTop())+1);
		}).animate({ top: toper }, 10, function() {
			$(window).scrollTop(($(window).scrollTop())-1);
		});
	}).css({ visibility: 'visible' });
}

//openPack
function openPack(caminho,titulo) {
	if ( $('#openPack').size() < 1 ) {
		$('#footer').after('<a href="#modalPack" id="openPack" style="display: none;">&nbsp;</a><div id="modalPack" style="display: none;"><div id="pack"></div></div>');
	}
	caminho = caminho.replace('png','jpg');
	$('#pack').html('<p class="image"><img src="'+caminho+'" height="346" width="306" /></p><div><strong>'+titulo+'</strong></div>');
	$("#openPack").fancybox({ 'overlayOpacity': 0.75, 'overlayShow':true, 'frameHeight': 430, 'frameWidth': 565 }).trigger('click');
	$('#pack strong').each(function() { FLIR.replace(this, new FLIRStyle({ mode: 'wrap', output:'gif' }))});
	return false;
}	

//FANCYBOX
eval(function(p,a,c,k,e,d){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--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[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}(';(7($){$.b.2Q=7(){u B.2t(7(){9 1J=$(B).n(\'2Z\');5(1J.1c(/^3w\\(["\']?(.*\\.2p)["\']?\\)$/i)){1J=3t.$1;$(B).n({\'2Z\':\'45\',\'2o\':"3W:3R.4m.4d(3h=F, 3T="+($(B).n(\'41\')==\'2J-3Z\'?\'4c\':\'3N\')+", Q=\'"+1J+"\')"}).2t(7(){9 1b=$(B).n(\'1b\');5(1b!=\'2e\'&&1b!=\'2n\')$(B).n(\'1b\',\'2n\')})}})};9 A,4,16=D,s=1t 1o,1w,1v=1,1y=/\\.(3A|3Y|2p|3c|3d)(.*)?$/i;9 P=($.2q.3K&&2f($.2q.3z.2k(0,1))<8);$.b.c=7(Y){Y=$.3x({},$.b.c.2R,Y);9 2s=B;7 2h(){A=B;4=Y;2r();u D};7 2r(){5(16)u;5($.1O(4.2c)){4.2c()}4.j=[];4.h=0;5(Y.j.N>0){4.j=Y.j}t{9 O={};5(!A.1H||A.1H==\'\'){9 O={d:A.d,X:A.X};5($(A).1G("1m:1D").N){O.1a=$(A).1G("1m:1D")}4.j.2j(O)}t{9 Z=$(2s).2o("a[1H="+A.1H+"]");9 O={};3C(9 i=0;i<Z.N;i++){O={d:Z[i].d,X:Z[i].X};5($(Z[i]).1G("1m:1D").N){O.1a=$(Z[i]).1G("1m:1D")}4.j.2j(O)}3F(4.j[4.h].d!=A.d){4.h++}}}5(4.23){5(P){$(\'1U, 1Q, 1P\').n(\'1S\',\'3s\')}$("#1i").n(\'25\',4.2U).J()}1d()};7 1d(){$("#1f, #1e, #V, #G").S();9 d=4.j[4.h].d;5(d.1c(/#/)){9 U=11.3r.d.3f(\'#\')[0];U=d.3g(U,\'\');U=U.2k(U.2l(\'#\'));1k(\'<6 l="3e">\'+$(U).o()+\'</6>\',4.1I,4.1x)}t 5(d.1c(1y)){s=1t 1o;s.Q=d;5(s.3a){1K()}t{$.b.c.34();$(s).x().14(\'3b\',7(){$(".I").S();1K()})}}t 5(d.1c("17")||A.3j.2l("17")>=0){1k(\'<17 l="35" 3q="$.b.c.38()" 3o="3n\'+C.T(C.3l()*3m)+\'" 2K="0" 3E="0" Q="\'+d+\'"></17>\',4.1I,4.1x)}t{$.4p(d,7(2m){1k(\'<6 l="3L">\'+2m+\'</6>\',4.1I,4.1x)})}};7 1K(){5(4.30){9 w=$.b.c.1n();9 r=C.1M(C.1M(w[0]-36,s.g)/s.g,C.1M(w[1]-4b,s.f)/s.f);9 g=C.T(r*s.g);9 f=C.T(r*s.f)}t{9 g=s.g;9 f=s.f}1k(\'<1m 48="" l="49" Q="\'+s.Q+\'" />\',g,f)};7 2F(){5((4.j.N-1)>4.h){9 d=4.j[4.h+1].d;5(d.1c(1y)){1A=1t 1o();1A.Q=d}}5(4.h>0){9 d=4.j[4.h-1].d;5(d.1c(1y)){1A=1t 1o();1A.Q=d}}};7 1k(1j,g,f){16=F;9 L=4.2Y;5(P){$("#q")[0].1E.2u("f");$("#q")[0].1E.2u("g")}5(L>0){g+=L*2;f+=L*2;$("#q").n({\'v\':L+\'z\',\'2E\':L+\'z\',\'2i\':L+\'z\',\'y\':L+\'z\',\'g\':\'2B\',\'f\':\'2B\'});5(P){$("#q")[0].1E.2C(\'f\',\'(B.2D.4j - 20)\');$("#q")[0].1E.2C(\'g\',\'(B.2D.3S - 20)\')}}t{$("#q").n({\'v\':0,\'2E\':0,\'2i\':0,\'y\':0,\'g\':\'2z%\',\'f\':\'2z%\'})}5($("#k").1u(":19")&&g==$("#k").g()&&f==$("#k").f()){$("#q").1Z("2N",7(){$("#q").1C().1F($(1j)).21("1s",7(){1g()})});u}9 w=$.b.c.1n();9 2v=(g+36)>w[0]?w[2]:(w[2]+C.T((w[0]-g-36)/2));9 2w=(f+1z)>w[1]?w[3]:(w[3]+C.T((w[1]-f-1z)/2));9 K={\'y\':2v,\'v\':2w,\'g\':g+\'z\',\'f\':f+\'z\'};5($("#k").1u(":19")){$("#q").1Z("1s",7(){$("#q").1C();$("#k").24(K,4.2X,4.2T,7(){$("#q").1F($(1j)).21("1s",7(){1g()})})})}t{5(4.1W>0&&4.j[4.h].1a!==1L){$("#q").1C().1F($(1j));9 M=4.j[4.h].1a;9 15=$.b.c.1R(M);$("#k").n({\'y\':(15.y-18)+\'z\',\'v\':(15.v-18)+\'z\',\'g\':$(M).g(),\'f\':$(M).f()});5(4.1X){K.25=\'J\'}$("#k").24(K,4.1W,4.2W,7(){1g()})}t{$("#q").S().1C().1F($(1j)).J();$("#k").n(K).21("1s",7(){1g()})}}};7 2y(){5(4.h!=0){$("#1e, #2O").x().14("R",7(e){e.2x();4.h--;1d();u D});$("#1e").J()}5(4.h!=(4.j.N-1)){$("#1f, #2M").x().14("R",7(e){e.2x();4.h++;1d();u D});$("#1f").J()}};7 1g(){2y();2F();$(W).1B(7(e){5(e.29==27){$.b.c.1l();$(W).x("1B")}t 5(e.29==37&&4.h!=0){4.h--;1d();$(W).x("1B")}t 5(e.29==39&&4.h!=(4.j.N-1)){4.h++;1d();$(W).x("1B")}});5(4.1r){$(11).14("1N 1T",$.b.c.2g)}t{$("6#k").n("1b","2e")}5(4.2b){$("#22").R($.b.c.1l)}$("#1i, #V").14("R",$.b.c.1l);$("#V").J();5(4.j[4.h].X!==1L&&4.j[4.h].X.N>0){$(\'#G 6\').o(4.j[4.h].X);$(\'#G\').J()}5(4.23&&P){$(\'1U, 1Q, 1P\',$(\'#q\')).n(\'1S\',\'19\')}5($.1O(4.2a)){4.2a()}16=D};u B.x(\'R\').R(2h)};$.b.c.2g=7(){9 m=$.b.c.1n();$("#k").n(\'y\',(($("#k").g()+36)>m[0]?m[2]:m[2]+C.T((m[0]-$("#k").g()-36)/2)));$("#k").n(\'v\',(($("#k").f()+1z)>m[1]?m[3]:m[3]+C.T((m[1]-$("#k").f()-1z)/2)))};$.b.c.1h=7(H,2A){u 2f($.3I(H.3u?H[0]:H,2A,F))||0};$.b.c.1R=7(H){9 m=H.4g();m.v+=$.b.c.1h(H,\'3k\');m.v+=$.b.c.1h(H,\'3J\');m.y+=$.b.c.1h(H,\'3H\');m.y+=$.b.c.1h(H,\'3D\');u m};$.b.c.38=7(){$(".I").S();$("#35").J()};$.b.c.1n=7(){u[$(11).g(),$(11).f(),$(W).3i(),$(W).3p()]};$.b.c.2G=7(){5(!$("#I").1u(\':19\')){33(1w);u}$("#I > 6").n(\'v\',(1v*-40)+\'z\');1v=(1v+1)%12};$.b.c.34=7(){33(1w);9 m=$.b.c.1n();$("#I").n({\'y\':((m[0]-40)/2+m[2]),\'v\':((m[1]-40)/2+m[3])}).J();$("#I").14(\'R\',$.b.c.1l);1w=3Q($.b.c.2G,3X)};$.b.c.1l=7(){16=F;$(s).x();$("#1i, #V").x();5(4.2b){$("#22").x()}$("#V, .I, #1e, #1f, #G").S();5(4.1r){$(11).x("1N 1T")}1q=7(){$("#1i, #k").S();5(4.1r){$(11).x("1N 1T")}5(P){$(\'1U, 1Q, 1P\').n(\'1S\',\'19\')}5($.1O(4.1V)){4.1V()}16=D};5($("#k").1u(":19")!==D){5(4.26>0&&4.j[4.h].1a!==1L){9 M=4.j[4.h].1a;9 15=$.b.c.1R(M);9 K={\'y\':(15.y-18)+\'z\',\'v\':(15.v-18)+\'z\',\'g\':$(M).g(),\'f\':$(M).f()};5(4.1X){K.25=\'S\'}$("#k").31(D,F).24(K,4.26,4.2S,1q)}t{$("#k").31(D,F).1Z("2N",1q)}}t{1q()}u D};$.b.c.2V=7(){9 o=\'\';o+=\'<6 l="1i"></6>\';o+=\'<6 l="22">\';o+=\'<6 p="I" l="I"><6></6></6>\';o+=\'<6 l="k">\';o+=\'<6 l="2I">\';o+=\'<6 l="V"></6>\';o+=\'<6 l="E"><6 p="E 44"></6><6 p="E 43"></6><6 p="E 42"></6><6 p="E 3V"></6><6 p="E 3U"></6><6 p="E 3O"></6><6 p="E 3M"></6><6 p="E 3P"></6></6>\';o+=\'<a d="2P:;" l="1e"><1p p="1Y" l="2O"></1p></a><a d="2P:;" l="1f"><1p p="1Y" l="2M"></1p></a>\';o+=\'<6 l="q"></6>\';o+=\'<6 l="G"></6>\';o+=\'</6>\';o+=\'</6>\';o+=\'</6>\';$(o).2H("46");$(\'<32 4i="0" 4h="0" 4k="0"><2L><13 p="G" l="4l"></13><13 p="G" l="4o"><6></6></13><13 p="G" l="4n"></13></2L></32>\').2H(\'#G\');5(P){$("#2I").47(\'<17 p="4a" 4e="2J" 2K="0"></17>\');$("#V, .E, .G, .1Y").2Q()}};$.b.c.2R={2Y:10,30:F,1X:D,1W:0,26:0,2X:3G,2W:\'28\',2S:\'28\',2T:\'28\',1I:3B,1x:3v,23:F,2U:0.3,2b:F,1r:F,j:[],2c:2d,2a:2d,1V:2d};$(W).3y(7(){$.b.c.2V()})})(4f);',62,274,'||||opts|if|div|function||var||fn|fancybox|href||height|width|itemCurrent||itemArray|fancy_outer|id|pos|css|html|class|fancy_content||imagePreloader|else|return|top||unbind|left|px|elem|this|Math|false|fancy_bg|true|fancy_title|el|fancy_loading|show|itemOpts|pad|orig_item|length|item|isIE|src|click|hide|round|target|fancy_close|document|title|settings|subGroup||window||td|bind|orig_pos|busy|iframe||visible|orig|position|match|_change_item|fancy_left|fancy_right|_finish|getNumeric|fancy_overlay|value|_set_content|close|img|getViewport|Image|span|__cleanup|centerOnScroll|normal|new|is|loadingFrame|loadingTimer|frameHeight|imageRegExp|50|objNext|keydown|empty|first|style|append|children|rel|frameWidth|image|_proceed_image|undefined|min|resize|isFunction|select|object|getPosition|visibility|scroll|embed|callbackOnClose|zoomSpeedIn|zoomOpacity|fancy_ico|fadeOut||fadeIn|fancy_wrap|overlayShow|animate|opacity|zoomSpeedOut||swing|keyCode|callbackOnShow|hideOnContentClick|callbackOnStart|null|absolute|parseInt|scrollBox|_initialize|bottom|push|substr|indexOf|data|relative|filter|png|browser|_start|matchedGroup|each|removeExpression|itemLeft|itemTop|stopPropagation|_set_navigation|100|prop|auto|setExpression|parentNode|right|_preload_neighbor_images|animateLoading|appendTo|fancy_inner|no|frameborder|tr|fancy_right_ico|fast|fancy_left_ico|javascript|fixPNG|defaults|easingOut|easingChange|overlayOpacity|build|easingIn|zoomSpeedChange|padding|backgroundImage|imageScale|stop|table|clearInterval|showLoading|fancy_frame|||showIframe||complete|load|bmp|jpeg|fancy_div|split|replace|enabled|scrollLeft|className|paddingTop|random|1000|fancy_iframe|name|scrollTop|onload|location|hidden|RegExp|jquery|355|url|extend|ready|version|jpg|425|for|borderLeftWidth|hspace|while|300|paddingLeft|curCSS|borderTopWidth|msie|fancy_ajax|fancy_bg_w|scale|fancy_bg_sw|fancy_bg_nw|setInterval|DXImageTransform|clientWidth|sizingMethod|fancy_bg_s|fancy_bg_se|progid|66|gif|repeat||backgroundRepeat|fancy_bg_e|fancy_bg_ne|fancy_bg_n|none|body|prepend|alt|fancy_img|fancy_bigIframe|60|crop|AlphaImageLoader|scrolling|jQuery|offset|cellpadding|cellspacing|clientHeight|border|fancy_title_left|Microsoft|fancy_title_right|fancy_title_main|get'.split('|'),0,{}))


//FLIR 2.0B2
var FLIR={version:"2.0b2",options:{path:"",defaultStyle:null,ignoredEls:"BR,HR,IMG,INPUT,SELECT",bkgCheckForBlock:false,onreplacing:null,onreplaced:null,onreplacingchild:null,onreplacedchild:null},findEmbededFonts:false,dpi:96,flirElements:{},flirPlugins:[],isIE6:true,isIE:true,hoverEnabled:false,debug:false,init:function(a){if(typeof a!="undefined"){for(var b in a){this.options[b]=a[b]}}if(this.options.defaultStyle==null){this.options.defaultStyle=new FLIRStyle()}this.detectBrowser();this.calcDPI();if((this.findEmbededFonts=(typeof FLIR.discoverEmbededFonts=="function"))){this.discoverEmbededFonts()}this.hoverEnabled=(typeof this.addHover=="function");FLIR.pcall("init",arguments)},install:function(a){this.flirPlugins.push(a)},pcall:function(d,c){var a=c;for(var b=0;b<this.flirPlugins.length;b++){if(typeof this.flirPlugins[b][d]=="function"){var e=this.flirPlugins[b][d](a);if(typeof e=="undefined"){continue}if(typeof e=="boolean"&&e==false){return false}if(typeof e!="boolean"){a=c}}}var a=typeof a!="object"?[a]:a;if(a.length&&a[0]&&a[0].callee){return a[0]}else{return a}},prepare:function(f,b){if(!(args=FLIR.pcall("prepare",arguments))){return}f=args[0];if(f&&f.hasChildNodes()&&f.childNodes.length>1){for(var c=0;c<f.childNodes.length;c++){var e=f.childNodes[c];if(e&&e.nodeType==3){if(b){trimreg=c==0?/^\s+/g:/\s+$/g;e.innerHTML=e.innerHTML.replace(trimreg,"")}var d=document.createElement("SPAN");d.style.margin=d.style.padding=d.style.border="0";d.className="flir-span";d.flirSpan=true;if(e.nodeValue.match(/^[\n\r]+$/)){continue}var a=e.nodeValue.replace(/[\t\n\r]/g," ").replace(/\s\s+/g," ");d.innerHTML=!FLIR.isIE?a:e.nodeValue.replace(/^\s+|\s+$/g,"&nbsp;");f.replaceChild(d,e)}}}},replace:function(c,b){if(!(args=FLIR.pcall("replace",arguments))){return}c=args[0];b=args[1];if(!c||c.flirReplaced){return}if(!this.isFStyle(b)&&typeof b=="object"){b=new FLIRStyle(b)}else{if(!this.isFStyle(b)){b=this.options.defaultStyle}}if(typeof c=="string"){c=this.getElements(c)}if(typeof c.length!="undefined"){if(c.length==0){return}for(var a=0;a<c.length;a++){this.replace(c[a],b)}return}c.flirStyle=b;if(typeof FLIR.options.onreplacing=="function"){c=FLIR.options.onreplacing(c,b)}c.flirMainObj=true;this.saveObject(c);if(this.findEmbededFonts&&typeof this.embededFonts[b.getFont(c,FLIR.getStyle(c,"font-family"))]!="undefined"){return}FLIR.prepare(c);this._replace_tree(c,b);if(typeof FLIR.options.onreplaced=="function"){FLIR.options.onreplaced(c,b)}},_replace_tree:function(e,c){var d=!e.hasChildNodes()||(e.hasChildNodes()&&e.childNodes.length==1&&e.childNodes[0].nodeType==3)?[e]:e.childNodes;var a;for(var b=0;b<d.length;b++){a=d[b];if(typeof FLIR.options.onreplacingchild=="function"){a=FLIR.options.onreplacingchild(a,c)}if(!a.innerHTML||a.nodeType!=1){continue}if(FLIR.isIgnoredEl(a)){continue}if(a.flirReplaced){continue}if(FLIR.hoverEnabled&&a.nodeName=="A"&&!a.flirHasHover){FLIR.addHover(a)}if(a.hasChildNodes()&&(a.childNodes.length>1||a.childNodes[0].nodeType!=3)){FLIR.prepare(a);FLIR._replace_tree(a,c);continue}if(a.innerHTML==""){continue}var f=c.options.output;if(FLIR.isIE6&&(a.flirIE6PNG=(f=="png"||(f=="auto"&&FLIR.getStyle(a,"background-color")=="transparent")))){FLIR._Rimg(a,c,true)}else{if(c.replaceBackground){FLIR._Rbkg(a,c)}else{FLIR._Rimg(a,c)}}a.className+=" flir-replaced";a.flirReplaced=true;if(typeof FLIR.options.onreplacedchild=="function"){FLIR.options.onreplacedchild(e,c)}}},_Rbkg:function(e,d){if(!(args=FLIR.pcall("replaceBackground",arguments))){return}e=args[0];d=args[1];var c=this.saveObject(e);var a=d.URL(e);if(FLIR.options.bkgCheckForBlock){if(FLIR.getStyle(e,"display")!="block"){e.style.display="block"}}var b=new Image();b.onload=function(){FLIR.flirElements[c].style.width=this.width+"px";FLIR.flirElements[c].style.height=this.height+"px";if(FLIR.hoverEnabled&&d!=d.hoverStyle){var f=new Image();e.flirHoverURL=f.src=d.hoverStyle.URL(e)}};b.src=a;e.style.background='url("'+a.replace(/ /g,"%20")+'") no-repeat';e.flirOrig=a;e.oldTextIndent=e.style.textIndent;e.style.textIndent="-9999px"},_Rimg:function(f,e,d){if(!(args=FLIR.pcall("replaceMethodOverlay",arguments))){return}f=args[0];e=args[1];var c=this.saveObject(f);var a=document.createElement("IMG");var b=e.URL(f);a.alt=f.innerHTML;if(FLIR.hoverEnabled&&e!=e.hoverStyle){a.onload=function(){var g=new Image();f.flirHoverURL=g.src=e.hoverStyle.URL(f,a.alt)}}if(a.onerror){a.onerror=function(){var g=document.createElement("SPAN");g.innerHTML=a.alt;try{f.replaceChild(g,a)}catch(h){}}}a.flirImage=true;a.className="flir-image";a.style.border="none";if(d){a.src=this.options.path+"spacer.png";if(f.offsetWidth){a.style.width=f.offsetWidth+"px";a.style.height=f.offsetHeight+"px"}a.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+b+'", sizingMethod="image")';f.flirOrig=b}else{a.src=b;f.flirOrig=a.src}f.innerHTML="";f.appendChild(a)},saveObject:function(a){if(typeof a.flirId=="undefined"){a.flirId=this.generateUID();this.flirElements[a.flirId]=a}return a.flirId},generateUID:function(){var a="flir-";if(typeof __flir_uid_count=="undefined"){__flir_uid_count=0}else{__flir_uid_count++}return a+__flir_uid_count},calcDPI:function(){if(screen.logicalXDPI){var b=parseInt(screen.logicalXDPI)}else{var d=document.cookie.match(/<dpi>(\d+)<\/dpi>/);if(d){this.dpi=d[1];return}var c=document.createElement("DIV");c.style.position="absolute";c.style.visibility="hidden";c.style.border=c.style.padding=c.style.margin="0";c.style.height=c.style.width="1in";document.body.appendChild(c);var b=parseInt(c.offsetHeight);document.body.removeChild(c);var a=new Date();a.setDate(new Date().getDate()+365);document.cookie="dpi=<dpi>"+this.dpi+"</dpi>;expires="+a.toGMTString()+";path=/"}if(b>0){this.dpi=b}},isIgnoredEl:function(a){return((","+this.options.ignoredEls+",").indexOf(","+a.nodeName+",")>-1)},sanitizeHTML:function(a){return a.replace(/<[^>]+>/g,"")},isFStyle:function(a){if(!a){return false}return(typeof a.cssMap!="undefined")}};__flirstyle_instances=0;function FLIRStyle(a,c){__flirstyle_instances++;this.uid=__flirstyle_instances;this.replaceBackground=false;this.hoverStyle=c&&FLIR.isFStyle(c)?c:this;this.options={};this.defaults={mode:"static",output:"auto",fixBaseline:false,hq:false,css:{}};this.cssMap={"background-color":"Background",color:"Color","font-family":"Font","font-size":"FontSize","letter-spacing":"Measurement","line-height":"LineHeight","text-align":"Default","font-stretch":"Default","font-style":"FontStyle","font-variant":"Default","font-weight":"Weight",opacity:"Default","text-decoration":"Default"};for(var b in this.defaults){this.options[b]=this.defaults[b]}if(a&&typeof a.css=="string"){a.css=this.parse_css_string(a.css)}this.loadopts(a)}FLIRStyle.prototype.loadopts=function(b){for(var c in this.cssMap){this.options.css[c]=b&&b.css&&typeof b.css[c]!="undefined"?b.css[c]:null}if(typeof this.loadopts_compat=="function"){b=this.loadopts_compat(b)}if(typeof b!="undefined"){for(var c in b){if(b[c]==null){continue}if(typeof this[c]!="undefined"){this[c]=b[c]}else{if(c=="css"){for(var a in b[c]){this.options[c][a]=b[c][a]}}else{this.options[c]=b[c]}}}}};FLIRStyle.prototype.parse_css_string=function(c){var d=c.split(";");var a={};var e;for(var b=0;b<d.length;b++){if(d[b].indexOf(":")<0){continue}e=d[b].split(":");a[e[0].replace(/^\s+|\s+$/,"")]=e[1].replace(/^\s+|\s+$/,"")}return a};FLIRStyle.prototype.URL=function(d){var c=(arguments[1]?arguments[1]:d.innerHTML);var b=this.options.css["text-transform"];if(b==null){b=FLIR.getStyle(d,"text-transform")}switch(b){case"capitalize":c=c.replace(/\w+/g,function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()});break;case"lowercase":c=c.toLowerCase();break;case"uppercase":c=c.toUpperCase().replace(/&[a-z0-9]+;/gi,function(e){return e.toLowerCase()});break}c=this.encodeText(c,d.flirIE6PNG);var a=FLIR.options.path+"generate.php?t="+c+"&h="+d.offsetHeight+"&w="+d.offsetWidth+"&c="+this.flattenCSS(d)+"&d="+FLIR.dpi+"&f="+this.serialize();if(FLIR.debug){a+="&rand="+(Math.random()*Math.random())}return a};FLIRStyle.prototype.encodeText=function(b,a){b=encodeURIComponent(b.replace(/&/g,"{*A}").replace(/\+/g,"{*P}").replace(/\(/g,"{*LP}").replace(/\)/g,"{*RP}"));if(a){b=escape(b)}return b};FLIRStyle.prototype.serialize=function(){var b="";for(var a in this.options){if(a=="css"||this.options[a]==this.defaults[a]){continue}b+=',"'+a+'":"'+this.options[a].toString().replace(/"/g,"'")+'"'}return encodeURIComponent("{"+b.substr(1)+"}")};FLIRStyle.prototype.flattenCSS=function(d){var a=this.copyObject(this.options.css);for(var c in this.cssMap){this.options.css[c]=this.get(d,c,this.cssMap[c])}var b="";for(var c in this.options.css){if(this.options.css[c]==null||typeof this.options.css[c]=="undefined"){this.options.css[c]=""}b+="|"+encodeURIComponent(this.options.css[c].toString().replace(/|/g,""))}b=b.substr(1);this.options.css=a;return b};FLIRStyle.prototype.get=function(g,a,d){var c="get"+d;while(g.flirSpan&&g!=document.body){g=FLIR.getParentNode(g)}var e=this.options.css[a];var f=!e||e==null?FLIR.getStyle(g,a):this.options.css[a];var b=typeof this[c]=="function"?this[c](g,f):f;return b=="normal"||b=="none"||b=="start"?"":b};FLIRStyle.prototype.getFontStyle=function(b,a){return(b.nodeName=="EM"||FLIR.getParentNode(b).nodeName=="EM"?"italic":a)=="italic"?"1":""};FLIRStyle.prototype.getBackground=function(d,c){if(this.options.output=="gif"&&c.search(/^(transparent|none)$/i)>-1){var b=FLIR.getParentNode(d);var a=FLIR.getStyle(b,"background-color");if(typeof __flirstyle_root_obj=="undefined"){__flirstyle_root_obj=FLIR.getParentNode(document.body)}while(a.search(/^(transparent|none)$/i)>-1&&b!=__flirstyle_root_obj){b=FLIR.getParentNode(b);a=FLIR.getStyle(b,"background-color")}return this.getColor(d,a)}else{return this.getColor(d,c)}};FLIRStyle.prototype.getWeight=function(c,b){var a=c.nodeName=="STRONG"||FLIR.getParentNode(c).nodeName=="STRONG"?"bold":b;switch(a.toString()){case"100":case"200":case"300":case"lighter":return"-1";case"400":case"normal":return"";case"500":case"600":case"700":case"bold":return"1";case"800":case"900":case"bolder":return"2"}};FLIRStyle.prototype.getLineHeight=function(c,b){var a=this.getMeasurement(c,b)/c.flirFontSize;return Math.round((a*100000))/100000};FLIRStyle.prototype.getFont=function(b,a){if(a.indexOf(",")){a=a.split(",")[0]}return a.replace(/['"]/g,"").toLowerCase()};FLIRStyle.prototype.getColor=function(b,a){switch(a){case"transparent":case"none":return"";default:if(a.substr(0,1)=="#"){a=a.substr(1)}return a.replace(/['"\(\) ]|rgba?/g,"").toLowerCase()}};FLIRStyle.prototype.getFontSize=function(o,val){var px=this.getMeasurement(o,val,true);var prepx=px;if("*/+-".indexOf(val[0])>-1){try{px=Math.round((parseFloat(eval(px.toString().concat(val))))*10000)/10000}catch(err){px=16}}o.flirFontSize=px;return px};FLIRStyle.prototype.getMeasurement=function(g,f,d){var c,b,a;if(f=="normal"||f=="none"){return""}if(f.indexOf("px")>-1){c=Math.round(parseFloat(f))}else{if(f.indexOf("pt")>-1){var e=parseFloat(f);c=e/(72/FLIR.dpi)}else{if((b=(f.indexOf("em")>-1))||(a=(f.indexOf("%")>-1))){if(!g.flirFontSize){var h=document.createElement("DIV");h.style.padding=h.style.border="0";h.style.position="absolute";h.style.visibility="hidden";if(d){h.style.lineHeight="100%"}h.innerHTML="FlirTest";g.appendChild(h);c=h.offsetHeight;g.removeChild(h)}else{c=g.flirFontSize}}}}return c};FLIRStyle.prototype.copyObject=function(b){var c={};for(var a in b){c[a]=b[a]}return c};FLIRStyle.prototype.toString=function(){return this.uid};FLIR.addHover=function(a){if(!(args=FLIR.pcall("addHover",arguments))){return}a=args[0];a.flirHasHover=true;if(a.addEventListener){a.addEventListener("mouseover",FLIR.hover,false);a.addEventListener("mouseout",FLIR.hover,false)}else{if(a.attachEvent){a.attachEvent("onmouseover",function(){FLIR.hover(window.event)});a.attachEvent("onmouseout",function(){FLIR.hover(window.event)})}}};FLIR.flirIERepObj=[];FLIR.flirIEHovEls=[];FLIR.flirIEHovStyles=[];FLIR.hover=function(m){var b=FLIR.evsrc(m);var p=b;var s=b.flirHasHover;var j=b;var n=(m.type=="mouseover");while(b!=document.body&&!b.flirMainObj){b=FLIR.getParentNode(b);if(!s){s=b.flirHasHover;j=b}}if(b==document.body){return}var c=b.flirStyle;if(n&&c!=c.hoverStyle){c=c.hoverStyle}if(!(args=FLIR.pcall("hover",[n,p,b,j]))){return}n=args[0];p=args[1];b=args[2];j=args[3];var k=FLIR.getChildren(j);if(k.length==0||(k.length==1&&(k[0].flirImage||k[0].flirHasHover))){k=[j]}else{if(k.length==1&&!FLIR.isIgnoredEl(k[0])){var f=FLIR.getChildren(k[0]);if(f.length>0){if((f.length==1&&!f[0].flirImage)||f.length>1){k=f}}}}var q;for(var h=0;h<k.length;h++){q=k[h];if(q.nodeName=="IMG"){continue}if(!q.innerHTML){continue}if(FLIR.isIE){var r=FLIR.flirIEHovEls.length;FLIR.flirIERepObj[r]=q;FLIR.flirIEHovStyles[r]=c;var l=c.options.output;if(FLIR.isIE6&&(q.flirIE6PNG=(l=="png"||(l=="auto"&&FLIR.getStyle(q,"background-color")=="transparent")))){FLIR.flirIEHovEls[r]=q.flirImage?q:FLIR.getChildren(q)[0];setTimeout("FLIR.flirIEHovEls["+r+"].style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\"'+FLIR.flirIEHovStyles["+r+"].URL(FLIR.flirIERepObj["+r+"], FLIR.flirIEHovEls["+r+'].alt)+\'", sizingMethod="image")\';  ',0)}else{if(c.replaceBackground&&FLIR.getStyle(q,"display")=="block"){FLIR.flirIEHovEls[r]=q;setTimeout("FLIR.flirIERepObj["+r+'].style.background = "url("+('+n+" ? FLIR.flirIEHovStyles["+r+"].URL(FLIR.flirIERepObj["+r+"]) : FLIR.flirIERepObj["+r+'].flirOrig)+") no-repeat";',0)}else{FLIR.flirIEHovEls[r]=q.flirImage?q:FLIR.getChildren(q)[0];if(!FLIR.flirIEHovEls[r].flirOrigWidth){FLIR.flirIEHovEls[r].flirOrigWidth=FLIR.flirIEHovEls[r].width;FLIR.flirIEHovEls[r].flirOrigHeight=FLIR.flirIEHovEls[r].height}var d="FLIR.flirIEHovEls["+r+"].src = "+n+" ? FLIR.flirIEHovStyles["+r+"].URL(FLIR.flirIERepObj["+r+"], FLIR.flirIEHovEls["+r+"].alt) : FLIR.flirIERepObj["+r+"].flirOrig;";d+="FLIR.flirIEHovEls["+r+"].onload = function() { ";if(n&&!FLIR.flirIEHovEls[r].flirHoverWidth){d+="		FLIR.flirIEHovEls["+r+"].flirHoverWidth = this.width; ";d+="		FLIR.flirIEHovEls["+r+"].flirHoverHeight = this.height; "}d+="	this.style.width = FLIR.flirIEHovEls["+r+"]."+(n?"flirHoverWidth":"flirOrigWidth")+'+"px"; ';d+="	this.style.height = FLIR.flirIEHovEls["+r+"]."+(n?"flirHoverHeight":"flirOrigHeight")+'+"px"; ';d+="}; ";setTimeout(d,0)}}}else{if(c.replaceBackground){var a=q.flirHoverURL?q.flirHoverURL:c.URL(q);q.style.background="url("+(n?a:q.flirOrig)+") no-repeat"}else{var g=q.flirImage?q:FLIR.getChildren(q)[0];var a=q.flirHoverURL?q.flirHoverURL:c.URL(q,g.alt);g.src=n?a:q.flirOrig}}}};FLIR.detectBrowser=function(){FLIR.isIE=(navigator.userAgent.toLowerCase().indexOf("msie")>-1&&!window.opera);FLIR.isIE6=(typeof document.body.style.maxHeight=="undefined")};FLIR.getElements=function(r){var q=[];if(document.querySelectorAll){var e=false;try{q=document.querySelectorAll(r);e=true}catch(f){e=false}if(e){return q}}var i,n,l,j,r,d,h,o,k;d=r;o=false;if(d.indexOf(" ")>-1){var g=d.split(" ");d=g[0];o=g[1]}else{if(d.substr(0,1)=="#"){return document.getElementById(d.substr(1))}}var c=false;if(d.indexOf("#")>-1){c=d.split("#")[1];r=d.split("#")[0]}var m=false;if(d.indexOf(".")>-1){m=d.split(".")[1];r=d.split(".")[0]}i=document.getElementsByTagName(r);for(var a=0;a<i.length;a++){if(i[a].nodeType!=1){continue}h=false;l=i[a].className?i[a].className:"";if(c&&i[a].id&&i[a].id==c){h=true}if(m&&FLIR.hasClass(i[a],m)){h=true}if(!c&&!m){h=true}if(!h){continue}n=false!=o?i[a].getElementsByTagName(o):[i[a]];for(var b=0;b<n.length;b++){k=n[b];q.push(k)}}return q};FLIR.getStyle=function(a,c){if(a.currentStyle){if(c.indexOf("-")>-1){c=c.split("-")[0]+c.split("-")[1].substr(0,1).toUpperCase()+c.split("-")[1].substr(1)}var b=a.currentStyle[c]}else{if(window.getComputedStyle){var b=document.defaultView.getComputedStyle(a,"").getPropertyValue(c)}}return b};FLIR.getChildren=function(c){var b=[];if(c&&c.hasChildNodes()){for(var a in c.childNodes){if(c.childNodes[a]&&c.childNodes[a].nodeType==1){b[b.length]=c.childNodes[a]}}}return b};FLIR.getParentNode=function(b){var a=b.parentNode;while(a!=document&&a.nodeType!=1){a=a.parentNode}return a};FLIR.hasClass=function(a,b){return(a&&a.className&&a.className.indexOf(b)>-1)};FLIR.evsrc=function(a){var b;if(a.target){b=a.target}else{if(a.srcElement){b=a.srcElement}}if(b.nodeType==3){b=b.parentNode}return b};FLIRStyle.prototype.loadopts_compat=function(b){if(!b){return}if(!b.css){b.css={}}b.fixedBaseline=b.realFontHeight?true:false;var a={cBackground:"background-color",cColor:"color",cFont:"font-family",cSize:"font-size",cSpacing:"letter-spacing",cLine:"line-height",cAlign:"text-align",cTransform:"text-transform",cStretch:"font-stretch",cFontStyle:"font-style",cVariant:"font-variant",cWeight:"font-weight",cOpacity:"opacity",cDecoration:"text-decoration"};var d;for(var c in a){if(typeof b[c]!="undefined"){switch(c){default:d=b[c];break;case"cSize":d=b[c]+"px";break;case"cColor":case"cBackground":d="#"+b[c];break}b.css[a[c]]=d;b[c]=null}}return b};FLIR.auto=function(a){FLIR.replace((!a?["h1","h2","h3","h4","h5"]:(a.indexOf&&a.indexOf(",")>-1?a.split(","):a)))};