 (function(){ /*Use Object Detection to detect IE6*/ var m = document.uniqueID /*IE*/ && document.compatMode /*>=IE6*/ && !window.XMLHttpRequest /*<=IE6*/ && document.execCommand ; try{ if(!!m){ m("BackgroundImageCache", false, true) /* = IE6 only */ } }catch(oh){}; })(); 
 
if( typeof( WC ) == "undefined" ) WC={}; // define public Namespace

window.$=function( sId ){return document.getElementById( sId)};

function getTr( el ){
      while (  el && el.tagName != 'TR' ) {
       el = el.parentNode;
     }
    return el;
 };

function getParentByTagName( o,sTagName ){
    while (  o && o.tagName != sTagName) {
       o = o.parentNode;
     }
    return o;
 };

function getPosTopLeft(o) {
    var p = new Object();
    p.top = 0;
    p.left = 0;
    while (o != null) {
        p.top += o.offsetTop;
        p.left += o.offsetLeft;
        o = o.offsetParent;
       //TEST This out
       if(o && ( o.style.position == 'relative'|| o.style.position=='absolute') )   break;

    }
    return p;
} ;

function addEvent(obj,sEvent,oFn,bUseCapture){
   if( window.attachEvent != null ) return obj.attachEvent('on' + sEvent ,oFn);
   else if( window.addEventListener) {
   
   obj.addEventListener(sEvent,oFn,bUseCapture||false);
   return true;
   }
  else obj['on'+sEvent] = oFn ;
};

function removeEvent(o, sEvent, oFn,bUseCapture){
 
  if (document.detachEvent){
   //window.status=o + oFn;
  o.detachEvent('on' + sEvent, oFn);
  return;
  }
  else {
  if (document.removeEventListener){
  bUseCapture=bUseCapture?bUseCapture:false;
  o.removeEventListener(sEvent, oFn,bUseCapture);
  return true;}
  else o['on'+sEvent] = null;}
};
  
function onSelectStart(){
	if(window.event.srcElement.tagName == "INPUT")
		return;
	window.event.cancelBubble = true; 
	window.event.returnValue = false; 
	return false;	
};
  

function getDocClientAndOffsetHeight(){
var oBody = document.getElementsByTagName('BODY')[0];
//if Internet Explorer
if( document.all ) {
    // IE in strict mode  
    if( document.documentElement.clientHeight > 0 && oBody.currentStyle){
          this.clientHeight = document.documentElement.clientHeight;
          this.offsetHeight = document.body.offsetHeight;
          this.offsetHeight = document.body.scrollHeight;
          var m={};
          m.top  =    oBody.currentStyle['marginTop'];
          m.bottom = oBody.currentStyle['marginBottom'];
         this.offsetHeight += ( parseInt(m.top) + parseInt(m.bottom));
    }
    else{ 
          this.clientHeight = document.body.clientHeight;
          this.offsetHeight=document.body.scrollHeight;
       }
 }
 else{
   // Gecko
     this.clientHeight = self.innerHeight;       
     this.offsetHeight = document.body.offsetHeight;
      
     var m={};
      if( document.defaultView ) {
      m.top  =  document.defaultView.getComputedStyle(oBody, '').getPropertyValue('margin-top') ;
      m.bottom = document.defaultView.getComputedStyle(oBody, '').getPropertyValue('margin-bottom') ;
      this.offsetHeight += ( parseInt(m.top) + parseInt(m.bottom)   ); //20px offset for scroll bars          
      }
 }   
   return this;  
};



function fade(el,state){
      if( el ){
        
        fade.el = el;
        el.style.display='block';
        
    if( state.toLowerCase()== 'on' ){
          fade.opacity=10;
          fade.target=100;
          fade.increment=1;
        }
        else {
         fade.opacity=90;
         fade.target=0;
         fade.increment=-1;
        }
          
      }
     
      if( (fade.opacity <= 50 && fade.target==100) || (fade.opacity>=50 && fade.target==0)){
        fade.opacity += fade.increment;
        fade.el.style.filter='alpha(opacity=' + fade.opacity + ')';
        fade.el.style['opacity'] = fade.opacity/100;
        var wait = (fade.target == 0? -1 * (49 - fade.opacity ): 52 - fade.opacity);
     //        window.status = fade.el.style.filter  + '  ' + fade.target + ' ' + _i++ + '  wait:' + wait;
        setTimeout( "fade()",wait);
    }
    else{
      if(fade.target==0) {
        fade.el.style.display='none';
        fade.el.style.opacity='';    
      }
      else{
         fade.el.style.filter='alpha(opacity=' + 100 + ')';
         fade.el.style.opacity='';  
      }
      
   }
 
};

String.prototype._format=function(args){
var s = this.toString();
if( typeof( args ) == 'object' ){ 
s = s.replace( /{/g, '\'+args[\'' );
return eval( '\''+s.replace(/}/g,'\']+ \'') +'\'');
}
    s = s.replace( /{/g, '\'+arguments[' );
    return eval( '\''+s.replace(/}/g,']+ \'') +'\'');
};


