
function hidediv(sElementName) { 
    if (document.getElementById) { // DOM3 = IE5, NS6 
        alert("1a");
	    document.getElementById(sElementName).style.visibility = 'hidden'; 
	    
        alert("1b");
	    document.getElementById(sElementName).style.display = 'none';
        alert("1c");
	    //document.getElementById(sElementName).style.display = ''; 
    } 
    else { 
	    if (document.layers) { // Netscape 4 
		    document.NoChecked.visibility = 'hidden';
		    document.NoChecked.display = 'none';
		    document.YesChecked.display = '';
	    } 
	    else { // IE 4 
		    document.all.NoChecked.style.visibility = 'hidden'; 													
		    document.all.NoChecked.style.display = 'none'; 													
		    document.all.YesChecked.style.display = '';
	    } 
    } 
} 

function showdiv(sElementName) { 
    if (document.getElementById) { // DOM3 = IE5, NS6 
        //alert(sElementName);
        document.getElementById(sElementName).style.visibility = 'visible'; 
        document.getElementById(sElementName).style.display = ''; 
        //document.getElementById(sElementName).style.display = 'none';
    } 
    else { 
        if (document.layers) { // Netscape 4 
        document.NoChecked.visibility = 'visible'; 
        document.NoChecked.display = ''; 
        document.YesChecked.display = 'none'; 
        } 
        else { // IE 4 
        document.all.NoChecked.style.visibility = 'visible'; 
        document.all.NoChecked.style.display = ''; 
        document.all.YesChecked.style.display = 'none'; 
        } 
    } 
} 

function toggle(div_id) {
	var el = document.getElementById(div_id);
	//alert(div_id + ':' + el.style.display);
	if ( el.style.display == 'none') {	
	    el.style.display = '';
	    el.style.visibility = 'visible';
	}
	else 
	{
	    el.style.display = 'none';
	    el.style.visibility = 'visible';	
	}
}

function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}
	var blanket = document.getElementById('cA_blanket');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	//alert("blanket_height: " + blanket_height);
	popUpDiv_height=blanket_height/2-255-10;//150 is half popup's height
	if (popUpDiv_height < 0) {
	    popUpDiv_height = 5;
	}
	popUpDiv.style.top = popUpDiv_height + 'px';
	//alert("Height:" + popUpDiv_height);
	
}

function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-340;//150 is half popup's width
//	alert("Width: " + window_width);
	popUpDiv.style.left = window_width + 'px';
}

function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('cA_blanket');
	toggle(windowname);
	if (isIE()) {
	    opacity('cA_blanket', 10, 60, 500)	
	    opacity('cA', 0, 100, 500)
	}else{
	    opacity('cA_blanket', 10, 60, 2000)	
	    opacity('cA', 0, 100, 3000)
	}
}
 
 function switchwhy(){
    toggle('cA_T2');
    toggle('cA_T3');
 }


var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = 2
    StopTheClock()
    StartTheTimer()
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock()
        // Here's where you put something useful that's
        // supposed to happen after the allotted time.
        // For example, you could display a message:
        //alert('Here I am!');
        //toggle('cA')
        popup('cA')
    }
    else
    {
        self.status = secs
        secs = secs - 1
        timerRunning = true
        timerID = self.setTimeout("StartTheTimer()", delay)
    }
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

 
function isIE(){
    return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
}


