/*
window.addEvent('domready', function(){
	var Tips3 = new Tips($$('.researchtip'), {
		//fixed: true,
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
});
*/
if (document.images){
top_off = new Image();			top_off.src = view_path + "images/clear.gif";
top_act_on = new Image();		top_act_on.src = view_path + "images/bar_act.gif";
top_compare_on = new Image();	top_compare_on.src = view_path + "images/bar_compare.gif";
top_learn_on = new Image();		top_learn_on.src = view_path + "images/bar_learn.gif";
lea3_on = new Image();			lea3_on.src = view_path + "images/3btns_learn_on.gif";
com3_on = new Image();			com3_on.src = view_path + "images/3btns_compare_on.gif";
act3_on = new Image();			act3_on.src = view_path + "images/3btns_act_on.gif";
one_on = new Image();			one_on.src = view_path + "images/nh_learn_on.gif";
one_off = new Image();			one_off.src = view_path + "images/nh_learn_off.gif";
two_on = new Image();			two_on.src = view_path + "images/nh_compare_on.gif";
two_off = new Image();			two_off.src = view_path + "images/nh_compare_off.gif";
three_on = new Image();			three_on.src = view_path + "images/nh_act_on.gif";
three_off = new Image();		three_off.src = view_path + "images/nh_act_off.gif";
}

function roll(sname,rname){
    sname.src = rname.src;
}

function roll2(aname,bname,cname,dname) {
	aname.src = bname.src;
	cname.src = dname.src;
}

function roll_learn(aname,bname,cname,dname,ename) {
	aname.src = view_path + "images/bar_compare.gif";
	bname.src = view_path + "images/bar_act.gif";
	cname.src = view_path + "images/home_learn_on.gif";
	dname.src = view_path + "images/home_compare_learn.jpg";
	ename.src = view_path + "images/home_act_learn.jpg";
}

function unroll_learn(aname,bname,cname,dname,ename) {
	aname.src = view_path + "images/clear.gif";
	bname.src = view_path + "images/clear.gif";
	cname.src = view_path + "images/home_learn.gif";
	dname.src = view_path + "images/home_compare.gif";
	ename.src = view_path + "images/home_act.gif";
}

function get_learn_on(){
	$('home_learn').addClass('hlearn_on');
	//$('home_learn').setText('hello!');
}
function set_learn_off(){
	$('home_learn').addClass('hlearn_off');
	//$('home_learn').setText('hello!');
}
function roll_compare(aname,bname,cname,dname,ename) {
	aname.src = view_path + "images/bar_learn.gif";
	bname.src = view_path + "images/bar_act.gif";
	cname.src = view_path + "images/home_learn_compare.jpg";
	dname.src = view_path + "images/home_compare_on.gif";
	ename.src = view_path + "images/home_act_compare.jpg";
}

function unroll_compare(aname,bname,cname,dname,ename) {
	aname.src = view_path + "images/clear.gif";
	bname.src = view_path + "images/clear.gif";
	cname.src = view_path + "images/home_learn.gif";
	dname.src = view_path + "images/home_compare.gif";
	ename.src = view_path + "images/home_act.gif";
}

function roll_act(aname,bname,cname,dname,ename) {
	aname.src = view_path + "images/bar_learn.gif";
	bname.src = view_path + "images/bar_compare.gif";
	cname.src = view_path + "images/home_learn_act.jpg";
	dname.src = view_path + "images/home_compare_act.jpg";
	ename.src = view_path + "images/home_act_on.gif";
}

function unroll_act(aname,bname,cname,dname,ename) {
	aname.src = view_path + "images/clear.gif";
	bname.src = view_path + "images/clear.gif";
	cname.src = view_path + "images/home_learn.gif";
	dname.src = view_path + "images/home_compare.gif";
	ename.src = view_path + "images/home_act.gif";
}

function id2elem(id) {
	if (typeof(id) != 'string') {
		return id;
	}
	if (document.getElementById) {
		id = document.getElementById(id);
	} else if (document.all) {
		id=document.all[id];
	} else {
		id = null;
	}
	return id;
}

