var lang="fi";var def_lang="fi";var products_navigation=null;var product_sections=null;var visible_product=null;var products=["events_container","strategy_container","reviews_container","cop_container","shareflect_container","dcp_container","training_container"];var visible_reference=null;var references=["tekes-signals","kesko","oz","vod","tivit","cloud","rytmikorjaamo","hrcommunity","servicedesign","tekes","bantora","nomadskolan","hoc","rte","digibusiness","deski","gtf"];var visible_person="teemu";var people=["jussi","eetu","teemu","sam","jyrki","lotta","mikko","esko","antti","viivi","petra","ilmari","veikko"];var contact_in_flight=0;dojo.addOnLoad(function(){if(dojo.byId("products")){products_navigation=dojo.byId("products_navigation");product_sections=dojo.byId("product_sections");var d=location.hash.substr(1)+"_container";if(d&&dojo.indexOf(products,d)!=-1){show_product(d)}dojo.connect(dojo.byId("products_home"),"onclick",null,dojo.partial(show_product,null));dojo.connect(dojo.byId("products_previous"),"onclick",null,previous_product);dojo.connect(dojo.byId("products_next"),"onclick",null,next_product);dojo.query(".product_link").forEach(function(e){dojo.connect(e,"onclick",null,function(f){show_product(e.href.split("#")[1]+"_container")})})}else{if(dojo.byId("references")){var a=location.hash.substr(1);if(a&&dojo.indexOf(references,a)!=-1){show_reference(a)}dojo.connect(dojo.byId("lightbox_close"),"onclick",null,hide_lightbox);dojo.connect(dojo.byId("lightbox_previous"),"onclick",null,previous_reference);dojo.connect(dojo.byId("lightbox_next"),"onclick",null,next_reference);dojo.query(".reference_link").forEach(function(e){dojo.connect(e,"onclick",null,function(f){show_reference(e.href.split("#")[1])})})}else{if(dojo.byId("people")){var c=location.hash.substr(1);if(c&&dojo.indexOf(people,c)!=-1){show_person(c)}else{show_person(visible_person)}dojo.query(".person_link").forEach(function(e){dojo.connect(e,"onclick",null,function(f){show_person(e.href.split("#")[1])})})}else{if(dojo.byId("radar")){var b=dojo.query(".timestamp");setTimeout(function(){b.forEach(function(e){e.innerHTML=time_ago(Number(dojo.attr(e,"title")))});setTimeout(arguments.callee,1000)},1000)}}}}dojo.query(".language_link").forEach(function(e){dojo.connect(e,"onclick",null,function(f){dojo.stopEvent(f);if(e.id!=lang){if(e.id==def_lang){window.location=window.location.pathname.substr(3)+window.location.hash}else{window.location="/"+e.id+window.location.pathname+window.location.hash}}})});dojo.query(".tip_field").forEach(function(e){dojo.connect(e,"onfocus",null,function(f){dojo.stopEvent(f);if(dojo.trim(e.value)==e.defaultValue){e.value=""}});dojo.connect(e,"onblur",null,function(f){dojo.stopEvent(f);if(!dojo.trim(e.value).length){e.value=e.defaultValue}})});dojo.query(".message").forEach(function(j){var e=dojo.query(".contact_form_container",j)[0];var k=dojo.query(".contact_form_success",j)[0];var i=dojo.query(".contact_form",e)[0];var g=dojo.query(".contact_name",i)[0];var f=dojo.query(".contact_email",i)[0];var h=dojo.query(".contact_content",i)[0];dojo.connect(i,"onsubmit",null,function(m){dojo.stopEvent(m);var l=new Date();l=l.getTime()/1000;if(l<contact_in_flight+5){return}if(!g.value.length||!f.value.length||!h.value.length){alert("Täytäthän kaikki kentät.")}contact_in_flight=l;dojo.xhrPost({url:"/cgi-bin/mail_us.pl",handleAs:"json",content:{name:g.value,email:f.value,content:h.value},load:function(n){dojo.style(e,"display","none");dojo.style(k,"display","block")},error:function(n){alert("Odottamaton virhe. Ole hyvä ja yritä uudelleen.")}})})})});function show_product(a){if(a){if(visible_product){dojo.style(visible_product,"display","none")}visible_product=a;dojo.style(visible_product,"display","block");dojo.style(products_navigation,"display","block");dojo.style(product_sections,"display","none");location.hash="#"+a.split("_")[0]}else{dojo.style(visible_product,"display","none");visible_product=null;dojo.style(products_navigation,"display","none");dojo.style(product_sections,"display","block");location.hash=""}}function previous_product(b){dojo.stopEvent(b);var a=dojo.indexOf(products,visible_product)-1;if(a==-1){show_product(products[products.length-1])}else{show_product(products[a])}}function next_product(b){dojo.stopEvent(b);var a=dojo.indexOf(products,visible_product)+1;if(a==products.length){show_product(products[0])}else{show_product(products[a])}}function show_person(a){dojo.removeClass(visible_person+"_link","active");dojo.style(visible_person,"display","none");dojo.addClass(a+"_link","active");dojo.style(a,"display","block");visible_person=a}function show_lightbox(){dojo.style("lightbox_overlay","display","block")}function hide_lightbox(a){dojo.stopEvent(a);dojo.style("lightbox_overlay","display","none")}function show_reference(a){if(visible_reference){dojo.style("lightbox_"+visible_reference,"display","none")}show_lightbox();visible_reference=a;dojo.style("lightbox_"+a,"display","block");location.hash="#"+visible_reference}function previous_reference(b){dojo.stopEvent(b);var a=dojo.indexOf(references,visible_reference)-1;if(a==-1){show_reference(references[references.length-1])}else{show_reference(references[a])}}function next_reference(b){dojo.stopEvent(b);var a=dojo.indexOf(references,visible_reference)+1;if(a==references.length){show_reference(references[0])}else{show_reference(references[a])}}function time_ago(c){var a=Math.floor(new Date().getTime()/1000);var d=a-c;var b=0;if(b=Math.floor(d/(60*60*24*365))){return b+"v"}else{if(b=Math.floor(d/(60*60*24*30))){return b+"kk"}else{if(b=Math.floor(d/(60*60*24))){return b+"p"}else{if(b=Math.floor(d/(60*60))){return b+"t"}else{if(b=Math.floor(d/60)){return b+"m"}else{return Math.floor(d)+"s"}}}}}};
