Cufon.replace('.f-replace', { 
    fontFamily: 'helvetica_neue',
    hover: true
});

Cufon.replace('.f-replace-bold', {
    fontFamily: 'helvetica_neue_bold',
    hover: true
});

Cufon.replace('.f-replace-black, #framework h2, #framework h1, #state-provisions h2', { 
    fontFamily: 'helvetica_neue_black',
    hover: true
});

jQuery.noConflict();

function form_input_classes(){
    jQuery('input[type="text"]').addClass('text');
    jQuery('input[type="password"]').addClass('text');
    jQuery('input[type="checkbox"]').addClass('checkbox');
    jQuery('input[type="radio"]').addClass('radiobutton');
    jQuery('input[type="submit"]').addClass('submit');
    jQuery('input[type="image"]').addClass('buttonImage');
    jQuery('.socialnet input[type="button"]').addClass('input-button');
}

function form_labelize(){  jQuery(".labelize input:text").clearingInput(); }   

function modifySpeakout(){
    jQuery('#framework #speakout table.buttons input.button.submit').attr('value','Next');
}

function makeNav(){
	jQuery('ul.sf-menu').superfish();
}

function featureRotate(){
    jQuery('#home-rotating-content').before('<div id="pager"><a id="rotate-prev" href="#">&laquo;</a><a id="rotate-next" href="#">&raquo;</a></div>').cycle({
        fx: 'fade', 
        prev: '#rotate-prev',
        next: '#rotate-next', 
        timeout: 4500
    });
}

function codeFormat(){
	jQuery('.interior code').before('<div class="code-embed" style="border: 1px solid #000; padding:0 10px 10px;"><p>Use the following code to embed this image:</p>');
	jQuery('.interior code').after('</div><!--/#code-embed-->');
}


function surveySwitcher(){

	jQuery("#test-list").sortable({
	
		handle : '.handle',
		placeholder: 'ui-placeholder',
		forcePlaceholderSize: true,
		update : function () {
	
			var result = jQuery('#test-list').sortable('toArray');
			
			jQuery('#rankfirst').val(result[0]);
			jQuery('#ranksecond').val(result[1]);
			jQuery('#rankthird').val(result[2]);
			jQuery('#rankfourth').val(result[3]);
	
		}
		
	});

}

function legislativeSidebar(){

    //get URL
    var url = location.href;
    
    //loop through all legislative page links
    jQuery('.la-side-policy-list a').each(function(){
    
        //create shortcut
        elem = jQuery(this);
    
        //get href value
        var href = elem.attr('href');
        
        //detect if this is the current page
        if(href == url){
        
            //apply active class
            elem.addClass('active');
            
            elem.parent().parent().addClass('expanded');
        
        }
    
    });
    
    //initialy exp/contr
    jQuery('ul.la-side-policy-list:not(.expanded)').each(function(){
    
        jQuery(this).slideUp();
    
    });
    
    //add slide down function to sidebar elements
    jQuery('.la-side-slide-btn').click(function(){

        var $this = jQuery(this);
        
        $this.parent().prev().slideDown('500');
        $this.parent().fadeOut();
        
        return false;
    
    });

}

function blogCommentOpens() {
    jQuery('#comments-toggle-button').one('click',function(){
        _gaq.push(['_trackEvent', 'Blog Posts', 'Comments Opened'])
    });
}


//easy on or off switch
jQuery(document).ready(function() {
    form_input_classes();
    form_labelize();
//    makeNav();
    featureRotate();
    codeFormat();
    surveySwitcher();
    if(jQuery('#sidebar-la')){legislativeSidebar();}
    if(jQuery('#framework #speakout')){modifySpeakout();}
    blogCommentOpens();
    jQuery('#framework #speakout #recipient_table').prev().hide();
});
