// jQuery Goodies

// Headline Rotator Variables
var headline_count = 0;
var headline_interval = 0;
var old_headline = 0;
var current_headline = 0;

// Document Ready
$(document).ready(function(){
	
	// Headline Rotator
	headline_count = $('div.headline').size();
	$('div.headline:eq('+current_headline+')').css('top','5px');

	headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
	$('#scrollup').hover(function() {
		clearInterval(headline_interval);
	}, function() {
		headline_interval = setInterval(headline_rotate,5000); //time in milliseconds
		headline_rotate();
	});

	// TOGGLES
	// educational-umrah.php
	$('#scholars').click(function(){
		$('#scholarsDiv').slideToggle('slow');
	});	
	// educational-umrah.php
	$('#umrahLocations').click(function(){
		$('#umrahLocationsDiv').slideToggle('slow');
	});	
	// requirementsNew.php
	$('.dropListBarTop').click(function(){
		toggleMe = $(this).attr('toggleThis');
		$('.'+toggleMe).slideToggle('slow');
	});
	
	// Hide/Show Stuff
	// This causes drop down divs to be hidden when client javascript is enabled.
	// if client javascript is disabled - the divs stay open so paragraphs are readable.
	$('.reqParConHide, #scholarsDiv, #umrahLocationsDiv').css({display: 'none'});
	
	// Other
	$('#scholars p, #umrahLocations p').append(' (Click here to see list)');
	
	// IMAGE ROTATOR (SEE BELOW)
	setInterval('rotateImages()', 5000);
});

// IMAGE ROTATOR
function rotateImages(){
	var curPhoto = $('#slideShow div.current');
	var nxtPhoto = curPhoto.next();
	if(nxtPhoto.length == 0)
		nxtPhoto = $('#slideShow div:first');
	curPhoto.removeClass('current').addClass('previous');
	if(navigator.appName == "Microsoft Internet Explorer")
		nxtPhoto.css({'-ms-filter': 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)'}).addClass('current').animate({'-ms-filter': 'progid:DXImageTransform.Microsoft.Alpha(Opacity=100)'}, 1000, function()
		{
			curPhoto.removeClass('previous');
		});
	else
		nxtPhoto.css({opacity: 0.0}).addClass('current').animate({opacity: 1.0}, 1000, function()
		{
			curPhoto.removeClass('previous');
		});
	//alert($('#slideShow div.current img').attr('src'));
}

// HEADLINE ROTATOR
function headline_rotate() {
	current_headline = (old_headline + 1) % headline_count; 
	$('div.headline:eq(' + old_headline + ')').animate({top: -205},'slow', function() {
		$(this).css('top','210px');
	});
	$('div.headline:eq(' + current_headline + ')').show().animate({top: 5},'slow');  
	old_headline = current_headline;
}

// SEARCH BAR ANIMATION


$(document).ready(function(){

// Google Search
	var inputVal = "Search..";
	var animateDistance = 100;
	$('#google-search-input').val(inputVal);
	$('#google-search-input').focus(function(){
		$(this).val('');
		$(this).animate({
			width: '+='+animateDistance
			}, 500, function() {
		});
		$('#nav-pane ul').animate({
			width: '-='+animateDistance
			}, 500, function() {
		});
	});
	$('#google-search-input').blur(function(){
		$(this).val(inputVal);
		$(this).animate({
			width: '-='+animateDistance
			}, 500, function() {
		});
		$('#nav-pane ul').animate({
			width: '+='+animateDistance
			}, 500, function() {
		});
	});
});

// ACCORDION
$(document).ready(function() {  
	$('#accordion').accordion();  
});  

