dispDivItems=new Array();
dispDivItemTimeout=0;
dispDivMouseOut=1;
dispDivOpacity=0;
dispDivCurrent=null;

function dispDiv1(id,on) {
	var f=document.getElementById(id);
	if(on) {
		if(dispDivCurrent!=f) {
			dispDivCurrent=f; dispDivOpacity=0; 
			checkDispDivOpacity();
		}
	} else {
		dispDivCurrent=null;
	}
	f.style.display=on?"inline":"none";
}

function dispLevelDiv(id,lvl,on) {
	var item=dispDivItems[lvl];
	if(item!=id && item!=undefined && on) {
		// hide previous focused div
		dispDiv1(item,0);
	}

	dispDivItems[lvl]=id;
	dispDivItemTimeout=0;
	dispDivMouseOut=0;
	dispDiv1(id,on);
}

function dispDiv(id,on) {
	dispLevelDiv(id,0,on);
}

function setDispDivMouseOut() {
	dispDivMouseOut=1;
}

function checkDispDivOpacity() {
	if(dispDivCurrent!=null) {
		if(dispDivOpacity>97) { dispDivOpacity=97; }
		if(dispDivCurrent.filters) {
			dispDivCurrent.filters.alpha.opacity=dispDivOpacity;
		}
		dispDivCurrent.style.MozOpacity=dispDivOpacity/100;
		dispDivOpacity+=5;
	}
}

currOnMenu=null;
currOnMenuOrig=null;

function checkDispDiv() {
	dispDivItemTimeout++;
	checkDispDivOpacity();

//window.status=dispDivItems.length+":"+dispDivItems[0]+":"+dispDivItems[1]+":"+dispDivMouseOut+":"+dispDivItemTimeout;
	for(var i=dispDivItems.length-1; i>=0; i--) {
		var item=dispDivItems[i];
		if(item==undefined) { continue; }
		if(item!=undefined && dispDivItemTimeout>16 && dispDivMouseOut) {
			dispDiv1(item,0);
			dispDivItems[i]=undefined;
			offSubMenu();
			continue;
		}
	}
	setTimeout('checkDispDiv()',50);
}
setTimeout('checkDispDiv()',50);


function dispSubMenu(id,color1,color2) {
	dispLevelDiv(id,0,1);
	var imgObj=document.getElementById("img_"+id);
	var i;
	if(currOnMenu!=null && imgObj.id!=currOnMenu.id) {
		offSubMenu();
	}
	if((i=imgObj.src.indexOf(color1))>=0) {
		var s=imgObj.src;
		currOnMenu=imgObj;
		currOnMenuOrig=s;
		s=s.substr(0,i)+color2+s.substr(i+color1.length);
		imgObj.src=s;
	}
}

function offSubMenu() {
	if(currOnMenu!=null) {
		currOnMenu.src=currOnMenuOrig;
		currOnMenu=null;
		currOnMenuOrig=null;
	}
}


function toggleDiv(id) {
	var f=document.getElementById(id);
	f.style.display=f.style.display=="" || f.style.display=="none"?"inline":"none";
}
function setDivDisp(id,on) {
	var f=document.getElementById(id);
	if(!f) { return; }
	f.style.display=on?"inline":"none";
}
function setDivDispAll(pref,on) {
	for(num=1; num<100; num++) {
		setDivDisp(pref+num,on);
	}
}

function dispDivOneOnly(name,id) {
	var currentId=document['oneOnly'+name];
	if(currentId!=undefined) {
		var div=document.getElementById(currentId);
		if(div) {
			div.style.display='none';
		}
	}
	var display='inline';
	if(id==currentId) {
		// clicked on same one twice, let's hide it.
		display='none';
		document['oneOnly'+name]=undefined
	} else {
		document['oneOnly'+name]=id;
	}
	var div=document.getElementById(id);
	div.style.display=display;
}

var overDivTimeout=0;
var currentOverDiv=null;
function overDiv(id,on) {
	if(!on) {
		overDivTimeout=0;
		currentOverDiv=id;
		return;
	}
	currentOverDiv=null;
	setDivDisp(id,on);
}

