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);

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];}
}
var dsN4=document.layers;
function AE(event,mt){ // v1.0 4LevelWebs
 this[event]=mt;if(dsN4){this.captureEvents(Event[event.substr(2,event.length).toUpperCase()])}}function RE(event){
 this[event]=null;if(dsN4){this.releaseEvents(Event[event.substr(2,event.length).toUpperCase()])}}
 function FN(){if(dsN4){history.go(0)}}var dsCC=null;var dsDL=false;function OS(i){
 var e,q,pp=(!dsN4)?"px":"";if((e=MM_findObj(i))!=null){q=(document.layers)?e:e.style}
 e.gT=function(){return parseInt(q.top+pp)||0};e.sT=function(y){q.top=y+pp};
 e.gH=function(){return dsN4?e.document.height:e.offsetHeight};
 e.gC=function(){return dsN4?e.clip.height:e.offsetHeight};
 e.AE=AE;e.RE=RE;return e;}function GM(e){return document.all?event.clientY:e.pageY;
}
function dsSC(s,d,t,a,b,c,e,m){ // v1.0 4LevelWebs
 var mu='onmouseup',md='onmousedown',mo='onmouseout';
 sT=null;sS=s;dH=d;tH=t;tO=OS(a);uO=OS(b);dO=OS(c);gO=OS(e);
 cM=OS(m);tT=gO.gT();tL=tH-dH;tB=tT+tL;cH=cM.gC();tO.AE(md,SJ);
 uO.AE(md,function(){SC(sS);return false});uO.AE(mu,SS);uO.AE(mo,SS);
 dO.AE(md,function(){SC(-sS);return false});dO.AE(mu,SS);dO.AE(mo,SS);
 gO.AE(md,SD);gO.AE('ondragstart',function(){return false});dsDL=true;LC(dsvNm);
 }function LC(n){if(!dsDL)return;if(dsCC!=null){cOb.sT(0);cOb.hV()}
 cOb=OS(n,'dsvContainer');cHt=cOb.gH();cLt=cHt-cH;sLt=tL/cLt;gO.sT(tT);
}
function SD(e){ // v1.0 4LevelWebs
dSM=GM(e);dSO=gO.gT();document.AE("onmousemove",DG);document.AE("onmouseup",PD);
 return false}function cT(){clearTimeout(sT)}function PD(){document.RE("onmousemove");document.RE("onmouseup")}
 function DG(e){var m=GM(e),d=m-dSM,x =dSO+d,d=(x<tT)?tT:(x>tB)?tB:x;gO.sT(d);var c=-(d-tT)*(1/sLt);cOb.sT(c);
 return false}function SC(s){cT();var c=cOb.gT()+s,d=tT-Math.round(cOb.gT()*(tL/cLt));if(c>0){c=0}else{
 if(c<-cLt){c=-cLt}}if(d<tT){d=tT}else{if(d>tB){d=tB}}cOb.sT(c);gO.sT(d);sT=setTimeout("SC("+s+")",25)}
 function SS(){cT();sT=null}function SJ(e){cT();var m=GM(e),x=m-(dH/2),d=(x<tT)?tT:(x>tB)?tB:x;
 gO.sT(d);var c=-(d-tT)*(1/sLt);cOb.sT(c);return false;
}
document.AE=AE;document.RE=RE,dsvNm="dsvContent1";

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_hideHideLayers() { //v6.0
  var i,p,v,obj,args=MM_hideHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='hide')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function hilite(obj) {
	obj.style.background = '#ffffff';
}

function delite(obj) {
	obj.style.background = '#cccccc';
}



/*************************** dhtml popup ***********************/


function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? (curobj.offsetHeight + 20) : 20)
subobj.style.left=xpos+"px"
subobj.style.top=ypos+"px"
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}


/**** slider menu ***********/

var dhtmlgoodies_slideSpeed = 5;	// Higher value = faster
var dhtmlgoodies_timer = 10;	// Lower value = faster

var objectIdToSlideDown = false;
var dhtmlgoodies_activeId = false;
var dhtmlgoodies_slideInProgress = false;
function showHideContent(e,inputId)
{

	if(dhtmlgoodies_slideInProgress)return;
	dhtmlgoodies_slideInProgress = true;
	if(!inputId)inputId = this.id;
	inputId = inputId + '';
	var numericId = inputId.replace(/[^0-9]/g,'');
	var answerDiv = document.getElementById('dhtmlgoodies_a' + numericId);

	objectIdToSlideDown = false;
	
	if(!answerDiv.style.display || answerDiv.style.display=='none'){		
		if(dhtmlgoodies_activeId &&  dhtmlgoodies_activeId!=numericId){			
			objectIdToSlideDown = numericId;
			slideContent(dhtmlgoodies_activeId,(dhtmlgoodies_slideSpeed*-1));
		}else{
			
			answerDiv.style.display='block';
			answerDiv.style.visibility = 'visible';
			
			slideContent(numericId,dhtmlgoodies_slideSpeed);
		}
	}else{
		slideContent(numericId,(dhtmlgoodies_slideSpeed*-1));
		dhtmlgoodies_activeId = false;
	}	
}

