<!--
function openHelp(url){ window.open(url,"Help", "width=380,height=400,menu=no,status=yes,resizable=yes,scrolling=yes,scrollbars=yes") }
function openEmailPDF(url){ window.open(url,"email", "width=460,height=390,menu=no,status=yes,resizable=yes,scrolling=yes,scrollbars=yes") }
function openViewPDF(url){ window.open(url,"view", "width=380,height=300,menu=no,status=yes,resizable=yes,scrolling=yes,scrollbars=yes") }
function openPDF(url){ parent.location.href = url; }
function openNetITOLD(url){
	T = ((screen.availWidth)-640)/2;
	L = ((screen.availHeight)-480)/2;
	window.open(url,"", "width=640,height=480,top="+T+",left="+L+",menu=no,status=yes,resizable=yes,scrolling=yes,scrollbars=yes")
}
function openPDF(url){ location.href = url }
function openPDFNetit(url){ parent.location.href = url }
function openNetIT(url){ location.href = url }
function openDiscuss(url){ window.open(url,"", "width=400,height=410,menu=no,status=yes,resizable=yes,scrolling=yes,scrollbars=yes") }
function openDatePicker(url){ window.open(url,"", "width=200,height=215,menu=yes,status=no,resizable=no,scrolling=yes,scrollbars=no") }
function openPopup(URL,id,width,height){ window.open(URL, id, "toolbar=no,location=no,width="+width+",height="+height+",status=yes,scrollbars=yes,scrolling=yes,menubar=no,resizable=yes"); }
function openPopupLocked(URL,id,width,height){ window.open(URL, id, "toolbar=no,location=no,width="+width+",height="+height+",status=yes,scrollbars=yes,scrolling=yes,menubar=no,resizable=no"); }
function goPage(u){ location.href = u; }
function setDefCookie(name, value) {
  var today = new Date(); 
  expires = new Date(); 
  expires.setTime(today.getTime() + 1000*60*60*24*1);
  document.cookie = name + "=" + value + ";path=/;expires=" + expires.toGMTString();
}
function replaceSubstring(s,f,w){
	rtn = "";
	flg = 0;
	
	for(i = 0; i < s.length; i++){
		if(s.substr(i,f.length) == f){
			rtn += w;
			i += (f.length - 1);
		} else {
			rtn += s.charAt(i);
		}
	}
	return (rtn);
}
function submitSearch(lang){
	var str = 'You must enter a text string to search for before clicking OK';
	if(lang == "es"){
		var str = 'Introducir el texto de búsqueda antes de pulsar OK';
	} else if(lang == "fr"){
		var str = 'Veuillez introduire les mots à rechercher avant de cliquer OK';
	}
	if(document.forms['sitesearch'].elements['query'].value.length <= 0){ alert(str); } else { document.forms['sitesearch'].submit(); }
}
function setLanguageCookie(lang){
	if(location.href[location.href.length-1] == "/"){ var add = location.href.substring(0,-1)+"?t=1"; } else { var add = location.href; }
	location.href = "/80256B3C005BF3C2/setLanguageCookie?OpenAgent&langcode="+lang+"&url="+add;
}
function contentResize(){
	var v = 0;
	if(document.getElementById('navigation_column')){ v += 190; }
	if(document.getElementById('right_column')){ v += 280; }
	var num = (parseInt($(document).width())-(v+29));
	if($.browser.msie  && parseInt($.browser.version) >= 8){ num = (num-25); }
	$('#content_column').css({'width': num + 'px'});
}
function updateTextSize(){
	if($.cookie('textsize')){
		$('#sectionhead ul a').each(function(){ $(this).removeClass('sel'); });
		$('#' + $.cookie('textsize')).addClass('sel');
		var s = 100;
		if($.cookie('textsize') == "ts2"){ s = 130; } else if($.cookie('textsize') == "ts3"){ s = 160; } else if($.cookie('textsize') == "ts4"){ s = 190; }
		$('#content_container').css({'font-size': s + '%'})
	}
	contentResize();
}
function trimStr(tmpString){
  var tmpStr = new String(tmpString);
  if(tmpStr != ""){
    for(var i=0;i<tmpStr.length;i++){  
      if(tmpStr.charAt(tmpStr.length-1) == " ") { tmpStr = tmpStr.substring(0,(tmpStr.length-1)) }
    }
    return tmpStr
  } else {
    return ""
  }
}
function displayDateField(t){
  var ele1 = document.getElementById('hideme1');
  var ele2 = document.getElementById('hideme2');
  if( (t.selectedIndex == 3) || (t.selectedIndex == 4) ){
    ele2.className = "show";
    ele1.className = "show";
  } else {
    ele1.className = "hide";
    ele2.className = "hide";
  }
}
function getCookie(Name){ 
   var search = Name + "=" 
   if (document.cookie.length > 0) { 
      offset = document.cookie.indexOf(search) 
      if (offset != -1) { 
         offset += search.length 
         end = document.cookie.indexOf(";", offset) 
         if (end == -1) 
            end = document.cookie.length 
         return unescape(document.cookie.substring(offset, end)) 
      } 
   } 
} 
function setDefCookie(name, value) {
  var today = new Date(); 
  expires = new Date(); 
  expires.setTime(today.getTime() + 1000*60*60*24*1);
  document.cookie = name + "=" + value + ";path=/;expires=" + expires.toGMTString();
}
function siteAdvancedSearch(lang){
  var tmpAnd = "", tmpNot = "", tmpOr = "";
  var thisForm = document.forms[0];
  if(thisForm.queryV.value != ""){
    thisForm.Query.value = thisForm.queryV.value;
  }
  var tmpField = trimStr(thisForm.Query.value);
  var tmpFieldV = trimStr(tmpField.toLowerCase());
  var Str1 = tmpFieldV.substring(0,3);
  var Str1a = tmpFieldV.substring(0,2);
  var Str2 = tmpFieldV.substring(tmpFieldV.length-3,tmpFieldV.length);
  var Str2a = tmpFieldV.substring(tmpFieldV.length-2,tmpFieldV.length);
  if(Str1 == "and"){ tmpAnd = "1" }; if(Str2 == "and"){ tmpAnd = "1" };
  if(Str1 == "not"){ tmpNot = "1" }; if(Str2 == "not"){ tmpNot = "1" };
  if(Str1a == "or"){ tmpOr = "1" }; if(Str2a == "or"){ tmpOr = "1" };
  if(tmpAnd == "1" || tmpOr == "1" || tmpNot == "1") {
    alert(eval("tmpBoolean"+lang));
  } else {
    document.forms[0].submit();
  }
}
function resizeFancyBox(){
	var iFrameContentHeight = document.getElementById('fancybox-frame').contentWindow.document.body.scrollHeight;
	var iFrameContentWidth = document.getElementById('fancybox-frame').contentWindow.document.body.scrollWidth;
	var outer = $('#fancybox-wrap');
	var inner = $('#fancybox-inner');
	var paddingTotal = 60;
	var extra = 20; // some extra space to avoid Scrollbars
	if(iFrameContentHeight > 0 && iFrameContentWidth > 0){
		outer.css({
			height: iFrameContentHeight + paddingTotal + extra,
			width: iFrameContentWidth + paddingTotal + extra
		});
		inner.css({
			height: iFrameContentHeight + extra,
			width: iFrameContentWidth + extra
		});
		parent.$.fancybox.center();
	}
}
function forgottenPassword(language){
	if($('#fpEmailAddress').val().length > 0){
		var eaddress = replaceSubstring($('#fpEmailAddress').val(),"@","~");
		location.href = "/80256B3C005C2802/ForgottenPassword?OpenAgent&email=" +eaddress;
	}
}
$(document).ready(function(){
	$.extend({
		getUrlVars: function(){
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++){
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
		},
		getUrlVar: function(name){
			return $.getUrlVars()[name];
		}
	});
	$(window).resize(function(){ contentResize(); });
	contentResize();
	updateTextSize();
	$('#sectionhead ul a').click(function(){ $.cookie('textsize', $(this).attr('id')); updateTextSize(); });
	$('#headerlogin').fancybox({
		'hideOnContentClick': false,
		'padding': '0px',
		'overlayColor': '#333333',
		'overlayOpacity': 0.65,
		'type': 'iframe',
		'scrolling': 'no',
		'autoScale': true,
		'autoDimensions': true,
		'onClosed': function(){ parent.location.reload(); }
	});
	$('.loginopen').click(function(){
		var h = $(this).attr('href');
		if(h.indexOf('httpmyUNRISD_Login') > -1){
			$.fancybox(h,{
				'hideOnContentClick': false,
				'padding': '0px',
				'overlayColor': '#333333',
				'overlayOpacity': 0.65,
				'type': 'iframe',
				'scrolling': 'no',
				'autoScale': true,
				'autoDimensions': true,
				'onClosed': function(){ parent.location.reload(); }
			});
			return false;
		} else if(h.indexOf('httpEmailPDFNew') > -1){
			$.fancybox(h,{
				'hideOnContentClick': false,
				'padding': '0px',
				'overlayColor': '#333333',
				'overlayOpacity': 0.65,
				'type': 'iframe',
				'scrolling': 'no',
				'autoScale': true,
				'autoDimensions': true,
				'onClosed': function(){ parent.location.reload(); }
			});
			return false;
		} else {
			return true;
		}
	});
	$('#navigation_column li.browse_opt:last').css({'padding-bottom':'10px'});
	$('#navigation_column li.nav:last').css({'border-bottom':'1px solid #aabadc'});
	$('#navigation_column li.subresearch:first').css({'border-top':'1px solid #aabadc'});
	$('#navigation_column li.subresearch:last').css({'padding-bottom':'10px'});
	$('.news_view li:last').css({'border':'0','margin-bottom':'0'});
	$('.newsitem:last').css({'border':'0','margin-bottom':'0'});
	$('.info .sub:first').css({'padding-top':'10px'});
	$('.info .sub:last').css({'padding-bottom':'10px'});
	$('.item_options .newsitem:last').css({'border':'0','padding-bottom':'0','margin-bottom':'0'});
	$('ul.language li:last a').css({'border':'0'});
	$('ul.info_files li:last a').css({'border':'0'});
	$('ul.ordering li.pub:last').css({'border':'0','padding-bottom':'0','margin-bottom':'0'});
	$('.homepagelist ul.list a:last').css({'border':'0','padding-bottom':'0','margin-bottom':'0'})
	$('#content_column div.content:first p:first').css({'padding-top':'12px'});
	if(document.getElementById('aboutusnav')){
		$('#navigation_column ul').each(function(){
			var c = "aabadc";
			if($(this).hasClass('lightnav')){ c = "b0c7d3"; } else if($(this).hasClass('greennav')){ c = "bac9ae"; } else if($(this).hasClass('brownnav')){ c = "d5d5b9"; }
			$(this).css({'border-top':'2px solid #'+c,'margin-bottom':'5px'});
			$(this).children('li.nav').last().css({'border-bottom':'1px solid #'+c});
			$(this).children('li.subresearch').first().css({'border-top':'1px solid #'+c});
		});
	}
	if($.getUrlVar('expand')){
		var vt = $.getUrlVar('view');
		var ex = $.getUrlVar('expand');
		var sex = $.getUrlVar('expand');
		var sub = false;
		if(ex.indexOf('#') > -1){ ex = ex.substring(0,ex.indexOf('#')); }
		if(sex.indexOf('#') > -1){ sex = sex.substring(0,sex.indexOf('#')); }
		if(ex.indexOf('.') > -1){
			sub = true;
			ex = ex.substring(0,ex.indexOf('.'));
		}
		var c = 0;
		$('ul.news_view li').each(function(){
			if($(this).attr('id')){		
				if(c == 0){ if($(this).attr('id').indexOf(ex) > -1){ $(this).addClass('open'); c++; } }
				if(vt == "news" || vt == "viewpoint" || vt == "review"){
				} else {
					if($(this).attr('id').indexOf(sex) > -1 && sub == true){ $(this).addClass('opensub'); }
				}
			}
		});
		if(sub){
			$('ul.news_view .link').css({'margin-left':'52px'});
			$('ul.news_view .news').css({'margin-left':'52px'});
			$('ul.news_view .event').css({'margin-left':'52px'});
		} else {
			$('ul.news_view .link').css({'margin-left':'20px'});
			$('ul.news_view .news').css({'margin-left':'20px'});
			$('ul.news_view .event').css({'margin-left':'20px'});
		}
	}
	$('#content_column .content ul').each(function(){ $(this).children('li').last().css({'margin-bottom':'0px'}); });
	$('#CheckAllSections').click(function(){
		if($(this).attr('checked') == "checked"){
			$('#sectioncheckboxes input').each(function(){ $(this).attr('checked',true); });
		} else {
			$('#sectioncheckboxes input').each(function(){ $(this).attr('checked',false); });
		}
	});
	if(document.getElementById('pagetabs')){
		var w1 = parseInt($('#pagetabs').width());
		var w2 = parseInt($('.item_options').width())+15;
		if((w2 > 0) && ($('#pagetabs').attr('class') != "undefined")){ $('#pagetabs').css({'width':(w1-w2) + 'px !important'}); $('#pagetabs').width((w1-w2) + 'px'); }
		$('#pagetabs ul.tabs li:first').addClass('sel');
		$('#pagetabs .tabcontent:first').css({'display':'block'});
		$('#pagetabs ul.tabs li').click(function(){
			$('#pagetabs .tabcontent').each(function(){ $(this).css('display','none'); });
			$('#pagetabs ul.tabs li').each(function(){ $(this).removeClass('sel'); });
			$(this).addClass('sel');
			$('#' + $(this).attr('id') + 'content').css({'display':'block'});
		});
	}
	if($('.decadelist').size() > 1){
		if($('.decadelist').size() <= 2){ var c = 0; } else { var c = 1; }
		$('.decadelist').each(function(){
			if(c == ($('.decadelist').size()/2)){
				$(this).before('{BREAK}');
			}
			c++;
		});
		var data = $('#content_column').html();
		$('#content_column').html( replaceSubstring(data,'{BREAK}','</div><div class="decadeprojects">') );
		$('.decadeprojects').css({'float':'left','width':'49%'});
		$('.decadeprojects:first').css({'width':'48%','margin-right':'20px'})
	}
	if($('.currentprojects li').size() > 1){
		var c = 0;
		$('.currentprojects li').each(function(){
			if(c == ($('.currentprojects li').size()/2)){
				$(this).before('{BREAKTWO}');
			}
			c++;
		});
		var data = $('#content_column').html();
		$('#content_column').html( replaceSubstring(data,'{BREAKTWO}','</ul></div><div class="currentdecade"><ul class="currentprojects none">') );
		$('.currentdecade').css({'float':'left','width':'49%'});
		$('.currentdecade').css({'width':'48%','margin-right':'20px'})
	}
	$('ul.faqs li.question').click(function(){
		var id = $(this).attr('id');
		$('ul.faqs li.question').removeClass('qsel');
		$('ul.faqs li.answer').slideUp('fast');
		$(this).addClass('qsel');
		$('#'+id+'a').slideDown('fast');
	});
	$('div.vacancies .vacancy:last').css({'border':'0','padding':'0px'});
	$('a.lightbox').attr('rel','imagegroup').fancybox();
	$('div.spacerline:last').css({'border':'0'})
	$('.people_list .group:first').css({'padding-top':'0px'})
	$('.board_members .group:first').css({'padding-top':'0px'})
	if($('.people_list .group').size() > 1){
		var c = 0;
		$('.people_list .group').each(function(){
			if(c == Math.round($('.people_list .group').size()/2)){
				$(this).before('{BREAKPEOPLE}');
			}
			c++;
		});
		var data = $('#content_column').html();
		$('#content_column').html( replaceSubstring(data,'{BREAKPEOPLE}','</ul><ul class="people_list none">') );
		$('.people_list').each(function(){ $(this).children('.group').first().css({'padding-top':'0px'}); });
	}
	var rc=0;
	$('.reports li').each(function(){
		if((rc%2) === 0){
			$(this).addClass('cleft');
		}
		rc++;
	});
	if(document.getElementById('timeline')){
		var h = $('#content_container').height();
		$('#timeline').css({'height':h+'px','display':'block','border-left':'15px solid #fff'});
		var d = parseInt($('#timeline h4').height())+12;
		$('#timeline .timescroll').css({'height':(h-d)+'px','display':'block'});
	}
});
//-->

