jQuery(document).ready(function(){
    // Menu Functions
    jQuery("#dropmenu ul").css({
        display: "none"
    }); // Opera Fix 	
    jQuery("#dropmenu li").hover(function(){
        jQuery(this).find('ul').css({
            visibility: "visible",
            display: "none"
        }).show(250);
        
        jQuery(this).find('a:first').addClass('dropmenuhover');
    }, function(){
        jQuery(this).find('ul').css({
            visibility: "hidden"
        });
        
        jQuery(this).find('a:first').removeClass('dropmenuhover');
    });
    jQuery("#dropmenu li").has('ul').find('a:first').addClass('dropmenuarrow');
    jQuery("#dropmenu li a:last").addClass('last');
    jQuery("#dropmenu li ul").find('a:last').addClass('sub-last');
    //End Menu Functions
    
    //Search box clear
    jQuery.fn.search = function(){
        return this.focus(function(){
            if (this.value == this.defaultValue) {
                this.value = "";
            }
        }).blur(function(){
            if (!this.value.length) {
                this.value = this.defaultValue;
            }
        });
    };
    jQuery("#s").search();
    
    //Homepage slider
    function formatText(index, panel){
        switch(index)
		{
			case 1:
				return '<img src="wp-content/themes/ClairviaV2/images/clairviafor.png" border="0">';
				break;
			case 2:
				return "Administration";
				break;
			case 3:
				return "Finance";
				break;
			case 4:
				return "Nursing";
				break;
			case 5:
				return "Physicians";
				break;
			case 6:
				return "Quality Care";
				break;
			case 7:
				return "IT";
				break;
		}
		
		return "";
    }
    
    jQuery('.anythingSlider').anythingSlider({
        easing: "easeInOutExpo",
        autoPlay: false,
        animationTime: 600,
        hashTags: false,
        buildNavigation: true,
        navigationFormatter: formatText
    });
    
	//Product Literature - Insert Image
	jQuery("h2.widgettitle").each(function(){
		if(this.innerHTML == "Product Literature")
		{
			this.innerHTML = '<img src="http://www.clairvia.com/wp-content/themes/ClairviaV2/images/product_literature.png" border="0" align="top" style="padding-right:10px;">Product Literature';
		}
		if(this.innerHTML == "Contact a Clairvia Rep")
		{
			this.innerHTML = '<img src="http://www.clairvia.com/wp-content/themes/ClairviaV2/images/contact.png" border="0" style="float:left;padding-right:10px;">Contact a<br />Clairvia Rep';
		}
		if(this.innerHTML == "White Papers and Articles")
		{
			this.innerHTML = 'White Papers<br />and Articles';
		}
	});
	
	jQuery(".widget_polls-widget h2").prepend("<img src=\"wp-content/themes/ClairviaV2/images/polls.png\" align=\"top\" />");
	jQuery(".cform input.sendbutton").val('');
	
	if(window.fixPNG){fixPNG();}
	
	//Executives more/close
	if(jQuery.browser.msie && jQuery.browser.version=="6.0")
	{
		jQuery(".more").hide();
	}
	else
	{
		jQuery(".more_reveal").hide();
		jQuery(".more").click(function(){
			jQuery(this).next(".more_reveal").toggle();
			if(jQuery(this).text() == "More")jQuery(this).text("Close");
			else jQuery(this).text("More");
			return false;
		});		
	}
	
	
	jQuery('#dropmenu li').each(function(index)
	{
		var width = jQuery(this).width();
		if(width > 0)
		{		
			//Subtract padding
			width -= 24;
		    jQuery('ul li a', this).css("width",  width + 'px');
		}
	});

});