function slideContent(inputId,direction)
{
	
	var obj =document.getElementById('dhtmlgoodies_a' + inputId);
	var contentObj = document.getElementById('dhtmlgoodies_ac' + inputId);
	height = obj.clientHeight;
	if(height==0)height = obj.offsetHeight;
	height = height + direction;
	rerunFunction = true;
	if(height>contentObj.offsetHeight){
		height = contentObj.offsetHeight;
		rerunFunction = false;
	}
	if(height<=1){
		height = 1;
		rerunFunction = false;
	}

	obj.style.height = height + 'px';
	var topPos = height - contentObj.offsetHeight;
	if(topPos>0)topPos=0;
	contentObj.style.top = topPos + 'px';
	if(rerunFunction){
		setTimeout('slideContent(' + inputId + ',' + direction + ')',dhtmlgoodies_timer);
	}else{
		if(height<=1){
			obj.style.display='none'; 
			if(objectIdToSlideDown && objectIdToSlideDown!=inputId){
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.display='block';
				document.getElementById('dhtmlgoodies_a' + objectIdToSlideDown).style.visibility='visible';
				slideContent(objectIdToSlideDown,dhtmlgoodies_slideSpeed);				
			}else{
				dhtmlgoodies_slideInProgress = false;
			}
		}else{
			dhtmlgoodies_activeId = inputId;
			dhtmlgoodies_slideInProgress = false;
		}
	}
}



function initShowHideDivs()
{
	
	var divs = document.getElementsByTagName('DIV');
	var divCounter = 1;
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='dhtmlgoodies_question'){
			divs[no].onclick = showHideContent;
			divs[no].id = 'dhtmlgoodies_q'+divCounter;
			var answer = divs[no].nextSibling;
			while(answer && answer.tagName!='DIV'){
				answer = answer.nextSibling;
			}
			answer.id = 'dhtmlgoodies_a'+divCounter;	
			contentDiv = answer.getElementsByTagName('DIV')[0];
			contentDiv.style.top = 0 - contentDiv.offsetHeight + 'px'; 	
			contentDiv.className='dhtmlgoodies_answer_content';
			contentDiv.id = 'dhtmlgoodies_ac' + divCounter;
			answer.style.display='none';
			answer.style.height='1px';
			divCounter++;
		}		
	}	
}

		function displayul()
		{
			if(document.getElementById("ul").style.display=="" || document.getElementById("ul").style.display=="none")
				{
					document.getElementById("ul").style.display="inline";
					document.getElementById("ul").style.color="#eeeeee";
					setTimeout("displayurl_one()",50);
				}
			else
			{
					document.getElementById("ul").style.color="#222222";
					setTimeout("undisplayurl_one()",50);
			}
		}
		function undisplayurl_one()
		{
				document.getElementById("ul").style.color="#444444";
				setTimeout("undisplayurl_two()",50);
		}
		function undisplayurl_two()
		{
			document.getElementById("ul").style.color="#666666";
			setTimeout("undisplayurl_three()",50);
		}
		function undisplayurl_three()
		{
			document.getElementById("ul").style.color="#888888";
			setTimeout("undisplayurl_four()",50);
		}
		function undisplayurl_four()
		{
			document.getElementById("ul").style.color="#aaaaaa";
			setTimeout("undisplayurl_five()",50);
		}
		function undisplayurl_five()
		{
			document.getElementById("ul").style.color="#cccccc";
			document.getElementById("ul").style.display="none";
		}
		function displayurl_one()
		{
			document.getElementById("ul").style.color="#cccccc";
			setTimeout("displayurl_two()",50);
		}
		function displayurl_two()
		{
			document.getElementById("ul").style.color="#aaaaaa";
			setTimeout("displayurl_three()",50);
		}
		function displayurl_three()
		{
			document.getElementById("ul").style.color="#888888";
			setTimeout("displayurl_four()",50);
		}
		function displayurl_four()
		{
			document.getElementById("ul").style.color="#666666";
			setTimeout("displayurl_five()",50);
		}
		function displayurl_five()
		{
			document.getElementById("ul").style.color="#444444";
			setTimeout("displayurl_six()",50);
		}
		function displayurl_six()
		{
			document.getElementById("ul").style.color="#222222";
			setTimeout("displayurl_seven()",50);
		}
		function displayurl_seven()
		{
			document.getElementById("ul").style.color="#000000";
		}

function expand(ele) {	
	if (document.getElementById('list'+ele).style.display == '') 
		document.getElementById('list'+ele).style.display='none';
	else
		document.getElementById('list'+ele).style.display='';
	
	for (i=0;i <= 75;i++) {
		if (document.getElementById('list'+i) != null && i != ele) document.getElementById('list'+i).style.display='none';
	}
}

function collapse(ele) {
	document.getElementById('list'+ele).style.display='none';	
}

function topic_title_cancel(tid){
	var el = document.getElementById('topic_title_td_'+tid);
	el.innerHTML = '<a class="linkBlack" href="javascript:void(0)" onclick="f_put_topic_title(\''+tid+'\')">&lt;Enter Title&gt;<div class="textred">Only group owner or admin can add a title</div>';
}

function update_topic_title(tid){
	var title = document.getElementById('topic_t_'+tid).value;
	if(title != "") {
		url = 'ajax/actions.php?action=update_topic_title&tid='+tid+'&title='+encodeURIComponent(title);
		new Ajax.Request(url, {
						 method:'GET',
						 onSuccess:function(r){
							 if(r.responseText == "OK") window.location=window.location;
							 else alert(r.responseText);
							 }
						 }) 
		
	}
}


function f_put_topic_title(tid) {
	var el = document.getElementById('topic_title_td_'+tid);
	el.innerHTML = '<table width="320" border="0" cellspacing="0" cellpadding="0"><tr><td width="38">Title: </td><td width="140"><input type="text" name="topic_t_'+tid+'" id="topic_t_'+tid+'" value="" /></td><td width="22">&nbsp;</td><td width="60" align="left"><input type="button" name="" value="save" onclick="update_topic_title(\''+tid+'\');" /></td><td width="60"><input type="button" name="" value="cancel" onclick="topic_title_cancel(\''+tid+'\');" /></td></tr></table>';
	
}