function PleaseWait(icon,mesg){
 var elLoad = document.createElement('div');
 if( ! icon ) icon='spinner.gif';
 if( ! mesg ) mesg='Please Wait...';
  with ( elLoad.style ){
     visibility='hidden';
     position='absolute';
     border='1px solid #eee';
     padding='5px 10px 5px 10px';
     zIndex=1000;
     backgroundColor='#eee';
    } 
     elLoad.innerHTML = '<img border="0" src="' + icon + '">&nbsp;' + mesg + '</span>';
   document.body.appendChild( elLoad );
  PleaseWait.id = elLoad;
};

PleaseWait.show=function(viewPort){
var t,l;
var elView = document.getElementById(viewPort);
var elLoad = PleaseWait.id;

if( true || ! elView ) {
t = ((document.body.clientHeight - elLoad.offsetHeight) / 2 );
l = ((document.body.clientWidth - elLoad.offsetWidth )/ 2 );
}
else {
t =  parseInt(elView.style.top)  + ( (elView.offsetHeight - elLoad.offsetHeight ) / 2 );
l = parseInt(elView.style.left) + ( (elView.offsetWidth - elLoad.offsetWidth )/ 2 );

if( (t <=0 ) || ( l <=0 ) ) {
l = parseInt(elView.style.left);
t = parseInt(elView.style.top);
}

}


elLoad.style.visibility='visible';
elLoad.style.left = l.toString() + "px";
elLoad.style.top = t.toString() + "px";


};

PleaseWait.hide=function(){
PleaseWait.id.style.visibility='hidden';
};

function tabInit( tabsID, tabName ){
  try{
 
  var tabs = $(tabsID).getElementsByTagName("A");
 
   if( ( ! tabName) || (tabName.length == 0) ) 
       tabName = tabs[0].hash.substring(1);
   
 
  for(var i=0;i<tabs.length;i++){
    if ( tabs[i].hash == "#" + tabName ) {
       var current = new Object();
       current.tab = tabs[i].parentNode;    
       current.tabPanel = $(tabName);
       current.tab.className += " selected";   
       current.tabPanel.className += " tabPanelSelected";
       if( !tabOnClick.prev ) tabOnClick.prev = new Object();
       tabOnClick.prev[tabsID] = current;
     }else {
       var tabPanel = $(tabs[i].hash.substring(1));
       if( tabPanel ) tabPanel.className += " tabPanelHidden";
     }
  }
  }catch(e){
   alert( "Error initializing Tabs\n" + e.message); 
  }
 };
    
 function tabClick( sId,hash ){
   var tabs = $(sId).getElementsByTagName("A");
   for(var i=0;i<tabs.length;i++){
     if ( tabs[i].hash == "#"+hash )  {
       //synthetic click function
       elementClick(tabs[i]);
       return;
     };
   }  
   
         
  };
  
 function elementClick( el ){
 if( document.createEvent ) {
 //FF support
 e = document.createEvent("MouseEvents");
 e.initEvent("click", true, false);
 // The "click" argument is one that's significant to the "MouseEvents" set mentioned earlier -- again, consult that reference. The two Boolean values // refer to whether the event bubbles up through the DOM and whether the event may be canceled with the preventDefault() method.
 el.dispatchEvent(e);
 }else el.click();
 };
  
 function tabOnClick(sId,e, hash){
 var  o = (window.event ? window.event.srcElement:e.target) ;

 if( o.tagName != "A" ) return;
 
 if( tabOnClick.prev && tabOnClick.prev[sId] ) {
  tabOnClick.prev[sId].tab.className=tabOnClick.prev[sId].tab.className.replace("selected","");
 if( tabOnClick.prev[sId].tabPanel) 
 tabOnClick.prev[sId].tabPanel.className=tabOnClick.prev[sId].tabPanel.className.replace("tabPanelSelected","tabPanelHidden");
 }
 current = new Object();
 current.tab = o;
 if( o.tagName.indexOf("A") != -1 ) {
 current.tabPanel = $(o.hash.substring(1)); 
 current.tab = o.parentNode;
}
 current.tab.className += ' selected'; 
 if( current.tabPanel) 
 current.tabPanel.className = current.tabPanel.className.replace("tabPanelHidden", "tabPanelSelected");
 tabOnClick.prev[sId] = current;
 //cancel the click event in IE and Firefox
 e.returnValue = false;
 if( e.stopPropagation) {e.preventDefault();e.stopPropagation();}

};

function getSelectedTab(sId) {
var tabs = $(sId).getElementsByTagName("A");
   for(var i=0;i<tabs.length;i++){
     if ( tabs[i].parentNode.className.indexOf("selected") != -1 )  {
       return tabs[i].hash.substring(1);
     };
   }       
return tabs[0].hash.substring(1);;
}