function overDivCheck() {
	if(currentOverDiv!=null && ++overDivTimeout>7) {
		setDivDisp(currentOverDiv,0);
		currentOverDiv=null;
	}
	setTimeout('overDivCheck()',100);
}
setTimeout('overDivCheck()',100);


function mindd_top(img) {
        var tl=document.getElementById('mindd_tl');
	if(img==undefined) {
		var bgs=['kid_apple_bg','mother_baby_bg','girl_cup_bg','hands_bg','rego_bg','about_us_bg','contact_us_bg','books_bg','home_bg'];
		img=bgs[Math.floor(Math.random()%bgs.length)];
	}

        tl.className=img;
}
function mindd_top_mid(img) {
        var tl=document.getElementById('mindd_tm');
        tl.innerHTML=img;
}


// stuff for login pages...

function rememberPassword() {
 var f=document.registration_login_form;
 if(f.remember.checked) {
   var expires=new Date();
   expires.setTime(expires.getTime()+(365*24*60*60*1000));
   document.cookie = "registration_login="+f.fullname.value+"#"+f.password.value+"; expires="+expires.toGMTString()+";";
 }
}

function loadPassword() {
 var f=document.registration_login_form;
  var idx=document.cookie.indexOf("registration_login=");
  if(idx>=0) {
     var str=document.cookie.substring(idx,document.cookie.length);
     var idxEnd=str.indexOf(";");
     if(idxEnd<0) { idxEnd=str.length; }

     str=str.substring(idx,idxEnd);
     str=document.cookie.substring(str.indexOf("=")+1,str.length);
     var arr=new Array();
     arr=str.split("#");
     f.fullname.value=arr[0];
     f.password.value=arr[1];
     f.remember.checked=true;
  }
}

function goToHash(h) {
	document.location.hash=h;
}



document.conferenceDivNumber=1;
function getConferenceItem(divNameNum,speaker,title,description) {
	var width="100%";
	var conferenceDivNumber=document.conferenceDivNumber++;
	var html='';

if(0) {
	html='<table width="100%" border="0"><tbody><tr>	<td class="darkline" colspan="2"><img height="1" width="1" alt="" src="templates/mindd/img/blank.gif" /></td></tr>'+
		'<tr><td ><img height="1" width="200" alt="" src="templates/mindd/img/blank.gif" /></td></tr>'+
		'<tr><td class="conference_td"> '+speaker+' </td>'+
		'<tr><td class="conference_td" width="100%">';
	if(description!="") {
		html+=' <a class="conflink" href="javascript:toggleDiv(\'conference'+conferenceDivNumber+'\');"> '+title+' </a>'+
			'<div id="conference'+conferenceDivNumber+'" class="conference_more"> <br /> <font class="conference_light">'+description+'  </font></div>';
	} else {
		html+=' <font class="conflink"> '+title+' </font>';
	}
	html+='</td></tr></tbody></table>';
}

	var divClass="conferenceItemDiv";
//	if(title=="" && speaker=="") { return; }
	if(title.substring(0,4)=="Tea/" || title.substring(0,6)=="Lunch/") { 
		if(divNameNum!="1") { title=""; }
		divClass+="Tea"; 
	}
	if(description!="") {
		html='<div class="'+divClass+'"><a href="javascript:setDivDispAll(\'conference\',0); dispDivOneOnly(\'conference\',\'conferencePopup'+conferenceDivNumber+'\');" class="conflink">'+title+'</a><br /><i>'+speaker+'</i></div>'+
			'<div id="conference'+conferenceDivNumber+'" class="conference_more"> <font class="conference_med" style="font-size: 8pt"><br />'+
			description+'</font><br /><br /></div>'+
			'<div style="position: absolute;" id="conferencePopup'+conferenceDivNumber+'" class="conference_popup"> <font class="conference_dark">'+
			'<div align="right"><a class="conflink" style="text-decoration: none; font-size: 8pt;" href="javascript:setDivDispAll(\'conference\',0); dispDivOneOnly(\'conference\',\'conferencePopup'+conferenceDivNumber+'\');">&#9447; close</a></div>'+
			description+'</font></div>';
	} else {
		html='<div width="'+width+'">'+
			(title==""?'':'<a class="conflink">'+title+'</a><br />')+
			''+speaker+'</div>';
	}

	//div.innerHTML+=
	return "<table class='"+divClass+"' border='0' cellpadding='0' cellspacing='0' width='"+width+"'>"+
		"<tr>"+
		"<td ><img src='templates/mindd/img/blank.gif' width='1' height='80' /></td>"+
		"<td valign='top' "+(divNameNum=="0"?"nowrap='nowrap'":"")+">"+
		html+"<br />"+
		"</td></tr></table>";
}

