﻿function search(strCategory) {
    strUrl = "results.aspx?c=" + strCategory;
	var a = document.getElementById('sttop').value;
    if (a != "")
        strUrl += "&q=" + urlencode(a);
	a = document.getElementById('txtLayout').value;
    if (a != "")
        strUrl += "&l=" + a;
    document.location.href = strUrl;
}

function setDefaultSearch(e, defaultSearch) {
    var keynum;

    if (window.event) // IE
    {
        keynum = e.keyCode;        
    }
    else if (e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }

    if (keynum != 13) {
        //alert("Not enter key!");
        return;
    }
    
	document.getElementById('txtDefaultSearch').value = defaultSearch;
	document.form1.submit();
}

function giterDone() {
	var a = document.getElementById('sttop');
	if(a){
		a.focus();
		a.value = a.value;
	}
    //document.form1.sttop.value = document.form1.sttop.value;    
}

function ToolBarInit(tool) {
    if (tool) {
        if ((document.form1) && (document.form1.txtToolbarID) && (document.form1.txtToolbarID.value == "")) {
            document.form1.txtToolbarID.value = tool.toolbarid;            
        }
    }
    //alert(document.form1.txtToolbarID.value);
}

function showMoreSearches(){
	var a = document.getElementById('related2');
	if(a){
		a.style.display = 'inline';
	}
	var b = document.getElementById('showMore');
	if(b){
		b.style.display = 'none';
	}
}

var isPushed = false;
function pushIt(btnSubmit, pressed) {    
    if (pressed == true)
    {
        isPushed = true;
    }
    if (isPushed == true) {
        btnSubmit.className = "sbutton_pushed";
    }
    return true;
}

function popIt(btnSubmit, released) {
    btnSubmit.className = "sbutton";
    if (released == true) {
        isPushed = false;
    }
    return true;
}

function findIt(box) {
    document.form1.txtDefaultSearch.value = box;
    document.form1.submit();
}


function urlencode(str) {
  str = escape(str);
  str = str.replace('+', '%2B');
//  str = str.replace('%20', '+');
  str = str.replace('*', '%2A');
  str = str.replace('/', '%2F');
  str = str.replace('@', '%40');
  str = str.replace('&', '%26');
  return str;
}
