var rootDir = location.href;
var pos = rootDir.indexOf("public");
if (pos==-1){
	pos = rootDir.indexOf("admin");
}
if (pos==-1){
	pos = rootDir.indexOf("learning");
}
if (pos==-1){
	pos = rootDir.indexOf("other");
}
if (pos==-1){
	pos = rootDir.indexOf("dustydiaries");
}
if (pos==-1){
	pos = rootDir.indexOf("uganda");
}
rootDir = rootDir.substring(0, pos);
//glossary items
var glossaryArray = ["00 refugee:A person who has been displaced by war or persecution and has crossed a border into another country.", "01 internally displaced person:A person who has been displaced by war or persecution but is still located within their home country.", "02 displaced:Lacking a home or country.", "03 conflict:Disagreement between groups which can lead to fights, struggle and war", "04 livelihoods:How you 'earn a living', e.g. a job", "05 latrines:Toilet, often just a trench in the ground", "06 diarrhoea:A condition where sufferer has frequent watery and loose bowel movements", "07 waterborne diseases:Diseases spread by water. E.g. drinking water or sewerage", "08 cholera:A severe diarrhoea disease caused by bacteria. Cholera is curable but life threatening" , "09 asylum seekers:Someone who has applied for refugee status but whose decision is pending.", "10 humanitarian crisis:An event where the lives of a very large group of people is threatened. E.g. a famine or war.", "11 persecute:Causing continuous harassment and suffering to a person or group of people often because of religion, race, gender, sexuality or political beliefs", "12 welfare:The health or happiness of a person", "13 deprived:Taken away", "14 human rights:Rights that every person should have. E.g. the right to an education", "15 designated:Already chosen (usually by the government).", "16 urban:From the city or living in the city.", "17 grey zone:In between two things or two areas.", "18 exploited:To make use of something or someone selfishly. E.g. a refugee may be exploited by their boss because nobody will stand up for their rights - they may not be paid as much for a non-refugee worker, if they get paid at all.", "19 trafficking:The movement of goods around the world for sale or trade. Unfortunately sometimes people can be traded and trafficked e.g. slaves. Traffickers are the people who are controlling the trading and sale of these goods.", "20 outreach:Reaching out to people in the community who need help.", "21 assistance delivery:Services who provide help to people in need.", "22 vulnerable:Open to attack or assault.", "23 conventions:An international agreement usually about a specific issue e.g. refugees or global warming.", "24 protocol:Supplementary or \'add-on\' sections for a convention or international agreement.", "25 United Nation High Commissioner for Refugees:The UNHCR helps to protect the human rights of refugees as well as providing services and aid.", "26 resettlement:The movement of people or a person to a new settlement, often to a new country.", "27 influx:Flowing in, in large numbers.", "28 humanitarian intake:The acceptance and intake of refugees and people migrating for humanitarian reasons.", "29 recruited:Added to the population.", "30 ratify:To agree, confirm or approve e.g. Australia ratified (confirmed) the United Nations Convention Realting to the Status of Refugees.", "31 obligation:Requirement or duty of a promise, law, agreement or contract.", "32 anglo:Of English origin or heritage - sometimes can mean a person of light skin.", "33 explicit:Expressed in a clear and detailed way. ", "34 genocide:Delibrate extermination of a group of people because of their race, religion, political views, sexuality, culture etc.", "35 offshore:Outside of the Australian mainland. ", "36 visa:A stamp or ducument allowing a person to enter and stay in a country.", "37 humanitarian:A person, organisation or act that helps to improve or save people's lives. E.g. Oxfam is a humanitarian organisation.", "38 non-combatants:People who are not soldiers/fighters or involved with the military.", "39 civilian:Anyone who is not involved with the military or police.", "40 repatriate:To return to your home country or area of origin.", "41 integrate:To become part of a whole. E.g. for refugees to become part of the community they have first moved into.", "42 non-derogable rights:Human rights that cannot, under any circumstances, be lawfully denied to anyone.", "43 retroactive:Relating to things that have happened in the past. ", "44 derogable:Human rights that may be limited in extreme circumstances such as war.", "45 distinction:The difference between. ", "46 combatants:Someone who is involved in fighting and conflict, e.g. a soldier, but NOT including medical personel working for armies.", "47 proportionality:Making sure things stay in balance and in 'proportion'. ", "48 precautionary:Steps taken to prevent danger.", "49 prohibited:Forbidden, banned.", "50 dignity:Self esteem and self respect. ", "51 humilitation:A loss of self esteem or self respect.", "52 humanely:Kind, sympathetic and merciful treatment.", "53 states:Nation or country.", "54 resolution:A statement of agreement. ", "55 responsibility to protect:An obligation to protect civilians from gross human rights violations such as gencodie, ethnic cleansing, war crimes and crimes against humanity. ", "56 war crimes:A crime during wartime that violates the international rule of law.  ", "57 ethnic cleansing:The removal or killing of one ethnic or racial group by another ethnic or racial group. ", "58 sovereign state:An independent country which has its own government - its government is not controlled by another nation.", "59 mitigating:Lessening or making less harsh or severe.", "60 unaccompanied:Alone, sometimes referring to children travelling without their parents or carers.", "61 provision:Supplies or stocks (e.g. food stocks or medical supplies) or providing or supplying those things.", "62 advocacy:To speak up for or to support other people or their causes. ", "63 durable:Long lasting.", "64 small arms:Small weapons that an individual soldire can carry, such as firearms (pistols, rifles, machine guns etc.)", "65 underpinning:Supporting, strengthening or propping up.", "66 appropriate: The most suitable or acceptable.", "67 non-refoulement:An international law that forbids the expulsion of a refugee into an area where s/he might be again subject to persecution.", "68 enforced:To put into action and make sure the rules are followed.", "69 massacred:Unnecessary killing and slaughter of a large number of people.", "70 inadequate:Not enough, not sufficient.", "71 destitute:Extremely poor, not being able to find food or shelter.", "72 prosperous:Rich or well-off.", "73 EU:The European Union - a group of countries in Europe that work together.","74 disproportionate:Not in fair or equal terms.", "75 significant:Important or meaningful.", "76 reconstruction:Rebuilding or restoring - putting the pieces back together.", "77 gender:The roles that women and men play in a given society.", "78 accountability:Called to take responsibility, can be explained.", "79 beneficiaries:Someone or something that recieves benefits or advantages.", "80 sustainable:Being able to continue into the future.", "81 development:Process of removing barriers to economic justice and human rights enjoyment.", "82 assessment:The process of documenting something, usually involving measurements or a comparison with something else.", "83 evaluation:Investigating whether an activity or group is doing a good job and working out to improve or make it better.", "84 marginalised:On the outer edges, often meaning people that are outside the areas of attention or influence in our communities", "85 equitable:Fair and equal, i.e. where everyone is treated fairly and equally.", "86 injustice:A violation of someon'e rights or an act that is unfair.", "87 sanitation:Making sure things are clean and hygenic - this includes taking care of toilet waste, garbage etc.", "88 alleviate:To make something easier or to relieve something.", "89 natural disasters:Destructive events that are not caused by humans e.g. earthquakes or tsunamis", "90 devastation:Where people, a place or things have been extremely destroyed or damaged.", "91 policy:A plan, guide or rule of action to tackle a problem.", "92 confederation:An alliance or union between people, groups or countries.", "93 unjust policies:Policies (laws, rules, plans, guides) that are unfair or not equitable (treating people equally)", "94 amnesty:Protection against punishment.", "94 armed forces:people in the military (like soldiers in the army, sailors in navy).", "95 asylum:Protection and immunity from extradition granted by a government to a political refugee from another country.", "96 capacity:Ability to do something, within one's skills and abilities.", "97 cease-fire:A break in fighting", "98 conduct:Personal behaviour, way of acting.", "99 consent:To agree, give permission.", "100 declaration:A formal statement or announcement.", "101 emphasise:To stress or make obvious.", "102 empower:to give power to, or give authority to.", "103 endure:To carry on through, despite hardships.", "104 facilities:Items and services like water, power, roads, shops, etc.", "105 fur tribe:Largest ethnic group in Darfur - Darfur meaning 'land of the Fur'.", "106 infringe:To trespass, breach or violate a law, a right or obligation.", "107 local integration:To become part of the whole e.g. for refugees to become a part of the community they have first moved into.", "108 moral:Concerned with right conduct, or the difference between right and wrong.", "109 persecution:The act or practice of persecuting on the basis of race, religion, gender, sexual orientation, or beliefs that differ from those of the persecutor. ", "110 predominantly:Mainly", "111 rationed:A small portion or allowance of food. Food is often rationed to make sure that everyone gets a fair amount and that the small amount of food that there is lasts a long time.", "112 regime:A mode or system of rule of government.", "113 repeal:To take back or withdraw formally or officially.", "114 right:In line with what is just (justice) or good, in conformity with the moral law.", "115 sanction:Authoritative permission, which gives binding force to support an action. ", "116 sovereignty:Total and independent power or authority in government. ", "117 stereotype:A conventional and oversimplified conception, opinion, or image. ", "118 temporary:Not permanent, not lasting.", "119 totalitarian:Government where those in control do not recognise or tolerate others of different opinion.", "120 vaginal fistula:A severe medical condition whereby a fistula (hole) develops either between the vagina and rectum or between the bladder and vagina, causing women and girls to lose control of urine or faeces (or both). The condition is treatable with surgery, but because women and girls in crisis situations often to not have access to proper medical care they are forced to live in isolation from their communities.", "121 variables:Likely to change, be altered, a symbol which may represent any one of a given set of numbers.", "122 violate/violation:To break, infringe or do violence to."];





