// JavaScript Document
//
// The following 2 variables are the total # of photos of each set. Photos should starting counting from 0 to n.
// Whenever new photos are added, the following number should be increased to n+1. Since there's 2 slide shows,
// each one represent 1 set of photos.
var totalImgPeople = 25;
var totalImgScenes = 25;

var thisImgT = 0;
var thisImgB = 0;
var imageW = 180;
var imageH = 180;

// Two random slide shows with the top one proportionally scalling down the size of the photos to fit.
// The scalling seems to be causing problem in display. Once a while, no photo is displayed.
// Another problem... The bottom one can't scale (even using the exact same code as the top one)
// so I think it may be a browser problem.
// To get the best performance is not to do any scalling of the photos. Another problem is, it's hard
// to ensure consistant result throughout revisions of browsers.
//
// This program uses the above global variables and assumes images names to be Salzburg(n).jpg and sjsu(n).jpg
//
// setImgSize funtion not used.
function setImgSize (imgObj, dspAreaName) {
	if (imgObj.width > imageW || imgObj.height > imageH) {
		var i = 0;
		if (imgObj.width < imgObj.height) {
			i = ingObj.height / imageH;
		} else {
			i = imgObj.width / imageW;
		}
		document.getElementById(dspAreaName).width = imgObj.width / i;
		document.getElementById(dspAreaName).height = imgObj.height / i;
	} else {
		document.getElementById(dspAreaName).width = imgObj.width;
		document.getElementById(dspAreaName).height = imgObj.height;
	}
}

function rotateTop() {
	var thisImgT=Math.floor(Math.random()*totalImgPeople);
	//imageSalzburg = new Image();
	//imageSalzburg.src = "photos/People" + thisImg + ".jpg";
	//document.getElementById("photoArea1").src = imagePeople.src;
	//setImgSize (imagePeople, "photoArea1");
	document.getElementById("photoArea1").src = "photos/People" + thisImgT + ".jpg";
	//delete imageSalzburg;
	
	// upadte photos every 6 seconds.
	setTimeout("rotateTop()", 6 * 1000);
}

function rotateBottom() {
	// Second set of images
	var thisImgB=Math.floor(Math.random()*totalImgScenes);
	document.getElementById("photoArea2").src = "photos/Scenes" + thisImgB + ".jpg";
	
	// upadte photos every 4 seconds.
	setTimeout("rotateBottom()", 4 * 1000);
}

/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Menu 1 for Fellows
var menu1=new Array()
menu1[0]='<a href="SP_fellows.html">SJSU Salzburg Fellows</a>'
menu1[1]='<a href="SP_fellows_all.html">SJSU Salzburg Fellows (All)</a>'
menu1[2]='<a href="SP_fellows_0910.html">SJSU Salzburg Fellows 2009</a>'
menu1[3]='<a href="SP_fellows_0809.html">SJSU Salzburg Fellows 2008</a>'
menu1[4]='<a href="SP_fellows_0708.html">SJSU Salzburg Fellows 2007</a>'
menu1[5]='<a href="SP_fellows_0607.html">SJSU Salzburg Fellows 2006</a>'
menu1[6]='<a href="SP_fellows_other.html">SJSU Salzburg Fellows (Other)</a>'

//Menu 2 for Scholars
var menu2=new Array()
menu2[0]='<a href="SP_scholars.html">SJSU Salzburg Scholars</a>'
menu2[1]='<a href="SP_scholars_all.html">SJSU Salzburg Scholars (All)</a>'
menu2[2]='<a href="SP_scholars_2009.html">SJSU Salzburg Scholars 2009</a>'
menu2[3]='<a href="SP_scholars_0809.html">SJSU Salzburg Scholars 2008</a>'
menu2[4]='<a href="SP_scholars_0708.html">SJSU Salzburg Scholars 2007</a>'
menu2[5]='<a href="SP_scholars_other.html">SJSU Salzburg Scholars (Other)</a>'

//Menu 3 for Activities
var menu3=new Array()
menu3[0]='<a href="SP_activities.html">Program Activities</a>'
menu3[1]='<a href="SP_activities_mentor.html">Mentoring Program</a>'
menu3[2]='<a href="SP_activities_dialogue.html">Salzburg Global Dialogue</a>'
menu3[3]='<a href="SP_activities_projects.html">Salzburg Projects</a>'
menu3[4]='<a href="SP_activities_projects_0708.html">Salzburg Projects Summary (2007-2008)</a>'
menu3[5]='<a href="SP_events.html">Salzburg Events</a>'

//Global variables
var menuwidth='165px' //default menu width
var menubgcolor='lightyellow'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)

dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu
