// JavaScript Document

function formatText(index, panel) {
		return index + "";
	}
	
function validate(form)
	{
		var valid = true;
		if(form.realname.value == '')
		{
			valid = false;
			alert("You must supply your name.");
		}
		if(form.email.value == '')
		{
			valid = false;
			alert("You must supply your email.");
		}
		if(valid)
		{
			form.submit();
		}
	}
	
function validate_required(field,alerttxt)
{
	with (field)
	{
		if (value==null||value=="")
		  {alert(alerttxt);return false;}
		else {return true}
	}
}

function validate_form(thisform)
{
	with (thisform)
	{
		if (validate_required(contact_phone1,"At least one phone number is required!")==false)
		  {contact_phone1.focus();return false;}
	}
}

$(document).ready(function() {

	// Check for hash value in URL  
	//var hash = window.location.hash.substr(1);  
	//var href = $('.outputtomain a').each(function(){  
	//	var href = $(this).attr('href');  
	//	if(hash==href.substr(0,href.length-5)){  
	//		var toLoad = hash+'.html';  
	//		$('#content').load(toLoad)  
	//	}   
	//});
	
	// Animate menu links to view in main container
	$('.outputtomain a').click(function() {
	  var toLoad = $(this).attr('href')+' #content';
      $('#content').hide('slow',loadContent);  
      $('#load').remove();  
      // $('#mainviewer').append('<span id="load">LOADING...</span>');
      $('#load').fadeIn('normal');
	  //window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); 
      function loadContent() {  
          $('#content').load(toLoad,'',showNewContent())  
      }  
      function showNewContent() {  
	  	  $("#content").addClass("hilighted");
          $('#content').show('slow',hideLoader());  
      }  
      function hideLoader() {  
          $('#load').fadeOut('normal');  
      }  
      return false;
	});
	
	
  	// Animate links within a div in mainviewer to view in mainviewer
  	$('#area3 a').click(function() {
	  var toLoad_bru = $(this).attr('href');  
      $('#content').hide('slow',loadContent_bru);  
      $('#load').remove();  
      // $('#mainviewer').append('<span id="load">LOADING...</span>');
      $('#load').fadeIn('normal');
	  window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); 
      function loadContent_bru() {  
          $('#content').load(toLoad_bru,'',showNewContent_bru())  
      }  
      function showNewContent_bru() {  
	  	  $("#content").addClass("hilighted");
          $('#content').show('slow',hideLoader_bru());  
      }  
      function hideLoader_bru() {  
          $('#load').fadeOut('normal');  
      }  
      return false;
	});
	
	// Animate links within a div in mainviewer to view in mainviewer
  	$('#area5 a').click(function() {
	  var toLoad_php = $(this).attr('href')+' #content';  
      $('#content').hide('slow',loadContent_php);  
      $('#load').remove();  
      // $('#mainviewer').append('<span id="load">LOADING...</span>');
      $('#load').fadeIn('normal');
	  //window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); 
      function loadContent_php() {  
          $('#content').load(toLoad_php,'',showNewContent_php())  
      }  
      function showNewContent_php() {  
	  	  $("#content").addClass("hilighted");
          $('#content').show('slow',hideLoader_php());  
      }  
      function hideLoader_php() {  
          $('#load').fadeOut('normal');  
      }  
      return false;
	});
	
	// Animate links within a div in mainviewer to view in mainviewer
  	$('#donate a').click(function() {
	  var toLoad_new = $(this).attr('href')+' #content';  
      $('#content').hide('slow',loadContent_new);  
      $('#load').remove();  
      // $('#mainviewer').append('<span id="load">LOADING...</span>');
      $('#load').fadeIn('normal');
	  //window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-5); 
      function loadContent_new() {  
          $('#content').load(toLoad_new,'',showNewContent_new())  
      }  
      function showNewContent_new() {  
	  	  $("#content").addClass("hilighted");
          $('#content').show('slow',hideLoader_new());  
      }  
      function hideLoader_new() {  
          $('#load').fadeOut('normal');  
      }  
      return false;
	});
  
  	// Cycle slideshow
	$('.slideshow1').cycle({
		fx: 'scrollHorz', // blindX,blindY,blindZ,cover,curtainX,curtainY,fade,fadeZoom,growX,growY,none,scrollUp,scrollDown,scrollLeft,scrollRight,scrollHorz,scrollVert
    				// shuffle,slideX,slideY,toss,turnUp,turnDown,turnLeft,turnRight,uncover,wipe,zoom
		timeout: 4000
	});
  	$('.slideshow2').cycle({
		fx: 'scrollUp',
		timeout: 6000
	});
	$('.slideshow3').cycle({
		fx: 'scrollDown',
		timeout: 6000
	});
	$('.slideshow4').cycle({
		fx: 'scrollRight',
		timeout: 5000
	});
	$('.showimages').cycle({
		fx: 'fade',
		timeout: 6000
	});
	$('.2010images').cycle({
		fx: 'fade',
		timeout: 6000
	});
	
	$('.anythingSlider').anythingSlider({
                easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
                autoPlay: false,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
                delay: 5000,                    // How long between slide transitions in AutoPlay mode
                startStopped: false,            // If autoPlay is on, this can force it to start stopped
                animationTime: 1000,             // How long the slide transition takes
                hashTags: true,                 // Should links change the hashtag in the URL?
                buildNavigation: true,          // If true, builds and list of anchor links to link to each slide
        		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
        		startText: "Play",             // Start text
		        stopText: "Stop",               // Stop text
		        navigationFormatter: formatText       // Details at the top of the file on this use (advanced use)
	});
  	
});
