//© Ward6 2010
//For debugging see http://www.ward6.com.au/wp-content/themes/ward6/js/work.js


function ActiveGrid(gridHolder){this.rows=new Array();var works=document.getElementById(gridHolder);this.domElement=works;works=works.getElementsByTagName('article');var numberOfWorks=works.length;var colNo=0;var newRow=new Row(this);var rowArticles=new Array();var lowEndBrowser=$.browser.msie&&parseInt($.browser.version)<9;for(articleNo=0;articleNo<numberOfWorks;articleNo++){var articleElement=works[articleNo];var jqArticle=$(articleElement);var jqTag=jqArticle.children(".tag");if(!this.lowEndBrowser){jqTag.css({opacity:'1.0'}).fadeOut(100);}else{jqTag.hide();}
var thisArticle=new Article(newRow,articleElement,jqArticle,jqTag);jqArticle.data('instantiatedActiveGrid',this);jqArticle.data('articleObject',thisArticle);var width=jqArticle.width();thisArticle.setWidth(width);jqArticle.hover(function(){var jqThis=$(this);var iAG=jqThis.data('instantiatedActiveGrid');var thisArticle=jqThis.data('articleObject');var otherArticles=jqThis.siblings();otherArticles.fadeTo(100,.4);if(thisArticle!==null){thisArticle.parentRow.makeRoom(thisArticle.cellNo);thisArticle.parentRow.activeCell=thisArticle.cellNo;var newWidth=thisArticle.standardWidth+iAG.desiredWidth;thisArticle.jqElement.css({zIndex:20});thisArticle.jqElement.stop(true,false).animate({width:newWidth+'px',opacity:'1'},300,'easeinout');}
var thisTag=thisArticle.jqTag;if(!this.lowEndBrowser){thisTag.stop(true,true).delay(100).fadeIn(100);}else{thisTag.show();}},function(){var jqThis=$(this);var thisArticle=jqThis.data('articleObject');thisArticle.parentRow.activeCell=-1;thisArticle.parentRow.restore();thisArticle.jqElement.css({zIndex:10});$(this).fadeTo(100,.4);var thisTag=thisArticle.jqTag;if(!this.lowEndBrowser){thisTag.stop(true,true).delay(100).fadeOut(50);}else{thisTag.hide();}});rowArticles.push(thisArticle);colNo++;if(colNo===this.articlesPerRow){colNo=0;newRow.articles=rowArticles;this.rows.push(newRow);newRow=new Row(this);rowArticles=new Array();}}
jqGrid=$("#"+gridHolder);jqGrid.data('instantiatedArticleGrid',this);jqGrid.hover(null,function(){var iAG=$(this).data('instantiatedArticleGrid');iAG.deactivate();});}
ActiveGrid.prototype.rows;ActiveGrid.prototype.articlesPerRow=4;ActiveGrid.prototype.domElement;ActiveGrid.prototype.activeCell;ActiveGrid.prototype.desiredWidth=30;ActiveGrid.prototype.deactivate=function(){var rowNo=this.rows.length;while(rowNo--){var theRow=this.rows[rowNo];theRow.restore(true);}}
function Row(parentGridObject){this.parentGrid=parentGridObject;this.rowNo=parentGridObject.rows.length;this.domElement=this.parentGrid.domElement
this.articles=new Array();}
Row.prototype.rowNo;Row.prototype.parentGrid;Row.prototype.domElement;Row.prototype.jqElement;Row.prototype.articles;Row.prototype.activeCell;Row.prototype.getCell=function(article){var cellNo=this.articles.length;while(cellNo--){var thisCell=this.articles[cellNo];if(thisCell.domElement===article){return thisCell;}}
return null;}
Row.prototype.makeRoom=function(columnNo){var displacement=0;var cellNo=this.articles.length;var widthDifference=Math.floor(this.parentGrid.desiredWidth/(cellNo-1));while(cellNo--){if(cellNo!==columnNo){var thisCell=this.articles[cellNo];var newWidth=thisCell.standardWidth-widthDifference;thisCell.jqElement.stop(true,false).animate({width:newWidth+'px',opacity:'0.4'},300,'easeinout');}}}
Row.prototype.restore=function(restoreAlpha){if(restoreAlpha===undefined)restoreAlpha=false;if(this.activeCell===-1){var cellNo=this.articles.length;while(cellNo--){var thisCell=this.articles[cellNo];if(restoreAlpha){thisCell.jqElement.stop(true,false).animate({width:thisCell.standardWidth+'px',opacity:'1.0'},200,'easeinout');}else{thisCell.jqElement.stop(true,false).animate({width:thisCell.standardWidth+'px'},200,'easeinout');}}}}
function Article(row,domElementSpec,jqElementSpec,jqTagSpec){this.parentRow=row;this.domElement=domElementSpec;this.jqElement=jqElementSpec;this.jqTag=jqTagSpec;this.cellNo=this.parentRow.articles.length-1;}
Article.prototype.parentRow;Article.prototype.domElement;Article.prototype.jqElement;Article.prototype.jqTag;Article.prototype.cellNo;Article.prototype.standardWidth;Article.prototype.setWidth=function(width){if(this.standardWidth===undefined){this.standardWidth=width;}}
var articleGrid;$(document).ready(function(){articleGrid=new ActiveGrid('works');});
