// JavaScript Document

//Style Sheet Switcher version 1.0 Nov 9th, 2005
//Author: Dynamic Drive: http://www.dynamicdrive.com
//Usage terms: http://www.dynamicdrive.com/notice.htm

function getCookie(Name) { 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return null
}

function setCookie(name, value, days) {
var expireDate = new Date()
//set "expstring" to either future or past date, to set or delete cookie, respectively
var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";
}

function deleteCookie(name){
setCookie(name, "moot")
}

function setStylesheet(title) {
var i, cacheobj
for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
if(cacheobj.getAttribute("rel").indexOf("style") != -1 && cacheobj.getAttribute("title")) {
cacheobj.disabled = true
if(cacheobj.getAttribute("title") == title)
cacheobj.disabled = false //enable chosen style sheet
}
}
}

function chooseStyle(styletitle, days){
if (document.getElementById){
setStylesheet(styletitle)
setCookie("mysheet", styletitle, days)
}
}

function indicateSelected(element){ //Optional function that shows which style sheet is currently selected within group of radio buttons or select menu 
var i
if (selectedtitle!=null && (element.type==undefined || element.type=="select-one")){ //if element is a radio button or select menu
var element=(element.type=="select-one") ? element.options : element
for (i=0; i<element.length; i++){
if (element[i].value==selectedtitle){ //if match found between form element value and cookie value
if (element[i].tagName=="OPTION") //if this is a select menu
element[i].selected=true
else //else if it's a radio button
element[i].checked=true
break
}
}
}
}

var selectedtitle=getCookie("mysheet")
if (document.getElementById && selectedtitle!=null) //load user chosen style sheet if there is one stored
setStylesheet(selectedtitle)

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_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_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 PopUp(url,w,h) {
        var dim = eval('"width=' + w + ',height=' + h + '"');
        Npop = window.open(url,"pop",dim);
        }
		
var UniqueID = 314 // Make each link open in a new window 
 var newWinOffset = 0 // Position of first pop-up

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
		
function PlayerOpen(soundfiledesc,soundfilepath) { 
 PlayWin = window.open('',UniqueID,'width=320,height=400,top=' + newWinOffset +',left=0,resizable=0,scrollbars=0,titlebar=0,toolbar=0,menubar=0,status=0,directories=0,personalbar=0');
 PlayWin.focus(); 

 var winContent = "<html><head><TITLE>" + soundfiledesc + "</TITLE></head><body bgcolor='#94aedf' background='/images/bg_topheader.jpg' style='background-repeat:repeat-x;background-position:top;background-attachment: fixed'>"; 
	
 winContent += "<p  style='font-size:12px;font-family:arial, serif, helvetica, verdana;text-align:center'><img src='/images/logo_usip_100.gif'></p>";
 winContent += "<p  style='font-size:13px;font-family:arial, serif, helvetica, verdana;text-align:center;color:white;font-weight:bold'>" + soundfiledesc + "</p>";

 winContent += "<OBJECT width='300' height='42'>"; 
 winContent += "<param  name='SRC' value='" + soundfilepath + "'>";
 winContent += "<param name='AUTOPLAY' VALUE='true'>"; 
 winContent += "<param name='CONTROLLER' VALUE='true'>";
 winContent += "<param  name='BGCOLOR' VALUE='#94aedf'>"; 
 winContent += "<EMBED  SRC='" + soundfilepath + "'  AUTOSTART='TRUE' LOOP='FALSE' WIDTH='300' HEIGHT='42' CONTROLLER='TRUE' BGCOLOR='#94aedf'></EMBED>";
 winContent += "</OBJECT>"; 

 winContent += "<p  style='font-size:12px;font-family:arial, serif, helvetica, verdana;text-align:center'><a href='/events/webcasts/faqs.html' target='_blank'>Audio Help</a></p>";
  winContent += "<p  style='font-size:11px;font-family:arial, serif, helvetica, verdana;text-align:center'><a href='../United States Institute of Peace Committed to the Prevention, Management, and Peaceful Resolution of International Conflicts_files/styleswitcher.js' target='_blank'>Please email the webmaster with any problems!</a></p>";
 winContent += "<FORM><DIV  align='center'><INPUT type='button' value='Close this window' onclick='javascript:window.close();'></DIV></FORM>"; 
 winContent += "</BODY></HTML>"; 

 PlayWin.document.write(winContent); 
 PlayWin.document.close(); // "Finalizes" new  window 
 UniqueID = UniqueID + 1 //  newWinOffset = newWinOffset + 20 // subsequent pop-ups will be this many pixels  lower 
 }


function takeYear(theDate)
{
	x = theDate.getYear();
	var y = x % 100;
	y += (y < 38) ? 2000 : 1900;
	return y;
}

function leadingZero(nr)
{
	if (nr < 10) nr = "0" + nr;
	return nr;
}