/* ****************************************************************************
 * Globals
 * ****************************************************************************
 */
var g_objCLIENT_IS;											// used to detect browser version
var g_objMSXML_IS;											// used to detect MSXML version
var g_debug = false;										// set to true when debugging this
																				// script; otherwise, false.

/* ****************************************************************************
 * Functions
 * ****************************************************************************
 */


function ShowAllFaqAnswers(bShowAnswers, oFaqContainer) {
	var colElements;
	colElements = oFaqContainer.getElementsByTagName("tr");
	if (bShowAnswers == true) {
		for (i=0; i<colElements.length; i++) {
			if (colElements[i].style.display == "none" && colElements[i].getAttribute("id").indexOf("_a") > 0) {
				colElements[i].style.display = "block";
			}
		}
	} else {
		for (i=0; i<colElements.length; i++) {
			if (colElements[i].style.display == "block" && colElements[i].getAttribute("id").indexOf("_a") > 0) {
				colElements[i].style.display = "none";
			}
		}
	}
}

// Generates and returns the HTML necessary to show a FAQ.
//
// baseId - a string that is the base of the id attribute for the question and answer.
//   The id's generated will be id_q (question) and id_a (answer).
// question - a string that is the question
// answer - a string that is the answer
// showAnswer - true if the answer should be shown by default; otherwise, false.
function GenerateFaqHtml(baseId, question, answer, showAnswer) {
	var html = "";
	var idQ = baseId + "_q";
	var idA = baseId + "_a";
	var displayStyle = (showAnswer == true) ? "" : "style='display:none'";
	
	html = "<table cellpadding='0' cellspacing='5' border='0' width='100%'>"
			 + "	<tr style='cursor:hand' onclick='showElement(" + idA + ")' id='" + idQ + "'>"
			 + "		<td width='16' valign='top'><img src='resources/question 32.gif' width='16' /></td>"
			 + "		<td width='100%'><a name='" + idQ + "' href='#" + idQ + "'>" + question + "</a></td>"
			 + "	</tr>"
			 + "	<tr id='" + idA + "' " + displayStyle + ">"
			 + "		<td colspan='2'>"
			 + "			<div class='greyCallout'>" + answer + "</div>"
			 + "		</td>"
			 + "	</tr>"
			 + "</table>";
	return html;
}
 
function GenerateScreenshotHtml(imageFullRes, imageThumbRes, description) {
	var html = "";
	
	html = "<div class='greyCallout' style='width:100%'>"
					+ "		<p align='center'>"
					+ " 		<a href='" + imageFullRes + "'>"
					+ " 			<img src='" + imageThumbRes + "' /><br />"
					+					description
					+ " 		</a>"
					+ " 	</p>"
					+ " </div>"
					+ "	<br /><br />";
	
	return html;
}

function getCookie(NameOfCookie) {
	if (document.cookie.length > 0) { 
		begin = document.cookie.indexOf(NameOfCookie+"="); 
		if (begin != -1) { 
			begin += NameOfCookie.length+1; 
			end = document.cookie.indexOf(";", begin);
			if (end == -1) {
				end = document.cookie.length;
			}
			return unescape(document.cookie.substring(begin, end));
		} 
	}
	return null;  
}

