// JavaScript Document

		myAI.release_$_namespace = true;
		
		myAI.init();
		
		
		function reloadForAuthChange ()	{
			window.location = window.location;
		}
		
		myAI.onLoginStatus = function () {			
			if (myAI.isLoggedIn == true)
			{
				myAI.getProfile(profileLoaded);
			}
			else if (myAI.isLoggedIn == false)
			{
				updateLoginBar();
			}
		}
		
		
		myAI.loginStateChanged = function (loggedin) {
			if (myAI.isLoggedIn)
			{
				loadprofile();
			}
		}
		
		
		myAI.loginFail = function (error)
		{
			window.alert(error)
		}
		
		myAI.ready = function(){
			alert('ready');
			myAI.doAPICall("test", {}, "GET", displayMessage, callfail); 
		}
		
		function callfail (data)
		{
			window.alert(data);
			document.getElementById("messageHolder").innerText = "API call failed";
		}
		
		var publicpersonid = null;
		
	function doMyAiLogout(){
		myAI.doLogOut();
		//window.location = window.location + "?go=signout";
	}



function toggle_index_credit(){
	if($('divIndexCredCont').style.display == "none"){
		Effect.Appear($('divIndexCredCont'), {duration: 0.15, fps:50, from:0.0, to:1});
		$('imgIndexCredArrowUp').style.display="";
		$('imgIndexCredArrowDown').style.display="none";
		$('divIndexCredCont').style.zIndex=200;
	} else {
		Effect.Fade($('divIndexCredCont'), {duration: 0.15, fps:50, from:1, to:0.0});		
		$('imgIndexCredArrowUp').style.display="none";
		$('imgIndexCredArrowDown').style.display="";
	}
}
var arrGNSticky = new Array();

function do_show_GNPanel(strIn){
	var targDiv = $('divGNPanel_' + strIn);	
	var contDiv = $('divHeadCont');	
	if(targDiv){
		if(arrGNSticky.indexOf(strIn) < 0)
			arrGNSticky.push(strIn);
		if(targDiv.style.display == "none"){			
			Effect.Appear($(targDiv), {duration: 0.1, fps:50, from:0.0, to:0.8});
			$(targDiv).style.left = contDiv.left;
		} 
	}
}

function do_hide_GNPanel(strIn){
	var targDiv = $('divGNPanel_' + strIn);
	if(targDiv){
		arrGNSticky = arrGNSticky.without(strIn);
		if(targDiv.style.display != "none" && arrGNSticky.indexOf(strIn) < 0){			
			Effect.Fade($(targDiv), {duration: 0.1, fps:50, from:0.8, to:0.0});	
		}
	}
}

var strNotLoaded = "Error loading javascript library!";
var tTimer;

function toggle_GNpop(strAuth){
	if(typeof Prototype == "undefined")
		alert(strNotLoaded)
	else{
		var dDiv = $('divGNPanel_'+ strAuth);
		if(dDiv){
			var arrDivs = $$('div.divGNMainPanel');
			//arrDivs.push($('divNavEmail'))
			arrDivs.push($('divGNPanel_contact'));
			arrDivs.push($('divGNPanel_rss'));
			
			var cBut;
			if (typeof dDiv.tTimer != "undefined")
			  clearTimeout(dDiv.tTimer);
			 
			if(dDiv.style.display == "none"){
				Effect.Appear($(dDiv), {duration: 0.1, fps:50, from:0.0, to:0.8});
				cBut = $('but_' + $(dDiv).id);
				if(cBut){
					if(!cBut.src.indexOf('_o'))
						cBut.src = cBut.hsrc;	
					cBut.removeClassName('imgnavover');
					cBut.onmouseover = "";
					cBut.onmouseout = "";
				}
				arrDivs.each(function(item) {
					//alert('DEBUG: ' + $(item).id + ' == ' + $(dDiv).id);				
					if($(item).id != $(dDiv).id){
						cBut = $('but_' + $(item).id);
						if(cBut){
							if(cBut.src.indexOf('_o')){
								cBut.src = cBut.src.replace('_o', '');
								cBut.addClassName('imgnavover');
							}
						}
						Effect.Fade($(item), {duration: 0.1, fps:50, from:0.8, to:0});
					}
				});	
				
				//Special case
				if($('divGNPanel_email').id != $(dDiv).id){
					Effect.Fade($('divGNPanel_email'), {duration: 0.1, fps:50, from:0.8, to:0});
				}			
			} else {
				Effect.Fade($(dDiv), {duration: 0.1, fps:50, from:0.8, to:0});
				cBut = $('but_' + $(dDiv).id);
				if(cBut){
					if(cBut.src.indexOf('_o')){
						cBut.src = cBut.src.replace('_o', '');
						cBut.addClassName('imgnavover');
					}
				}
			}
			initRollovers();
		} else
		 	alert('divGNPanel_'+ strAuth);
	}
}

