function goTo(url)
{
window.location=url;
}

function goToNew(url)
{
window.open(url);
}

function showTime(id)
{
	if (document.getElementById('times_'+id).style.display!='block')
		{
			if (id>1)
			{
				old_id=id-1;
				if (document.getElementById('times_'+old_id).style.display!='block')
				{
					alert ('Location '+old_id+' have to be set first');
					document.getElementById('location_'+id).selectedIndex=0;
					return;
				}
			}
		}
	if (document.getElementById('location_'+id).options[document.getElementById('location_'+id).selectedIndex].value!=0)
	{
		document.getElementById('times_'+id).style.display='block';
	}
	else
	{
		for (id;id<=4;id++)
		{
			document.getElementById('location_'+id).selectedIndex=0;
			document.getElementById('times_'+id).style.display='none';
		}
	}
}

function showTimeAjax(id)
{
	if (document.getElementById('ajax_times_'+id).style.display!='block')
		{
			if (id>1)
			{
				old_id=id-1;
				if (document.getElementById('ajax_times_'+old_id).style.display!='block')
				{
					alert ('Location '+old_id+' have to be set first');
					document.getElementById('ajax_location_'+id).selectedIndex=0;
					return;
				}
			}
		}
	if (document.getElementById('ajax_location_'+id).options[document.getElementById('ajax_location_'+id).selectedIndex].value!=0)
	{
		document.getElementById('ajax_times_'+id).style.display='block';
	}
	else
	{
		for (id;id<=4;id++)
		{
			document.getElementById('ajax_location_'+id).selectedIndex=0;
			document.getElementById('ajax_times_'+id).style.display='none';
		}
	}
}

function advSearch(auto)
{
	var advSearch=document.getElementById('searchBox').options[document.getElementById('searchBox').selectedIndex].value;
	if (advSearch=='dp' || advSearch=='events' || advSearch=='conferences' || advSearch=='retreats' || auto=='1')
	{
		if(inAdvMode==null || inAdvMode==false)
		{
		ajaxEdit('adv_search.ajax.php','advSearchBox','0','0');
		document.getElementById('adv').value='true';
		inAdvMode=true;
		}
	}
	else if(inAdvMode==true)
	{
		ajaxEdit('adv_search.ajax.php','advSearchBox','0','0');
		document.getElementById('advSearchBox').innerHTML='';
		document.getElementById('adv').value='false';
		inAdvMode=false;
	}
}

function fixAddress()
{
	
	if(document.getElementsByName('e'))
	{
		var address=document.getElementsByName('e')
		for(i=0; i<address.length; i++)
		{
			document.getElementById(address.item(i).id).href=document.getElementById(address.item(i).id).href.replace("@nti$p@m","@");
		}
	}
}

function fixSingle()
{
	if(document.getElementById('e'))
	{
		document.getElementById('e').innerHTML=document.getElementById('e').innerHTML.replace("@nti$p@m","@");
	}
}

function picEnlarge(pic)
{
	window.open('admin/preview.php?pic='+pic,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=100, height=100");
}

var Trash = new Array();

if (!Array.prototype.indexOf)
	Array.prototype.indexOf = function(item, startIndex) {
		var len = this.length;
		if (startIndex == null)
			startIndex = 0;
		else if (startIndex < 0) {
			startIndex += len;
			if (startIndex < 0)
				startIndex = 0;
		}
		for (var i = startIndex; i < len; i++) {
			var val = this[i] || this.charAt && this.charAt(i);
			if (val == item)
				return i;
		}
		return -1;
	};

function addToTrash(id)
{
	if (Trash.indexOf(id)!=-1)
	{
		index=Trash.indexOf(id);
		Trash.splice(index,1);
	}
	else
	{
		Trash.push(id);
	}
	//alert(Trash);
}

function emptyTrash()
{
	//alert(Trash);
	if (Trash=="")
	{
		alert('No item is selected!');
	}
	else
	{
		document.getElementById('trash').trash.value=Trash;
		document.getElementById('trash').submit();
	}
}

function formSubmit(formName)
{
document.getElementById(formName).submit();
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return null
}

function setCookie(c_name,value,expiredays)
{
var exdate=new Date()
exdate.setTime(exdate.getTime()+(expiredays*24*3600*1000))
document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : "; expires="+exdate)
}

function getElementHeight(id)
{
	if(document.getElementById)
	{
		var elem = document.getElementById(id);
	}
	else if (document.all)
	{
		var elem = document.all[Elem];
	}
	return elem.offsetHeight;
}

