
$(document).ready(function(){var defaultTitle=$('title').text();$.preloadImages('/framework/images/tab-sprite.png','/framework/images/oneword-profile-modal.png','/framework/images/site-content-modal.png');$('<div id="help"></div>').appendTo('div#site-wrapper');$('a#oneword-visualizer-help').live('click',function(){if($('div#help').css('display')=='block'){$('div#help').hide();}else{$('div#help').show();}
return false;});$('div#help').live('mouseover',function(){$('div#help').animate({left:734},500,function(){if($.browser.msie){$('div#help').hide();}else{$('div#help').fadeOut('slow');}});});if(!$.cookie('onewordVisitor')){$.ajax({url:'/welcome.php',cache:false,success:function(html){$.BlockUI();$('<div id="site-content-modal">').appendTo('body').html('<div id="site-content-modal-content" class="nav-welcome">'+$('#site-content',html).html()+'<a href="#" id="site-content-modal-close">Close Window</a></div>');$('div#help').show();document.title='One Word Project | Welcome';$.cookie('onewordVisitor','true',{expires:30,path:'/'});}});}else{$.cookie('onewordVisitor','true',{expires:30,path:'/'});}
reloadCommunity('initial');$('input:text').defaultText();$.ajax({url:'/oneword-search.php',cache:false,success:function(html){$('<div id="oneword-words-tab">').appendTo('div#site-wrapper').html($('#site-content',html).html());}});$('li#oneword-search-words a').toggle(function(){if($('div#oneword-filter-tab').hasClass('tab-open')){$('li#oneword-images-filter a').trigger('click');}
$('#search-container').removeClass('search-container-active');$('div#oneword-words-tab').addClass('tab-open');return false;},function(){$('div#oneword-words-tab').removeClass('tab-open');return false;});$('li#oneword-images-filter a').toggle(function(){$.ajaxInfo('Loading filters &hellip;');$.ajax({url:'/oneword-filter.php',cache:false,success:function(html){$.removeAjaxInfo();$('<div id="oneword-filter-tab">').appendTo('div#site-wrapper').html($('#site-content',html).html());customSelect();if($('div#oneword-words-tab').hasClass('tab-open')){$('li#oneword-search-words a').trigger('click');}
$('#search-container').removeClass('search-container-active');$('div#oneword-filter-tab').addClass('tab-open');}});return false;},function(){$('div#oneword-filter-tab').remove();return false;});$('form#oneword-filter input:submit').live('click',function(){$.cookie('SearchType',$('input#SearchType').val(),{path:'/'});$.cookie('FilterYear',$('select#FilterYear').val(),{path:'/'});$.cookie('FilterType',$('select#FilterType').val(),{path:'/'});$.cookie('FilterMajor',$('select#FilterMajor').val(),{path:'/'});$('li#oneword-images-filter a').trigger('click');reloadCommunity('filter');return false;});var videoContentArray=new Array();var videoNumericArray=new Array();$('ul#site-navigation-main a').click(function(){$this=$(this);$.ajaxInfo('Loading content &hellip;');$.ajax({url:$(this).attr('href'),cache:false,success:function(html){$.removeAjaxInfo();$.BlockUI();$('<div id="site-content-modal">').appendTo('body').html('<div id="site-content-modal-content" class="'+$this.parent('li').attr('id')+'">'+$('#site-content',html).html()+'<a href="#" id="site-content-modal-close">Close Window</a></div>');document.title='One Word Project | '+$this.text();$i=0;$('div.video').each(function(){videoContentArray[$(this).attr('id')]=$(this).html();videoNumericArray[$i]=$(this).attr('id');$(this).remove();$i++;});$('div.nav-about').find('div#site-content-videos').append('<div id="video-holder" class="video"></div>');}});return false;});$('ul#about-project-subnav a').live('click',function(){$this=$(this);$('div.nav-about div.about-content').hide();$('div.nav-about').find('div#'+$this.attr('rel')).show();if($this.attr('rel')=='site-content-videos'){$this.closest('ul').addClass('selected');$('div#video-holder').html(videoContentArray[videoNumericArray[0]]);$('a.video-link').removeClass('selected');$('a[rel='+videoNumericArray[0]+']').addClass('selected');}else{$this.closest('ul').removeClass('selected');$('div#video-holder').empty();}
return false;});$('a.video-link').live('click',function(){$('a.video-link').removeClass('selected');$(this).addClass('selected');$('div#video-holder').html(videoContentArray[$(this).attr('rel')]);return false;});$('a.ajax-profile').live('click',function(){$this=$(this);$.ajaxInfo('Loading &lsquo;'+$this.attr('rel')+'&rsquo; &hellip;');$.ajax({url:$(this).attr('href'),cache:false,success:function(html){$.removeAjaxInfo();$.BlockUI();$('<div id="oneword-profile-modal">').appendTo('body').html($('#site-content',html).html()+'<a href="#" id="site-content-modal-close">Close Window</a>');if($('#oneword-detail',html).hasClass('no-text')){$('div#oneword-profile-modal').addClass('no-text');}
document.title='One Word Project | '+$this.attr('rel');}});return false;});$('div#oneword-detail img').live('contextmenu',function(e){return false;});$('ul#search-wordlist a.ajax-search').live('click',function(){$.cookie('SearchType',$.getAllQueryStrings({URL:$(this).attr('href')})['SearchType'].value,{path:'/'});$.cookie('SearchVal',$.getAllQueryStrings({URL:$(this).attr('href')})['ShowWord'].value,{path:'/'});$('li#oneword-search-words a').trigger('click');reloadCommunity('filter');return false;});$('div#oneword-images-visualizer a.clear-search').live('click',function(){$.cookie('SearchType',null,{path:'/'});$.cookie('SearchVal',null,{path:'/'});reloadCommunity('filter');return false;});$('div#oneword-images-visualizer a.clear-filter').live('click',function(){$.cookie($.getAllQueryStrings({URL:$(this).attr('href')})['FilterType'].value,null,{path:'/'});reloadCommunity('filter');return false;});$('a#site-content-modal-close, div#UIBlock').live('click',function(){$('div#site-content-modal, div#oneword-profile-modal').remove();$.unBlockUI();document.title=defaultTitle;return false;});$('ul#search-alphabet a').live('click',function(){$('ul#search-wordlist').scrollTo($(this).attr('href'),'fast');return false;});setWidth();var gestureArea=240;var timeInterval=10;var moveInterval=1000;var containerWidth=$('div#oneword-images').width();var mousePos=false;var moving=false;var easing='linear';var counterFrom=0;var counterTo=0;gestureScroll=setInterval("checkMouse()",timeInterval);checkMouse=function(){if(mousePos==true){moveList();}};$('div#oneword-images').mousemove(function(e){var offset=e.pageX-$('div#oneword-images').offset().left;if(offset<=gestureArea){moveIncrement=Math.round(offset-gestureArea);moveDistance=120;}else if(offset>=(containerWidth-gestureArea)){moveIncrement=Math.round(offset-(containerWidth-gestureArea));moveDistance=-120;}else{moveIncrement=0;moveDistance=0;}
if(moveIncrement<0){moveIncrement=moveIncrement*-1;}
if(moveIncrement>=((gestureArea/3)*2)){moveInterval=250;easing='linear';}else if(moveIncrement>=(gestureArea/3)){moveInterval=500;easing='easeOutSine';}else{moveInterval=1000;easing='easeOutSine';}});mouseOverFunc=function(){mousePos=true;};mouseOutFunc=function(){mousePos=false;};var config={interval:50,over:mouseOverFunc,timeout:160,out:mouseOutFunc};$('div#oneword-images').hoverIntent(config);moveList=function(){var containerPos=$('div#oneword-images').offset().left-$('div#oneword-images ul#oneword-images-carousel').offset().left;if(moveDistance<0&&containerPos>=($('div#oneword-images ul#oneword-images-carousel').width()-$('div#oneword-images').width())){}else if(moveDistance>0&&containerPos<=0){}else{activateMove();}};activateMove=function(){if(!moving){var unitSize=$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').outerWidth();var unitsLeft=(parseInt($('div#oneword-images ul#oneword-images-carousel').css('left'))/unitSize)*-1;var unitsRight=$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').size()-unitsLeft-(containerWidth/unitSize);if(moveDistance<0){counterFrom=(((unitsLeft+1)+(($('div#oneword-images ul#oneword-images-carousel').attr('class')-2)*16))*4)+1;}else if(moveDistance>0){counterFrom=(((unitsLeft-1)+(($('div#oneword-images ul#oneword-images-carousel').attr('class')-2)*16))*4)+1;}
if(moveDistance<0||moveDistance>0){counterTo=counterFrom+31;$('span#pagelocation-range').html(counterFrom+' &ndash; '+counterTo);}
moving=true;$('div#oneword-images ul#oneword-images-carousel').animate({left:parseInt($('div#oneword-images ul#oneword-images-carousel').css('left'))+moveDistance},moveInterval,easing,function(){if((moveDistance<0)&&((unitsRight-1)==0)&&!$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group:last').is('#oneword-last')){moving=true;$.ajaxInfo('Fetching more members &hellip;');$.ajax({type:'POST',url:'/framework/php/ajax.community.php',data:'start='+(parseInt($('div#oneword-images ul#oneword-images-carousel').attr('class'))*64)+'&number=64',success:function(html){$.removeAjaxInfo();$('div#oneword-images ul#oneword-images-carousel').append(html);$('div#oneword-images ul#oneword-images-carousel').attr('class',(parseInt($('div#oneword-images ul#oneword-images-carousel').attr('class'))+1));$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').slice(0,16).remove();$('div#oneword-images ul#oneword-images-carousel').css('left',(parseInt($('div#oneword-images ul#oneword-images-carousel').css('left'))+(16*$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').outerWidth())));setWidth();moving=false;}});}else if((moveDistance<0)&&((unitsRight-1)==0)&&$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group:last').is('#oneword-last')){moving=false;$('span#pagelocation-range').html(counterFrom+' &ndash; '+$('span#pagelocation-total').text());}else if((moveDistance>0)&&((unitsLeft-1)==0)&&!$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group:first').is('#oneword-first')){moving=true;$.ajaxInfo('Fetching more members &hellip;');$.ajax({type:'POST',url:'/framework/php/ajax.community.php',data:'start='+(parseInt($('div#oneword-images ul#oneword-images-carousel').attr('class')-3)*64)+'&number=64',success:function(html){$.removeAjaxInfo();$('div#oneword-images ul#oneword-images-carousel').prepend(html);$('div#oneword-images ul#oneword-images-carousel').attr('class',(parseInt($('div#oneword-images ul#oneword-images-carousel').attr('class'))-1)).css('left',(parseInt($('div#oneword-images ul#oneword-images-carousel').css('left'))-(16*$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').outerWidth())));num=($('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').size()/16);if(parseInt(num)==num){remove=16;}else if(parseFloat(num)==num){remove=$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').size()-(Math.floor(num)*16);}
$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').slice(($('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').size()-remove),$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').size()).remove();setWidth();moving=false;}});}else if((moveDistance>0)&&((unitsLeft-1)==0)&&$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group:first').is('#oneword-first')){moving=false;}else{moving=false;}});}};$('div#site-wrapper').append('<div id="searching"><img src="/framework/images/ajax-loader-16.gif" width="16" height="16" /></div>');$('#SearchWord').focus(function(){if($('div#oneword-filter-tab').hasClass('tab-open')){$('li#oneword-images-filter a').trigger('click');}
if($('div#oneword-words-tab').hasClass('tab-open')){$('li#oneword-search-words a').trigger('click');}});var current=-1;var numView=5;$('div#site-wrapper').append('<div id="search-container">');$('#SearchWord').keyup(function(e){$this=$(this);if($this.val().length>=2){if(e.which==38||e.which==40){height=$('#search-container li').height()*numView;offset=$('#search-container ul').scrollTop();if(e.which==38){if((current-1)<0){current=($('#search-container li').size()-1);}else{current--;}
if(current==($('#search-container li').size()-1)){$('#search-container ul').scrollTop($('#search-container li').size()*$('#search-container li').height()-height);}else if((current*$('#search-container li').height())<offset){$('#search-container ul').scrollTop(current*$('#search-container li').height());}}else if(e.which==40){if((current+1)==$('#search-container li').size()){current=0;}else{current++;}
if(current==0){$('#search-container ul').scrollTop(0);}else if(((current*$('#search-container li').height())-offset)>=height){$('#search-container ul').scrollTop(((current+1)*$('#search-container li').height())-height);}}
$('#search-container li a').removeClass('hover');$('#search-container li:eq('+current+') a').addClass('hover');}else{current=-1;$('#search-container').addClass('search-container-active');$('#searching').css({top:$this.offset().top+(($this.outerHeight()-$('#searching').outerHeight())/2),left:$this.offset().left-$('div#site-wrapper').offset().left+4});$.ajax({type:"GET",url:"/framework/php/ajax.search.php?search="+$this.val(),cache:false,success:function(html){$('#SearchWord').ajaxStop(function(){$('#searching').css('left',-9999);});$('#search-container').html(html);$('body, html').click(function(){$('#search-container').removeClass('search-container-active');});$('#search-container li a').hover(function(){$('#search-container li a').removeClass('hover');$(this).addClass('hover');},function(){$(this).removeClass('hover');});},fail:function(){}});}}else{$('#search-container').removeClass('search-container-active');}});$('#SearchWord').keydown(function(e){if(e.which==9){$('#search-container').removeClass('search-container-active');}else if(e.which==13){if(current>=0){$('#search-container li:eq('+current+') a').trigger('click');}
$('#search-container').removeClass('search-container-active');$('#SearchWord').trigger('blur');}});});reloadCommunity=function(loadType){if(loadType=='initial'){$.ajaxInfo('Loading the One Word Community &hellip;');}else if(loadType=='filter'){$.ajaxInfo('Updating the One Word Community &hellip;');}
$.ajax({type:'GET',url:'/framework/php/ajax.visualizer.php?load=AJAX',success:function(html){$('div#oneword-images-visualizer').html(html+'<a id="oneword-visualizer-help" href="#">Help</a>');}});$.ajax({type:'POST',url:'/framework/php/ajax.community.php',data:'start=0&number=128',success:function(html){$.removeAjaxInfo();$('div#oneword-images').html('<ul id="oneword-images-carousel" class="2">'+html+'</ul>');setWidth();}});};$.ajaxInfo=function(message){$('<div id="ajaxInfo">'+message+'<img src="/framework/images/ajax-loader-16Black.gif" width="16" height="16" /></div>').appendTo('body');$('div#ajaxInfo').css({marginLeft:'-'+($('div#ajaxInfo').outerWidth()/2)+'px'});if($.browser.msie){$('div#ajaxInfo').css({background:'#000',opacity:0.75});}};$.removeAjaxInfo=function(){$('#ajaxInfo').fadeOut(100,function(){$(this).remove();});};$.BlockUI=function(){$('<div id="UIBlock"></div>').css({background:'#000',height:'100%',left:0,opacity:0.75,position:'fixed',top:0,width:'100%',zIndex:900}).appendTo('body');if($.browser.msie&&($.browser.version<7)){$('div#UIBlock').css({position:'absolute',top:$(window).scrollTop()});}};$.unBlockUI=function(){$('#UIBlock').fadeOut(100,function(){$(this).remove();});};customSelect=function(){$('.select-wrapper').each(function(){$this=$(this);$this.prepend('<span>'+$this.find('select option:selected').text()+'</span>');});$('.select-wrapper select').bind('change',function(){$(this).prev('span').replaceWith('<span>'+$(this).find('option:selected').text()+'</span>');});};setWidth=function(){$('div#oneword-images ul#oneword-images-carousel').css({width:$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').size()*$('div#oneword-images ul#oneword-images-carousel li.oneword-images-carousel-group').outerWidth()});};$.preloadImages=function(){for(var i=0;i<arguments.length;i++){$('<img>').attr('src',arguments[i]);}};