var sip=false,brefresh=true,typing=false;function fixString(item){item=item.replace(/\\/gi,"\\\\");item=item.replace(/'/gi,"\\'");return item;}
function runSearch(){var cVal=$('#q').val();if(!typing&&cVal.length>2){sip=true;$.post('/ajax/qsearchmysql.php?'+Math.random(),{q:cVal},function(data){var cVal2=$('#q').val();sip=false;if(cVal!=cVal2&&cVal2.length>2)
runSearch(cVal2);else
$('#liveBox').html(data).show();});}
if(typing)
setTimeout("runSearch('"+fixString(cVal)+"')",100);}
function isTypingInSearch(termThen){var termNow=$('#q').val();if(termNow==termThen)
typing=false;else
setTimeout("isTypingInSearch('"+fixString(termNow)+"')",250);}
function activateRefresh(){$('#refresh').css({'opacity':'1','cursor':'pointer'});brefresh=true;}
$(function(){$('#refresh').click(function(event){event.preventDefault();if(brefresh)
$.getScript('/ajax/randombanner.php?'+Math.random(),function(){$('.ileft div').html("\"<a href='/series/"+banner[0]+"' title='Read \""+banner[1]+"\" now!'>"+banner[1]+"</a>\" by <a href='/mangaka/"+banner[2]+"' title='View all of "+banner[2]+"'s works on MangaToshokan'>"+banner[2]+" </a>");$('#banner').attr('href','/series/'+banner[0]).attr('title','Read "'+banner[1]+'" now!').css('background-image','url(http://img.mangatoshokan.com/images/banners/'+banner[3]+')');$('#refresh').css({'opacity':'.5','cursor':'default'})
brefresh=false;setTimeout("activateRefresh()",1000);});});$('#q').val('Enter a term here to search...').focus(function(){if(this.value=='Enter a term here to search...')
$('#q').val('').css('font-style','normal');}).blur(function(){if(this.value=="")
$('#q').val('Enter a term here to search...').css('font-style','italic');}).keyup(function(){var q=$('#q').val();if(!sip&&q.length>2){runSearch();}else if(!sip)
$('#liveBox').html('').hide();if(!typing)setTimeout("isTypingInSearch('"+fixString(q)+"')",250);typing=true;});if(document.getElementById('loginform'))
$('#loginform').submit(function(){if($('#loginform input:text').val().length<2){alert('You must enter a username that is at least two characters long.');return false;}else if($('#loginform input:password').val().length<2){alert('You must enter a password that is at least two characters long.');return false;}else
return true;});});function oLoc(loc){window.location.href=loc;}