// JavaScript Document


var i=0;
id3=null
function swapImage(id,elm,name1) {

swp=document.getElementById(id).src

if(id!=id3)
{
i=0	
}
id3=id

reee=/formJavascript1.jpg/

	if(reee.test(swp) && i==0)
	{
		
	j=0
	k=0
	
		while(j<name1.length)
		{
	
			if(name1[j].checked)
			{
			++k		
			}
			++j
		}
		if(k==0)
		{
			document.getElementById(id).src = "templates/default/images/formJavascript.jpg"
			
		}						
	
	}
	else if(elm.checked == true)
	{
		i++;
		
	}
	else{
		--i;
		
			if(i==0)
				document.getElementById(id).src = "templates/default/images/formJavascript.jpg"
	}


	if(i>0)
	{
		
		   document.getElementById(id).src = "templates/default/images/formJavascript1.jpg" 
	   
	}

}


var i=0;
id3=null

function swapComp(id,elm,name1) {

swp=document.getElementById(id).src

if(id!=id3)
{
i=0	
}
id3=id

re=/formJavascriptComp1.jpg/

	if(re.test(swp) && i==0)
	{
		
	j=0
	k=0
	
		while(j<name1.length)
		{
	
			if(name1[j].checked)
			{
			++k		
			}
			++j
		}
		if(k==0)
		{
			document.getElementById(id).src = "templates/default/images/formJavascriptComp.jpg"
			
		}						
	
	}
	else if(elm.checked == true)
	{
		i++;
		
	}
	else{
		--i;
		
			if(i==0)
				document.getElementById(id).src = "templates/default/images/formJavascriptComp.jpg"
	}


	if(i>0)
	{
		
		   document.getElementById(id).src = "templates/default/images/formJavascriptComp1.jpg" 
	   
	}

}

function swapOther(id,elm,name1) {

swp=document.getElementById(id).src

if(id!=id3)
{
i=0	
}
id3=id

re=/formJavascriptOther1.jpg/

	if(re.test(swp) && i==0)
	{
		
	j=0
	k=0
	
		while(j<name1.length)
		{
	
			if(name1[j].checked)
			{
			++k		
			}
			++j
		}
		if(k==0)
		{
			document.getElementById(id).src = "templates/default/images/formJavascriptOther.jpg"
			
		}						
	
	}
	else if(elm.checked == true)
	{
		i++;
		
	}
	else{
		--i;
		
			if(i==0)
				document.getElementById(id).src = "templates/default/images/formJavascriptOther.jpg"
	}


	if(i>0)
	{
		
		   document.getElementById(id).src = "templates/default/images/formJavascriptOther1.jpg" 
	   
	}

}



function search_swapImage(id,elm,name1) 
{
	
swp=document.getElementById(id).src
	if(id!=id3)
	{
		i=0	
	}
id3=id

re=/formJavascriptplease1.jpg/

	if(re.test(swp) && i==0)
	{
		
	j=0
	k=0
	
		while(j<name1.length)
		{
	
			if(name1[j].checked)
			{
			++k		
			}
			++j
		}
		if(k==0)
		{
			document.getElementById(id).src = "templates/default/images/formJavascriptplease.jpg"
		}						
	
	}
	else if(elm.checked == true)
	{
		i++;
	}
	else{
		--i;
			if(i==0)
				document.getElementById(id).src = "templates/default/images/formJavascriptplease.jpg"
	}
	

	if(i>0)
	{
		   document.getElementById(id).src = "templates/default/images/formJavascriptplease1.jpg" 
	   
	}
	
}



function swapImage2(id,elm,name1) {

swp=document.getElementById(id).src

re=/formJavascript1.jpg/

if(re.test(swp) && i==0)
{
	
j=0
k=0

	while(j<name1.length)
	{

		if(name1.checked)
		{
			k++		
		}
	}
	if(k==0)
	{
		document.getElementById(id).src = "templates/default/images/formJavascript.jpg"
	}						

}
else if(elm.checked == true)
{
	i++;
}
else{
	--i;
		if(i==0)
			document.getElementById(id).src = "templates/default/images/formJavascript.jpg"
}

if(intImage==2 || i>0)
{
	   document.getElementById(id).src = "templates/default/images/formJavascript1.jpg" 
   intImage = 1
}

}


/*function swapImage(id,elm) 
{



	swp=document.getElementById(id).src
	re=/formJavascript1.jpg/
	if(re.test(swp) && i==0)
	{
		document.getElementById(id).src = "templates/default/images/formJavascript.jpg"
		
	}
	else if(elm.checked == true)
	{
	i++;
	}
	else{
	--i;
		if(i==0)
			document.getElementById(id).src = "templates/default/images/formJavascript.jpg"
	}
	if(intImage==2 || i>0)
	{
	   document.getElementById(id).src = "templates/default/images/formJavascript1.jpg"
	   intImage = 1
	}

}
*/


