﻿/* -- article <n> fix -- */
var col_aList = document.getElementsByTagName("a"); 
var theRel = new String();
for( var i = 0; i < col_aList.length; i++ ) 
{ 

theRel = col_aList[i].rel;
theText = col_aList[i].innerText;
theOC = col_aList[i].onclick;

if(theRel)
	{
		col_aList[i].rel = theRel.replace(/\<n\>/,theText);
	}

/* -- image no text, fix [use link text] -- */
if(theText == "" && (col_aList[i+1]) && (col_aList[i+1].innerText))
	{
		col_aList[i].rel = theRel.replace(/\<n\>/,col_aList[i+1].innerText);
	}

/* -- open new window atlas tracking fix, logo etc -- */
if(theOC && (theRel))
	{
		//overwrite existing onclick call and set target to blank
		col_aList[i].onclick = "Atlas.Action('"+theRel+"')";
		col_aList[i].target = "_blank";
		
	}

/* -- for debug only -- */
//alert(theRel);
//alert(theOC);

}



//section highlight fix
section=window.location.pathname.substring(1,window.location.pathname.indexOf('/',1));
if (document.getElementById('section_'+section)){document.getElementById('section_'+section).parentNode.className='selected';
if (document.getElementById('section_'))document.getElementById('section_').parentNode.className='';}


//Hide all QuestionAnswer divs
    var cfaq_divs = new Array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);

    var num = cfaq_divs.length;
    
    for (i=0;i<num;i++)
    {
        var tmpdiv_a = "cal_qa"+cfaq_divs[i];
        if(document.getElementById(tmpdiv_a))
	    {
		    document.getElementById(tmpdiv_a).style.display = "none";
	    }
    }

    // Convert object name string or object reference
    // into a valid object reference
    function getObject(obj)
    {
	    var theObj;
	    if( typeof obj == "string" )
	    {
		    theObj = eval("document.getElementById('"+obj+"').style");
    	}
	    else
	    {
		    theObj = obj;
	    }
	    return theObj;
    }

    // Hide and Show an object
    function ShowAnswer(source,obj)
    {
	    var isHidden = "";
	    var theObj = getObject(obj);
	    var theSource = document.getElementById(source);
    	
	    var titleAr = new Array();
	    var titleSt;
	    var aobj;

	    aobj=theSource.getElementsByTagName("a")[0];
	    titleSt=aobj.title;
	    titleAr = titleSt.split('|');	
    	
	    isHidden = (theObj.display == "none");
	    if( isHidden == true )
	    {
		    theObj.display = 'block';
            aobj.innerText = titleAr[0];
	    }
	    else
	    {
		    theObj.display = 'none';
		    aobj.innerText = titleAr[1];
	    }	
    }
    function ShowAllQuestions()
    {
        for (i=0;i<num;i++)
        {
            var tmpdiv_a = "cal_qa"+cfaq_divs[i];
            if(document.getElementById(tmpdiv_a))
	        {
		        document.getElementById(tmpdiv_a).style.display = "";
    		   
	        }
        }
        
        for (i=0;i<num;i++)
        {
            var tmpdiv_a = "cal_a"+cfaq_divs[i];
            var tmpdiv_sld = "cal_sld"+cfaq_divs[i];
            if(document.getElementById(tmpdiv_a))
	        {
		        document.getElementById(tmpdiv_a).style.display = "none";
		        var titleAr = new Array();
	            var titleSt;
	            var aobj;
		        var theObj = getObject(tmpdiv_a);
		        var theSource = document.getElementById(tmpdiv_sld);
		        aobj=theSource.getElementsByTagName("a")[0];
	            titleSt=aobj.title;
	            titleAr = titleSt.split('|');	
	            aobj.innerText = titleAr[1];
	        }
        }
    }