/* ----------------------------------------------------------
	title		  : CYA Framework
	created		  : 3/16/09
	last updated  : 3/25/09
---------------------------------------------------------- */
jQuery.noConflict();     
jQuery(document).ready(function($){

/* Flash */
$('#feature-content').flash({
swf: '/Websites/cya/templates/cyaTheme/flash/feature.swf',
width: 960,
height: 343,
params: {
	wmode: 'transparent'
	}
});




/* Testimonials */
if ( $('#testimonial').length ) {
	$.ajax({
		type: "GET",
		url: "/Websites/cya/templates/cyaTheme/testimonials.xml",
		dataType: "xml",
		success: function(xml) {
		
			var quotes = $(xml).find('quote');
			var numOfQuotes = $(quotes).length;
			var randNum = Math.floor(Math.random()*(numOfQuotes));
			var selectedQuote = $(quotes).eq(randNum);

			
			$(selectedQuote).each(function(){
				var theQuote = $(this).attr('contentHTML');			
				var thePerson = $(this).attr('who');
				
				theQuote = '<p>&quot;' + theQuote + '&quot;</p>';				
				thePerson = '<p class="from">' + thePerson + '</p>';
				
				$('#testimonial').empty();
				$(theQuote).appendTo('#testimonial');
				$(thePerson).appendTo('#testimonial');
			}); 
		
	
		
		}
	}); 
}



/* Quote Forms */
if ( $('#adminbar #toolbar').length ) {

$('#quote-form').prepend('<h1 style="background:#ffc; color:#555;">Only place quote forms in this section. Also make sure they have a title on the element as well as the form itself.</h1>').css({'padding':'10px','background':'#333'});

} else {


function loadQuoteForm () {
	var theFormID = $(this).val();
	
	if (!theFormID == '' ) {
	$('.element', '#quote-form').hide();	
	$('#'+theFormID, '#quote-form').show();
	}
}



//hide unless there is a lightbox
$('.container, .element', '#quote-form').filter(function(){
	
	if ( $('#FormBuilderLightBox', this).length ) {return false;} else {
		return true;
		}
	
	}).hide();



//create the select list
$('#quote-filter').html('<label for="quoteSelect">Please select the appropriate form: </label><select id="quoteSelect"><option value="">Select One...</option></select>');
$('.element', '#quote-form').each(function(){
	var quoteFormID = $(this).attr('id');
	var quoteFormTitle = $(this).prev('.container').text();
	$('#quoteSelect').append('<option value="#'+ quoteFormID +'">' + quoteFormTitle + '</option>');
	});


$("#quoteSelect").change(loadQuoteForm);

}


});//end doc ready