function keep_GNpop(strAuth){
	if(typeof Prototype == "undefined")
		alert(strNotLoaded)
	else{
	var dDiv = $('divGNPanel_'+ strAuth);
	if (typeof dDiv.tTimer != "undefined")
      clearTimeout(dDiv.tTimer);
	}
}

function show_GNpop(strAuth){
	if(typeof Prototype == "undefined")
		alert(strNotLoaded)
	else{
		var dDiv = $('divGNPanel_'+ strAuth);
		if (typeof dDiv.tTimer != "undefined")
		  clearTimeout(dDiv.tTimer);
		if(dDiv.style.display == "none"){
			Effect.Appear($(dDiv), {duration: 0.1, fps:50, from:0.0, to:0.8});
		}
	}
}
//

function hide_GNpop(strAuth, force){
	if(typeof Prototype == "undefined")
		alert(strNotLoaded)
	else{
	var dDiv = $('divGNPanel_'+ strAuth);
	dDiv.tTimer = setTimeout('fade_GNpop(\'' + strAuth + '\')',50);
	}
}

function fade_GNpop(strAuth){
	if(typeof Prototype == "undefined")
		alert(strNotLoaded)
	else{
	var dDiv = $('divGNPanel_'+ strAuth);
		Effect.Fade($(dDiv), {duration: 0.1, fps:50, from:0.8, to:0.0});	
	}
}

function make_GNpop(strAuth){
	if(typeof Prototype == "undefined")
		alert(strNotLoaded)
	else{
	if(arrSticky.indexOf(strAuth) >= 0)
		arrSticky = arrSticky.without(strAuth);
	else
		arrSticky.push(strAuth);
	}
}


var speakoutValid;
function submit_SO_step1(){
	if($('divSpeakoutFail')){
		$('divSpeakoutFail').style.display = "none";
	}
	if(speakoutValid.validate()){
		strFunc = 'after_SO_step1';			
		var poststr = "SOaction=save_speakout&" + get_arg_list('frmSpeakout1');
		make_req(strSpeakoutAjaxURL + 'ajax_SO_tool.php',strFunc,poststr,'POST');
		show_update_new('divGNPanel_email');
		if(pageTracker){
			_gaq.push(['_trackEvent', 'Speak Out', 'SignUp', 'Submit']);
		}
	}
}

function after_SO_step1(strArgs){
	hide_update_new('divGNPanel_email');
	if(strArgs == "error-email"){
		$('divSpeakoutError').innerHTML = "<STRONG>ERROR:</STRONG><BR>That E-mail address is already in use.";
		if($('divSpeakoutError').style.display == "none")
			$('divSpeakoutError').blindDown({duration:0.25});
	}else if(strArgs == "error"){
		$('divSpeakoutError').innerHTML = "<STRONG>ERROR:</STRONG><BR>There was a problem saving your data - please try again later.";
		if($('divSpeakoutError').style.display == "none")
			$('divSpeakoutError').blindDown({duration:0.25});
	}else if(strArgs){
		$('divGNPanel_email').innerHTML = strArgs;
		if($('frmSpeakout1')){
			//fail - not using above checking now, if the form comes back it failed
			speakoutValid = new Validation('frmSpeakout1');
			_gaq.push(['_trackEvent', 'Speak Out', 'SignUp', 'Email In Use']);
		}else {
			if(pageTracker){
				_gaq.push(['_trackEvent', 'Speak Out', 'SignUp', 'Success']);
			}
			//if($('aSpeOutNav1').style.display == "none")
				//Effect.Appear($('aSpeOutNav1'), {duration : 0.25, fps : 100});
			//Effect.BlindUp($('divSpeOutCont1'), {duration : 0.25, fps : 100});
			//Effect.BlindDown($('divSpeOutCont2'), {duration : 0.25, fps : 100});
		}
	}
}

/* MyAmnesty */

 function open_myamnesty_window(){
	window.open('https://myamnesty.ca', 'myAmnesty', 'toolbar=0,resizable=1,scrollbars=1,status=0,width=1200,height=800');
	
}	

function open_banner_window(strURL, intID){
	var strFunc = 'after_bannerLog';
	var poststr = "GNaction=logClick&ID=" + intID;
	
	make_req(strGlobalAjaxURL + 'ajax_globalnav_tool.php',strFunc,poststr,'POST'); //log clickthrough
	
	window.open(strURL, '_Banner', 'toolbar=1,resizable=1,scrollbars=1,status=1,width=1200,height=800'); //open window
	
}
function after_bannerLog(strArgs){
	//alert(strArgs);
}