/*function swapImageupdate(id,elm) {
	if(elm.checked == true)
	{
	i++;
	}
	else{
	--i;
	
		if(i<0)
			document.getElementById(id).src = "formJavascript.jpg"
	}
	if(i>=0)
	{
	   document.getElementById(id).src = "formJavascript1.jpg" 
	}
}*/
var map = null;
var geocoder = null;
function initializeGmap(loc,details) {
	try {
		if (GBrowserIsCompatible()) {
		   map = new GMap2(document.getElementById("map_canvas"));
		   map.setCenter(new GLatLng(37.4419, -122.1419), 13);
		   geocoder = new GClientGeocoder();
		}
	}
	catch(e){}
	
	try {
	 if (geocoder) {
      geocoder.getLatLng(loc,function(point) {
            if (!point || loc=='0, CA') {
             
			  document.getElementById("map_canvas").innerHTML='<img src="templates/default/images/noMap.jpg" alt="map" width="250" height="250" />';
			 
            } else {
              map.setCenter(point, 13);
			  map.addControl(new GSmallMapControl());
			  //map.addControl(new GMapTypeControl());
              //var marker = new GMarker(point);
			  //alert(loc + " not found");
			   var marker = new GMarker(point, {draggable: true});

        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(details);
        });
			  
              map.addOverlay(marker);
              //marker.openInfoWindowHtml(address);
            }
          }
        );
      }
	}
	catch(e){}
}
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 showAddress(address) {
   if (geocoder) {
      geocoder.getLatLng(
      address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              //marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
function downme(id) {
	//alert(id);
	Effect.SlideDown(id, {duration:1.0}); return false;
	//document.getElementById(id).style.display = "none";
	//alert(id);
	//return false;	
}

function results_per_page(val) {
		
		if(document.getElementById('current_url').value.indexOf('?') > 0 )
			loc = document.getElementById('current_url').value + '&show=' + val.value;
		else
			loc = document.getElementById('current_url').value + '?show=' + val.value;

		document.location.href = loc;
}
function search_event(val) {
	
		var hash = getUrlVars();
		alert(hash['show']);
		if(document.getElementById('current_url').value.indexOf('?') > 0 )
			loc = document.getElementById('current_url').value + '&q=' + document.getElementById('key').value;
		else
			loc = document.getElementById('current_url').value + '?q=' + document.getElementById('key').value;

		document.location.href = loc;

}
function confirmation(id,title) {
	var answer = confirm("Delete entry "+title+" ?")
	if (answer){
		alert("Entry Deleted")
		window.location = "admin_cms_news.php?del="+id;
	}
	else{
		alert("No action taken")
	}
//Added by Brendan on Nov 19 to delete featured volunteers.	
}
function confm(url,id) {
	var answer = confirm("Delete entry ? ")
	if (answer){
		alert("Entry Deleted")
		window.location=url+"&Del="+id;
		//document.form1.submit();
		return true;
	}
	else{
		
		alert("No action taken")
		return false;
	}
//Added by Brendan on Nov 19 to delete featured volunteers.	
}
function confirmationNews(id,title) {
	var answer = confirm("Delete entry "+title+" ?")
	if (answer){
		alert("Entry Deleted")
		window.location = "admin_featuredVolunteers.php?del="+id;
	}
	else{
		alert("No action taken")
	}
}
function getUrlVars()
{    

	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');     
	alert(hashes);
	for(var i = 0; i < hashes.length; i++)   
	{ 
		hash = hashes[i].split('=');
		vars.push(hash[0]); 
		vars[hash[0]] = hash[1];   
	} return vars;
}
function delVol(id,name) {
	var answer = confirm("Delete entry " + name + " ?");
	if (answer){
		alert("Entry Deleted")
		window.location = "admin_manage_volunteers.php?del="+id;
	}
	else{
		alert("No action taken")
	}
}

function confirmation_region(id,title,ProvID) {
	var answer = confirm("Delete "+title+" ?")
	if (answer){
		alert("Region Deleted")
		window.location = "admin_region.php?del="+id+"&ProvID="+ProvID;
	}
	else{
		alert("No action taken")
	}
}

function confirmation_export(confrm,url)
{
	//alert(title)
	
		var answer = confirm(confrm)
	if (answer){
				window.location =url;		
	}
	
}
function confirmation_common(confrm,after,decl,id,title)
{
	//alert(title)
	
		var answer = confirm(confrm+" "+title+" ?")
	if (answer){
		//alert(title+" "+after)
		l=window.location.href;
		if(l.indexOf('?') > 0)
			window.location = window.location.href+"&"+decl+"="+id;
		else
			window.location = window.location.href+"?"+decl+"="+id;
		
	}
	else{
		//alert("No action taken")
		}
}
function sortNewsVar(val,form){
	if (document.getElementById(val).value=='ASC')
		document.getElementById(val).value='DESC';
	else
		document.getElementById(val).value='ASC';
	
	
	document.getElementById(form).submit();
}
function sortVar(val,form){
		
	if (document.getElementById(val).value=='ASC')
		document.getElementById(val).value='DESC';
	else
		document.getElementById(val).value='ASC';
	
	
	document.getElementById(form).submit();
}
//func for sorting
function sortevelist(tit,val1,form1){
		
	if (document.getElementById(val1).value=='ASC')
		document.getElementById(val1).value='DESC';
	else
		document.getElementById(val1).value='ASC';
	
	
	document.getElementById('sorteve').value=tit;

	document.getElementById(form1).submit();
}

function confirm_details(id,id1,stat)
{
	//alert(stat)
	
		var answer = confirm("confirm position deletion ?")
	if (answer){
		alert("Position deleted")
		
		window.location = window.location.href+"&PosID="+id+"&stat="+stat+"&EventID="+id1;
		//alert(window.location)
	}
	else{
		alert("No action taken")
		}
}

// SWAP IMAGE ON ROLOVER
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_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_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 hide() {
var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
   browserType= "gecko"
}
	
	
  if (browserType == "gecko" )
     document.poppedLayer = 
         eval('document.getElementById("aBox")');
  else if (browserType == "ie")
     document.poppedLayer = 
        eval('document.getElementById("aBox")');
  else
     document.poppedLayer =   
        eval('document.getElementById("aBox")');
  document.poppedLayer.style.visibility = "inline";
}


function HideContent(d) {
	
	document.getElementById(d).style.display = "none";
	document.getElementById('alert').value=1;
	document.form1.submit();
}
function ShowContent(d) {
	
document.getElementById(d).style.display = "block";
}
function reapproval(re,rid)
{
	var1=document.getElementById(rid).value;
	if(re==var1)
	{
		document.getElementById('reapp').value='';
	}
	else
	{
		document.getElementById('reapp').value=1;
	}
}

function opennewsletter(){
	emailwindow=dhtmlmodal.open('EmailBox', 'iframe', 'test.php', 'Newsletter Signup page', 'width=350px,height=200px,center=1,resize=0,scrolling=1')


} //End "opennewsletter" function
function clearSearch(url){
	
	sp=document.location.href.split("?");alert(sp[0]);
window.location= sp[0];	
}
function doGeocode(address, details) {

	// function provided by geoquo.js
	
	xmlhttp=null
  // code for Mozilla, etc.
var request = GeoQuo.createXMLHttpRequest();
	var url = GeoQuo.getURL(address);
 if (request.overrideMimeType) {
                request.overrideMimeType('text/xml');
                // See note below about this line
            }
	

	request.open("GET", url, true);

	request.onreadystatechange = function() {

		if (request.readyState == 4) {
			if (request.status == 200) {

				// GeoQuo helper class. Provided by geoquo.js
				var result = new GeoQuo(request.responseXML);

				if (result.success()) {
					var lat = result.getLat();
					var lon = result.getLon();

					// your additional logic to handle the returned coordinate.
					initializeGmap(lat + ' ' + lon, details);

				} else {

					// do something to handle failure
					if (result.getErrorCode() == 101)
					alert();
				}
			}
		}
	}
	
	request.send(null);
	
}
function showreason(dd,rediv)
{
	if(dd==5)
	{
		document.getElementById(rediv).style.display = "block";		
	}
	else 
	{
		document.getElementById(rediv).style.display = "none";
	}
	if(rediv!='')
	{
		//document.getElementById(dd).style.display = "none";	
		document.getElementById(rediv).style.display = "block";
	}
	if(dd==1)
	{
		document.getElementById(rediv).style.display = "none";
	}
	//document.getElementById(d).style.display = "none";

}
function counterUpdate(opt_countedTextBox,opt_maxSize) {
        var countedTextBox = opt_countedTextBox ;
        
        var maxSize = opt_maxSize;

        var field = document.getElementById(countedTextBox);

        if (field && field.value.length >= maxSize) {
                field.value = field.value.substring(0, maxSize);
        }
       
}
function org_dash(locate,id){
window.location=locate+".php?decline="+id;	
}

function CheckAll(chk){
	for (var i=0;i < document.findvolunteers.elements.length;i++){
		var e = document.findvolunteers.elements[i];
		if (e.type == "checkbox"){
			if(e.getAttribute("class")=="check_input"){
				e.checked = chk.checked;
			}
		}
	}
}