var tabHelper = {
tabCollections: new Array(),
showTab: function(sender) {
var rel = sender.getAttribute('rel');
if (!this.tabCollections[rel]) {
var parentElement = this._getParentElement(sender, rel);
if (parentElement) {
var parentRel = this._getAttributeValue(parentElement, 'rel', '');
if (parentRel == rel) {
var childRelations = this._getRelatedChildren(parentElement, parentRel);
var childDetails = new Array();
for (var i = 0; i < childRelations.length; i++) {
childDetails.push({
Element: childRelations[i],
Key: this._getAttributeValue(childRelations[i], 'key', ''),
TargetContrainerElement: $get(this._getAttributeValue(childRelations[i], 'targetContainer', '')),
ParentElement: this._getParentElement(childRelations[i], 'parentElement')});}
this.tabCollections[rel] = {
ContainerElement: parentElement,
ClientStateElement: $get(this._getAttributeValue(parentElement, 'clientState', '')),
EndContainerElement: this._getRelatedChildren(parentElement, 'endElement')[0],
Children: childDetails};}}}
var tabColl = this.tabCollections[rel];
tabColl.ClientStateElement.value = '';
var senderKey = this._getAttributeValue(sender, 'key', '');
var previousSelected = false;
for (var i = 0; i < tabColl.Children.length; i++) {
var child = tabColl.Children[i];
var isSelected = child.Key == senderKey;
child.TargetContrainerElement.style.display = (isSelected ? 'block' : 'none');
Sys.UI.DomElement.removeCssClass(child.ParentElement, 'selected');
Sys.UI.DomElement.removeCssClass(child.ParentElement, 'after');
if (isSelected) {
previousSelected = true;
Sys.UI.DomElement.addCssClass(child.ParentElement, 'selected');
tabColl.ClientStateElement.value = senderKey;} else if (previousSelected == true) {
previousSelected = false;
Sys.UI.DomElement.addCssClass(child.ParentElement, 'after');}}
if (previousSelected) {
Sys.UI.DomElement.addCssClass(tabColl.EndContainerElement, 'after');} else {
Sys.UI.DomElement.removeCssClass(tabColl.EndContainerElement, 'after');}},
_getRelatedChildren: function(currentNode, relation) {
var result = new Array();
for (var i = 0; i < currentNode.childNodes.length; i++) {
var childNode = currentNode.childNodes[i];
if (this._getAttributeValue(childNode, 'rel', '') == relation) {
result.push(childNode);} else {
var childResults = this._getRelatedChildren(childNode, relation);
for (var j = 0; j < childResults.length; j++) {
result.push(childResults[j]);}}}
return result;},
_getAttributeValue: function(node, attribute, defaultValue) {
if (node && node.getAttribute) {
var attr = node.getAttribute(attribute);
if (attr) {
return attr;}};
return defaultValue;},
_getParentElement: function(node, relation) {
while (node.parentNode) {
if (this._getAttributeValue(node.parentNode, 'rel', '') == relation) {
return node.parentNode;}
node = node.parentNode;}
return null;}};
