var shown = '';
var olfid = '1';

var olpid = '1';
var oltid = '1';

function win(url) {
	if(shown == '' || shown.closed) {
		shown = window.open(url,'win','scrollbars=no,status=no, high,width=550,height=320');
	} else {
		shown.close();
		shown = window.open(url,'win','scrollbars=no,status=no, high,width=550,height=320');
	}
}



function fswitch(fid) {

	if(olfid != '') {
		if(olfid == '1') {
			document.getElementById('fid_' + olfid).className = 'dis tl';
		} else if(olfid == '104') {
			document.getElementById('fid_' + (olfid -1)).className = 'dis';
			document.getElementById('fid_' + olfid).className = 'dis bl';
		} else {
			if(olfid > 2) {
				document.getElementById('fid_' + (olfid -1)).className = 'dis';
			} else {
				document.getElementById('fid_' + (olfid -1)).className = 'dis tl';
			}
			document.getElementById('fid_' + olfid).className = 'dis';
		}
	}

	if(fid == '1') {
		document.getElementById('fid_' + fid).className = 'highlighted hightl';
	} else if(fid == '104') {
		document.getElementById('fid_' + fid).className = 'highlighted bl';
	} else {
		document.getElementById('fid_' + fid).className = 'highlighted';
	}
	
	if(fid > 2) {
		document.getElementById('fid_' + (fid -1)).className = 'dis highbot';
	} else if(fid == 2) {
		document.getElementById('fid_' + (fid -1)).className = 'dis highbot tl';
	}
	document.getElementById('display').innerHTML = document.getElementById('bid_' + fid).innerHTML;
	olfid = fid;
}

function tswitch(tid) {

	
	
	
	document.getElementById('tips' + tid).innerHTML = document.getElementById('btid_' + tid).innerHTML;
	document.getElementById('tips' + tid).className = 'tips';
	
}
function toff(tid) {

	
	
	
	document.getElementById('tips' + tid).innerHTML = '';
	document.getElementById('tips' + tid).className = 'tipshide';
	
}


function pswitch(pid) {

	if(olpid != '') {
		if(olpid == '1') {
			document.getElementById('pid_' + olpid).className = 'dis tl';
		} else if(olpid == '104') {
			document.getElementById('pid_' + (olpid -1)).className = 'dis';
			document.getElementById('pid_' + olpid).className = 'dis bl';
		} else {
			if(olpid > 2) {
				document.getElementById('pid_' + (olpid -1)).className = 'dis';
			} else {
				document.getElementById('pid_' + (olpid -1)).className = 'dis tl';
			}
			document.getElementById('pid_' + olpid).className = 'dis';
		}
	}

	if(pid == '1') {
		document.getElementById('pid_' + pid).className = 'highlighted hightl';
	} else if(pid == '104') {
		document.getElementById('pid_' + pid).className = 'highlighted bl';
	} else {
		document.getElementById('pid_' + pid).className = 'highlighted';
	}
	
	if(pid > 2) {
		document.getElementById('pid_' + (pid -1)).className = 'dis highbot';
	} else if(pid == 2) {
		document.getElementById('pid_' + (pid -1)).className = 'dis highbot tl';
	}
	document.getElementById('display2').innerHTML = document.getElementById('hid_' + pid).innerHTML;
	olpid = pid;
}

function loadFeatures() {
	document.getElementById('display').innerHTML = document.getElementById('bid_1').innerHTML;
	document.getElementById('display2').innerHTML = document.getElementById('hid_1').innerHTML;
	
}
var LoadHandler = {
  handlers:[],
  add:function(fn){
    if(window.onload!=LoadHandler.theHandler) LoadHandler._push(window.onload);
    LoadHandler._push(fn);
    window.onload=LoadHandler.theHandler;
  },
  _push:function(fn){
    if(typeof(fn)!='function') return;
    LoadHandler.handlers[LoadHandler.handlers.length]=fn;
  },
  theHandler:function(){
    var handlers=LoadHandler.handlers,i=-1,fn;
    while(fn=handlers[++i]) fn();
  }
}
// Example 2 (JS part 1)
function changeInputType(
  oldElm, // a reference to the input element
  iType, // value of the type property: 'text' or 'password'
  iValue, // the default value, set to 'password' in the demo
  blankValue, // true if the value should be empty, false otherwise
  noFocus) {  // set to true if the element should not be given focus
  if(!oldElm || !oldElm.parentNode || (iType.length<4) || 
    !document.getElementById || !document.createElement) return;
  var isMSIE=/*@cc_on!@*/false; //http://dean.edwards.name/weblog/2007/03/sniff/
  if(!isMSIE){
    var newElm=document.createElement('input');
    newElm.type=iType;
  } else {
    var newElm=document.createElement('span');
    newElm.innerHTML='<input type="'+iType+'" name="'+oldElm.name+'">';
    newElm=newElm.firstChild;
  }
  var props=['name','id','className','size','tabIndex','accessKey'];
  for(var i=0,l=props.length;i<l;i++){
    if(oldElm[props[i]]) newElm[props[i]]=oldElm[props[i]];
  }
  newElm.onfocus=function(){return function(){
    if(this.hasFocus) return;
    var newElm=changeInputType(this,'password',iValue,
      (this.value.toLowerCase()==iValue.toLowerCase())?true:false);
    if(newElm) newElm.hasFocus=true;
  }}();
  newElm.onblur=function(){return function(){
    if(this.hasFocus)
    if(this.value=='' || (this.value.toLowerCase()==iValue.toLowerCase())) {
      changeInputType(this,'text',iValue,false,true);
    }
  }}();
 // hasFocus is to prevent a loop where onfocus is triggered over and over again
  newElm.hasFocus=false;
  // some browsers need the value set before the element is added to the page
  // while others need it set after
  if(!blankValue) newElm.value=iValue;
  oldElm.parentNode.replaceChild(newElm,oldElm);
  if(!isMSIE && !blankValue) newElm.value=iValue;
  if(!noFocus || typeof(noFocus)=='undefined') {
    window.tempElm=newElm;
    setTimeout("tempElm.hasFocus=true;tempElm.focus();",1);
  }
  return newElm;
}
 
 
// Example 2 (JS part 2)
LoadHandler.add(function(){
  // Normally I use object detection, however, in this case since I need to 
  // detect Konqueror and Safari which don't have unique objects,
  // I will use the user agent string to detect them. Only use this type of 
  // detection as a last resort.
  // I'm doing this because example 2 crashes Konqueror 3.4 and Safari 1.0
 
  var ua=navigator.userAgent.toLowerCase();
  if(!((ua.indexOf('konqueror')!=-1) && /khtml\/3\.[0-4]/.test(ua)) && 
    !(((ua.indexOf('safari')!=-1) && !window.print))) {
 
      // Set the third value to the text you want to appear in the field.
      changeInputType(document.forms[0].password,'text','Password',false,true);
  }
});
function popitup(url)
{
	newwindow=window.open(url,'name','height=530,width=790,top=100,left=100');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popitup2(url)
{
	newwindow=window.open(url,'name','height=490,width=510,top=100,left=100');
	if (window.focus) {newwindow.focus()}
	return false;
}
function popitup3(url)
{
	newwindow=window.open(url,'name','height=490,width=500,top=200,left=200,scrollbars=yes,resizeable=yes');
	if (window.focus) {newwindow.focus()}
	return false;
}
