	// set up tablesorter grid
	$(document).ready(function() {
        $("#rwTable").tablesorter({
						 widgets: ['cookie']
						,widthFixed: true
						,debug: false
						//,sortList: [[0,0],[1,0],[2,0],[3,0]]
		});
		$("#rwTable").tablesorterPager({container: $("#pager"),positionFixed: false});
		$("#rwTable").tablesorterFilter({
						 filterContainer: $("#filter-box")
						,filterClearContainer: $("#filter-clear-button")
						,filterColumns: [0,1,2,3]
						,filterCaseSensitive: false
		});
		$("#rwTable").tablesorterCheckbox();

		// any link that is clicked on and has a class of 'reloadAds' will refresh the ad iframes
		$(".reloadAds").click(function() {
            var _col = $(this).text();
            var _colDir = $(this).attr("class");
            //reloadAds(_col,_colDir);
            reloadAds({
                        _col: $(this).text(),
                        _colDir: $(this).attr("class"),
                        _t: $("#filter-box").val()
                    });
		});
		
		$("#printGrid").click(function() {
			
			// expand the entire grid to print
			$('#resizeGrid a.expand').click();
			
			// write a new document that looks printer friendly
			// window.print for ?event=view.restaurant week is not printer friendly
	        var WindowObject = window.open('',"","width=620,height=450,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");
			WindowObject.document.writeln('<html><head><title>On the House - Print</title>');
			WindowObject.document.writeln('<style type="text/css" media="screen, projection, print">@import "/stylesheets/programs/oth_grid.css";</style>');
			WindowObject.document.writeln('</head><body>');
			WindowObject.document.writeln('<img src="/images/programs/onthehouse/OTH_2010_minisite_carousel1_620x390.jpg"><br />');
			WindowObject.document.writeln('<table id="rwTable" width="620" class="tablesorter" border="0" cellpadding="0" cellspacing="0">');
			WindowObject.document.writeln($('#rwTable').html());
			WindowObject.document.writeln('</table>');
			WindowObject.document.writeln('<script language="JavaScript" type="text/javascript" src="/javascripts/omniture/s_code.H20.3.js"></script>');
			WindowObject.document.writeln('<script language="JavaScript" type="text/javascript">');
			WindowObject.document.writeln('<!-- s.channel = "on the house";');
			WindowObject.document.writeln('s.server = location.host;');
			WindowObject.document.writeln('s.pageName = "On the House - Print";');
			WindowObject.document.writeln('s.prop1="on the house printer friendly";');
			WindowObject.document.writeln('s.prop12=window.location;');
			WindowObject.document.writeln('var s_code=s.t();if(s_code)document.write(s_code)//-->');
			WindowObject.document.writeln('</script>');
			WindowObject.document.writeln("<script language='JavaScript' type='text/javascript'><!-- if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')//--></script><noscript><a href='http://www.omniture.com' title='Web Analytics'><img src='http://nycgoprod.112.2O7.net/b/ss/nycgoprod/1/H.20.3--NS/0' height='1' width='1' border='0' alt='' /></a></noscript>");
			WindowObject.document.writeln('</body></html>');
	        WindowObject.document.close();
	        WindowObject.focus();
	        WindowObject.print();
	        WindowObject.close();
			
			// shrink the grid back down to only show 10
			$('#resizeGrid a.shrink').click();
			return false;
		});
	});
	
	// input clear text event 
	function textClear() {
		$("input.clearText").focus(function() {
			if(this.value == this.defaultValue) {
				this.value = '';
			}
		}).blur(function() {
			if(!this.value.length) {
				this.value = this.defaultValue;
			}
		});	
	}
	
	function reloadAds(options) {
    
        // defaults
        var defaults = { 
            _b: 'default', 
            _g: 'default', 
            _t: 'default', 
            _f: 'default',			
            _col: 'default', 
            _colDir: 'default'
        };
        // override defaults
        var options = $.extend({}, defaults, options); 

        // set strings.
        if ((options._t == "") || (options._t == "keyword search")) {
            _sText = defaults._t;
        } else {
            _sText = options._t;    
        }

        // Columns
        if ((options._col == "") || (options._col == "null")) {
            _sCol = defaults._col;
        } else {
            _sCol = options._col;   
        }//end if

        // Boroughs
        if (($.cookie('rwBoroughFilter') == "") || ($.cookie('rwBoroughFilter') == "null") || ($.cookie('rwBoroughFilter') === null)) {
            _sBor = defaults._b;
        } else {
            _sBor = $.cookie('rwBoroughFilter');    
        }//end if

        // Genre
        if (($.cookie('rwGenreFilter') == "") || ($.cookie('rwGenreFilter') == "null") || ($.cookie('rwGenreFilter') === null)) {
            _sGenre = defaults._g;
        } else {
            _sGenre = $.cookie('rwGenreFilter');   
        }//end if

        // Text
        if (($.cookie('rwTextFilter') == "") || ($.cookie('rwTextFilter') == "null") || ($.cookie('rwTextFilter') === null)) {
            _sTxt = defaults._f;
        } else {
            _sTxt = $.cookie('rwTextFilter');   
        }//end if

        // Full string.
        var _omnistring = "b: " + _sBor + "|g: " + _sGenre /*+ "|t: " + _sTxt */ + "|p: " + _sText + "|cl: " + _sCol;
        
        axel = Math.random() + "";
        ord = axel * 1000000000000000000;
        jQuery.each($("iframe"), function() {
            $(this).attr({
                src: $(this).attr("src").replace(/(?:ord=)(.*)?/, "ord=" + ord)
            });
        });
        // omniture page view   
        s.prop2 = "oth|" + _omnistring;
        s.t({eVar3:""});
        return false;
	}