// Class to manage searches
var SearchManager = {
	
	search:function(site, qstr) {

		var loc;
		var sos = (($('#search_box').val().length < 1) || ($('#search_box').val() == 'Enter your search here'))?'site':'search';

		if (site == 'info') { $('#info_div').animate({top:0}, 500); return;	}
		else if (site == 'weather') {

			if ((qstr.length < 1) || ($('#search_box').val() == 'Enter your search here')) {
				if ((UserLocation.get().length < 1) && (l = promptLocation())) {
					UserLocation.set(l);
				}
				var l = parseInt(UserLocation.get());
				if (isNaN(l)) {	loc = URL.weather[SiteType.get()].nam.replace(/#loc#/g, UserLocation.get()); }
				else { loc = URL.weather[SiteType.get()].zip.replace(/#loc#/g, UserLocation.get());	}
			}

			else {
				var l = parseInt(qstr);
				if (isNaN(l)) {	loc = URL.weather[SiteType.get()].nam.replace(/#loc#/g, qstr); }
				else { loc = URL.weather[SiteType.get()].zip.replace(/#loc#/g, qstr);	}
			}
		}

		else if (((site == 'business') || (site == 'movies')) && (UserLocation.get().length < 1)) {
			if (l = promptLocation()) {
				UserLocation.set(l);
				loc = URL[site][sos][SiteType.get()].replace(/#qstr#/g, qstr);
				loc = loc.replace(/#loc#/g, UserLocation.get());
			} else { return; }
		}

		else {
			if (!URL[site][sos][SiteType.get()]) { return; }
			else {
				loc = URL[site][sos][SiteType.get()].replace(/#qstr#/g, qstr);
				loc = loc.replace(/#loc#/g, UserLocation.get());
			}
		}
		document.location = loc;
	}
};
