﻿function Button2_onclick() {
  var text= document.getElementById('Text2').value;
  text=text.replace(/[\&'"]/,' ');
  if(text.length>0)
  {
    var key=encodeURI(text); 
    var mdid=getMdid();
    if(mdid!="" && document.getElementById("radio").checked)
    {
       window.open("Result.aspx?Keyword="+key+"&mdid="+mdid);
    }
    else {window.open("Result.aspx?Keyword="+key);}
  }
  return false;
}
function getMdid()
{
  var strHref = window.location.search;
  if(strHref.length==0)return "";
  var target="mdid";
  var mdid="";
  var strQueryString = strHref.substr(strHref.indexOf("?")+1).toLowerCase();
  var aQueryString = strQueryString.split("&");
  for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
  {
    if (aQueryString[iParam].indexOf(target.toLowerCase() + "=") > -1 )
    {
        var aParam = aQueryString[iParam].split("=");
        mdid=aParam[1];
        break;
    }
  }
  return mdid;  
}
function KeyDownHandler(btn)
{
        // process only the Enter key
     if (event.keyCode == 13)
     {
            // cancel the default submit
         event.returnValue=false;
         event.cancel = true;
            // submit the form by programmatically clicking the specified button
         SearchResult();
     }
}
function SearchResult(){
	var txt = document.getElementById('Text2').value;
	//cookie.set('keyword',encodeURI(txt));
    //alert(cookie.get('keyword'));
	//alert(decodeURI(cookie.get('keyword')));
	window.open('SearchResult.aspx?key=' + txt,'_self');
}