
// JavaScript Document
jQuery(function( $ ){
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	// The default axis is 'y', but in this demo, I want to scroll both
	// You can modify any default like this
	$.localScroll.defaults.axis = 'y'; //xy
	
	// Scroll initially if there's a hash (#something) in the url 
	//$.localScroll.hash({
	//	target: '#content', // Could be a selector or a jQuery object too.
	//	queue:true,
	//	duration:1500
	//});
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 */
	$.localScroll({
		offset: -400		  
	});
});

/***********************************************
* 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 currPage=""
var scrollPos=0
var loadtimerid=0
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function fadePage(url,containerid){
if(currPage!=url){
	clearInterval(loadtimerid);
	loadtimerid=0;
	jQuery(document.getElementById(containerid)).fadeOut(250);
	setTimeout(function(){ajaxpage(url,containerid)},500);
	//ajaxpage(url,containerid)
}
}

function ajaxpage(url, containerid){
if(currPage!=url){
	document.getElementById(containerid).innerHTML="<div style=\"width: 580px; padding-top: 100px; text-align: center;\">Loading...<br\/><br\/><img border=\"0\" src=\"images/ajax-loader.gif\"/></div>"
	setHash=url.substring(0, url.indexOf('.php'))
	window.location.hash=setHash
	currPage=url
	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, containerid)
	}
	if (bustcachevar) //if bust caching of external page
	bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
	page_request.open('GET', url+bustcacheparameter, true)
	page_request.send(null)
	}
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
setTimeout(function(){jQuery(document.getElementById(containerid)).fadeIn('normal')},500)
setTimeout(function(){if(loadtimerid==0){loadtimerid = setInterval ("loadpagehash()", 1500)}},5000)
setTimeout('gotohash()',1000);

$("a[rel^='prettyPhoto']").prettyPhoto({
	animationSpeed: 'normal', /* fast/slow/normal */
	padding: 40, /* padding for each side of the picture */
	opacity: 0.35, /* Value betwee 0 and 1 */
	showTitle: false, /* true/false */
	allowresize: true, /* true/false */
	counter_separator_label: '|', /* The separator for the gallery counter 1 "of" 2 */
	theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square */
	callback: function(){}
});

if(document.getElementById("tvspot")!=null){
	var so = new SWFObject("blueribbonadcampaign.swf", "tvspot", "480", "400", "8", "");
	so.write("tvspot");
}
    loadgallery('2010');
/*if(document.getElementById("videogallery")!=null){
	var so = new SWFObject("2008_amigos_dominonight.swf", "videogallery", "550", "410", "8", "");
	so.write("videogallery");
	
	var so2 = new SWFObject("2008_amigos_dominonight.swf", "videogallery", "360", "264", "8", "");
	so2.Append("videogallery");
	
}*/
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

ddaccordion.init({
	headerclass: "expandable", //Shared CSS class name of headers group
	contentclass: "subexpand", //Shared CSS class name of contents group
	revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
	mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
	collapseprev: true, //Collapse previous content (so only one open at any time)? true/false 
	defaultexpanded: [0], //index of content(s) open by default [index1, index2, etc] [] denotes no content
	onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
	animatedefault: true, //Should contents open by default be animated into view?
	persiststate: true, //persist state of opened contents within browser session?
	//toggleclass: ["", ""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	toggleclass: ["",""], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	togglehtml: ["suffix", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
	animatespeed: "normal", //speed of animation: "fast", "normal", or "slow"
	oninit:function(headers, expandedindices){ //custom code to run when headers have initalized
		//do nothing
	},
	onopenclose:function(header, index, state, isclicked){ //custom code to run whenever a header is opened or closed
		//do nothing
	}
})

function changeStyle(div_id, div_src)
	{
	document.getElementById(div_id).style.backgroundImage = "url("+div_src+")";
	}


function roll(img_id, img_src)
   {
   document.getElementById(img_id).src = img_src;
   }

var image1 = new Image();
image1.src = "images/img_menu_awareness_over.gif";
var image2 = new Image();
image2.src = "images/img_menu_whoweare_over.gif";
var image3 = new Image();
image3.src = "images/img_menu_donate_over.gif";
var image4 = new Image();
image4.src = "images/img_menu_eventspress_over.gif";
var image5 = new Image();
image5.src = "images/img_menu_contactus_over.gif";
var image6 = new Image();
image6.src = "images/img_submenu_over.gif";
var image7 = new Image();
image7.src = "images/img_menu_whatwedo_over.gif";
var image8 = new Image();
image8.src = "images/img_menu_volunteer_over.gif";
<!--
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_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 inquiry(){
	tmpVals="contactName=" + document.getElementById('contactName').value;
	tmpVals+="&contactEmail=" + document.getElementById('contactEmail').value;
	tmpVals+="&contactPhone=" + document.getElementById('contactPhone').value;
	tmpVals+="&contactMessage=" + document.getElementById('contactMessage').value;

	jQuery.get('inquiry.php?'+tmpVals, function(data) {
		if(data=='Inquiry sent.'){
			document.getElementById('contactName').value="";
			document.getElementById('contactEmail').value="";
			document.getElementById('contactPhone').value="";
			document.getElementById('contactMessage').value="";
		}
		document.getElementById('inquiryOutput').innerHTML=data;
	})
}

function slideToggle(id){
	 $(id).slideToggle();
}


//-->

function loadgallery(y){
	document.getElementById('gallery_container').innerHTML='<div style=\"width: 580px; padding-top: 100px; text-align: center;\">Loading...<br\/><br\/><img border=\"0\" src=\"images/ajax-loader.gif\"/></div>';
$.get('gallery-'+y+'.php',function(data){
	document.getElementById('gallery_container').innerHTML=data;
	$("a[rel^='prettyPhoto']").prettyPhoto({
	animationSpeed: 'normal', /* fast/slow/normal */
	padding: 40, /* padding for each side of the picture */
	opacity: 0.35, /* Value betwee 0 and 1 */
	showTitle: false, /* true/false */
	allowresize: true, /* true/false */
	counter_separator_label: '|', /* The separator for the gallery counter 1 "of" 2 */
	theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square */
	callback: function(){}
});
	})
	return false;


}

