// etc.js for The English Training Centre, February 2002 - .
// Last modified: Dec 2008

// Remove index.php from href
// href=window.location.href;
// if (href.search(/index.php/i)>0)window.location.href=href.replace(/index.php/i,'');

function faqsinit(){ // Show all FAQs. Hide all answers.
	for (n=1; n<=23; n++){ 
		var obj=document.getElementById('q'+n);
		obj.className='quietQ';
		obj.style.display='block';
		var obj=document.getElementById('a'+n);
		obj.style.display='none';	
	}
}
function display(n) { // Hide selected FAQ. Reveal selected answer panel.
	faqsinit();
	var obj=document.getElementById('q'+n);
	obj.style.display='none';
	var obj=document.getElementById('a'+n);
	obj.className='loudAns';
	obj.style.display='block';
}
function fbinit(maxi){ // feedback
	for (n=1; n<=maxi; n++){ 
		var obj=document.getElementById('q'+n);
		obj.className='quietQ';
		obj.style.display='block';
		var obj=document.getElementById('a'+n);
		obj.style.display='none';	
	}
}
function show(n) { // feedback
	fbinit(34);
	var obj=document.getElementById('q'+n);
	obj.style.display='none';
	var obj=document.getElementById('a'+n);
	obj.className='loudAns';
	obj.style.display='block';
}

function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value = maxlimit - field.value.length;
}

function DDSM(str) {
	if (str=='etc'){
		this.defaultStatus = ' www.englishtc.co.uk  -  The English Training Centre. '
	} else {
		this.defaultStatus = str 
	}	
} 
function DSM(str) {
	this.defaultStatus = str;
}
function noDots(which){ // Gets rid of the dotted line around the links
if(which.blur)which.blur();
}

