jQuery(function( $ ){


 if( $.cookie('mobile') == "off" ){ 
   $('#Footer .MobileLink').addClass('Txt').html('<a href="/index.php/mobile" class="ViewMobileSite">View Mobile Site</a>');
};



$('#Quotecycle').cycle();

$('#MainSlide').cycle({ speed: 500, timeout: 5000, pager: '#Pager' });


$(".ViewFullSite").click( function(){ $.cookie('mobile','off',{ path: '/' }); });
$(".ViewMobileSite").click( function(){ $.cookie('mobile','on',{ path: '/' }); });


$(".ButtonSearch").click( function(){ $('.SearchBox').find('form').submit(); });

$('#Caption').html($('#Slideshow img:first').attr('alt'));

$('#MainNavigation LI').hover( function() { $(this).find('DD').show();}, function() { $(this).find('DD').hide();} );
$('#NavDropDown LI').hover( function() { $(this).find('DD').show(); }, function() { $(this).find('DD').hide();} );

$('#Button1').click( function() {  $('#Page1').hide();  $('#Page2').show(); });
$('#Button2').click( function() {  $('#Page2').hide();  $('#Page3').show(); });
$('#BackButton1').click( function() {  $('#Page2').hide();  $('#Page1').show(); });
$('#BackButton2').click( function() {  $('#Page3').hide();  $('#Page2').show(); });

$('#s1').cycle({  fx: 'fade',    speed:   1000,    timeout: 5900 });
$('#s2').cycle({  fx: 'fade',    speed:   1000,    timeout: 5000 });

$('#Slideshow').cycle({  
fx: 'fade',    
speed:   900,   
timeout: 6000, 
after: onAfter,
before: onBefore
});

$('.SlidesWrapper').stop().hover(
function(){ if($('#Caption').html()){ $('#Caption').slideDown('fast').fadeTo("fast", 0.65); } else {  $('#Caption').slideUp('fast');  };},
function(){  $('#Caption').slideUp('fast');   }

);


$('#Press.Index  #Column1 A').html('View Article');
$('#Press.Index  #Column1 A').click(function(){ window.open(this.href); return false;});


$('#OpenComments').click( function() { $(".CommentForm").toggle(); } );


$('#LargeSlideshow').cycle({ 
    fx:     'fade', 
    speed:  1100, 
    timeout: 4000,
	after: onAfter,
	before: onBefore, 
    pager:  '#nav',      
    pagerAnchorBuilder: function(idx, slide) {return '<li><a href="#"> <img src="' + slide.src + '" width="25" height="25" /> </a></li>';} 
});

$('.Slides').cycle({ 
fx: 'fade', 
speed:  1100, 
timeout: 4000
}); 


$(".parentCheckBox").click(

function() {

$(this).parents('fieldset:eq(0)').find('.childCheckBox').attr('checked', this.checked);

}

);

//clicking the last unchecked or checked checkbox should check or uncheck the parent checkbox

$('.childCheckBox').click(

function() {

if ($(this).parents('fieldset:eq(0)').find('.parentCheckBox').attr('checked') == true && this.checked == false)

$(this).parents('fieldset:eq(0)').find('.parentCheckBox').attr('checked', false);

if (this.checked == true) {

var flag = true;

$(this).parents('fieldset:eq(0)').find('.childCheckBox').each(

function() {

if (this.checked == false)

flag = false;

});

	$(this).parents('fieldset:eq(0)').find('.parentCheckBox').attr('checked', flag);
}

});

 });
 
function onAfter() {
 // $('#Caption').slideDown('fast').fadeTo("fast", 0.65);
    $('#Caption').html(this.alt);
}

function onBefore() {
//  $('#Caption').slideUp('fast');  
}