//random image and links highlights on front page
var totImg = 2; //number of available images -- EDIT images names and links below
var images = ["hlite-game.jpg", "hlite-dustyd.jpg"];
var links = ["public/resources/multimedia/mobilephonevirtualcamp.php","public/resources/dustydiaries/"];
//generate random image and links
function randLHImage(){
	var loc = location.href;
	if (loc.indexOf("/learning/")!=-1){
		//for learning space (image has transparent border)
		randomNo = generateRandom(23)+1;
		document.write("<img class='left' src='"+rootDir+"images/lhs-photos_learning/"+randomNo+".jpg' alt=''></a>");
	} else {
		randomNo = generateRandom(31)+1;
		document.write("<img class='left' src='"+rootDir+"images/lhs-photos/"+randomNo+".jpg' alt=''></a>");
	}
}

function randImage(){
	randomNo = generateRandom(totImg);
	if (links[randomNo].indexOf("dustydiaries")!=-1) {
		document.write("<a href='"+rootDir+links[randomNo]+"' onclick=\"newwindow(this.href, '815', '600'); return false;\"><img class='margintop' src='"+rootDir+"images/highlights/"+images[randomNo]+"'></a>");
	} else {
		document.write("<a href='"+rootDir+links[randomNo]+"'><img class='margintop' src='"+rootDir+"images/highlights/"+images[randomNo]+"'></a>");
	}
	if (randomNo == (totImg-1)){
		randomNo2 = 0;
	} else {
		randomNo2 = randomNo+1;	
	}
	if (randomNo2 == 3) {
		document.write("<a href='"+rootDir+links[randomNo2]+"' onclick=\"newwindow(this.href, '800', '600'); return false;\"><img class='margintop' src='"+rootDir+"images/highlights/"+images[randomNo2]+"'></a>");
	} else {
		document.write("<a href='"+rootDir+links[randomNo2]+"'><img class='margintop' src='"+rootDir+"images/highlights/"+images[randomNo2]+"'></a>");
	}
}

