var BALL_ENLARGE_FACTOR=40;var aBalls=[];var bRtl=false;$(function(){bRtl=$(document.body).hasClass("he");$("ul.thumbnails li").hover(function(){var $site=$(this);var $content=$site.find("div.c");var $thumb=$site.find("div.img .thumb");$site.parent().addClass("out");$site.addClass("over");$thumb.stop().animate({marginTop:-$content.height()+5},300);},function(){var $site=$(this);var $thumb=$site.find("div.img .thumb");$site.parent().removeClass("out");$thumb.stop().animate({marginTop:2},"fast",function(){$site.removeClass("over");});});$('#dem, #dem2').attr('href',('ma'+'il'+'#'+'t#o:'+'ev'+'yattt'+''+'ron'+'!'+'gma'+'il'+'.'+'co'+'z').replace(/#/g,'').replace('ttt','t').replace('!','@').replace('z','m'));$("#contact li").hover(function(){$(this).siblings().stop().animate({"opacity":0.3},"fast");},function(){$(this).siblings().stop().animate({"opacity":1},"fast");});$("img").each(function(){$(this).attr('title',$(this).attr('alt'));});$("form.contact-form .txt").each(function(){$(this).focus(function(){formLabelToggle($(this),true);}).blur(function(){formLabelToggle($(this),false);});if(jQuery.trim($(this).val()).length>0)
formLabelToggle($(this),true);});if(!isCrappyBrowser()){var ball=new Ball();aBalls.push(ball);}});function isCrappyBrowser()
{return(navigator.userAgent.indexOf("MSIE")!==-1);}
var Mario=function(){var $mario=$("#mario");var $brick=$("#brick");var docWidth=$(document.body).width();var back=false;var move=function(){var speed=0;if(back)
{speed=(docWidth-(docWidth-parseInt($mario.css("left"))))*11;$mario.animate({left:0},speed,"linear",function(){flip();move();});}
else
{speed=(docWidth-parseInt($mario.css("left")))*11;$mario.animate({left:docWidth-300},speed,"linear",function(){flip();move();});}};var jump=function(){var to1=parseInt($mario.css("left"));var to2=0;if(back)
{to1-=15;to2=to1-15;}
else
{to1+=15;to2=to1+15;}
$brick.css("left",(to1+7)+"px");window.setTimeout(function(){$brick.show().animate({top:-91},60,function(){$("#brick").animate({top:-89},60,function(){window.setTimeout(function(){$("#brick").hide();},80);});});},110);$mario.stop();$mario.animate({left:to1,top:-45},150,"linear",function(){$mario.animate({left:to2,top:-35},150,"linear",function(){move();});});};var restart=function(){$mario.stop();docWidth=$(document.body).width();move();};var flip=(function(){back=!back;$mario.attr("class",((back)?'back':''));});$(window).resize(function(e){restart();});$mario.click(jump);move();return{"move":move,"jump":jump,"restart":restart};};var mario=new Mario();var Ball=function(){var $container=$("h1");var COLORS=["indigo","brown","red","orange","yellow","blue","green","purple","black","teal","magenta","navy"];var SPEED=1500;var id=aBalls.length+1;var size=Math.ceil(Math.random()*25)+5;var inplace=false;var $element=$('<div class="ball" pos="0" id="ball'+id+'" />');$element.css({"background":COLORS[Math.floor(Math.random()*COLORS.length)],"width":size+"px","height":size+"px","left":0});$container.append($element);var addHover=function(){$element.hover(function(){if(inplace)
{var _width=size+BALL_ENLARGE_FACTOR;var _height=size+BALL_ENLARGE_FACTOR;var _pos=parseInt($(this).attr("pos"))-BALL_ENLARGE_FACTOR/2;var _bottom=-BALL_ENLARGE_FACTOR/2;var opts={width:_width,height:_height,bottom:_bottom};if(bRtl){opts.right=_pos;}else{opts.left=_pos;}
$(this).stop().animate(opts,"fast");}},function(){if(inplace)
{var opts={width:size,height:size,bottom:0};if(bRtl){opts.right=parseInt($(this).attr("pos"));}else{opts.left=parseInt($(this).attr("pos"));}
$(this).stop().animate(opts,"fast");}});};var move=function(){var pos=0;if(aBalls.length<1)
{pos=$container.width()-$element.width()-1;}
else
{var $target=aBalls[aBalls.length-1].element;var offset=Math.round(Math.random()*4)+1;if(bRtl)
pos=$container.width()-$target.width()-$target.position().left;else
pos=$target.position().left;pos+=-$element.width()+offset;}
if(pos>0)
{pos=Math.round(pos);$element.attr("pos",pos);var dir=(bRtl)?{right:pos}:{left:pos};$element.animate(dir,SPEED-aBalls.length*20,"easeOutBounce",moved);}
else
{remove();for(var i=0;i<aBalls.length;i++)
{if(i<aBalls.length-1)
{aBalls[i].remove(false);}
else
{aBalls[i].remove(function(){aBalls=[];var ball=new Ball();aBalls.push(ball);});}}}};var moved=function(){inplace=true;var ball=new Ball();aBalls.push(ball);};var remove=function(callback){inplace=false;$element.animate({bottom:-1000},28*(50-size),"easeInExpo",function(){$(this).remove();if(typeof callback=="function")
callback();});};addHover();move();return{"remove":remove,"element":$element};};function formLabelToggle(oInput,bFocus)
{var label=oInput.siblings("label");if(bRtl)
{if(bFocus)
label.animate({"color":"#000","right":"-"+(label.width()+17)+"px"},500);else if(jQuery.trim(oInput.val()).length==0)
label.animate({"color":"#777","right":"7px"},500);}
else
{if(bFocus)
label.animate({"color":"#000","left":"-"+(label.width()+17)+"px"},500);else if(jQuery.trim(oInput.val()).length==0)
label.animate({"color":"#777","left":"7px"},500);}}
function sendMessage()
{var emailRegEx=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;var name=jQuery.trim($("#name").val());var email=jQuery.trim($("#email").val());var phone=jQuery.trim($("#phone").val());var message=jQuery.trim($("#message").val());if(!require($("#name")))
return false;if(!require($("#email"),emailRegEx))
return false;if(!require($("#message")))
return false;$("#send").attr("disabled","disabled");$.ajax({type:"POST",url:"send.php",data:"name="+encodeURIComponent(name)+"&email="+encodeURIComponent(email)+"&phone="+encodeURIComponent(phone)+"&message="+encodeURIComponent(message),dataType:"json",success:function(data){if(data.status=="ok")
{var f=$(".contact-form fieldset");f.height(f.height()).fadeOut("normal",function(){$(this).html('<div class="success">'+data.message+'</div>').fadeIn();});}}});return true;}
function require(input,regex)
{var val=jQuery.trim(input.val());if(val.length==0||(typeof regex!="undefined"&&!val.match(regex)))
{err(input);return false;}
return true;}
function err(input)
{input.focus().siblings("label").animate({color:"#f00"}).animate({color:"#000"});}
