// Auto-Fill Plugin
(function($){$.fn.autofill=function(options){var defaults={value:'First Name',defaultTextColor:"#b2adad",activeTextColor:"#333"};var options=$.extend(defaults,options);return this.each(function(){var obj=$(this);obj.css({color:options.defaultTextColor}).val(options.value).focus(function(){if(obj.val()==options.value){obj.val("").css({color:options.activeTextColor});}}).blur(function(){if(obj.val()==""){obj.css({color:options.defaultTextColor}).val(options.value);}});});};})(jQuery);

jQuery(document).ready(function(){
    
	// Dropdown Main Navigation
	jQuery('ul#main-nav').superfish({
		    animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation 
            speed:       'fast',                          // faster animation speed 
            autoArrows:  false,                           // disable generation of arrow mark-up 
            dropShadows: false 	   						  // disable drop shadows					   
	}); 
	// Auto-Fill Newsflash Signup
	jQuery('#jkhrij-jkhrij').autofill({
			value: 'Email Address',
			defaultTextColor: '#999',
			activeTextColor: '#000'
	});
	
	// Auto-Fill Search
	jQuery('#keywords').autofill({
			value: 'Search for Keyword(s)...',
			defaultTextColor: '#999',
			activeTextColor: '#000'
	});
	jQuery(".newsticker-jcarousellite").jCarouselLite({  
        vertical: true,  
        visible: 1,  
        auto:1800,  
        speed:1000  
	});
	jQuery('a.print').click(function() {
		window.print();
		return false;
	});
	
	jQuery("ul#news-ticker").liScroll(); 
							   
}); 

function initJumpMenus() {
    // Turns all <select> elements with the 'jumpmenu' class into jump menus
    var selectElements = document.getElementsByTagName("select");
    for( i = 0; i < selectElements.length; i++ ) {
        // Check for the class and make sure the element has an ID
        if( selectElements[i].className == "jumpmenu" && document.getElementById(selectElements[i].id) != "" ) {
            jumpmenu = document.getElementById(selectElements[i].id);
            jumpmenu.onchange = function() {
                if( this.options[this.selectedIndex].value != '' ) {
                    // Redirect
                    window.open (this.options[this.selectedIndex].value,"new-window");
                    //Open in same window - location.href=this.options[this.selectedIndex].value;
                }
            }
        }
    }
}

function initJumpMenusSame() {
    // Turns all <select> elements with the 'jumpmenu' class into jump menus
    var selectElementsSame = document.getElementsByTagName("select");
    for( i = 0; i < selectElementsSame.length; i++ ) {
        // Check for the class and make sure the element has an ID
        if( selectElementsSame[i].className == "jumpmenusame" && document.getElementById(selectElementsSame[i].id) != "" ) {
            jumpmenusame = document.getElementById(selectElementsSame[i].id);
            jumpmenusame.onchange = function() {
                if( this.options[this.selectedIndex].value != '' ) {
                    // Redirect
                    location.href=this.options[this.selectedIndex].value;
                }
            }
        }
    }
}

window.onload = function() {
    initJumpMenus();
    initJumpMenusSame();
}
