//
// DECLARE GLOBAL VARIABLES
//
var visible= new Array(); // Is <DIV id="qq_X_answer"> ... </DIV> visible
for( var i=0; i<11; i++) // Max 10 top-level questions
visible[i] = new Array();
var children= new Array(); // Is <DIV id="qq_X_answer"> ... </DIV> visible
var howManyVisible= 0; // current number of visible (expanded) answers
var docTitle= window.document.title; // Get document title (important)
//
// FUNCTIONS
//
function showOrHideAnswer( id, subId) { // SHOW / HIDE QUICK ANSWER
if( !visible[id][subId] ) { // Not visible?
visible[id][subId]= true;
howManyVisible++;
// Hide "I have another question" table.
// But only if this table in fact exists, i.e. has in fact been
// successfuly created. (Think Netscape.)
if( document.getElementById( 'qq_another')) {
document.getElementById( 'qq_another').style.position= 'absolute';
document.getElementById( 'qq_another').style.visibility= 'hidden';
}
// Show answer
document.getElementById( 'qq_'+id+'_'+subId+'_answer').style.position= 'relative';
document.getElementById( 'qq_'+id+'_'+subId+'_answer').style.visibility= 'visible';
document.getElementById( 'qq_'+id+'_'+subId+'_question').style.fontWeight= 'bold';
// Turn "plus" image into "minus"
document.getElementById( 'qq_'+id+'_'+subId+'_image').alt= 'Click to hide answer..';
document.getElementById( 'qq_'+id+'_'+subId+'_image').src= 'images/minusSign2.gif';
}
else {
if( subId==0) { // First check if any children are visible
// If so, hide them
for( var i=1; i<=children[id]; i++) {
if( visible[id][i]) {
showOrHideAnswer( id, i);
document.getElementById( 'qq_'+id+'_'+i+'_image').src= 'images/plusSign.gif';
}
}
}
visible[id][subId]= false;
howManyVisible--;
// Hide answer
document.getElementById( 'qq_'+id+'_'+subId+'_answer').style.position= 'absolute';
document.getElementById( 'qq_'+id+'_'+subId+'_answer').style.visibility= 'hidden';
document.getElementById( 'qq_'+id+'_'+subId+'_question').style.fontWeight= 'normal';
// Turn "minus" image into "plus"
document.getElementById( 'qq_'+id+'_'+subId+'_image').alt= 'Click to see answer..';
document.getElementById( 'qq_'+id+'_'+subId+'_image').src= 'images/plusSign2.gif';
// If no answers are visible, show "I have another question" table.
if( howManyVisible == 0) {
// But only if this table in fact exists, i.e. has in fact been
// successfuly created. (Think Netscape.)
if( document.getElementById( 'qq_another')) {
document.getElementById( 'qq_another').style.position= 'relative';
document.getElementById( 'qq_another').style.visibility= 'visible';
}
}
}
}
function invertPlusOrMinus( id, subId) {
var currImg= document.getElementById( 'qq_'+id+'_'+subId+'_image').src;
//window.status='_'+id+'_'+subId+'_  '+ visible[id][subId];
var pos= currImg.indexOf( '2.gif');
if( pos>=1) { // is inverted, so turn to "normal"
// eg. 'images/plusSign2.gif' --> 'images/plusSign.gif'
document.getElementById( 'qq_'+id+'_'+subId+'_image').src= currImg.substr( 0, pos) + '.gif';
}
else { // is "normal", so invert it
pos= currImg.indexOf( '.gif');
// eg. 'images/plusSign.gif' --> 'images/plusSign2.gif'
document.getElementById( 'qq_'+id+'_'+subId+'_image').src= currImg.substr( 0, pos) + '2.gif';
}
}
function checkQuestion() {
// <form action="/cgi-bin/contact.cgi" method="GET" onsubmit="return( checkQuestion())">
if( document.getElementById( 'question').value.match(/\S+/)) {
return( true);
}
else {
alert('Please enter a question, then click Ask.');
return(false)
}
}
function anotherQuestionTable() { 
var locId;
if(      docTitle == 'Offshore Fox: Offshore Company Formation')            { locId= 'ofqs0101'; }
else if( docTitle == 'Offshore Fox: Offshore Banking Advice')               { locId= 'ofqs0201'; }
else if( docTitle == 'Offshore Fox: Information about Offshore Tax Havens') { locId= 'ofqs0301'; }
else                                                                        { locId= 'ofqsxxxx'; }
var html= '<table id="qq_another" class="qsAnotherQuestion" width="324" border="0" cellspacing="0" cellpadding="0" align="right">'
+ '<form action="/cgi-bin/contact.cgi" method="GET" onsubmit="return( checkQuestion())">'
+ '  <tr>'
+ '    <td rowspan="2" width="20"><img src="/cimages/px.gif" width="20" height="1" alt=""></td>'
+ '    <td colspan="2" width="304">I have another question:'
+ '    <input type="hidden" name="sendTo" value="Offshore Fox">'
+ '    <input type="hidden" name="subject" value="' + docTitle + '"><br>'
+ '    <img src="/cimages/px.gif" width="304" height="1" alt=""></td>'
+ '  </tr>'
+ '  <tr>'
+ '    <td width="260"><input id="question" type="text" name="message" maxlength="500">'
+ '      <input type="hidden" name="locId" value="' + locId + '"><br>'
+ '      <img src="/cimages/px.gif" width="260" height="1" alt=""></td>'
+ '      <td width="44"><input type="image" src="images/qsAsk.gif" width="27" height="18" style="width: 27px; height: 18px" border="0" alt="Ask"><br>'
+ '      <img src="/cimages/px.gif" width="44" height="1" alt=""></td>'
+ '  </tr>'
+ '</form>'
+ '</table>';
return( html);
}
//
// ASSIGN IDs TO ALL <H2> AND <DIV> ELEMENTS AND INSERT "PLUS" IMAGES WITHIN <H2>'s
// ALSO CREATE AND INSERT THE "I HAVE ANOTHER QUESTION" TABLE
//
var dd= 0; // Index of <H2 id="qq_X_question"> & <DIV id="qq_X_answer"> pairs
var plusSignImg= '<img src="images/plusSign.gif" width="18" height="11" border="0" alt="Click to see answer.." id="qq_';
if( document.getElementById('quickAnswers').childNodes) { buildMenu( document.getElementById('quickAnswers')) }
function buildMenu( divBlock) {
var currentTag= new Object;
// For all sub-elements of <TD id="quickAnswers ...">
for( var d=0; d<divBlock.childNodes.length; d++) {
currentTag= divBlock.childNodes[d];
if( currentTag.tagName == 'H2' ) {
dd++; // Got another one
children[dd]= 0;
}
else if( currentTag.tagName == 'H3' ) {
children[dd]++;
}
if( (currentTag.tagName == 'H2') || (currentTag.tagName == 'H3') ) {
// "qq_3_2_question"
currentTag.id= 'qq_' + dd + '_' + children[dd] + '_question'; // <H2> or <H3> is a question
// "qq_3_2_image"
currentTag.innerHTML= plusSignImg + dd + '_' + children[dd] + '_image">' + currentTag.innerHTML; // Insert the little "plus" image
visible[dd][children[dd]]= false; // Init visibility status
}
else if( currentTag.tagName == 'DIV' ) { 
// "qq_3_2_answer" 
currentTag.id= 'qq_' + dd + '_' + children[dd] + '_answer'; // <DIV> contains the answer
currentTag.style.position= 'absolute';
currentTag.style.visibility= 'hidden';
//
// Remove any links found within the current <div>...</div>
//
// Note: To keep a link, use the following:
// <a id="idB4href" href="whatever.html">, i.e.
// put an "id before href" so the <a> tag
// doesn't match the regex.
//
var str= currentTag.innerHTML;
str= str.replace( /[\n|\r]/g, " "); // Netscape fix (because in Nescape, "<a href=...>Link \n Text</a>"
// does not match the next regex:                                               
//currentTag.innerHTML= str.replace( /\<a +href.*?\>(.*?)\<\/a\>/igm, "<b style='color:red'>$1</b>");
currentTag.innerHTML= str.replace( /\<a +href.*?\>(.*?)\<\/a\>/igm, "$1");
//
// End "Remove links" block
//
buildMenu( currentTag);
}
else if( currentTag.tagName == 'HR' ) {  
// Create table
var table= document.createElement("TABLE");
// Insert before the next element, i.e. after the <HR> (not before the <HR> or you'll crash the browser!!!)
document.getElementById('quickAnswers').insertBefore( table, document.getElementById('quickAnswers').childNodes[d+1]);
// Finally,
// table.outerHTML ='<table id="qq_another" class="qsAnotherQuestion" width="324" border="0" cellspacing="0" cellpadding="0" align="right"> ... '
// etc...
table.outerHTML= anotherQuestionTable();
// And set the id here, just to be sure (think Netscape)
table.id= 'qq_another';
}
}
}
//
// SET EVENTS HANDLERS FOR <H2> ELEMENTS
//
// NOTE: showOrHideAnswer( event.srcElement.id) does NOT work with Netscape
// Netscape does not support event.srcElement
if( docTitle == 'Offshore Fox: Offshore Banking Advice') {
document.getElementById('qq_1_0_question').onclick= function() { showOrHideAnswer(1,0) };
document.getElementById('qq_2_0_question').onclick= function() { showOrHideAnswer(2,0) };
document.getElementById('qq_3_0_question').onclick= function() { showOrHideAnswer(3,0) };
document.getElementById('qq_4_0_question').onclick= function() { showOrHideAnswer(4,0) };
document.getElementById('qq_4_1_question').onclick= function() { showOrHideAnswer(4,1) };
document.getElementById('qq_4_2_question').onclick= function() { showOrHideAnswer(4,2) };
document.getElementById('qq_4_3_question').onclick= function() { showOrHideAnswer(4,3) };
document.getElementById('qq_5_0_question').onclick= function() { showOrHideAnswer(5,0) };
document.getElementById('qq_6_0_question').onclick= function() { showOrHideAnswer(6,0) };
document.getElementById('qq_6_1_question').onclick= function() { showOrHideAnswer(6,1) };
document.getElementById('qq_6_2_question').onclick= function() { showOrHideAnswer(6,2) };
document.getElementById('qq_6_3_question').onclick= function() { showOrHideAnswer(6,3) };
document.getElementById('qq_7_0_question').onclick= function() { showOrHideAnswer(7,0) };
document.getElementById('qq_8_0_question').onclick= function() { showOrHideAnswer(8,0) };
document.getElementById('qq_9_0_question').onclick= function() { showOrHideAnswer(9,0) };
document.getElementById('qq_10_0_question').onclick= function() { showOrHideAnswer(10,0) };
// ////////
document.getElementById('qq_1_0_question').onmouseover= function() { invertPlusOrMinus(1,0) };
document.getElementById('qq_2_0_question').onmouseover= function() { invertPlusOrMinus(2,0) };
document.getElementById('qq_3_0_question').onmouseover= function() { invertPlusOrMinus(3,0) };
document.getElementById('qq_4_0_question').onmouseover= function() { invertPlusOrMinus(4,0) };
document.getElementById('qq_4_1_question').onmouseover= function() { invertPlusOrMinus(4,1) };
document.getElementById('qq_4_2_question').onmouseover= function() { invertPlusOrMinus(4,2) };
document.getElementById('qq_4_3_question').onmouseover= function() { invertPlusOrMinus(4,3) };
document.getElementById('qq_5_0_question').onmouseover= function() { invertPlusOrMinus(5,0) };
document.getElementById('qq_6_0_question').onmouseover= function() { invertPlusOrMinus(6,0) };
document.getElementById('qq_6_1_question').onmouseover= function() { invertPlusOrMinus(6,1) };
document.getElementById('qq_6_2_question').onmouseover= function() { invertPlusOrMinus(6,2) };
document.getElementById('qq_6_3_question').onmouseover= function() { invertPlusOrMinus(6,3) };
document.getElementById('qq_7_0_question').onmouseover= function() { invertPlusOrMinus(7,0) };
document.getElementById('qq_8_0_question').onmouseover= function() { invertPlusOrMinus(8,0) };
document.getElementById('qq_9_0_question').onmouseover= function() { invertPlusOrMinus(9,0) };
document.getElementById('qq_10_0_question').onmouseover= function() { invertPlusOrMinus(10,0) };
// ////////
document.getElementById('qq_1_0_question').onmouseout= function() { invertPlusOrMinus(1,0) };
document.getElementById('qq_2_0_question').onmouseout= function() { invertPlusOrMinus(2,0) };
document.getElementById('qq_3_0_question').onmouseout= function() { invertPlusOrMinus(3,0) };
document.getElementById('qq_4_0_question').onmouseout= function() { invertPlusOrMinus(4,0) };
document.getElementById('qq_4_1_question').onmouseout= function() { invertPlusOrMinus(4,1) };
document.getElementById('qq_4_2_question').onmouseout= function() { invertPlusOrMinus(4,2) };
document.getElementById('qq_4_3_question').onmouseout= function() { invertPlusOrMinus(4,3) };
document.getElementById('qq_5_0_question').onmouseout= function() { invertPlusOrMinus(5,0) };
document.getElementById('qq_6_0_question').onmouseout= function() { invertPlusOrMinus(6,0) };
document.getElementById('qq_6_1_question').onmouseout= function() { invertPlusOrMinus(6,1) };
document.getElementById('qq_6_2_question').onmouseout= function() { invertPlusOrMinus(6,2) };
document.getElementById('qq_6_3_question').onmouseout= function() { invertPlusOrMinus(6,3) };
document.getElementById('qq_7_0_question').onmouseout= function() { invertPlusOrMinus(7,0) };
document.getElementById('qq_8_0_question').onmouseout= function() { invertPlusOrMinus(8,0) };
document.getElementById('qq_9_0_question').onmouseout= function() { invertPlusOrMinus(9,0) };
document.getElementById('qq_10_0_question').onmouseout= function() { invertPlusOrMinus(10,0) };
}
else if( docTitle == 'Offshore Fox: Offshore Company Formation') {
document.getElementById('qq_1_0_question').onclick= function() { showOrHideAnswer(1,0) };
document.getElementById('qq_2_0_question').onclick= function() { showOrHideAnswer(2,0) };
document.getElementById('qq_3_0_question').onclick= function() { showOrHideAnswer(3,0) };
document.getElementById('qq_4_0_question').onclick= function() { showOrHideAnswer(4,0) };
document.getElementById('qq_5_0_question').onclick= function() { showOrHideAnswer(5,0) };
document.getElementById('qq_6_0_question').onclick= function() { showOrHideAnswer(6,0) };
document.getElementById('qq_1_0_question').onmouseover= function() { invertPlusOrMinus(1,0) };
document.getElementById('qq_2_0_question').onmouseover= function() { invertPlusOrMinus(2,0) };
document.getElementById('qq_3_0_question').onmouseover= function() { invertPlusOrMinus(3,0) };
document.getElementById('qq_4_0_question').onmouseover= function() { invertPlusOrMinus(4,0) };
document.getElementById('qq_5_0_question').onmouseover= function() { invertPlusOrMinus(5,0) };
document.getElementById('qq_6_0_question').onmouseover= function() { invertPlusOrMinus(6,0) };
document.getElementById('qq_1_0_question').onmouseout= function() { invertPlusOrMinus(1,0) };
document.getElementById('qq_2_0_question').onmouseout= function() { invertPlusOrMinus(2,0) };
document.getElementById('qq_3_0_question').onmouseout= function() { invertPlusOrMinus(3,0) };
document.getElementById('qq_4_0_question').onmouseout= function() { invertPlusOrMinus(4,0) };
document.getElementById('qq_5_0_question').onmouseout= function() { invertPlusOrMinus(5,0) };
document.getElementById('qq_6_0_question').onmouseout= function() { invertPlusOrMinus(6,0) };
}
else if( docTitle == 'Offshore Fox: Information about Offshore Tax Havens') {
}
