﻿//
function goFreeTextSearch() {
		var freeTextValue = document.getElementById('SearchString').value;
		if (freeTextValue == '')
			return false;
		if( document.getElementById('search_categories').value == 'catchoice0' ) { DoSrches("Products",freeTextValue); }
		if( document.getElementById('search_categories').value == 'catchoice1' ) { DoSrches("Articles",freeTextValue); }
		if( document.getElementById('search_categories').value == 'catchoice2' ) { DoSrches("Doctors",freeTextValue); }
		if( document.getElementById('search_categories').value == 'catchoice3' ) { DoSrches("All",freeTextValue); }
		return false;
}
function GetWidth() { return window.document.body.clientWidth; }
function GetHeight() { 	return window.document.body.clientHeight; }
function DoLookAt(dlWORD) {
		if( document.getElementById('search_categories').value == 'catchoice0' ) { DoSrches("Products",dlWORD); }
		if( document.getElementById('search_categories').value == 'catchoice1' ) { DoSrches("Articles",dlWORD); }
		if( document.getElementById('search_categories').value == 'catchoice2' ) { DoSrches("Doctors",dlWORD); }
		if( document.getElementById('search_categories').value == 'catchoice3' ) { DoSrches("All",dlWORD); }
		return false;
}
function DoLookup( dluWORD ) {
    if( Trim(dluWORD)=="" ) {
        document.getElementById('WordBox').style.visibility='hidden';
    } else {
    zWORDS=PostGet( "GETWORDS",dluWORD,"","","","","","","","","" )
    if(zWORDS.indexOf("option")==-1) {
        document.getElementById('WordBox').style.visibility='hidden';
    } else {
    document.getElementById('WordBox').innerHTML=zWORDS;
    document.getElementById('WordBox').style.width='180px';
    ww=Number(GetWidth());
    vv=ww-980;
    yy=vv/2;
    zz=parseInt(String(yy))   
    zzzz=zz+800;
    zzzz=zzzz-45;
    ssss=String(zzzz)+"px";
    document.getElementById('WordBox').style.left=ssss;
    document.getElementById('WordBox').style.visibility='visible';
    }
    }
}
function DoSetWord() {
    document.getElementById('WordBox').style.visibility='hidden';
    document.getElementById("SearchString").value=document.getElementById("wsel").value;
    document.getElementById("SearchString").focus();
    document.getElementById("SearchGoBtn").click();
}
function checkArrows(field, evt) {
  var keyCode = 
    document.layers ? evt.which :
    document.all ? event.keyCode :
    document.getElementById ? evt.keyCode : 0;
    // (keyCode == 39)//arrow right //  (keyCode == 40)//arrow down //  (keyCode == 38)//arrow up //  (keyCode == 37)//arrow left
  if( keyCode==13 ) {
      // 
  }
  if( keyCode==40 ) {
    try { document.getElementById("wsel").focus(); }
    catch(dwe) { z=''; }
  }
  return true;
}
function checkArrows2(field, evt) {
  var keyCode = 
    document.layers ? evt.which :
    document.all ? event.keyCode :
    document.getElementById ? evt.keyCode : 0;
    if( keyCode==13 ) {
        document.getElementById('WordBox').style.visibility='hidden';
        document.getElementById("SearchString").value=document.getElementById("wsel").value;
        document.getElementById("SearchString").focus();
    }
    if( keyCode==40 ) {
        try { document.getElementById("wsel").focus(); }
        catch(dwe) { z=''; }
    }
    return true;
}
function DoSrches(ds1,ds2) {
    s_Space="_";
    s_Params="k";
    s_where = String(ds1);
    s_word = String(ds2);
    s_word = s_word.replace(/ /gi,s_Space);
    if( s_word != "" ) {
        if( s_where=="Products" ) { s_url="/ProductsSearch.aspx?"+s_Params+"="+s_word; }
        if( s_where=="Articles" ) { s_url="/ArticlesSearch.aspx?"+s_Params+"="+s_word; }
        if( s_where=="Doctors" ) { s_url="/DearDoctorSearch.aspx?"+s_Params+"="+s_word; }
        if( s_where=="All" ) { s_url="/Searches.aspx?"+s_Params+"="+s_word; }
        document.location=s_url;
    }
}
function Trim( str ) {
	astr = String( str );
	LastCharAt = 0;
	while(astr.substring(0,1)==" ") { astr=astr.substring(1); }
	for(x=astr.length-1;x>=0;x--) {
		if( astr.charAt(x) != " " ) {
			LastCharAt = x+1;
			break;
		}
	}
	rSTR=astr.substring(0,LastCharAt);
	if(rSTR=="null")
		rSTR="";
	return rSTR;
}





