var searchSubmitted = false;
var currAlpha = 'alpha-A';
var regClassName = document.getElementById('alpha-B').className;
function SetAlpha(newAlpha){ // AtoZTabs_fmt
    var el1 = document.getElementById(currAlpha);
	el1.className= regClassName;
    var el2 = document.getElementById(newAlpha);
	el2.className='highlightedTab_fmt';
	currAlpha = newAlpha;
	return true;
}
// Return boolean TRUE/FALSE
function isMobile(){
	var deviceWidth = $(window).width();
    return (deviceWidth < 600);
}
function DoSemanticSearch(){
    if (!document.getElementById) return;
    var el = document.getElementById('searchQuery_fmt');
    var url  = getSearchUrl(el.value);
    window.location = url;
    return true;
}
function getSearchUrl(qry){
    var url  = 'http://www.supplementexplorer.com/query/Search?q=' + qry;
    return url;
}
google_ad_client = "pub-8811589694497426";
google_ad_slot = "2608593622";
google_ad_width = 160;
google_ad_height = 90;
function SetGoogleAd(ad_client, ad_slot, ad_width, ad_height) {
	google_ad_client = ad_client;
	google_ad_width = ad_slot;
	google_ad_width = ad_width;
	google_ad_height = ad_height;
}

$(document).ready(function () {
	if (isMobile()) {
		window.location = 'http://m.supplementexplorer.com';
	}
	$('#searchQuery_fmt').focus(); // set focus on dialog entry field

	// to enable Enter
	$('#searchContainer_rdr *').live('keypress', function (ev) {
		if (ev.which === 13) { // prevent multiple events
			if (!searchSubmitted) {
				ev.preventDefault();
				DoSemanticSearch();
			}
			searchSubmitted = true; // prevent multiple events
		}
	});

	$('.searchButton_fmt').click(function () { //  Search button click
		DoSemanticSearch();
		searchSubmitted = true; // prevent multiple events
	});


});

