function getAttribute(node,name){if(document.all){var res=node[name];return res ? res : null}var attrs=node.attributes;if(attrs){var attr=attrs[name];if(attr)return attr.nodeValue}return null}function getNodesById(node,id,res){if(document.all){var res=document.all[id];if(res.tagName){var arr=new Array();arr[0]=res;return arr}return res}if(!res){res=new Array();if(node==document)node=document.body}var childNodes=node.childNodes;if(childNodes){for(var i=0;i<childNodes.length;i++){var n=childNodes[i];if(n.id==id)res[res.length]=n;getNodesById(n,id,res)}}return res}function getChildNodes(node,res){if(node.all)return node.all;if(!res)res=new Array();var childNodes=node.childNodes;if(childNodes){for(var i=0;i<childNodes.length;i++){var n=childNodes[i];res[res.length]=n;getChildNodes(n,res)}}return res}function _shl_click(a,b,skip){if(typeof(b)=="function"){var res=b(a);if(typeof(res)=="boolean"&&!res)return false}if(typeof(skip)=="undefined")skip=false;var shl_id=getAttribute(a,"shl_id");if(shl_id==null)return true;var views=getNodesById(document,shl_id);if(views.length!=2)return true;var active;var inactive;if(views[0].style.display=="none"){inactive=views[0];active=views[1]}else{inactive=views[1];active=views[0]}if(inactive.style.display!="none"||active.style.display=="none")return true;var active_sl_behavior=getAttribute(active,"sl_behavior");var active_sl_view=getAttribute(active,"sl_view");var active_sl_container=getAttribute(active,"sl_container");if(active_sl_behavior!="Radio"||active_sl_view!="clicked"||skip){active.style.display="none";inactive.style.display="block";if(!skip){if(active_sl_behavior=="Radio"){var sl_view=getAttribute(inactive,"sl_view");if(sl_view=="clicked"){var sl_container=getAttribute(inactive,"sl_container");var childNodes=getChildNodes(document);for(var i=0;i<childNodes.length;i++){var element=childNodes[i];if(getAttribute(element,"sl_container")!=sl_container||getAttribute(element,"sl_view")!=sl_view||element.style.display=="none"||element==inactive)continue;var anchors=element.getElementsByTagName("A");var anchor=null;for(var j=0;j<anchors.length;j++){var item=anchors[j];if(getAttribute(item,"shl_id")!=null){anchor=item;break}}if(anchor==null&&element.tagName=="A")anchor=element;if(anchor!=null)_shl_click(anchor,null,true)}}}}var remove;var param;var anchors=active.getElementsByTagName("A");for(var i=0;i<anchors.length;i++){var anchor=anchors[i];if(getAttribute(anchor,"shl_id")!=active.id)continue;param=getAttribute(anchor,"shl_param");var href=anchor.href;var index=href.indexOf(param);if(index>0&&(href.charAt(index-1)=='?'||href.charAt(index-1)=='&'))remove=false;else remove=true;break}if(param){var radio=(getAttribute(active,"sl_behavior")=="Radio");anchors=document.getElementsByTagName("A");var activeid=active.id;for(var i=0;i<anchors.length;i++){var anchor=anchors[i];var id=getAttribute(anchor,"shl_id");if(id!=null){if(id==activeid)continue;if(radio){var el=document.getElementById(id);if(el&&getAttribute(el,"sl_container")==active_sl_container)continue}}var href=anchor.href;var pattern=null;if(radio)pattern=param.substr(0,param.indexOf("=")+1);else if(remove)pattern=param;if(pattern!=null){var lastIndex=-1;for(var index=href.indexOf(pattern);index>0;index=href.indexOf(pattern,index+1)){if(href.charAt(index-1)!='?'&&href.charAt(index-1)!='&')continue;lastIndex=href.indexOf('&',index);if(lastIndex==-1)lastIndex=href.length-1;break}if(lastIndex!=-1){var begin=href.substr(0,index);var end=href.substr(lastIndex+1);href=begin+end;if(href.charAt(href.length-1)=='?')href=href.substr(0,href.length-1)}}if(!remove){var index=href.indexOf("?");if(index==-1)href+="?"+param;else href=href.substr(0,index+1)+param+"&"+href.substr(index+1)}anchor.href=href}}}return false}