function setCookie(NameOfCookie, value, expiredays) {
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + 
		((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function delCookie (NameOfCookie) {
	if (getCookie(NameOfCookie)) {
		document.cookie = NameOfCookie + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function showElement(oElement) {
	if (oElement.style.display == "none") {
		oElement.style.display = "block";
	} else {
		oElement.style.display = "none";
	}
}

function trim(s) {
	while ('' + s.charAt(0) == ' ') {
		s = s.substring(1, s.length);
	}
	while ('' + s.charAt(s.length-1) == ' ') {
		s = s.substring(0, s.length-1);
	}
	return s;
}

function showHTML(Text){
	HTMLWindow = window.open('', 'newWin', 'toolbar=yes,location=no,scrollbars=yes,resizable=yes,width=800,height=600');
	HTMLWindow.document.write(Text);
	HTMLWindow.document.close();
	HTMLWindow.focus();
}


// Ultimate client-side JavaScript client sniff. Version 3.02
// (C) Netscape Communications 1999.  Permission granted to reuse and distribute.
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.


function CLIENT_Is() {   
	// convert all characters to lowercase to simplify testing
	var agt=navigator.userAgent.toLowerCase();
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);

	this.nav  = 		((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
	this.nav2 =		(this.nav && (this.major == 2));
	this.nav3 =		(this.nav && (this.major == 3));
	this.nav4 =		(this.nav && (this.major == 4));
	this.nav4up =		(this.nav && (this.major >= 4));
	this.navonly =		(this.nav && ((agt.indexOf(";nav") != -1) || (agt.indexOf("; nav") != -1)) );
	this.nav6 = 		(this.nav && (this.major == 5));
	this.nav6up = 		(this.nav && (this.major >= 5));
	this.gecko = 		(agt.indexOf('gecko') != -1);

		this.ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    this.ie3    = (this.ie && (this.major < 4));
    this.ie4    = (this.ie && (this.major == 4) && (agt.indexOf("msie 4")!=-1) );
    this.ie4up  = (this.ie  && (this.major >= 4));
    this.ie5    = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
    this.ie5_5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.5") !=-1));
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4);
    this.ie5_5up =(this.ie && !this.ie3 && !this.ie4 && !this.ie5);
    this.ie6    = (this.ie && (this.major == 4) && (agt.indexOf("msie 6.")!=-1) );
    this.ie6up  = (this.ie  && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie5_5);


	// *** PLATFORM ***
	this.win   = 		( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
	this.win95 = 		((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
	this.win16 = 		((agt.indexOf("win16")!=-1) || (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("windows 16-bit")!=-1) );  
	this.win31 = 		((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) || (agt.indexOf("windows 16-bit")!=-1));
	this.win98 = 		((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
	this.winnt = 		((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
	this.win32 = 		(this.win95 || this.winnt || this.win98 || ((this.major >= 4) && (navigator.platform == "Win32")) || (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1));
	this.winme = 		((agt.indexOf("win 9x 4.90")!=-1));
	this.win2k = 		((agt.indexOf("windows nt 5.0")!=-1));
	this.winxp = 		((agt.indexOf("windows nt 5.1")!=-1));

	this.mac = 		(agt.indexOf("mac")!=-1);
	this.mac68k = 		(this.mac && ((agt.indexOf("68k")!=-1) || (agt.indexOf("68000")!=-1)));
	this.macppc = 		(this.mac && ((agt.indexOf("ppc")!=-1) || (agt.indexOf("powerpc")!=-1)));
}

function MSXML_Is() {
	var objDOM ;
	var xmlDoc = "<?xml version=\"1.0\"?><r>root</r>";
	
	try { 
		objDOM = new ActiveXObject("Microsoft.XMLDOM"); 
		objDOM.async = false; 
		if (objDOM.loadXML(xmlDoc)) {
			this.msxmldom = true ;
		} 
	} catch (e) { 
		this.msxmldom = false ;  
	}
	try { 
		objDOM = new ActiveXObject("Msxml2.DOMDocument"); 
		objDOM.async=false; 
		if (objDOM.loadXML(xmlDoc)) {
			this.msxml2 = true ; 
		}
	} catch (e) { 
		this.msxml2 = false ;  
	}
	
	try { 
		objDOM = new ActiveXObject("Msxml2.DOMDocument.2.6"); 
		objDOM.async=false; 
		if (objDOM.loadXML(xmlDoc)) {
			this.msxml2_6 = true ; 
		}
	} catch (e) { 
		this.msxml2_6 = false ;  
	}
	
	try { 
		objDOM = new ActiveXObject("Msxml2.DOMDocument.3.0"); 
		objDOM.async=false; 
		if (objDOM.loadXML(xmlDoc)) {
			this.msxml3 = true ; 
		}
	} catch (e) { 
		this.msxml3 = false ;  
	}
	
	try { 
		objDOM = new ActiveXObject("Msxml2.DOMDocument.4.0"); 
		objDOM.async=false; 
		if (objDOM.loadXML(xmlDoc)) {
			this.msxml4 = true ; 
		}
	} catch (e) { 
		this.msxml4 = false ;  
	}
	
}

function HandleGlobalScriptError() {
	var hideError = true;
	if(_debug == true) {
		hideError = false;
	}
	return hideError;
}

/* ****************************************************************************
 * Initialization
 * ****************************************************************************
 */
window.onerror=HandleGlobalScriptError;
g_objCLIENT_IS = new CLIENT_Is();
g_objMSXML_IS = new MSXML_Is();