function FieldFocus(){
      var focusSet=false;
      var oListOfInputs =  document.getElementsByTagName('INPUT');
     
      for( var i in oListOfInputs ){
         if( oListOfInputs[i].tagName == "INPUT" && oListOfInputs[i].type != "hidden" && oListOfInputs[i].type != "button" && oListOfInputs[i].type != "submit" && oListOfInputs[i].type != "reset"  && oListOfInputs[i].type != "checkbox"){ 
           oListOfInputs[i].onfocus = FieldFocus.focus;
           if( ! focusSet && ! oListOfInputs[i].disabled ) {
              try{
              oListOfInputs[i].focus();
              focusSet =true;
              }catch(err){}
           }    
         }
      }
      
      oListOfInputs = document.getElementsByTagName('SELECT'); 
      for(var i in oListOfInputs )if( oListOfInputs[i].tagName == 'SELECT') oListOfInputs[i].onfocus=FieldFocus.focus;
      
      oListOfInputs = document.getElementsByTagName('TEXTAREA'); 
      for(var i in oListOfInputs )if( oListOfInputs[i].tagName == 'TEXTAREA') oListOfInputs[i].onfocus=FieldFocus.focus;
      
      
};

FieldFocus.focus=function(e){
   var elInput = (e ? e.target :window.event.srcElement);
  
   if( FieldFocus._elPrevFocus )   FieldFocus._elPrevFocus.className =  FieldFocus._elPrevFocus.className.replace('focus','');
   
   elInput.className += ' focus';
   FieldFocus._elPrevFocus =  elInput;
   if( typeof( originalValues ) != 'undefined' && ! originalValues[elInput.name] ){
    originalValues[elInput.name] = new Object(); 
    originalValues[elInput.name].value = elInput.value;  
   }
   
 return true;
};

function getModifiedElementsOriginalValues( formName ){
  var f = document.forms[formName];
  var url='';
  for(var i=0;i<f.length;i++){
      if( f.elements[i].type != 'button' && f.elements[i].type != 'submit' ){
          if( originalValues[f.elements[i].name] &&  ( originalValues[f.elements[i].name].value != f.elements[i].value ) ) 
          url += '&' + f.elements[i].name + '=' + escape(originalValues[f.elements[i].name].value)  ;
           }
   }
  return url;
 };
 
         function interogateObj( o,all ){   
var s ='';
all = all || ''; //set default to false if not defined

for( a in o ){
    if( o[a]>'' || all== 'ALL' )
    s+= "\n" + a + ' = ' + o[a];
}
return s;
};


function showHelp(url ){
   var width=800;
   var height=600;
   var top =  ( screen.height - height) / 2;
   var left = ( screen.width - width ) / 2;
        
   var features="top={0},left={1},width={2},height={3},menu=0,toolbar=0,status=0,resizable=1";
   features = features._format([top,left,width,height]);
        
   hrefToOpen = url;
   w = window.open(hrefToOpen,"help",features,true);
   if( ! w.opener ) w.opener = self;
   w.focus();
   return false;
};

function getRadioButtonSelectedValue(sForm,sRadio){
var rb = document.forms[sForm][sRadio];
for(var i=0;i<rb.length;i++){
   if (rb[i].checked )   return rb[i].value; 
}
 return null;
};

function openWindow( url,w,h,target ){
        target  = target||"win";
        var width=w||800;
        var height=h||600;
        
        var top =  ( screen.height - height) / 2;
        var left = ( screen.width - width ) / 2;
        hrefToOpen=url;
        var features="top={0},left={1},width={2},height={3},menu=0,status=0,location=0,resizable=1";
         features = features._format([top,left,width,height]);
        var w = window.open("PleaseWait.htm",target,features,true);
        
        if( ! w.opener ) w.opener = self;
        w.focus();
        return false;
};

var ELEMENT_NODE = 1;
function _nextSibling(o){
 do
 {
    o = o.nextSibling;
   } while( o && o.nodeType != ELEMENT_NODE  ) 
     return o;
}

function _previousSibling(o){
 do
 {
    o = o.previousSibling;
   } while( o && o.nodeType != ELEMENT_NODE  ) 
  return o;
}

function _lastChild(o){
  o = o.lastChild;
   while( o && o.nodeType != ELEMENT_NODE ){
     o = o.previousSibling;
   }
   
    
 return o;
} 

function _firstChild(o){
  o = o.firstChild;
   while( o && o.nodeType != ELEMENT_NODE ){
     o = o.nextSibling;
   }
 return o;
} 

function _getChildNodes( o ){
  var childNodes = o.childNodes;
  
  if( document.all ) return childNodes;
  
  // filter FF Nodes for spaces/text
  // nodeType 1 = element  
  var children = new Array(); 
  for( var i=0; i< childNodes.length;i++ ){
    if( childNodes[i].nodeType == ELEMENT_NODE) children.push( childNodes[i]);
    }
  return children;
}

function setCookie (name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
    	((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
	
function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}
