$(document).ready( function() {
                       //tag box code
                       $('.tagbox').hide();
                       $('.viewtags').click(function(){
                               if($(this).html().indexOf("View") >= 0){
                                       $(this).next('.tagbox').stop(true, true).slideToggle(250);
                                       $(this).html("Hide Tags &laquo;");
                               }else if ($(this).html().indexOf("Hide") >= 0){
                                       $(this).next('.tagbox').stop(true, true).slideToggle(250);
                                       $(this).html("View Tags &raquo;");
                               }

                       });


                       $("menu li").hover(function(){  //Main menu - Drop-Down List functionality

                               if(($(this).parent().attr('nodeName') != "MENU") && (jQuery.support.opacity)) { //disable for IE - IE shouldn't exist. At all.
                                       //$(this).parent().parent().css('background-color', 'black');
//follow-through bg color

                                       $imgURL = $('.hidden-img-url').css('background-image'); // get absolute img loc
                                       // set with-child icon to highlighted
                                       $(this).parent().parent().find('a:first').find('.with-child').css('backgroundImage',$imgURL );

                               }
                               //if not the top level of the menu (pre-drop down) and not IE
                               if(($(this).parent().attr('nodeName') != "MENU") && (jQuery.support.opacity)) {
                                       //HL text
                                       $(this).parent().parent().find('span:first').css('color', '#222');
                               }

                               if($(this).parent().attr('nodeName') == "MENU") { //(top lvl menu)
                                       //find first drop down ul, make visible, set left position
                                       $(this).find('ul:first').css({visibility: "visible",display:
"none"}).stop(true, true).show(333).css({left:
$(this).last('li').attr('offsetLeft') + 'px'});
                                       //IF IE6 or 7 or IE8 in IE7 mode
                                       if((!jQuery.support.boxModel) || (document.documentMode &&
document.documentMode == 7)) {
                                               //account for weird offset in some IE versions
                                               $(this).find('ul:first').css({visibility: "visible",display:
"none"}).stop(true, true).show(333).css({left:
$(this).last('li').attr('offsetLeft') + 0 + 'px'});
                                       }

                               }else {

                                       //for all other lvls of menu
                                       $(this).find('ul:first').css({visibility: "visible",display:
"none"}).stop(true, true).show(333).css({left:
$(this).last('ul').attr('clientWidth') + 'px'});

                               }

                                       //// grab the width of the widest link in the next ul of the menu
                                       var childCount = 0;
                                       var wideChild = 0;

                                       while (childCount < $(this).find('ul:first').children().length){
                                               $childrenArray = ($(this).find('ul:first').attr('children'));
                                               $childWidth =
$($childrenArray[childCount]).find('a:first').attr('clientWidth');

                                               if($childWidth > wideChild){
                                                       wideChild = $childWidth;
                                               }

                                               childCount++;
                                       }

                                       //// adjust all links to be as wide as the widest

                                       childCount = 0;
                                       while (childCount < $(this).find('ul:first').children().length){

                                               $childrenArray = ($(this).find('ul:first').attr('children'));
                                               $($childrenArray[childCount]).find('a:first').css('width', wideChild + 'px');

                                               childCount++;
                                       }


                               },function(){
                               ///// on roll-out - set everything back to normal

                                       $(this).find('ul:first').hide(333);
                                       $(this).parent().parent().css('background-color', '');
                                       $(this).parent().parent().find('span:first').css('color', '#222');
                                       $(this).parent().parent().find('a:first').find('.with-child').css('backgroundImage', '' );
                               }
                       ); //END drop-down menu



                       $('menu li a').attr('title', ''); //Remove Titles - causes problems in some browsers, mouse-over pop-up title closes menu

                       $('menu li').animate({right: 0}, 1, function () { //SET menu ul props on load
                                       var childCount = 0;

                                       while (childCount < $(this).find('ul:first').children().length){
                                               $childrenArray = ($(this).find('ul:first').attr('children'));

                                               if( $($childrenArray[childCount]).children().length > 1 ){
//disabled/skipped in IE
                                                       $spanhtml = '<span class="spanpad">' +
$($childrenArray[childCount]).find('a:first').html() + '<span class="with-child"></span></span>';
                                                       $($childrenArray[childCount]).find('a:first').find('span:first').html($spanhtml);
                                               }else {
                                                       $spanhtml = '<span class="spanpad">' +
$($childrenArray[childCount]).find('a:first').html() + '</span>';
                                                       $($childrenArray[childCount]).find('a:first').find('span:first').html($spanhtml);
                                               }

                                               childCount++;
                                       }
                               }
                       );







               $("a").click(function(ev){
                               $("menu li").find('ul').fadeOut(500);
                       });
					   
					   
$('menu li').animate({right: 0}, 1, function () { //SET menu ul props on load
var childCount = 0;

while (childCount < $(this).find('ul:first').children().length){
$childrenArray = ($(this).find('ul:first').attr('children'));

if( $($childrenArray[childCount]).children().length > 1 ){ //disabled/skipped in IE
$spanhtml = '<span class="spanpad">' + $($childrenArray[childCount]).find('a:first').html() + '<span class="with-child"></span></span>';
$($childrenArray[childCount]).find('a:first').html($spanhtml);
}else {
$spanhtml = '<span class="spanpad">' + $($childrenArray[childCount]).find('a:first').html() + '</span>';
$($childrenArray[childCount]).find('a:first').html($spanhtml);
}

childCount++;
}
}
);

}); //End $(document).ready

function workTheMagic() {
         $('#header_cat ul:first').replaceWith('<menu>' +  $('#header_cat ul:first').html() + '</menu>');
}
