var collapseMessages=function(){$('.message').each(function(i,o){if(!$(this).is('.error')&&!$(this).is('.stayput'))
{$(this).slideUp(500,function(){$(this).remove();});}});};var loginDown=function(){$('#loginLink, .login-box-close').unbind('click').bind('click',function(){return false;});$('#login-box, #comment-vote-message').animate({top:'-20px'},500,function(){$('#loginLink, .login-box-close').unbind('click').bind('click',loginUp);});return false;};var loginUp=function(){$('#loginLink, .login-box-close').unbind('click').bind('click',function(){return false;})
$('#login-box, #comment-vote-message').animate({top:'-280px'},500,function(){$('#loginLink, .login-box-close').unbind('click').bind('click',loginDown);});return false;};var currentComment=-1;var commentReply=function(){var cid=parseInt($(this).attr('cid'));if(cid==currentComment)
return false;currentComment=cid;$('#commentBox').slideUp('fast',function(){$('#commentBox').siblings('.comment-body').css({borderBottom:'1px solid #646464'});$('#commentBox').appendTo('#comment-'+cid+' .comment-inner');if($('#comment-'+cid).hasClass('comment-inf'))
$('#commentBox').addClass('comment-box-inf');else
$('#commentBox').removeClass('comment-box-inf');$('#commentBox').slideDown('fast');$('#commentBox').siblings('.comment-body').css({borderBottom:'0px'});$('#inputReplyTo').val(cid);});return false;};var commentClose=function(){$('#commentBox').slideUp('fast',function(){$('#commentBox').siblings('.comment-body').css({borderBottom:'1px solid #646464'});$('#inputReplyTo').val(-1);currentComment=-1;});return false;};var commentVote=function(vote,cid){$(this).unbind('click');var c_vote=vote,c_cid=cid;$.post('/ajax/comment/vote',{cid:c_cid,vote:vote},function(d){var data=eval('('+d+')');if(data.success)
$('#comment-'+c_cid+' .score').html(data.newscore);else
{loginDown();$('#comment-vote-message').animate({top:'160px'},250);}});};var episodeVote=function(){var vote=parseInt($(this).html()),episode=$('.rate-scores').attr('episode');$.post('/ajax/episodes/vote',{vote:vote,episode:episode},function(d){var data=eval('('+d+')');$('.rate-scores li').children('a').removeClass('voted');$('.rate-scores li:eq('+vote+')').children('a').addClass('voted');$('.current-score b:first').html(data.score);$('.current-score b:last').html(data.votes);});return false;};var checkForm=function(){var formID=$(this).attr('id'),fData=formData[formID],errors=Array();$(this).find('input, select, textarea').each(function(i,d){var thisID=$(this).attr('id');if(fData.required[thisID]==1)
{var highlight=$(this);if($(this).attr('althighlight'))
highlight=$($(this).attr('althighlight'));if($(this).is('[type=checkbox]:not(:checked)')||$.trim($(this).val()).length==0||$(this).val()==$(this).attr('default'))
{if(fData.errClass)
highlight.addClass(fData.errClass[thisID]);else
highlight.addClass('redBorder');if($(this).attr('fullmsg'))
errors[errors.length]=$(this).attr('fullmsg');else
{var pre=$(this).attr('dname')?$(this).attr('dname'):'This';errors[errors.length]=pre+' is a required field';}}
else
{if(fData.errClass)
highlight.removeClass(fData.errClass[thisID]);else
highlight.removeClass('redBorder');}}});if(!errors.length)
{$(fData.errorBox).empty().hide();return true;}
else
{$(fData.errorBox).empty().show();$.each(errors,function(i,d){$(fData.errorBox).append(d+'<br />');});return false;}};var formData={contactForm:{required:{selectContactType:1,textareaContactInfo:1},errorBox:'#formErrors'}};var overlayShadow=function(){if(!$('.shadowman9').length)
{$('<div />').addClass('shadowman9').appendTo('body').fadeTo(350,0.5);$('.shadowman9').click(removeOverlay);}};var removeOverlay=function(){$('.shot-overlay img').stop();$('.shadowman9, .shot-overlay').stop().fadeOut(350,function(){$('.shadowman9, .shot-overlay').remove();});};var showContents=function(){$(this).children('div').stop().clearQueue().fadeTo(250,1.0);};var hideContents=function(){$(this).children('div').stop().clearQueue().fadeTo(250,0.0);};var doImgOverlay=function(i,gallery){var imgpath=i.attr('rel');overlayShadow();if(!$('.shot-overlay').length)
{$('<div />').addClass('shot-overlay').appendTo('body');}
$('.shot-overlay').html('<div class="centerit"><img src="/img/spinner.gif" alt="" /> Loading...</div>');$('<img />').attr({src:imgpath}).load(function(){var dims={width:this.width,height:this.height},winh=$(window).height(),winw=$(window).width(),imgsrc=$(this);imgsrc.hide().attr({width:1,height:1});if(winw<dims.width)
{dims.height*=(winw-60)/dims.width;dims.width=winw-60;}
if(winh<dims.height)
{dims.width*=(winh-80)/dims.height;dims.height=winh-80;}
$('div.shot-overlay:last').html(imgsrc).animate({width:dims.width+'px',height:dims.height+'px',marginLeft:((dims.width/2)*-1)+'px',marginTop:((dims.height/2)*-1)+'px'},500,function(){imgsrc.css({width:dims.width+'px',height:dims.height+'px'}).fadeIn();$('<div />').addClass('top-hover').css({width:dims.width+'px'}).hover(showContents,hideContents).appendTo('div.shot-overlay:last');$('<div />').addClass('overlay-close').css({left:dims.width-50+'px'}).html('X').click(removeOverlay).appendTo('div.shot-overlay:last div.top-hover');if(gallery)
{var hwidth=(dims.width/4);if(i.nextAll(gallery).length)
{$('<div />').addClass('right-hover').css({width:hwidth+'px',height:(dims.height-25)+'px',left:(dims.width-hwidth+10)+'px'}).appendTo('div.shot-overlay:last');$('<a href="" />').addClass('overlay-next').css({left:(hwidth-150)+'px'}).html('Next').click(function(){i.nextAll(gallery).first().trigger('click');return false;}).appendTo('div.right-hover');$('div.right-hover').hover(function(){$('a.overlay-next').fadeIn(250);},function(){$('a.overlay-next').fadeOut(250);});}
if(i.prevAll(gallery).length)
{$('<div />').addClass('left-hover').css({width:hwidth+'px',height:(dims.height-25)+'px',left:'10px'}).appendTo('div.shot-overlay:last');$('<a href="" />').addClass('overlay-prev').html('Previous').click(function(){i.prevAll(gallery).first().trigger('click');return false;}).appendTo('div.left-hover');$('div.left-hover').hover(function(){$('a.overlay-prev').fadeIn(250);},function(){$('a.overlay-prev').fadeOut(250);});}}});});};var doOtherOverlay=function(i){var path=i.attr('href');overlayShadow();$('<div />').addClass('shot-overlay').appendTo('body');$('<iframe />').attr({src:'http://new.mantiseye.com/?get='+path}).appendTo('.shot-overlay').animate({width:'500px',height:'400px'},500);$('div.shot-overlay:last').animate({width:'500px',height:'400px',marginLeft:'-250px',marginTop:'-200px'},500,function(){$('<div />').addClass('top-hover').css({width:'500px'}).hover(showContents,hideContents).appendTo('div.shot-overlay:last');$('<div />').addClass('overlay-close').css({left:'450px'}).html('X').click(removeOverlay).appendTo('div.shot-overlay:last div.top-hover');});};function checkCookie(cookie_name)
{var m_cookies=document.cookie.split(';');for(var i=0;i<m_cookies.length;i++)
{c_name=m_cookies[i].substr(0,m_cookies[i].indexOf('='));c_name=c_name.replace(/^\s+|\s+$/g,'');if(c_name==cookie_name)
return m_cookies[i].substr(m_cookies[i].indexOf('=')+1);}}
$(document).ready(function(){$('.loginLink').click(loginDown);$('.login-box-close').click(loginUp);if($('.message').length)
setTimeout('collapseMessages()',5000);$('.checkbox-holder').click(function(){$(this).children('input[type=checkbox]').each(function(i,o){if($(this).attr('checked'))
$(this).removeAttr('checked');else
$(this).attr({checked:'checked'});});});$('.new-comment a, .reply-button').click(commentReply);$('.comment-box-close').click(commentClose);$('.vote-up').click(function(){commentVote(1,$(this).parents('.comment').attr('cid'))});$('.vote-down').click(function(){commentVote(-1,$(this).parents('.comment').attr('cid'))});$('a.img-pop').click(function(){doImgOverlay($(this),false);return false;});$('.screenshot-thumb').click(function(){$(this).attr({rel:$(this).attr('href')});doImgOverlay($(this),false);return false;});$('form.checkform').submit(checkForm);$('#inputSearch').focus(function(){var v=$(this).val();if(!v.length||v==$(this).attr('default'))
$(this).val('');}).blur(function(){var v=$(this).val();if(!v.length)
$(this).val($(this).attr('default'));});$('#comment-form-anon, #comment-form').submit(function(){var form_id=$(this).attr('id'),comment=$.trim($('#textareaComment').val()),errctr=0;if(comment.length<5)
{$('#commentBodyMsg').css({color:'#C00000'}).html('Please write a comment with at least five characters.');errctr++;}
else
{$('#commentBodyMsg').html('');}
if(form_id=='comment-form-anon')
{var uname=$('#inputUserName').val();if(uname.length)
{$.post('/ajax/user-search',{search:uname},function(d){var dat=eval('('+d+')');if(dat.found)
{if(dat.found>0)
{$('#commentNameMsg').css({color:'#C00000'}).html('Sorry, that username has already been registered.');errctr++;}
else
$('#commentNameMsg').html('');if(!errctr)
$('#comment-form-anon').unbind('submit').submit();}});}}
else
{if(!errctr)
$('#comment-form').unbind('submit').submit();}
return false;});});var cycleTime=1000,holdTime=4500,currentItem=0,cycleTimer=null,numItems=0,runCycle=function(){var nextItem=currentItem+1;if(nextItem>numItems-1)
nextItem=0;$('#carousel-main li:visible').fadeOut(cycleTime,function(){$('#carousel-selector li:eq('+currentItem+')').children('a').removeClass('active');currentItem=nextItem;});$('#carousel-main li:eq('+nextItem+')').fadeIn(cycleTime,function(){$('#carousel-selector li:eq('+nextItem+')').children('a').addClass('active');cycleTimer=setTimeout(runCycle,holdTime);});},cycleHeadlines=function(){var ulwidth=0;$('#carousel-main li').each(function(i,d){$('<li />').appendTo('#carousel-selector');$('<a href="" />').appendTo('#carousel-selector li:last');ulwidth+=$('#carousel-selector li:last').outerWidth(true);});numItems=$('#carousel-main li').length;$('#carousel-selector').css({width:ulwidth+'px',paddingLeft:(640-ulwidth)+'px'});$('#carousel-main li').hide();$('#carousel-main li:eq('+currentItem+')').show();$('#carousel-selector li:eq('+currentItem+')').children('a').addClass('active');if(cycleTimer==null)
cycleTimer=setTimeout(runCycle,holdTime);},enterBox=function(){clearTimeout(cycleTimer);cycleTimer=null;$('#carousel-main li').stop().hide().css({opacity:'1.0'});$('#carousel-main li:eq('+currentItem+')').show();},exitBox=function(){if(cycleTimer==null)
cycleTimer=setTimeout(runCycle,holdTime);};$(document).ready(function(){$('#carousel-main').mouseenter(enterBox);$('#carousel-main').mouseleave(exitBox);cycleHeadlines();$('#carousel-selector li').mouseenter(function(){var ind=$(this).prevAll().length;$('#carousel-main li').hide();$('#carousel-main li:eq('+ind+')').show();$('#carousel-selector li').children('a').removeClass('active');$(this).children('a').addClass('active');clearTimeout(cycleTimer);currentItem=ind;});$('#carousel-selector li').mouseleave(function(){});});$(document).ready(function(){$('ul.epcaps-header li').click(function(){var ind=parseInt($(this).index());if(ind)
{$('ul.epcaps-header li a.active').removeClass('active');$(this).children('a').addClass('active');$('.epcapholder ul:not(.epcaps-header)').hide();$('.epcapholder ul:eq('+(ind)+')').show();}
return false;});$('ul.epcaps-header li:last').trigger('click').css({width:'37px'});var isAnimating=false;$('.schedule-holder #scroll-up').click(function(){if(isAnimating)return false;var move=$('#schedule-scroller li:first').outerHeight(true),ptop=parseInt($('#schedule-scroller ul').css('top')),pheight=$('#schedule-scroller ul').outerHeight(true),vheight=$('#schedule-scroller').height();if(ptop-move+pheight>vheight)
{isAnimating=true;$('#schedule-scroller ul').animate({top:'-='+move+'px'},350,function(){isAnimating=false;});}});$('.schedule-holder #scroll-down').click(function(){if(isAnimating)return false;var move=$('#schedule-scroller li:first').outerHeight(true),ptop=parseInt($('#schedule-scroller ul').css('top'));if(ptop+move<=0)
{isAnimating=true;$('#schedule-scroller ul').animate({top:'+='+move+'px'},350,function(){isAnimating=false;});}});$('.features-container h3.feat-bottom').each(function(){var text=$(this).html();text=text.replace('Mantis-Eye','<span class="mantiseye">Mantis-Eye</span>');$(this).html(text);});});