function generateRandom(maxNo){
	 randomNo = (Math.ceil(Math.random() * (maxNo))-1);
	 return randomNo;
}

function newwindow(URL, width, height) {
    x = (800 - width)/2, y = (600 - height)/2;

    if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
var small_window = window.open(URL,'newWin','width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',scrollbars=yes');
small_window.focus();
}
/*function enableAcronyms() {
	// enable for all js capable browsers.
	//if (window.webkit) {
		new Tips($$('acronym'), {
			maxTitleChars:10,
			offsets:{x:0},
			fixed:true
		});
	//}
}

// perform tasks on domready.
window.addEvent('load', function(){
	enableAcronyms();
});
*/
// GLOBAL FUNCTIONS

// check browser

ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;

//New Swap functions
function get(id)
{
    if (document.getElementById!=undefined) return document.getElementById(id);
    else return document.all[id];
}
function showDIV(id)
{
    get(id).style.display = 'block';
}
function hideDIV(id)
{
    get(id).style.display = 'none';
}
function toggleVisible(id)
{
    (get(id).style.display=='block') ? hide(id) : show(id);
}

function initSubmitButton()
{
	oBtn = document.getElementById('next');
	oBtn.src = 'images/next-button.gif';
	oBtn.onmouseover = function() { MM_swapImage('next','','images/next-button-ro.gif',1); }
	oBtn.onmouseout = function() { MM_swapImgRestore(); }
	oBtn.onclick = function() { document.quoteform.submit(); }
	oBtn.style.cursor = "pointer";
}

function updateFormAction(url)
{
	document.quoteform.action = url;
	initSubmitButton();
}

function deselectRadio(id)
{
	var form = document.quoteform;
	for (var i=0; i<form[id].length; i++) form[id][i].checked = false; 
}

function resetSelect(id)
{
	document.getElementById(id)[0].selected = true;
}

//Image swap function//
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

// jump menu

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// javascript open new browser window

function MM_openBrWindow(theURL,windowName,features,windowType) { //v2.0
	if (windowType == 'normal') {
	features = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=455,height=280'
	}
  mywindow = window.open(theURL,windowName,features);
  mywindow.focus();
}

//dropdowns for IE
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
  }
  node.onmouseout=function() {
  this.className=this.className.replace(" over", "");
   }
   }
  }
 }
}
window.onload=startList;

