///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//                       Copyright (c) 2003-2006                             //
//                            Marc Peterson                                  //
//                     marc.s.peterson at gmail.com                          //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

// Last updated: 06-19-2006

var gRowColorDark="#EEF9FE",gRowColorLight="#ffffff",gIsWinLoaded=false;if(window.addEventListener){window.addEventListener("load",bodyLoad,false);window.addEventListener("unload",bodyUnload,false);}else if(document.attachEvent){window.attachEvent("onload",bodyLoad);window.attachEvent("onunload",bodyUnload);};String.prototype.pad=function(len,str,side){return str||(str=" "),(len-=this.length)>0?(str=new Array(Math.ceil(len/str.length)+1).join(str)).substr(0,side=!side?len:side==1?0:Math.ceil(len/2))+this+str.substr(0,len-side):this;};Number.prototype.pad=function(len,str,side){return this.toString().pad(len,str,side);};String.prototype.trim=function(){return this.replace(/^\s*([^ ]*)\s*$/,"$1");};function bodyLoad(){gIsWinLoaded=true;};function bodyUnload(){gIsWinLoaded=false;};function openNewWin(path,id,w,h,x,y){if(id===undefined||id=="")id="_blank";if(w===undefined)w=600;if(h===undefined)h=400;if(x===undefined)x='half';if(y===undefined)y='half';if(document.layers||(document.getElementById&&!document.all)){browseWidth=window.outerWidth;browseHeight=window.outerHeight;}else if(document.all){browseWidth=document.body.clientWidth;browseHeight=document.body.clientHeight;};if(x=='half')x=Math.floor((browseWidth-w)/2);if(y=='half')y=Math.floor((browseHeight-h)/2);var new_win=window.open(path,id,"width="+w+",height="+h+",left="+x+",top="+y+",scrollbars=auto,resizable=yes");};function openHelpWin(path){openNewWin(path,"helpWindow",600,400);};function openInParent(path){if(top.opener){if(!top.opener.closed){top.opener.location.href=path;top.opener.focus();}else{window.open(path);window.focus();};}else{alert("Sorry, the page cannot be loaded because the parent window is no longer open");};};function showLayer(layerID){if(document.getElementById){if(typeof(layerID)=="string")obj=document.getElementById(layerID);else if(typeof(layerID)=="object")obj=layerID;if(obj)obj.style.visibility="visible";}else if(document.layers)document.layers[layerID].visibility="show";};function hideLayer(layerID){if(document.getElementById){if(typeof(layerID)=="string")obj=document.getElementById(layerID);else if(typeof(layerID)=="object")obj=layerID;if(obj)obj.style.visibility="hidden";}else if(document.layers)document.layers[layerID].visibility="hidden";};function moveLayer(layerID,x,y){var obj=null;if(document.getElementById){if(typeof(layerID)=="string")obj=document.getElementById(layerID);else if(typeof(layerID)=="object")obj=layerID;if(obj){if(x!=null)obj.style.left=x;if(y!=null)obj.style.top=y;};}else if(document.layers)document.layers[layerID].moveTo(x,y);};function getWidth(obj){var width=null;if(document.getElementById){if(typeof(obj)=="string"){obj=document.getElementById(obj);};if(typeof(obj)=="object"){width=getElementStyle(obj,"width","width");if(width=="auto")width=obj.clientWidth;width=parseInt(width);};};return width;};function getHeight(obj){var height=null;if(document.getElementById){if(typeof(obj)=="string"){obj=document.getElementById(obj);};if(typeof(obj)=="object"){height=getElementStyle(obj,"height","height");if(height=="auto")height=obj.clientHeight;height=parseInt(height);};};return height;};function findPosition(obj){var ret_obj=new Object;if(obj.offsetParent){for(var pos_x=0,pos_y=0;obj.offsetParent;obj=obj.offsetParent){pos_x+=obj.offsetLeft;pos_y+=obj.offsetTop;};ret_obj.x=pos_x;ret_obj.y=pos_y;return ret_obj;}else{ret_obj.x=obj.x;ret_obj.y=obj.y;return ret_obj;};};function setClass(dest,newClass){var obj=null;if(document.getElementById){if(typeof(dest)=="object")dest.className=newClass;else if(typeof(dest)=="string"){if(obj=document.getElementById(dest))obj.className=newClass;};};};function setDisplay(dest,vis){var obj=null;if(document.getElementById){if(typeof(dest)=="object")dest.style.display=vis;else if(typeof(dest)=="string"){if(obj=document.getElementById(dest))obj.style.display=vis;};};};function exists(var_name,obj){if(typeof(obj)!="undefined"){if(var_name in obj)return true;else return false;}else if(var_name in window)return true;else return false;};function getElementStyle(obj,IEStyleProp,CSSStyleProp){if(document.getElementById){if(typeof(obj)=="string"){obj=document.getElementById(obj);};if(obj.currentStyle){return obj.currentStyle[IEStyleProp];}else if(window.getComputedStyle){var compStyle=window.getComputedStyle(obj,"");return compStyle.getPropertyValue(CSSStyleProp);};};return"";};function findParentByTag(node,tag){var cur_node=node;tag=tag.toUpperCase();while(cur_node&&cur_node.nodeName!=tag){if(cur_node.parentNode)cur_node=cur_node.parentNode;else return null;};if(cur_node&&cur_node.nodeName==tag)return cur_node;else return null;};function findChildByTagAndId(node,tag,node_id,compare_type){if(compare_type===undefined)compare_type="equals";else compare_type=trim(compare_type.toLowerCase());if(document.getElementById){var nodes=node.getElementsByTagName(tag);for(var i=0;i<nodes.length;i++){if(nodes[i].id||nodes[i].name){switch(compare_type){case"starts_with":if((nodes[i].id&&nodes[i].id.indexOf(node_id)==0)||(nodes[i].name&&nodes[i].name.indexOf(node_id)==0)){return nodes[i];break;};case"equals":default:if((nodes[i].id&&nodes[i].id==node_id)||(nodes[i].name&&nodes[i].name==node_id)){return nodes[i];break;};};};};};return null;};function findChildrenById(node,node_id,compare_type,depth){var results=new Array();if(compare_type===undefined)compare_type="equals";else compare_type=trim(compare_type.toLowerCase());if(depth===undefined)depth=-1;else if(depth>0)depth--;if(!node.hasChildNodes())return null;else{var child=node.firstChild;while(child!=null){if(child.id||child.name){switch(compare_type){case"starts_with":if((child.id&&child.id.indexOf(node_id)==0)||(child.name&&child.name.indexOf(node_id)==0)){results[results.length]=child;break;};case"equals":default:if((child.id&&child.id==node_id)||(child.name&&child.name==node_id)){results[results.length]=child;break;};};if(child.hasChildNodes()&&depth>0){results=results.concat(findChildrenById(child,node_id,compare_type,depth));};};child=child.nextSibling;};return results;};};function findInputByTypeAndName(node,type,name,compare_type,debug){if(compare_type===undefined)compare_type="equals";else compare_type=trim(compare_type.toLowerCase());if(document.getElementById){var oInputs=node.getElementsByTagName("input");if(debug)alert(oInputs.length+" inputs found in this node");for(var i=0;i<oInputs.length;i++){if(oInputs[i].type==type){switch(compare_type){case"starts_with":if(oInputs[i].name.indexOf(name)==0){if(debug)alert("found input "+oInputs[i].name+" of type "+oInputs[i].type);return oInputs[i];break;};case"equals":default:if(oInputs[i].name==name){return oInputs[i];break;};};};};};return null;};function endEventBubble(evt){var evt=(evt)?evt:((window.event)?event:null);evt.cancelBubble=true;};function deleteAllChildren(obj){if(obj){while(obj.hasChildNodes()){obj.removeChild(obj.firstChild);};};};function getTbody(table_id,tbody_id){var oTable=null,oTbody=null,oTable=document.getElementById(table_id);if(!oTable)return null;oTbody=findChildByTagAndId(oTable,"TBODY",tbody_id);if(!oTbody)return null;else return oTbody;};function hasAttribute(obj,attribute){if(obj.hasAttribute)return obj.hasAttribute(attribute);else if(obj.getAttribute){var value=obj.getAttribute(attribute);if(value==null)return false;else return true;}else return false;};function hasAttributeValue(obj,attribute,val){if(obj.getAttribute){var value=obj.getAttribute(attribute);if(value==null)return false;else{if(typeof val=="number"){if(parseInt(value)==val)return true;else return false;}else if(typeof val=="string"){if(value.toLowerCase()==val.toLowerCase())return true;else return false;};};}else return false;};function hex2dec(hex){return parseInt(hex,16);};function dec2hex(dec,pad){var hex=Number(dec).toString(16);if(pad!==undefined)hex=strPad(hex,pad,"0","left");return hex;};function int2str(num){num+="";return num;};function strPad(str,len,pad_char,side){if(len===undefined)len=0;if(pad_char===undefined||pad_char=="")pad_char=" ";if(side===undefined||side=="")side="left";else side.toLowerCase();var chars_to_pad=len-str.length;if(chars_to_pad>0){for(var i=0;i<chars_to_pad;i++){if(side=="left")str=pad_char+str;else str+=pad_char;};};return str;};function createElementEx(type,attributes,styles){var elem=document.createElement(type);return setElemAttrStyle(elem,attributes,styles);};function setElemAttrStyle(elem,attributes,styles){if(elem){if(attributes!=null&&attributes!=""){for(var attr_name in attributes){if(attr_name=="className")elem.className=attributes[attr_name];else if(attr_name=="innerHTML")elem.innerHTML=attributes[attr_name];else elem.setAttribute(attr_name,attributes[attr_name]);};};if(styles!==undefined&&styles!=null&&styles!=""){for(var style_name in styles){elem.style[style_name]=styles[style_name];};};return elem;}else return null};function trim(txt){if(!txt||txt==""||txt==null||txt===undefined)return"";else{txt=txt.replace(/^[\s\t]*/,"");txt=txt.replace(/[\s\t]*$/,"");return txt;};};function trimQuotes(txt){if(!txt||txt==""||txt==null||txt===undefined)return"";else{txt=txt.replace(/^["']/,"");txt=txt.replace(/["']$/,"");return txt;};};function showError(title,msg,width){var error_box=document.getElementById("error_box");if(!error_box){var error_box=document.createElement("div");error_box.id="error_box";document.body.appendChild(error_box);};if(width!==undefined)error_box.style.width=width;moveLayer(error_box,gMouse.x+15,gMouse.y);showLayer(error_box);error_box.innerHTML="<div class='title'>"+title+"</div><div class='content'>"+msg+"</div>";error_box.innerHTML+="<div class='close' onclick='hideError();'>close</div>";};function hideError(){var error_box=document.getElementById("error_box");if(error_box){hideLayer(error_box);};};function createVarName(txt){var good="_0123456789abcdefghijklmnopqrstuvwxyz ",var_name="",txt_lc=trim(txt.toLowerCase());for(var i=0;i<txt_lc.length;i++){cur_char=txt_lc.charAt(i);if(good.indexOf(cur_char)!=-1){if(cur_char==" ")cur_char="_";var_name+=cur_char;};};return var_name;};function isArray(obj){return(typeof(obj.length)=="undefined")?false:true;};