function popup(url,width,height){
    nw = window.open(url,"newwindow","width="+width+",height="+height+",status=0,toolbar=0,menubar=0,scrollbars=1,resizable=1,location=0");
    nw.focus();
}

function demo_popup(section){
	var url, nw;

	switch (section) {
		case 'outcomes':
			url = def_path + 'popup/outcomes';
		break;

		default:
			url = def_path + 'popup/outcomes';
		break;
	}
    nw = window.open(url,"newwindow","width=650,height=600,status=0,toolbar=0,menubar=0,scrollbars=1,resizable=0,location=0");
    nw.focus();
}

function checkForm(){
if (document.subscribeForm.elements['Email Address'].value.length > 0){
 return true;
 }
else{
 alert('Please enter your email address.');
 document.subscribeForm.elements['Email Address'].focus();
 return false;
 }
}

//for drop-down menu
if (!document.layers&&!document.all&&!document.getElementById)
event="test"


function showDIV(divid,spanid){
	$(document).ready(function(){
		if ($('#'+divid).is(':visible')){
			$('#'+divid).slideUp("fast");
			$('#'+spanid).css("color","#000");
			$('#'+spanid).css("font-weight","normal");
		} else {
			$('#'+divid).slideDown("fast");
			$('#'+spanid).css("color","#bc7212");
			$('#'+spanid).css("font-weight","bold");
		}
	});
}

function highlightDIV(divid,spanid){
	$(document).ready(function(){
		if ($('#'+divid).is(':visible')){
			$('#'+spanid).css("color","#bc7212");
			$('#'+spanid).css("font-weight","bold");
		} else  {
			$('#'+spanid).css("color","black");
			$('#'+spanid).css("font-weight","normal");
		}
	});
}
function showtip(current,e,text){

if (document.all||document.getElementById){
thetitle=text.split('<br>')
if (thetitle.length>1){
thetitles=''
for (i=0;i<thetitle.length;i++)
thetitles+=thetitle[i]
current.title=thetitles
}
else
current.title=text
}

else if (document.layers){
document.tooltip.document.write('<layer bgColor="white" style="border:1px solid black;font-size:12px;">'+text+'</layer>')
document.tooltip.document.close()
document.tooltip.left=e.pageX+5
document.tooltip.top=e.pageY+5
document.tooltip.visibility="show"
}
}
function hidetip(){
if (document.layers)
document.tooltip.visibility="hidden"
}

function change(id, newClass)
{
	identity=document.getElementById(id);
	identity.className=newClass;
}

function clearInfo(sect) {
	$('#'+sect+'_sidebar').text(' ');
}

function createCleanUrl(id1,id2) {
	var newUrl = $(id1).value;

	//newUrl = newUrl.substr(50,newUrl.length);
	newUrl = newUrl.gsub("/!\[(.*?)\]\((.*?)\)/", '');
	newUrl = newUrl.gsub('!', '');
	newUrl = newUrl.gsub('/', '_');
	newUrl = newUrl.gsub('&', '_');
	newUrl = newUrl.gsub('-', '_');
	newUrl = newUrl.gsub("'", '');
	newUrl = newUrl.gsub('"', '');
	newUrl = newUrl.gsub(' ', '_');

	$(id2).value = newUrl.toLowerCase();

	return false;
}
function catMsg(sid,sect,cat){
	//$(sect+'_sidebar').setText('ID: '+sid+' Section: '+sect+' Category: '+cat);
	var cUrl = def_path + 'ajax/getcatinfo';
	var pars = 'sid='+sid+'&sect='+cat;
	var myAjax = $.ajax({
	   type: "POST",
	   url: cUrl,
	   data: pars,
	   dataType: "text",
	   success: function(rstr){
		$('#'+sect+'_sidebar').html(rstr);
		}
 	});
}

$(function() {
	$('#hottopics a').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fixPNG: true,
		extraClass: "slick",
		showBody: "|"
	});
	$('.reveallink').tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fixPNG: true,
		extraClass: "slick",
		showBody: "|"
	});
});
