﻿function setSearchBoxFormCode0(cmCode)
{
    document.getElementById("sbFormCode0").value = cmCode;
}

function checkForEnterKey() {

    var retVal = true;
    var keycode = 0;
    if ((typeof(window.event) != "undefined") && (window.event != null))
    {
        keycode = window.event.keyCode;
    }
    else if ((typeof(e) != "undefined") && (e != null))
    {
        keycode = e.which;
    }
    if (keycode == 13)
    {
        doSearch();
        retVal = false;
    }
    return retVal;
}

function TextBoxFocused(){
	var keywordsTextbox = $('.searchBar');
	if (keywordsTextbox.val() == 'Search with Bing') {
		keywordsTextbox.val('');
	}
}

function TextBoxBlurred(){
	var keywordsTextbox = $('.searchBar');
	if (keywordsTextbox.val() == '') {
		keywordsTextbox.val('Search with Bing');
	}
}

function findKeywordTextbox()
{
    var ret = null;
    
    var inputs = document.getElementsByTagName("input");
    for (var i=0; i<inputs.length; i++)
    {
        if (inputs[i].className == "searchBar search_watermark")
        {
            ret = inputs[i];
            break;
        }
    }
    
    return ret;
}

function doSearch() {
	
	var keywordsTextbox = $('.searchBar');

	if (keywordsTextbox != null) {
		var keywords = keywordsTextbox.val();
		if (keywords.length > 0 && keywords != 'Search with Bing') {
			var q = "q=" + escape(keywords);

			// Restrict the search to just pages in this site
			var s100 = "s100=on";
			var otherSite = "q1=site:http%3A%2F%2Fwww.netmf.com";

			var url = "http://www.bing.com/results.aspx?" + q + "&" + otherSite;
			window.location.href = url;
		}
	}
}


