$(function(){navigation();startTimers();if($("form#contact").length>0)contactForm();});function getMeta($name){return $("meta[name="+$name+"]").attr('content');}
function contactForm(){$(".input","form#contact").blur(function(){validateInput($(this));});$("#submit","form#contact").click(function(){$(".input","form#contact").each(function(){validateInput($(this));})
if(!isFormValid())
return false;});}
function isFormValid(){return $(".input.incorrect","form#contact").length>0?false:true;}
function validateInput(obj){var id=obj.attr("id");var correct=false;if(id=="email"){if(obj.val().match(/^[a-zA-Z0-9_\.\-]+\@([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/))
correct=true;}
else if(id=="message"){if(obj.val().replace(/(^\s+)|(\s+$)/g,"")!="")
correct=true;}
obj.removeClass("correct incorrect");if(correct){obj.addClass("correct");}
else{obj.addClass("incorrect");}}
var faderId,newstickerId;function startTimers(){if($("#newsline").length>0){newstickerId=setInterval("newsline()",getMeta("eriol"));}}
function stopTimers(){if(faderId)clearInterval(faderId);if(newstickerId)clearInterval(newstickerId);}
function navigation(){$("a","#nav").attr("title","");$("#nav > li > a").mouseout(function(e){$(this).css("backgroundPosition","center center");});$("li:has(ul)","#nav").each(function(){var li=$(this);var ul=li.find("ul:first");var time=ul.children("li").length*50;ul.css({display:"none"});li.hover(function(){ul.stop().css({width:ul.width(),height:"auto"}).slideDown(time,function(){ul.css({overflow:"visible",height:"auto"});});},function(){ul.stop().slideUp(time/1.5);});});}
function newsline(){var ph=$("#newsline a.ph");if(ph.length==0){var $first=$("#newsline a:first");$("#newsline p").append("<br />").append($first.clone());ph=$first.addClass("ph");}
var active=$("#newsline a.active");if(active.length==0){active=$("#newsline a:last");}
var next=active.next().next().length?active.next().next():$("#newsline a:not(.ph):first");next.addClass("active");active.removeClass("active");$("#newsline a.ph").animate({opacity:0},800,function(){$("#newsline a.ph").html(next.html());$("#newsline a.ph").attr("href",next.attr("href"));$("#newsline a.ph").animate({opacity:1},500);});}