// ns4 resize fix

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

// set as homepage functions
function getHomepage(qualify)
{
    switch (qualify)
    {
        case "give": return (is_ie) ? "<a href=\"#\" onclick=\"this.style.behavior=\'url(#default#homepage)\'; this.setHomePage(\'http://www.ripple.org\');\"><img src=\"images/set-as-home-button.gif\" alt=\"Set as homepage\" name=\"set-home\" width=\"115\" height=\"21\" border=\"0\" id=\"set-home\" onmouseover=\"MM_swapImage(\'set-home\',\'\',\'images/set-as-home-button-ro.gif\',1)\" onmouseout=\"MM_swapImgRestore()\" class=\"side-padding\" /></a>" : "<a href=\"set-as-homepage.html\"><img src=\"images/set-as-home-button.gif\" alt=\"Set as homepage\" name=\"set-home\" width=\"115\" height=\"21\" border=\"0\" id=\"set-home\" onmouseover=\"MM_swapImage(\'set-home\',\'\',\'images/set-as-home-button-ro.gif\',1)\" onmouseout=\"MM_swapImgRestore()\" class=\"side-padding\" /></a>"; break;
        case true: return (is_ie) ? "<a class=\"border-left\" href=\"#\" onclick=\"this.style.behavior=\'url(#default#homepage)\'; this.setHomePage(\'http://www.ripple.org\');\">Set as homepage</a>" : "<a class=\"border-left\" href=\"set-as-homepage.html\">Set as homepage</a>"; break;
        case false: return (is_ie) ? "this.style.behavior=\"url(#default#homepage)\"; this.setHomePage(\"http://www.ripple.org\");" : "window.location = \"set-as-homepage.html\";"; break;
    }
}

// dhtml show/hide functions

function show(id) {
        if (ns4) document.layers[id].visibility = "show"
        else if (ie4) document.all[id].style.visibility = "visible"
}

function hide(id) {
        if (ns4) document.layers[id].visibility = "hide"
        else if (ie4) document.all[id].style.visibility = "hidden"
}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function submitForm(formID,selectID)
{
	if (!document[formID][selectID][0].selected) { document[formID].submit(); }
}

// ------------------------------------------------------------------- GLOSSARY ROLLOVERS 
//position glossary roolover
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}

//position relative to right content div
as=document.getElementById("home-right");
var x=-250;
while(as.offsetParent){ x += as.offsetLeft; as=as.offsetParent;}
d.style.left = x + "px";
d.style.top = (cY) + "px";
}
function HideGlossary() {
if(d.length < 1) { return; }
document.getElementById("glossary").style.display = "none";
}
function ShowGlossary(id) {
d = document.getElementById("glossary");
if(d.length < 1) { return; }
var dd = document.getElementById("glossary");
AssignPosition(dd);
dd.style.display = "block";
var pos = glossaryArray[id].indexOf(":")+1;
var content = glossaryArray[id].substr(pos);
dd.innerHTML = content;
}
function ReverseContentDisplay() {
if(d.length < 1) { return; }
var dd = document.getElementById("glossary");
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}