function checkMenu()
{
	centerHeight=getElementHeight('center');
	menuHeight=getElementHeight('menu');
	if (menuHeight>=centerHeight)
	{
		newHeight=menuHeight+'px';
		document.getElementById('center').style.height=newHeight;
		document.getElementById('center').style.minHeight=newHeight;
	}
}
/*if (!getCookie('scroller'))
{
	setCookie('scroller','1',7300)
}*/

/*function getElementHeight(from,to)
{
	if(document.getElementById)
	{
		var elem = document.getElementById(from);
	}
	else if (document.all)
	{
		var elem = document.all[Elem];
	}
	div_height=elem.offsetHeight;
	div_width=elem.offsetWidth;
	document.getElementById(to).style.height=div_height+4+'px';
	document.getElementById(to).style.width=div_width+4+'px';
}

function getElementTop(id)
{
	if(document.getElementById)
	{
		var elem = document.getElementById(id);
	}
	else if (document.all)
	{
		var elem = document.all[Elem];
	}
	document.getElementById('scrolling').style.display="block";
}*/

function fixMemberImg(id,maxSize)
{
	if(document.getElementById)
	{
		var elem = document.getElementById(id);
	}
	else if (document.all)
	{
		var elem = document.all[Elem];
	}
	id_width=elem.offsetWidth;
	id_height=elem.offsetHeight;
	if (id_width>maxSize)
	{
		precent=(id_width-maxSize)/id_width;
		//alert('precent:'+precent);
		id_width=(1-precent)*id_width;
		id_height=(1-precent)*id_height;
		document.getElementById(id).style.height=id_height+'px';
		document.getElementById(id).style.width=id_width+'px';
		//document.getElementById(id+'_con').style.display='block';
		//alert('id_width:'+id_width+', id_height:'+id_height);
	}
}

function sc(div)
{
	if (document.getElementById(div).style.display=="none")
	{
		document.getElementById(div).style.display="block";
	}
	else
	{
		document.getElementById(div).style.display="none";
	}
}

/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var thisPage=document.URL;
var sliceTo=thisPage.indexOf('#');
if (sliceTo!='-1')
{
	thisPage=thisPage.slice(0,sliceTo);
}

function ajaxEdit(url, containerid, doTiny, doRe){
	if (containerid!='ajax_edit')
	{
		if (document.getElementById(containerid).style.display=="block")
		{
			document.getElementById(containerid).style.display="none";
			if (doTiny==1)
			{
				tinyMCE.execCommand("mceRemoveControl", false, containerid+'textarea');
			}
			return
		}
	}
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
	page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
	try {
	page_request = new ActiveXObject("Msxml2.XMLHTTP")
	} 
	catch (e){
	try{
	page_request = new ActiveXObject("Microsoft.XMLHTTP")
	}
	catch (e){}
	}
	}
	else
	return false
	page_request.onreadystatechange=function(){
	loadpage(page_request, url, containerid, doTiny, doRe)
	}
	page_request.open('GET', url, true)
	page_request.send(null)
}

function loadpage(page_request, url, containerid, doTiny, doRe)
{
	if (containerid == 'advSearchBox')
	{
		msg ='<img src="images/search_spinner.gif" style="margin-top:5px;" />';
	}
	else
	{
		msg ='<img src="../images/spinner.gif" />';
	}
	
	if (page_request.readyState == 1)
	{
		document.getElementById(containerid).style.display='block';
		document.getElementById(containerid).innerHTML=msg;
		
	}
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	{
		document.getElementById(containerid).innerHTML=page_request.responseText
		if (doTiny==1)
		{
			tinyMCE.execCommand("mceAddControl", false, containerid+'textarea');
		}
		if (doRe==1)
		{
			document.location = thisPage + '#re_'+containerid;
		}
	}
}

function ajaxYear(url, containerid){
	var page_request = false
	if (window.XMLHttpRequest) // if Mozilla, Safari etc
	page_request = new XMLHttpRequest()
	else if (window.ActiveXObject){ // if IE
	try {
	page_request = new ActiveXObject("Msxml2.XMLHTTP")
	} 
	catch (e){
	try{
	page_request = new ActiveXObject("Microsoft.XMLHTTP")
	}
	catch (e){}
	}
	}
	else
	return false
	page_request.onreadystatechange=function(){
	loadyears(page_request, url, containerid)
	}
	page_request.open('GET', url, true)
	page_request.send(null)
}

function loadyears(page_request, url, containerid, doTiny, doRe)
{	
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
	{
		document.getElementById(containerid).innerHTML=page_request.responseText
	}
}



function delver(url,msg)
{
    if (confirm(msg)) {
    window.location.href = url;
    } else {}
}