function addConferenceItem(divName,speaker,title,description) {
	var divNameNum=divName.charAt(divName.length-1);

	var div=document.getElementById(divName);
	div.innerHTML+=getConferenceItem(divNameNum,speaker,title,description);
}

function addConferenceItems(divName,items) {
	for(var i=0; i<items.length; i++) {
		var item=items[i];
		addConferenceItem(divName,item[0],item[1],item[2]);
	}
}

function addConferenceItemsTable(divName,itemsColumns,headerHtml) {
	var html='<table class="conferenceItems" border="0">'+headerHtml;
	for(var i=0; i<itemsColumns[0].length; i++) {
		html+="<tr>";
		for(var ic=0; ic<itemsColumns.length; ic++) {
			var item=itemsColumns[ic][i];
			if(item==undefined) { continue; }
			html+="<td class='conferenceItemsTd' valign='top'>"+
				getConferenceItem(ic,item[0],item[1],item[2])+
				"</td>";
		}
		html+="</tr>";
	}
	html+="</table>";
	var div=document.getElementById(divName);
	div.innerHTML+=html;
}



function checkNewWindow(popupDiv) {
	popupDiv=window.popupDivObj;
	var newWindow=popupDiv.newWindow;
	if(newWindow.document.getElementById('loaded')==undefined && popupDiv.timeOut>(new Date().getTime())) {
		setTimeout("checkNewWindow(popupDiv)",500);
		return;
	}
	newWindow.document.body.innerHTML=popupDiv.html;
	newWindow.document.body.style.background='#fff';
	newWindow.document.body.style.margin='20px';
}

function popupDiv(divId) {
	var div=document.getElementById(divId);
	var popupDiv=new Array();
	popupDiv.div=div;

	popupDiv.newWindow=window.open('/blank.html','','width=720,height=600,toolbar=no,menubar=no,scrollbars=yes');
	popupDiv.newWindow.moveTo(0,0);
	popupDiv.newWindow.resizeTo(screen.width,screen.height);
	var timeOut=new Date();
	timeOut=timeOut.getTime()+30000;
	popupDiv.timeOut=timeOut;


	popupDiv.html='<link id="sty" rel="stylesheet" type="text/css" href="http://mindd.org/serendipity/index.php?/serendipity.css" />'+
		'<style type="text/css"></style>'+
		div.innerHTML;

	window.popupDivObj=popupDiv;
	setTimeout("checkNewWindow(popupDiv)",500);
//sty.href='http://mindd.org/serendipity/index.php?/serendipity.css';
}

function toggleNextDiv(link) {
	var d=link.nextSibling;
	while(d!=undefined && (d.tagName==undefined || d.tagName.toLowerCase()!="div")) {
		d=d.nextSibling;
	}
	if(d.style.display=="none") {
		d.style.display="inline";
	} else {
		d.style.display="none";
	}
}


rotateSponsors=[
//'gluten_free_57h_fuzz.gif',
'ARI-DAN.gif',
'blackmores_201.gif',
'macquarie_80.gif',
'kingsway_180.gif',
'Metametrix_180.gif'
];

window.rotateSponsorUpto=0;
function RotateSponsorsTick() {
	if(window.rotateSponsorUpto>=rotateSponsors.length) {
		window.rotateSponsorUpto=0;
	}
	document.getElementById('sponsorImg').src='uploads/sponsors/'+rotateSponsors[window.rotateSponsorUpto];
	window.rotateSponsorUpto++;
	window.setTimeout(RotateSponsorsTick,1500);
}

