$(document).ready(function(){$("#comparison-grid table").replaceWith('<div id="breakout"></div>');
$("#breakout").append(createTable()).css({position:"absolute",paddingRight:"15px"});
var B=$("#breakout").height();
$("#comparison-grid").height(B);
redrawBg();
$("#content-primary").prepend('<p class="controls"><a href="#" class="reset"><i>Reset comparison table</i></a></p>');
$(".reset").click(function(){$("#comparison-grid").animate({opacity:0},200).queue(function(){$(this).find("table").replaceWith(createTable());
$(this).animate({opacity:1},300);
redrawBg();
$(this).dequeue()
});
qs=createQuerySrtring(comparisonTable);
return false
});
qs=createQuerySrtring(comparisonTable);
$("#taskbar .pdf").mousedown(function(){writeQueryString($("#taskbar .pdf"),"productid="+qs.products+"&attributeid="+qs.attr)
})
});
$(window).resize(function(){redrawBg()
});
function redrawBg(){var C=$("#shell").offset().left-40;
$(document.body).css({"background-position-x":C});
var D=$("#breakout").height();
$("#comparison-grid").height(D)
}function writeQueryString(J,F){var H=J.attr("href");
var G=/(&?productid=[^&]*)&?/;
H=H.replace(G,"");
var I=/(&?attributeid=[^&]*)&?/;
H=H.replace(I,"");
if(H.indexOf("?")==-1){H=H+"?"+F
}else{H=H+"&"+F
}J.attr("href",H)
}function createQuerySrtring(G){var J=[];
var I=[];
var F=G.products.length;
for(i=0;
i<F;
i++){J.push(G.products[i].id)
}F=G.attributeGroups.length;
for(i=0;
i<F;
i++){var H=G.attributeGroups[i].attributes.length;
for(j=0;
j<H;
j++){I.push(G.attributeGroups[i].attributes[j].id)
}}return{products:J,attr:I}
}function createTable(){var O,Q,T,N,L,V,P,S,M;
var U=newEl("table",{summary:"Comparison matrix of selected Products (columns) and their features (rows) - Products and features can be removed from the table"});
O=newEl("thead");
U.appendChild(O);
N=newEl("tr",{className:"product-name"});
V=newEl("td",{className:"blank first"});
O.appendChild(N);
N.appendChild(V);
S=comparisonTable.products.length;
for(i=0;
i<S;
i++){T=newEl("th",{id:"p"+i});
if(i===0){T.className="p1"
}if(i===S-1){T.className="last"
}$(T).hover(function(){var A=this.cellIndex;
$(this).addClass("over");
$("#comparison-grid thead .product-delete td").eq(A).addClass("over")
},function(){var A=this.cellIndex;
$(this).removeClass("over");
$("#comparison-grid thead .product-delete td").eq(A).removeClass("over")
}).click(function(){document.location=comparisonTable.products[i].url
}).data("id",comparisonTable.products[i].id);
L=newEl("div");
V=newEl("a",{href:comparisonTable.products[i].url},comparisonTable.products[i].name);
L.appendChild(V);
T.appendChild(L);
N.appendChild(T)
}N=newEl("tr",{className:"product-delete"});
V=newEl("td",{className:"blank first"});
O.appendChild(N);
N.appendChild(V);
for(i=0;
i<S;
i++){T=newEl("td",{headers:"p"+i});
if(i===0){T.className="delete p1"
}else{if(i===S-1){T.className="delete last"
}else{T.className="delete"
}}$(T).hover(function(){var A=this.cellIndex;
$(this).addClass("over");
$("#comparison-grid thead .product-name > *").eq(A).addClass("over")
},function(){var A=this.cellIndex;
$(this).removeClass("over");
$("#comparison-grid thead .product-name > *").eq(A).removeClass("over")
});
L=newEl("div");
V=newEl("a",{href:"#"+comparisonTable.products[i].id},"Close");
V.onclick=function(){deleteColumn(this);
return false
};
L.appendChild(V);
T.appendChild(L);
N.appendChild(T)
}N=newEl("tr",{className:"product-apply"});
V=newEl("td",{className:"blank first"});
O.appendChild(N);
N.appendChild(V);
for(i=0;
i<S;
i++){T=newEl("td",{headers:"p"+i});
if(i===0){T.className="apply p1"
}else{if(i===S-1){T.className="apply last"
}else{T.className="apply"
}}L=newEl("div");
if(comparisonTable.products[i].apply!=undefined){V=newEl("a",{href:comparisonTable.products[i].apply},"Apply");
L.appendChild(V)
}L.appendChild(V);
T.appendChild(L);
N.appendChild(T)
}tfoot=newEl("tfoot");
U.appendChild(tfoot);
N=newEl("tr",{className:"product-name"});
V=newEl("td",{className:"blank first"},"&#160;");
tfoot.appendChild(N);
N.appendChild(V);
S=comparisonTable.products.length;
for(i=0;
i<S;
i++){T=newEl("td");
if(i===S-1){T.className="last"
}if(i===0){T.className="p1"
}$(T).hover(function(){var A=this.cellIndex;
$(this).addClass("over");
$("#comparison-grid tfoot .product-delete td").eq(A).addClass("over")
},function(){var A=this.cellIndex;
$(this).removeClass("over");
$("#comparison-grid tfoot .product-delete td").eq(A).removeClass("over")
}).click(function(){document.location=comparisonTable.products[i].url
}).data("id",comparisonTable.products[i].id);
L=newEl("div");
V=newEl("a",{href:comparisonTable.products[i].url},comparisonTable.products[i].name);
L.appendChild(V);
T.appendChild(L);
N.appendChild(T)
}N=newEl("tr",{className:"product-delete"});
V=newEl("td",{className:"blank first"});
tfoot.appendChild(N);
N.appendChild(V);
for(i=0;
i<S;
i++){T=newEl("td",{headers:"p"+i});
if(i===0){T.className="delete p1"
}else{if(i===S-1){T.className="delete last"
}else{T.className="delete"
}}$(T).hover(function(){var A=this.cellIndex;
$(this).addClass("over");
$("#comparison-grid tfoot .product-name > *").eq(A).addClass("over")
},function(){var A=this.cellIndex;
$(this).removeClass("over");
$("#comparison-grid tfoot .product-name > *").eq(A).removeClass("over")
});
L=newEl("div");
V=newEl("a",{href:"#"+comparisonTable.products[i].id},"Close");
V.onclick=function(){deleteColumn(this);
return false
};
L.appendChild(V);
T.appendChild(L);
N.appendChild(T)
}N=newEl("tr",{className:"product-apply"});
V=newEl("td",{className:"blank first"});
tfoot.appendChild(N);
N.appendChild(V);
for(i=0;
i<S;
i++){T=newEl("td",{headers:"p"+i});
if(i===0){T.className="apply p1"
}else{if(i===S-1){T.className="apply last"
}else{T.className="apply"
}}L=newEl("div");
if(comparisonTable.products[i].apply!=undefined){V=newEl("a",{href:comparisonTable.products[i].apply},"Apply");
L.appendChild(V)
}L.appendChild(V);
T.appendChild(L);
N.appendChild(T)
}for(i=0;
i<comparisonTable.attributeGroups.length;
i++){Q=newEl("tbody");
Q.id="section"+(i+1);
$(Q).data("id",comparisonTable.attributeGroups[i].id);
N=newEl("tr",{className:"rowgroup"});
V=newEl("th",{className:"rowgrouphead first last",colspan:S+1,id:"rg"+i});
L=newEl("div",null,comparisonTable.attributeGroups[i].label);
V.appendChild(L);
N.appendChild(V);
Q.appendChild(N);
U.appendChild(Q);
for(j=0;
j<comparisonTable.attributeGroups[i].attributes.length;
j++){N=newEl("tr");
$(N).hover(function(){$(this).addClass("over")
},function(){$(this).removeClass("over")
});
$(N).data("id",comparisonTable.attributeGroups[i].attributes[j].id);
V=newEl("th",{className:"first",headers:"rg"+i,id:"f"+i+""+j});
L=newEl("div",null,comparisonTable.attributeGroups[i].attributes[j].label);
V.appendChild(L);
M=newEl("a",{href:"#"},"Close row");
M.onclick=function(){deleteRow(this);
return false
};
L.appendChild(M);
N.appendChild(V);
Q.appendChild(N);
for(k=0;
k<S;
k++){V=newEl("td",{headers:"rg"+i+" f"+i+""+j+" p"+k});
if(k===S-1){V.className="last"
}P=null;
if(typeof comparisonTable.products[k].featureSet!="undefined"&&comparisonTable.products[k].featureSet!=null){P=comparisonTable.products[k].featureSet[i][j]
}if(P===null){P="&nbsp;"
}if(P.toLowerCase()==="no"||P.toLowerCase()==="na"||P.toLowerCase()==="n/a"||P.toLowerCase()==="yes"){var R=P;
if(R.toLowerCase()==="na"||R.toLowerCase()==="n/a"){R="Not applicable"
}L=newEl("div");
M=newEl("i",null,R);
L.appendChild(M)
}else{L=newEl("div",null,P)
}if(P.toLowerCase()==="no"){$(V).addClass("no")
}if(P.toLowerCase()==="na"||P.toLowerCase()==="n/a"){$(V).addClass("nil")
}if(P.toLowerCase()==="yes"){$(V).addClass("yes")
}V.appendChild(L);
N.appendChild(V)
}}}return U
}function deleteColumn(J){var H=$(J).parents("td")[0].cellIndex;
var F=$(J).parents("tr").find("td").length;
if(F>3){var G=$("#comparison-grid tr").find("> *:eq("+H+") > div");
if($.browser.msie&&parseInt($.browser.version)<9){G.queue(function(){$(this).css({visibility:"hidden"});
$(this).animate({opacity:0},50);
$(this).dequeue()
})
}else{G.each(function(){var B=$(this).width();
var A=$(this).height();
$(this).css({width:B,height:A,overflow:"hidden"});
$(this).parent().css({width:"auto"});
$(this).animate({opacity:0},50);
$(this).animate({width:1},100)
})
}$(".rowgrouphead",$("#comparison-grid")).attr({colSpan:F-1});
G.queue(function(){var A=$(this).parent();
if($(A).hasClass("last")){$(A).prev().eq(0).addClass("last")
}if($(A).hasClass("p1")){$(A).next().eq(0).addClass("p1")
}$(A).remove();
redrawBg();
$(this).dequeue()
});
if(F===4){$("td.delete a").animate({opacity:0.3},300)
}var I=$("#comparison-grid .product-name").find("> *:eq("+H+")").data("id");
qs.products=$.grep(qs.products,function(A){return A!=I
})
}else{return false
}}function deleteRow(F){var H=$(F).parent().parent().parent();
var G=H.find("div");
if($(H).siblings().length<2){deleteRowGroup($(F).parent())
}else{if($.browser.msie&&parseInt($.browser.version)<9){G.queue(function(){$(this).css({visibility:"hidden"});
$(this).animate({opacity:0},500);
$(this).dequeue()
})
}else{G.each(function(){var B=$(this).width();
var A=$(this).height();
$(this).css({height:A,overflow:"hidden"});
$(this).parent().css({height:"auto"});
$(this).animate({opacity:0},200);
$(this).animate({height:1,padding:0},100)
})
}G.queue(function(){$(this).parent().parent().remove();
redrawBg();
$(this).dequeue()
})
}var E=$(H).data("id");
qs.attr=$.grep(qs.attr,function(A){return A!=E
})
}function deleteRowGroup(E){var D=$(E).parent().parent().parent();
var F=D.find("div");
if($.browser.msie&&parseInt($.browser.version)<9){F.queue(function(){$(this).css({visibility:"hidden"});
$(this).animate({opacity:0},500);
$(this).dequeue()
})
}else{F.each(function(){var B=$(this).width();
var A=$(this).height();
$(this).css({height:A,overflow:"hidden"});
$(this).parent().css({height:"auto"});
$(this).animate({opacity:0},200);
$(this).animate({height:1,padding:0},100)
})
}F.queue(function(){$(this).parent().parent().parent().remove();
redrawBg();
$(this).dequeue()
})
};