function newwin(winID) {
	//alert(winID);
	switch (winID) {//myWin = window.open(theURL,'newwin',params);

	//case 'secure_application': myWin = window.open('https://www.secure.englishtc.co.uk/regform_secure_2007_1.htm','secure_application','scrollbars=yes,status=yes,resizable=yes,toolbar=no,left=50,top=30,width=800,height=600'); break;		

		
	//case 'grammarguide': myWin = window.open('/English_Grammar/index.htm','grammarguide','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=200,width=500,height=300'); break;
	
	case 'actdec2cert':	myWin = window.open('/images/actdec_certs/actdec2.jpg','certificate','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=600,height=1200'); break;

	case 'actdec3cert':	myWin = window.open('/images/actdec_certs/actdec3.jpg','certificate','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=600,height=1200'); break;

	case 'special1':	myWin = window.open('/special/index.htm','special','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=500,height=600'); break;

	case 'special2':	myWin = window.open('/business-book/index.htm','special','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=500,height=600'); break;

case 't1p1': myWin = window.open('/intro-tesol-courses/course-sample-pages-1.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
	
	case 't1p2': myWin = window.open('/intro-tesol-courses/course-sample-pages-2.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
		
	case 't2p1': myWin = window.open('/ces-tesol/ces-sample-pages-1.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;

	case 't2p2': myWin = window.open('/ces-tesol/ces-sample-pages-2.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
	
	case 't2p3': myWin = window.open('/ces-tesol/ces-sample-pages-3.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
		
	case 't3p1': myWin = window.open('/ctm-tesol/ctm-sample-pages-1.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
	
	case 't3p2': myWin = window.open('/ctm-tesol/ctm-sample-pages-2.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
	
	case 't3p3': myWin = window.open('/ctm-tesol/ctm-sample-pages-3.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
		
	case 'tbe1': myWin = window.open('/teaching-business-english/Sample_1_BE.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
	
	case 'tbe2': myWin = window.open('/teaching-business-english/Sample_2_BE.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
	
	case 'tbe3': myWin = window.open('/teaching-business-english/Sample_3_BE.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;
		
	case 'fgg': myWin = window.open('/sample-pages/grammar-guide-sample-pages.pdf','sample','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=700'); break;

	case 'adobe': myWin = window.open('http://www.adobe.com/products/acrobat/readstep2.html','adobe','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=850,height=750'); break;
	
	case 'tellafriend': myWin = window.open('http://www.englishtc.co.uk/tellafriend_new.php','tellafriend','scrollbars=no,status=yes,resizable=no,toolbar=no,left=300,top=200,width=500,height=450'); break;

	default: myWin = window.open('/','EnglishTC','scrollbars=no,status=no,resizable=no,toolbar=no,left=100,top=50,width=800,height=700'); break;
	}
	myWin.focus();
}
function ONW(theURL) {
	myWin = window.open(theURL,'sample','scrollbars=yes,status=yes,resizable=yes,toolbar=no,left=100,top=50,width=800,height=600');
	myWin.focus();
	//myWin.defaultStatus = theURL;
}
function ONWPrint(theURL) {
	myWin = window.open(theURL,'printForm','scrollbars=yes,status=yes,toolbar=no,left=100,top=50,width=800,height=600');
	myWin.focus();
}
function refreshPrintMessage() {
	alert("You can print this blank form by:\r\n- pressing Ctrl-P on your keyboard; or by\r\n- right-clicking the mouse and then clicking on 'Print'.");
	this.defaultStatus="Print this blank form by pressing Ctrl-P or by mouse right-click and then clicking on 'Print'.";
}
function ONWStatus(theURL, theTitle) {
	myWin = window.open(theURL,'myWin','scrollbars=yes,status=yes,left=100,top=50,width=800,height=600');
	myWin.focus();
	myWin.defaultStatus = theURL;
}
function trim( str ) {
	while (str.charAt(0)==' ') { 
		str=str.substring(1,str.length);
	}
	while (str.charAt(str.length-1)==' ') { 
		str=str.substring(0,str.length-1);
	}	
	return str;
}
function VersionNav(Netscape, Explorer) {
  if ((navigator.appVersion.substring(0,3) >= Netscape && navigator.appName == 'Netscape') ||      
      (navigator.appVersion.substring(0,3) >= Explorer && navigator.appName.substring(0,9) == 'Microsoft'))
    return true;
else return false;
}

/*
function getResolutionWidth()
{
	if( self.screen ) // true in N4
        {
        W = screen.width
        H = screen.height
        N = Math.pow( 2, screen.pixelDepth )
        // Notes:
        // -availWidth and availHeight returns screen size
        //  minus client interface's standard features (e.g:taskbar)
        // -colorDepth isn't adapted for that purpose, returning
        //  the # of bits available for composing a palette
        //   color mode : 256 64K 16M
        //   pixelDepth :   8  16  24
        //   colorDepth :  18  16  24
        // -Returned values are good even if user change
        //  the screen or color res. during the session
        // -Testing this first prevents firing the slow Java of N4
        }
	else
	if( self.java ) // for N3, true if LiveConnect enabled
        {
        dtk = java.awt.Toolkit.getDefaultToolkit()
        ss = dtk.getScreenSize()
        W = ss.width
        H = ss.height
        N = Math.pow( 2, dtk.getColorModel().getPixelSize() )
        // Notes:
        // -Returned values for screen res. are good even if
        //  user change it during the session. The value for
        //  color res. is the one that was set at the moment
        //  of Java's startup, even if changed later.
        // -N3, with Java 1.0.2, always find 256 colors only.
        //  If N3's Java version can be upgraded, one could
        //  check the Java version to know if the value for
        //  color res. will be accurate or not.
        //  ver = java.lang.System.getProperty("java.version")
        //  return "1.0.2" (bad color) or "1.1.2" (good color)
        //  or perhaps other subversions
        }
	else
	if( self.theBody ) // here should come E4
        {
	    W = theBody.offsetWidth
	    H = theBody.offsetHeight
        N = "?"
        // Notes:
        // -Returned values are here the size of the current window,
        //  not of the whole screen...
        // -Dunno for color detection
        // -This part and its BODY tag are *** unchecked ***
        // -Possible heavy way to detect screen's size: quickly opening
        //  a new maximized window with the styled BODY into, grab its
        //  dimensions, then close the child window.
        }
	else // N2, E3, N3 w/Java off, probably Opera and WebTV
        {
        W = H = N = "?"
        }
	return W;        
}
*/