// JS Detect Broswer Script //

var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror')) {
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
function openDir(form) { 
	var newIndex = form.jump.selectedIndex; 
	cururl = form.jump.options[newIndex].value; 
	window.location.assign(cururl); 
} 
function openDir2(form) { 
	var newIndex = form.jump2.selectedIndex; 
	cururl = form.jump2.options[newIndex].value; 
	window.location.assign(cururl); 
}
function emailPageLink() {
	var SubjectLine='Interesting Link from JSB - ' + top.document.title; 
	var BodyText='I saw this on JSB website and thought you might be interested: ' + top.location.href;
	var Message='<a class="email" href="mailto:?subject='+escape(SubjectLine)+'&body='+escape(BodyText)+'" OnMouseOver="status=\'Email this page\'; return true;" title="Send an e-mail about this page">Email this page<\/A>';
	var MessageIE='<a class="email" href="mailto:?subject='+(SubjectLine)+'&body='+(BodyText)+'" OnMouseOver="status=\'Email this page\'; return true;" title="Send an e-mail about this page">Email this page<\/a>';
	if(document.all) { document.write(MessageIE); }
		else { document.write(Message); 
	}
}
function printPage() {
	window.print();  
}

// JS Table Row Toggle //

function jsHide(eId) {
   document.getElementById(eId).style.display = 'none';
}
function jsShow(eId) {
	document.getElementById(eId).style.display = 'block';
}
function jsEnable(f_id, i_id) {
   document.forms.f_id.i_id.disabled = true;
}
function jsToggle(whichLayer) {
	if (document.getElementById){
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = style2.display? "":"block";
	}
	else if (document.all){
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
	else if (document.layers){
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = style2.display? "":"block";
	}
}
// Copyright 2007 | Thierry Koblentz - www.TJKDesign.com All Rights reserved
// TJK_ToggleDL() Version 1.5.4 report bugs or errors to thierry@tjkdesign.com

function TJK_doToggleDL(x){
	var zDD=document.getElementById('faq_dl').getElementsByTagName('dd');
	var zDT=document.getElementById('faq_dl').getElementsByTagName('dt');	
		zDD[x].className=(zDD[x].className=='hideDD')?'showDD':'hideDD';
		zDT[x].className=(zDT[x].className=='DTplus')?'DTminus':'DTplus';	
}
function TJK_ToggleDLopen(){//we open all of them
	var zDD=document.getElementById('faq_dl').getElementsByTagName('dd');
	var zDT=document.getElementById('faq_dl').getElementsByTagName('dt');	
	for(var i=0;i<zDT.length;i++){
		zDD[i].className='showDD';
		zDT[i].className='DTminus';
	}
	return false;
}
function TJK_ToggleDLclose(){//we close all of them	
	var zDD=document.getElementById('faq_dl').getElementsByTagName('dd');
	var zDT=document.getElementById('faq_dl').getElementsByTagName('dt');	
	for(var i=0;i<zDT.length;i++){
		zDD[i].className='hideDD';
		zDT[i].className='DTplus';
	}
	return false;	
}
function TJK_ToggleDL(){
if (document.getElementById && document.getElementsByTagName){			
	var zDT=document.getElementById('faq_dl').getElementsByTagName('dt');
	var zDD=document.getElementById('faq_dl').getElementsByTagName('dd');
	var ToggleON = document.getElementById('TJK_ToggleON');
	var ToggleOFF = document.getElementById('TJK_ToggleOFF');	
	if (ToggleON && ToggleOFF){// Show All - Hide All "links"
		ToggleON.onclick = TJK_ToggleDLopen;
		ToggleON.title = "Show all answers";
		ToggleON.href = "#";		
		ToggleOFF.onclick = TJK_ToggleDLclose;	
		ToggleOFF.title = "Hide all answers";
		ToggleOFF.href = "#";		
	}
	for(var i=0;i<zDT.length;i++){
		var zContent = zDT[i].innerHTML;
		var zHref = "<a href='#' onclick=\"TJK_doToggleDL("+i+");return false\" title='Show/hide'>";
		zDT[i].innerHTML = zHref + zContent + "</a>";
		zDD[i].className='hideDD';
		zDT[i].className='DTplus';
		}
	}
}


function printCountrySelect(fldname) {
	//var fldname = 'cg_country';         // set the name of your country field
	
	// select your default country from the following
	var aus = ''; // Australia - selected as default
	var can = '';                    // Canada
	var fra = '';                    // France
	var ger = '';                    // Germany
	var nz = '';                     // New Zealand
	var uk = 'selected="selected"';                     // United Kingdom
	var us = '';                     // United States
	var xx = '';                     // add null entry and select as default
	
	// drop down country selection list
	// 233 countries with your choice of the above default country selections
	// copyright 11th December 2001, 29th December 2005 - Felgall Pty Ltd, Stephen Chapman
	// permission is granted to use this selection box script with your web page
	// provided that all of the code below and these comments
	// (including the copyright notice) are left intact
	document.writeln('<!-- start of drop down country selection list -->');
	document.writeln('<select name="' + fldname + '" class="text" size="1">');
	if (xx != '') document.writeln('<option selected="selected"> </option>');
	document.writeln('<option>Afghanistan</option><option>&Aring;land Islands</option><option>Albania</option><option>Algeria</option><option>American Samoa</option><option>Andorra</option><option>Angola</option><option>Anguilla</option><option>Antarctica</option><option>Antigua and Barbuda</option><option>Argentina</option><option>Armenia</option><option>Aruba</option><option ' + aus + '>Australia</option><option>Austria</option><option>Azerbaijan</option><option>Bahamas</option><option>Bahrain</option><option>Bangladesh</option><option>Barbados</option><option>Belarus</option><option>Belgium</option><option>Belize</option><option>Benin</option><option>Bermuda</option><option>Bhutan</option><option>Bolivia</option><option>Bosnia and Herzegovina</option><option>Botswana</option>');
	document.writeln('<option>Bouvet Island</option><option>Brazil</option><option>Brunei Darussalam</option><option>Bulgaria</option><option>Burkina Faso</option><option>Burundi</option><option>Cambodia</option><option>Cameroon</option><option' + can + '>Canada</option><option>Cape Verde</option><option>Cayman Islands</option><option>Central African Republic</option><option>Chad</option><option>Chile</option><option>China</option><option>Christmas Island</option><option>Cocos (Keeling) Islands</option><option>Colombia</option><option>Comoros</option><option>Congo</option><option>Congo, Democratic Republic</option><option>Cook Islands</option><option>Costa Rica</option><option>C&ocirc;te d\'Ivoire (Ivory Coast)</option><option>Croatia (Hrvatska)</option><option>Cuba</option><option>Cyprus</option>');
	document.writeln('<option>Czech Republic</option><option>Denmark</option><option>Djibouti</option><option>Dominica</option><option>Dominican Republic</option><option>East Timor</option><option>Ecuador</option><option>Egypt</option><option>El Salvador</option><option>Equatorial Guinea</option><option>Eritrea</option><option>Estonia</option><option>Ethiopia</option><option>Falkland Islands</option><option>Faroe Islands</option><option>Fiji</option><option>Finland</option><option ' + fra + '>France</option><option>French Guiana</option><option>French Polynesia</option><option>Gabon</option><option>Gambia</option><option>Georgia</option><option ' + ger + '>Germany</option><option>Ghana</option><option>Gibraltar</option><option>Greece</option><option>Greenland</option>');
	document.writeln('<option>Grenada</option><option>Guadeloupe</option><option>Guam</option><option>Guatemala</option><option>Guinea</option><option>Guinea-Bissau</option><option>Guyana</option><option>Haiti</option><option>Honduras</option><option>Hong Kong</option><option>Hungary</option><option>Iceland</option><option>India</option><option>Indonesia</option><!-- copyright Felgall Pty Ltd --><option>Iran</option><option>Iraq</option><option>Ireland</option><option>Israel</option><option>Italy</option><option>Jamaica</option><option>Japan</option><option>Jordan</option><option>Kazakhstan</option><option>Kenya</option><option>Kiribati</option><option>Korea (north)</option><option>Korea (south)</option><option>Kuwait</option><option>Kyrgyzstan</option>');
	document.writeln('<option>Latvia</option><option>Lebanon</option><option>Lesotho</option><option>Liberia</option><option>Libyan Arab Jamahiriya</option><option>Liechtenstein</option><option>Lithuania</option><option>Luxembourg</option><option>Macao</option><option>Macedonia</option><option>Madagascar</option><option>Malawi</option><option>Malaysia</option><option>Maldives</option><option>Mali</option><option>Malta</option><option>Marshall Islands</option><option>Martinique</option><option>Mauritania</option><option>Mauritius</option><option>Mayotte</option><option>Mexico</option><option>Micronesia</option><option>Moldova</option><option>Monaco</option><option>Mongolia</option><option>Montserrat</option><option>Morocco</option><option>Mozambique</option><option>Myanmar</option><option>Namibia</option>');
	document.writeln('<option>Nauru</option><option>Nepal</option><option>Netherlands</option><option>Netherlands Antilles</option><option>New Caledonia</option><option ' + nz + '>New Zealand</option><option>Nicaragua</option><option>Niger</option><option>Nigeria</option><option>Niue</option><option>Norfolk Island</option><option>Northern Mariana Islands</option><option>Norway</option><option>Oman</option><option>Pakistan</option><option>Palau</option><option>Palestinian Territories</option><option>Panama</option><option>Papua New Guinea</option><option>Paraguay</option><option>Peru</option><option>Philippines</option><option>Pitcairn</option><option>Poland</option><option>Portugal</option><option>Puerto Rico</option><option>Qatar</option><option>R&eacute;union</option><option>Romania</option><option>Russian Federation</option>');
	document.writeln('<option>Rwanda</option><option>Saint Helena</option><option>Saint Kitts and Nevis</option><option>Saint Lucia</option><option>Saint Pierre and Miquelon</option><option>Samoa</option><option>San Marino</option><option>Sao Tome and Principe</option><!-- copyright Felgall Pty Ltd --><option>Saudi Arabia</option><option>Senegal</option><option>Serbia and Montenegro</option><option>Seychelles</option><option>Sierra Leone</option><option>Singapore</option><option>Slovakia</option><option>Slovenia</option><option>Solomon Islands</option><option>Somalia</option><option>South Africa</option><<option>Spain</option><option>Sri Lanka</option><option>Sudan</option><option>Suriname</option>');
	document.writeln('<option>Swaziland</option><option>Sweden</option><option>Switzerland</option><option>Syria</option><option>Taiwan</option><option>Tajikistan</option><option>Tanzania</option><option>Thailand</option><option>Togo</option><option>Tokelau</option><option>Tonga</option><option>Trinidad and Tobago</option><option>Tunisia</option><option>Turkey</option><option>Turkmenistan</option><option>Turks and Caicos Islands</option><option>Tuvalu</option><option>Uganda</option><option>Ukraine</option><option>United Arab Emirates</option><option ' + uk + '>United Kingdom</option><option ' + us + '>United States of America</option><option>Uruguay</option><option>Uzbekistan</option><option>Vanuatu</option><option>Vatican City</option>');
	document.writeln('<option>Venezuela</option><option>Vietnam</option><option>Virgin Islands (British)</option><option>Virgin Islands (US)</option><option>Wallis and Futuna Islands</option><option>Western Sahara</option><option>Yemen</option><option>Zaire</option><option>Zambia</option><option>Zimbabwe</option></select><br /><font size="1"></font>');
	document.writeln('<!-- end of drop down country selection list -->');
}

function jsHeaderFlash(pRef) {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="770" height="242">\n');
	document.write('<param name="movie" value="/2007/flash/header.swf?page=');
	document.write(pRef);
	document.write('/>\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<embed src="/2007/flash/header.swf?page=');
	document.write(pRef);
	document.write('" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="770" height="242"></embed>\n');
	document.write('</object>\n');
}
function scrollObject(main, width, height, direct, deccel, begin, speed, pause) {
  var self = this;

  this.main = main;
  this.one = main + "Block1";
  this.two = main + "Block2";
  this.block = new Array();
  this.blockup = 1;
  this.divup = 1;
  this.height = height;
  this.width = width;
  this.direct = direct;
  this.deccel = Math.max(deccel, 1);
  this.begin = Math.max(Math.min(begin, (direct == "up" || direct == "down") ? height : width), 1);
  this.speed = speed;
  this.pause = pause;
  this.slide = ((direct == "up" || direct == "down") ? height : width) / this.begin;
  this.active = false;
  this.moving = false;
  this.process = 0;
  this.mouse = false;
  this.scroll = function() {
    if (!document.getElementById) return false;
    document.getElementById(this.main).innerHTML = "<div id=\"" + this.one + "\"></div><div id=\"" + this.two + "\"></div>";
    var divList = [document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
    for (var i = 0; i <= 2; i++) {
      if (i > 0) {
        divList[i].style.position = "absolute";
        if (this.direct == "up" || this.direct == "down") {
          divList[i].style.left = "0px";
          divList[i].style.top = (i == 1) ? "0px" : ((this.direct == "up") ? "" : "-") + this.height + "px";
        } else {
          divList[i].style.left = (i == 1) ? "0px" : ((this.direct == "left") ? "" : "-") + this.width + "px";
          divList[i].style.top = "0px";
        } divList[i].innerHTML = this.block[i - 1] + "";
      } else {
        divList[i].style.position = "relative";

        if (this.block.length > 1) {
          divList[i].onmouseover = function() {
            if (this.active) setTimeout(function() { self.scrollWait(); }, this.pause);
            this.mouse = true;
          }
          divList[i].onmouseout = function() {
            this.mouse = false;
          }
        }
      } divList[i].style.overflow = "hidden";
      divList[i].style.width = this.width + "px";
      divList[i].style.height = this.height + "px";
    } this.active = true;
    if (this.block.length > 1) this.process = setTimeout(function() { self.scrollLoop(); }, this.pause);
  }
  this.scrollLoop = function() {
    clearTimeout(this.process);
    if (this.moving == false && this.active == false) return false;
    var divList = [document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
    this.slide = Math.max(this.slide / this.deccel, 1);
    var slideInc = (this.direct == "up" || this.direct == "left") ? -parseInt(this.slide) : parseInt(this.slide);
    if ((this.direct == "up" && Math.max(parseInt(divList[1].style.top) + slideInc, parseInt(divList[2].style.top) + slideInc) <= 0) ||
        (this.direct == "down" && Math.min(parseInt(divList[1].style.top) + slideInc, parseInt(divList[2].style.top) + slideInc) >= 0) ||
        (this.direct == "left" && Math.max(parseInt(divList[1].style.left) + slideInc, parseInt(divList[2].style.left) + slideInc) <= 0) ||
        (this.direct == "right" && Math.min(parseInt(divList[1].style.left) + slideInc, parseInt(divList[2].style.left) + slideInc) >= 0)) {
      this.slide = ((this.direct == "up" || this.direct == "down") ? this.height : this.width) / this.begin;
      if (++this.blockup >= this.block.length) this.blockup = 0;
      this.divup = (this.divup == 1) ? 2 : 1;
      if (this.direct == "up" || this.direct == "down") {
        divList[3 - this.divup].style.top = ((this.direct == "down") ? "-" : "") + this.height + "px";
        divList[this.divup].style.top = "0px";
      } else {
        divList[3 - this.divup].style.left = ((this.direct == "right") ? "-" : "") + this.width + "px";
        divList[this.divup].style.left = "0px";
      } divList[3 - this.divup].innerHTML = this.block[this.blockup] + "";
      this.moving = false;
      this.process = setTimeout(function() { self.scrollLoop(); }, this.pause);
    } else {
      this.moving = true;
      for (var j = 1; j <= 2; j++) {
        if (this.direct == "up" || this.direct == "down") {
          divList[j].style.top = (parseInt(divList[j].style.top) + slideInc) + "px";
        } else divList[j].style.left = (parseInt(divList[j].style.left) + slideInc) + "px";
      } this.process = setTimeout(function() { self.scrollLoop(); }, this.speed);
    }
  }
  this.scrollWait = function() {
    clearTimeout(this.process);
    if (this.active) return false;
    if (!this.mouse) {
      this.active = true;
      this.process = setTimeout(function() { self.scrollLoop(); }, this.pause / 2);
    } else this.process = setTimeout(function() { self.scrollWait(); }, this.pause);
  }
}


function mouse_event_handler(e) {

    e = e ||  window.event;
    var cell = e.srcElement || e.target;

    var tname = (cell.nodeType == 1) ? cell.tagName.toLowerCase() : '';

    while(tname != "table" && tname !="td" && tname != "th"){
            cell= cell.parentNode || cell.parentElement;
            tname = cell.tagName.toLowerCase();
    }

    if (tname == "td" || tname == "th") {
        var newClass;

        var cellIdx = _getCellIndex(cell);
        var row = cell.parentNode || cell.parentElement;
        var rowIdx = _getRowIndex(row);

        if (cellIdx == 0 && rowIdx == 0) {
            _clearHighlight();
        }
        else if (cellIdx == 0) {
            _setRow();
        }
        else if (rowIdx == 0) {
            _setCol();
        }
        else {
            _setRow();
            _setCol();
        }
    }

    function _getTable() {
        var tbleObj;

        if (mouse_event_handler.previous.table)
            return;
        else {
            tbleObj = row.parentNode || row.parentElement; //tbody
            var tn = tbleObj.tagName.toLowerCase();
            while (tn != "table" && tn != "html") {
                tbleObj = tbleObj.parentNode || tbleObj.parentElement;
                tn = tbleObj.tagName.toLowerCase();
            }
            mouse_event_handler.previous.table = tbleObj;
        }
    }//eof _getTable

    function _clearHighlight() {
        _clearRow();
        _clearCol();

        mouse_event_handler.previous.row = null;
        mouse_event_handler.previous.cellIdx = null;
    }//eof clearHighlight

    function _clearRow() {
        if (mouse_event_handler.previous.row) {
            mouse_event_handler.previous.row.className = "";
            mouse_event_handler.previous.row.cells[0].className = "";
        }
    }//eof clearRow

    function _setRow() {
        _clearRow();
        if (tname == 'td' || mouse_event_handler.previous.row != row) {
            row.className = 'hlt';
            row.cells[0].className = 'hlt';
            mouse_event_handler.previous.row = row;
        }
        else {
            mouse_event_handler.previous.row = null;
        }
    }//eof setRow

    function _clearCol() {
        _getTable();
        if (mouse_event_handler.previous.cellIdx != null) {
            var table = mouse_event_handler.previous.table;
            var cell = mouse_event_handler.previous.cellIdx;
            for (var i = 0; i < table.rows.length; i++) {
                table.rows[i].cells[cell].className = '';
            }
        }
    }//eof clearCol

    function _setCol () {
        _clearCol();
        if (tname == 'td' || mouse_event_handler.previous.cellIdx != cellIdx) {
            mouse_event_handler.previous.table.rows[0].cells[cellIdx].className = 'hlt';
            var trs = mouse_event_handler.previous.table.rows;
            for (var i = 1; i < trs.length; i++) {
                trs[i].cells[cellIdx].className = 'hlt-col';
            }
            mouse_event_handler.previous.cellIdx = cellIdx;
        }
        else {
            mouse_event_handler.previous.cellIdx = null;
        }
    }//eof setCol

    function _getCellIndex(cell) {
        var rtrn = cell.cellIndex || 0;

        if (rtrn == 0) {
            do{
                if (cell.nodeType == 1) rtrn++;
                cell = cell.previousSibling;
            } while (cell);
            --rtrn;
        }
        return rtrn;
    }//eof getCellIndex

    function _getRowIndex(row) {
        var rtrn = row.rowIndex || 0;

        if (rtrn == 0) {
            do{
                if (row.nodeType == 1) rtrn++;
                row = row.previousSibling;
            } while (row);
            --rtrn;
        }
        return rtrn;
    }//eof getRowIndex

}//eof mouse_event

mouse_event_handler.previous = {cellIdx: null, row: null, table: null};

function addEvent(obj, event_name, fnc) {

    if (typeof obj == "undefined")
        return;
    else if (obj.attachEvent)
        obj.attachEvent("on"+event_name, fnc);
    else if (obj.addEventListener && !browser.isKHTML)
        obj.addEventListener(event_name, fnc, false);
    else
        obj["on" + event_name] = fnc;

}//eof addEvent


window.onload = function () {
          addEvent(document.getElementById("xytble"), "click", mouse_event_handler);
       };

window.onunload = function () {
    mouse_event_handler.previous = null;
}
