function Wowd() {

    this.curr = null;
    this.currView = '';

    this.run = function(view) {
        this.currView = view;
        $("#menu_search").addClass('menusel');
    }

    this.goToHotlist = function() {
        window.location = 'index.jsp';
    }

    this.goToSearch = function() {
        window.location = 'index.jsp?search';
    }
    this.runSortBy = function(opt) {
    	var str = window.location.href;
    	if(opt == 'time'){
        	window.location = str.replace("popularity","freshness");
        } else {
        	window.location = str.replace("freshness","popularity");
        }
    }

    this.runSearch = function() {
    	if($("#search_box").val().length > 0){
    		var str = window.location.href;
    		var sortby = 'time';
    		if(str.indexOf('/popularity/') >= 0){
    			sortby = 'rank';
    		}
        	window.location.replace("http://www.wowd.com?search&sortby=" + sortby + "&query=" + $("#search_box").val());
        }
        return false;
    }

    this.init = function() {
        
        
    }
}

var wowd = new Wowd();

$(document).ready(function() {
    wowd.init();
});
