var today=new Date();var numSlideYears;var numSlideMonths;var numSlideDays;var baseDateSlideYears;var baseDateSlideMonths;var baseDateSlideDays;var anyCity='';var dateFormatString='M d, yy';var suggestKeys=new Array();var suggestions=new Array();var incExcSites=new Array();incExcSites.push(new Array("facebook","Facebook","facebook.com","fa"));incExcSites.push(new Array("twitter","Twitter","twitter.com","tw"));incExcSites.push(new Array("friendfeed","FriendFeed","friendfeed.com","fr"));incExcSites.push(new Array("myspace","MySpace","myspace.com","my"));incExcSites.push(new Array("blogger","Blogger","blogspot.com","bl"));incExcSites.push(new Array("wordpress","WordPress","wordpress.com","wp"));incExcSites.push(new Array("tumblr","Tumblr","tumblr.com","tb"));incExcSites.push(new Array("ebay","Ebay","ebay.com","eb"));incExcSites.push(new Array("amazon","Amazon","amazon.com","am"));incExcSites.push(new Array("vimeo","vimeo","vimeo.com","vm"));incExcSites.push(new Array("youtube","YouTube","youtube.com","yt"));incExcSites.push(new Array("flickr","Flickr","flickr.com","fl"));incExcSites.push(new Array("photobucket","Photobucket","photobucket.com","ph"));incExcSites.push(new Array("wikipedia","Wikipedia","wikipedia.org","wk"));incExcSites.push(new Array("mahalo","Mahalo","mahalo.com","mh"));incExcSites.push(new Array("answers","Answers","answers.com","an"));incExcSites.push(new Array("digg","digg","digg.com","dg"));incExcSites.push(new Array("upcoming","Upcoming","upcoming.yahoo.com","up"));incExcSites.push(new Array("eventful","Eventful","eventful.com","ev"));incExcSites.push(new Array("nytimes","NYTimes","nytimes.com","ny"));incExcSites.push(new Array("cbc","CBC","cbc.ca","cb"));incExcSites.push(new Array("guardian","Guardian","guardian.co.uk","gu"));incExcSites.push( new Array("realnews", "RealNews", "therealnews.com", "rn") );var filetypes=new Array();filetypes.push(new Array("pdf","Adobe Acrobat (.PDF)"));filetypes.push(new Array("txt","Plain Text (.TXT)"));filetypes.push(new Array("rtf","Rich Text Format (.RTF)"));filetypes.push(new Array("doc","Microsoft Word (.DOC)"));filetypes.push(new Array("xls","Microsoft Excel (.XLS)"));filetypes.push(new Array("ppt","Microsoft Powerpoint (.PPT)"));filetypes.push(new Array("swf","Shockwave Flash (.SWF)"));filetypes.push(new Array("flv","Flash Video (.FLV)"));filetypes.push(new Array("ogg","OGG Vorbis Audio (.OGG)"));filetypes.push( new Array("torrent", "Torrent (.TOR)") );filetypes.push(new Array("jpg","JPG Image (.JPG)"));filetypes.push(new Array("dwf","Autodesk (.DWF)"));filetypes.push( new Array("kml", "Google Earth (.KML)") );var bX="cur";$(document).ready(function(){numSlideYears=20;numSlideMonths=10*12;if(today.getMonth()<=4)numSlideMonths-=(4-today.getMonth());else numSlideMonths+=(today.getMonth()-4);baseDateSlideDays=new Date(today.getFullYear(),today.getMonth(),1);numSlideDays=today.getDate();for(var i=0;i<4;++i){baseDateSlideDays.prevMonth();numSlideDays+=DaysInMonth(baseDateSlideDays.getFullYear(),baseDateSlideDays.getMonth());}baseDateSlideMonths=new Date(baseDateSlideDays);for(var i=0;i<numSlideMonths;++i)baseDateSlideMonths.prevMonth();baseDateSlideYears=new Date(baseDateSlideMonths.getFullYear()-numSlideYears,0,1);if(document.getElementById("q").value==""){bX="def";document.getElementById("bZ").selectedIndex=0;}aY("cur",bX);$('#date_from').datepicker({changeMonth:true,changeYear:true,dateFormat:dateFormatString,minDate:baseDateSlideYears,onClose:function(newDate){OnPickDate(0,1,newDate);}});var from=new Date(baseDateSlideYears);var defaultFromDate=GetConfigDate(bX,0,from);$('#date_from').datepicker('setDate',defaultFromDate);$('#date_to').datepicker({changeMonth:true,changeYear:true,dateFormat:dateFormatString,minDate:baseDateSlideYears,onClose:function(newDate){OnPickDate(1,0,newDate);}});var defaultToDate=GetConfigDate(bX,1,today);$('#date_to').datepicker('setDate',defaultToDate);$("#date_slider").slider({range:true,min:0,max:(numSlideYears+numSlideMonths+numSlideDays),values:[SliderFromDate(defaultFromDate),SliderFromDate(defaultToDate)]});DisplayFromDate(SliderFromDate(defaultFromDate));if(aJ(bX,true))document.getElementById("incexctype_2").checked=true;else document.getElementById("incexctype_1").checked=true;ap(bX);as(bX);aG(bX);aH(bX);aF(bX);$('#date_slider').bind('slide',function(event,ui){var fromDate=DateFromSlider(ui.values[0]);var toDate=DateFromSlider(ui.values[1]);$('#date_to').datepicker('setDate',toDate);SetConfigDate("cur",1,toDate);DisplayFromDate(ui.values[0]);$('#date_from').datepicker('setDate',fromDate);SetConfigDate("cur",0,fromDate);StarSelectedProfile();return true;});});function bn(){var cj=document.getElementById("ca").value;ak("numresults",cj);am();};function bj(){var cj=aj("numresults");if(!cj)return;for(var i=0;i<document.getElementById("ca").options.length;++i){if(document.getElementById("ca").options[i].value==cj){document.getElementById("ca").selectedIndex=i;return;}}};function GetElementClass(elem){var className=elem.getAttribute("class");if(className==null)className=elem.getAttribute("className");return className;};function SetElementClass(elem,cls){elem.setAttribute("class",cls);elem.setAttribute("className",cls);};function DisplayFromDate(sliderPos){if(sliderPos!=0){document.getElementById("date_from").style.display="block";document.getElementById("date_from_limit").style.display="none";}else if(document.getElementById("date_from").style.display!="none"){document.getElementById("date_from").style.display="none";document.getElementById("date_from_limit").style.display="block";}};function OnPickDate(sliderId,otherSliderId,newDate){var realDate=$.datepicker.parseDate(dateFormatString,newDate);var sliderPos=SliderFromDate(realDate);$('#date_slider').slider('values',sliderId,sliderPos);SetConfigDate("cur",sliderId,realDate);StarSelectedProfile();};function DateFromSlider(sliderValue){if(sliderValue==0)return baseDateSlideYears;else if(sliderValue==(numSlideYears+numSlideMonths+numSlideDays))return today;if(sliderValue<numSlideYears){return new Date(baseDateSlideYears.getFullYear()+sliderValue,0,1);}else if(sliderValue<(numSlideYears+numSlideMonths)){var sliderMonths=sliderValue-numSlideYears;var newDate=new Date(baseDateSlideMonths);for(var i=0;i<sliderMonths;++i)newDate.nextMonth();return newDate;}else{var sliderDays=sliderValue-numSlideYears-numSlideMonths;return new Date(baseDateSlideDays.getFullYear(),baseDateSlideDays.getMonth(),1+sliderDays);}};function SliderFromDate(newDate){if(newDate==null)return false;if(newDate.getFullYear()<baseDateSlideYears.getFullYear())return 0;if(newDate.getFullYear()<baseDateSlideMonths.getFullYear()){return(newDate.getFullYear()-baseDateSlideYears.getFullYear());}else if(newDate<baseDateSlideDays){var numMonths=(newDate.getFullYear()-baseDateSlideMonths.getFullYear())*12;numMonths+=newDate.getMonth();return numSlideYears+numMonths;}else if(newDate<today){var numDays=newDate.getDate();var tmpDate=new Date(baseDateSlideDays);for(;;){if(tmpDate.getFullYear()==newDate.getFullYear()&&tmpDate.getMonth()==newDate.getMonth())break;numDays+=DaysInMonth(tmpDate.getFullYear(),tmpDate.getMonth());tmpDate.nextMonth();}return numSlideYears+numSlideMonths+numDays;}else{return numSlideYears+numSlideMonths+numSlideDays;}};function SetRangeSince(numMonthsBack,numDaysBack){DisplayFromDate(1);var today=new Date();var since=new Date();for(var i=0;i<numMonthsBack;++i){since.prevMonth();}for(var i=0;i<numDaysBack;++i){since.setUTCDate(since.getUTCDate()-1);}$('#date_slider').slider('values',0,SliderFromDate(since));$('#date_from').datepicker('setDate',since);SetConfigDate("cur",0,since);$('#date_slider').slider('values',1,SliderFromDate(today));$('#date_to').datepicker('setDate',today);SetConfigDate("cur",1,today);StarSelectedProfile();};function OnClickDateFromLimit(){DisplayFromDate(1);$('#date_from').datepicker('show');};function GetDateFrom(){if(document.getElementById("date_from").style.display=="none")return null;return $('#date_from').datepicker('getDate');};function GetToDate(){var toDate=$('#date_to').datepicker('getDate');var slidePos=SliderFromDate(toDate);if(slidePos==(numSlideYears+numSlideMonths+numSlideDays))return null;return toDate;};function SetConfigDate(conf,sliderId,newDate){var namePref=conf+"_date_"+sliderId+"_";if(newDate){ak(namePref+"year",newDate.getFullYear());ak(namePref+"month",newDate.getMonth());ak(namePref+"day",newDate.getDate());}else{al(namePref+"year");al(namePref+"month");al(namePref+"day");}};function GetConfigDate(conf,sliderId,defaultDate){var namePref=conf+"_date_"+sliderId+"_";var year=aj(namePref+"year");var month=aj(namePref+"month");var day=aj(namePref+"day");if(!year)return defaultDate;return new Date(year,month,day);};function bF(siteIndex){var conf="cur";var selSites=aK(conf);var pos=selSites.find(incExcSites[siteIndex][3]);if(pos== -1){selSites.push(incExcSites[siteIndex][3]);}else{selSites.splice(pos,1);}av(conf,selSites);ap(conf);StarSelectedProfile();};function by(custIndex){var conf="cur";var selSites=aK(conf);var custSites=au();var pos=selSites.find(custSites[custIndex]);if(pos== -1){selSites.push(custSites[custIndex]);}else{selSites.splice(pos,1);}av(conf,selSites);ap(conf);StarSelectedProfile();};function bK(){var selSites=new Array();var custSites=au();for(var i=0;i<incExcSites.length;++i){selSites.push(incExcSites[i][3]);}for(var i=0;i<custSites.length;++i){selSites.push(custSites[i]);}var conf="cur";av(conf,selSites);ap(conf);StarSelectedProfile();};function aP(){var conf="cur";av(conf,new Array());ap(conf);StarSelectedProfile();};

function addEngine(name, ext)
{
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function")) {
    window.sidebar.addSearchEngine(
      "http://mycroft.mozdev.org/external.php/" + name + ".src",
      "http://mycroft.mozdev.org/external.php/" + name + "."+ ext, "", "");
  } else {
    alert("You will need a browser which supports Sherlock to install this plugin.");
  }
}

function addOpenSearch(name,ext,meth)
{
  if ((typeof window.external == "object") && ((typeof window.external.AddSearchProvider == "unknown") || (typeof window.external.AddSearchProvider == "function"))) {
    if ((typeof window.external.AddSearchProvider == "unknown") && meth == "p") {
      alert("This plugin uses POST which is not currently supported by Internet Explorer's implementation of OpenSearch.");
    } else {
      window.external.AddSearchProvider(
        "http://mycroft.mozdev.org/externalos.php/" + name + ".xml");
    }
  } else {
    alert("You will need a browser which supports OpenSearch to install this plugin.");
  }
}


function aM(imageId){var img=document.getElementById(imageId);if(GetElementClass(img)=="searchsite_norm")SetElementClass(img,"searchsite_norm_hover");};function aR(imageId){var img=document.getElementById(imageId);if(GetElementClass(img)=="searchsite_norm_hover")SetElementClass(img,"searchsite_norm");};function ap(conf){if(!conf)conf="cur";var html="";var searchOnlySites=aJ(conf,true);var selSites=aK(conf);for(var i=0;i<incExcSites.length;++i){var isSelected=(selSites.find(incExcSites[i][3])!= -1);html+='<img align=absmiddle id="'+incExcSites[i][0]+'" '+'onmouseover="javascript:aM(\''+incExcSites[i][0]+'\')" '+'onmouseout="javascript:aR(\''+incExcSites[i][0]+'\')" '+'width="16" height="16" onclick="javascript:bF(\''+i+'\')" '+'src="images/inc_'+incExcSites[i][0]+'.png" ';if((searchOnlySites&& !isSelected)||(!searchOnlySites&&isSelected))html+='title="'+incExcSites[i][1]+TitleBr()+'Click to include '+incExcSites[i][1]+' pages from your search" ';else html+='title="'+incExcSites[i][1]+TitleBr()+'Click to exclude '+incExcSites[i][1]+' pages from your search" ';if(searchOnlySites&&isSelected)html+='class="searchsite_green" ';else if(!searchOnlySites&&isSelected)html+='class="searchsite_red" ';else html+='class="searchsite_norm" ';html+='>';}var custSites=au();for(var i=0;i<custSites.length;++i){var isSelected=(selSites.find(custSites[i])!= -1);html+='<img align=absmiddle id="custsite_'+i+'" '+'onmouseover="javascript:aM(\'custsite_'+i+'\')" '+'onmouseout="javascript:aR(\'custsite_'+i+'\')" '+'width="16" height="16" onclick="javascript:by(\''+i+'\')" '+'src="http://www.google.com/s2/favicons?domain='+custSites[i]+'" ';if((searchOnlySites&& !isSelected)||(!searchOnlySites&&isSelected))html+='title="'+custSites[i]+TitleBr()+'Click to include '+custSites[i]+' pages from your search" ';else html+='title="'+custSites[i]+TitleBr()+'Click to exclude '+custSites[i]+' pages from your search" ';if(searchOnlySites&&isSelected)html+='class="searchsite_green" ';else if(!searchOnlySites&&isSelected)html+='class="searchsite_red" ';else html+='class="searchsite_norm" ';html+='>';}document.getElementById("search_site_icons").innerHTML=html;am();};function bc(){aU("cur",document.getElementById("incexctype_2").checked);StarSelectedProfile();ap("cur");};function aE(site){if(site==null)site="";ae_prompt(bA,'Please enter the domain name of the site (ex. hello.com):',site);};function bA(site){var searchSites=au();if(site==null||site=="")return;site=site.toLowerCase();if(site.substr(0,4)=="www.")site=site.substr(4);if(site.length>50||site.indexOf(" ")!= -1){alert("Please enter a valid domain name with no spaces.");aE(site);return;}if(searchSites.find(site)!= -1){alert("The specified site already exists. Please enter a valid domain name with no spaces.");aE(site);return;}searchSites.push(site);aN(searchSites);ap("cur");};function bs(){var searchOnly=document.getElementById("incexctype_2").checked;var custSites=au();var custSitesToDel=new Array();for(var i=custSites.length-1;i>=0;--i){var img=document.getElementById("custsite_"+i);if(searchOnly){if(GetElementClass(img)=="searchsite_green"){custSitesToDel.push(custSites[i]);custSites.splice(i,1);}}else{if(GetElementClass(img)=="searchsite_red"){custSitesToDel.push(custSites[i]);custSites.splice(i,1);}}}if(custSitesToDel.length==0){alert("Please select some custom sites that you wish to delete.");return;}var ok=confirm("Are you sure that you wish to delete the following custom sites?\n"+ar(custSitesToDel," "));if(!ok)return;aN(custSites);ap("cur");};function au(){var custSites=aj("custsites");if(custSites==null||custSites=="")return new Array();return custSites.split(",");};function aN(sites){ak("custsites",ar(sites,","));};function bk(conf){var selSites=new Array();var custSites=au();for(var i=0;i<incExcSites.length;++i){var img=document.getElementById(incExcSites[i][0]);if(GetElementClass(img)=="searchsite_green"||GetElementClass(img)=="searchsite_red")selSites.push(incExcSites[i][3]);}for(var i=0;i<custSites.length;++i){var img=document.getElementById("custsite_"+i);if(GetElementClass(img)=="searchsite_green"||GetElementClass(img)=="searchsite_red")selSites.push(custSites[i]);}av(conf,selSites);};function aK(conf){var sites=aj(conf+"_selsites");if(!sites)return new Array();else return sites.split(",");};function av(conf,sites){ak(conf+"_selsites",ar(sites,","));am();};function aU(conf,isChecked){ak(conf+"_onlysites",isChecked?"2":"3");am();};function aJ(conf,defVal){var onlysites=aj(conf+"_onlysites");if(!onlysites)return defVal;if(onlysites=="1")return true;else if(onlysites=="0")return false;return((onlysites=="3")?false:true);};function aL(conf){var cw=aj(conf+"_filetypes");if(cw==null)return new Array();return cw.split(",");};function aD(conf,selectedTypes){ak(conf+"_filetypes",ar(selectedTypes,","));};function aI(conf){if(conf==null)conf="cur";var selectedFiletypes=new Array();for(var i=0;i<filetypes.length;++i){var img=document.getElementById("filetype_"+filetypes[i][0]);if(GetElementClass(img)=="bY")selectedFiletypes.push(filetypes[i][0]);}var customTypes=at();for(var i=0;i<customTypes.length;++i){var img=document.getElementById("filetype_"+customTypes[i]);if(GetElementClass(img)=="bY")if(selectedFiletypes.find(customTypes[i])== -1)selectedFiletypes.push(customTypes[i]);}aD(conf,selectedFiletypes);};function ao(imageId){var img=document.getElementById(imageId);if(GetElementClass(img)=="bR")SetElementClass(img,"cs");};function an(imageId){var img=document.getElementById(imageId);if(GetElementClass(img)=="cs")SetElementClass(img,"bR");};function ay(){var html="";for(var i=0;i<filetypes.length;++i){html+='<img class="bR" align=absmiddle id="filetype_'+filetypes[i][0]+'" '+'onmouseover="javascript:ao(\'filetype_'+filetypes[i][0]+'\')" '+'onmouseout="javascript:an(\'filetype_'+filetypes[i][0]+'\')" '+'src="images/filetype_'+filetypes[i][0]+'.png" '+'width="32" height="32" onclick="javascript:aq(\''+i+'\')" '+'title="'+filetypes[i][0].toUpperCase()+TitleBr()+'Search for files of type '+filetypes[i][1]+'"'+'> ';}var customTypes=at();for(var i=0;i<customTypes.length;++i){if(i==0){html+='<br/>';}else if(i/10>=1){html+='<br/>';}html+='<span class="da" '+'onmouseover="javascript:ao(\'filetype_'+customTypes[i]+'\')" '+'onmouseout="javascript:an(\'filetype_'+customTypes[i]+'\')" '+'title="'+customTypes[i].toUpperCase()+TitleBr()+'Search for files of type '+customTypes[i].toUpperCase()+'" '+'onclick="javascript:bf(\''+customTypes[i]+'\')">'+customTypes[i].toUpperCase()+'</span>';html+='<img class="bR" align=absmiddle id="filetype_'+customTypes[i]+'" '+'onmouseover="javascript:ao(\'filetype_'+customTypes[i]+'\')" '+'onmouseout="javascript:an(\'filetype_'+customTypes[i]+'\')" '+'src="images/filetype_generic.png" '+'width="32" height="32" onclick="javascript:bf(\''+customTypes[i]+'\')" '+'title="'+customTypes[i].toUpperCase()+TitleBr()+'Search for files of type '+customTypes[i].toUpperCase()+'"'+'> ';}document.getElementById("cv").innerHTML=html;am();};function as(conf){if(conf==null)conf="cur";var selectedFiletypes=aL(conf);for(var i=0;i<filetypes.length;++i){var img=document.getElementById("filetype_"+filetypes[i][0]);if(selectedFiletypes.find(filetypes[i][0])!= -1)SetElementClass(img,"bY");else SetElementClass(img,"bR");}var customTypes=at();for(var i=0;i<customTypes.length;++i){var img=document.getElementById("filetype_"+customTypes[i]);if(selectedFiletypes.find(customTypes[i])!= -1)SetElementClass(img,"bY");else SetElementClass(img,"bR");}};function bJ(){var allTypes=new Array();var customTypes=at();for(var iPre=0;iPre<filetypes.length;++iPre)allTypes.push(filetypes[iPre][0]);for(var i=0;i<customTypes.length;++i)allTypes.push(customTypes[i]);aD("cur",allTypes);as("cur");StarSelectedProfile();};function aQ(){aD("cur",new Array());as("cur");StarSelectedProfile();};function aq(iType){var img=document.getElementById("filetype_"+filetypes[iType][0]);var selectedTypes=aL("cur");if(GetElementClass(img)=="bY")SetElementClass(img,"bR");else SetElementClass(img,"bY");aI("cur");StarSelectedProfile();};function bf(customType){var img=document.getElementById("filetype_"+customType);var selectedTypes=aL("cur");if(GetElementClass(img)=="bY")SetElementClass(img,"bR");else SetElementClass(img,"bY");aI("cur");StarSelectedProfile();};function ba(extension){if(extension==null)extension="";ae_prompt(bG,"Please enter a file extension. For example, for text files enter TXT.",extension);};function bG(extension){if(extension==null||extension=="")return;if(extension.length>10|| !extension.isAlphaNumeric()){alert("The file extension must be at most 10 characters long and may only include alphanumeric characters.");ba(extension);return;;}extension=extension.toLowerCase();var customTypes=at();if(customTypes.find(extension)== -1){customTypes.push(extension);aO(customTypes);}ay();as();};function bo(){var types=at();var typesToDelete=new Array();var typesRemaining=new Array();for(var i=0;i<types.length;++i){var img=document.getElementById("filetype_"+types[i]);if(GetElementClass(img)=="bY")typesToDelete.push(types[i]);else typesRemaining.push(types[i]);}if(typesToDelete.length==0){alert("Please select one or more custom types that you wish to delete.");return;}var typesToDeleteStr=ar(typesToDelete," ").toUpperCase();var del=confirm("Are you sure that you wish to permanently remove the following custom types?\nFile types: "+typesToDeleteStr);if(del){aO(typesRemaining);ay();as();}};function at(){var extCookie=aj("customtypes");if(!extCookie)return new Array();return extCookie.split(",");};function aO(typeList){ak("customtypes",ar(typeList,","));};function aw(){var cu=aj("bS");if(!cu)return new Array();return cu.split(",");};function aW(conf){var bS=aw();var i=bS.find(conf);if(i!= -1){bS.splice(i,1);ak("bS",ar(bS,","));}al(conf+"_name");SetConfigDate(conf,0,null);SetConfigDate(conf,1,null);al(conf+"_selsites");al(conf+"_onlysites");al(conf+"_filetypes");al(conf+"_zip");al(conf+"_region");al(conf+"_lang");};function aY(dest,source){ak(dest+"_date_0_year",aj(source+"_date_0_year"));ak(dest+"_date_0_month",aj(source+"_date_0_month"));ak(dest+"_date_0_day",aj(source+"_date_0_day"));ak(dest+"_date_1_year",aj(source+"_date_1_year"));ak(dest+"_date_1_month",aj(source+"_date_1_month"));ak(dest+"_date_1_day",aj(source+"_date_1_day"));ak(dest+"_selsites",aj(source+"_selsites"));ak(dest+"_onlysites",aj(source+"_onlysites"));ak(dest+"_filetypes",aj(source+"_filetypes"));ak(dest+"_zip",aj(source+"_zip"));ak(dest+"_region",aj(source+"_region"));ak(dest+"_lang",aj(source+"_lang"));};function az(conf){if(document.getElementById("date_from").style.display!="none"){SetConfigDate(conf,0,$('#date_from').datepicker('getDate'));}else{SetConfigDate(conf,0,null);}var toDate=$('#date_to').datepicker('getDate');var today=new Date();if(toDate.getFullYear()!=today.getFullYear()||toDate.getMonth()!=today.getMonth()||toDate.getDate()!=today.getDate()){SetConfigDate(conf,1,toDate);}else{SetConfigDate(conf,1,null);}bk(conf);aU(conf,document.getElementById("incexctype_2").checked);aI(conf);aV(conf);aZ(conf);aX(conf);am();};function StarSelectedProfile(){var list=document.getElementById("bZ");var option=list.options[list.selectedIndex];var name=option.text;if(name.length>0&&name.charAt(name.length-1)!="*"){option.text=name+"*";}am();};function bq(){var list=document.getElementById("bZ");for(var i=0;i<list.length;++i){var option=list.options[i];var name=option.text;if(name.length>0&&name.charAt(name.length-1)=="*"){name=name.substr(0,name.length-1);option.text=name;}}};function aA(){var list=document.getElementById("bZ");var option=list.options[list.selectedIndex];var name=option.text;if(name.length>0&&name.charAt(name.length-1)=="*"){name=name.substr(0,name.length-1);option.text=name;}am();};function bi(){az(document.getElementById("bZ").value);aA();};function IsProfileNameUsed(name){var list=document.getElementById("bZ");for(var i=0;i<list.length;++i){if(list.options[i].text==name)return true;}return false;};function aC(name){if(name==null)name="New Profile";ae_prompt(bD,"Please enter a new profile name (up to 20 characters long).",name);};function bD(name){if(name==null||name=="")return;if(IsProfileNameUsed(name)){alert("The chosen profile name is already in use. Please type a new profile name.");aC(name);return;}if(name.length>20){alert("The profile name must be at most 20 characters long.");aC(name);return;}aA();var bS=aw();for(var newId=0;newId<500;++newId){if(bS.find("p"+newId)== -1)break;}var conf="p"+newId;bS.push(conf);ak("bS",ar(bS,","));ak(conf+"_name",name);az(conf);var list=document.getElementById("bZ");var cp=document.createElement("option");cp.value=conf;cp.text=name;var newIndex=list.options.length;list.options[newIndex]=cp;list.selectedIndex=newIndex;};function bx(){var list=document.getElementById("bZ");var option=list.options[list.selectedIndex];var name=option.text;var answer;if(list.value=="def")answer=confirm("Are you sure that you wish to reset the default profile?");else answer=confirm("Are you sure that you wish to reset the default profile?");if(!answer)return;aW(list.value);if(list.value!="def")list.remove(list.selectedIndex);list.selectedIndex=0;be();az("cur");};function bz(){bq();be();az("cur");am();};function be(){aA();var conf=document.getElementById("bZ").value;var from=GetConfigDate(conf,0,baseDateSlideYears);$('#date_slider').slider('values',0,SliderFromDate(from));$('#date_from').datepicker('setDate',from);var to=GetConfigDate(conf,1,today);$('#date_slider').slider('values',1,SliderFromDate(to));$('#date_to').datepicker('setDate',to);DisplayFromDate(SliderFromDate(from));if(aJ(conf,true))document.getElementById("incexctype_2").checked=true;else document.getElementById("incexctype_1").checked=true;ap(conf);as(conf);aG(conf);aH(conf);aF(conf);};function bO(){var bS=aw();var conf="h1";if(bS.find(conf)== -1){bS.push(conf);ak(conf+"_name","Social Networking");ak(conf+"_onlysites","2");ak(conf+"_selsites","li,fa,tw,fr,my,bl");}conf="h2";if(bS.find(conf)== -1){bS.push(conf);ak(conf+"_name","Document Files");ak(conf+"_filetypes","pdf,ps,doc,rtf");}ak("bS",ar(bS,","));};function bt(keyword){for(var i=0;i<suggestKeys.length;++i)if(suggestKeys[i]==keyword)return true;return false;};function bw(keyword){if(bt(keyword)){ax();return;}suggestKeys.push(keyword);suggestions[keyword]=new Array();var url='http://www.google.com/complete/search?hl=en&client=suggest&js=true&q='+encodeURIComponent(keyword);if(document&&document.getElementsByTagName){var script=document.createElement('script');script.src=url;script.type='text/javascript';var head=document.getElementsByTagName('head')[0];head.appendChild(script);}};google = { ac: { h: function(results)
{
if (keyword === undefined) { var keyword = document.getElementById("q").value; }

   bm(keyword);
 
   // Add in these new suggestions
   var words = suggestions[keyword];

   results[1] = results[1].toString();

var resultWords = results[1].split( "," );

for( var iRes = 0; iRes < resultWords.length; ++iRes )
{
 if( words.find(resultWords[iRes]) == -1 && !/\d/.test(resultWords[iRes]))
 {
  words.push( resultWords[iRes] );
 }
}
   
   ax();
}}};

function bm(keyword){if(keyword.length!=0&&keyword.charAt(keyword.length-1)==" ")keyword=keyword.substr(0,keyword.length-1);while(true){if(keyword.length==0||keyword.charAt(keyword.length-1)==" ")return;keyword=keyword.substr(0,keyword.length-1);if(keyword.length==0||keyword.charAt(keyword.length-1)==" ")return;var i=suggestKeys.find(keyword);if(i== -1)continue;suggestKeys.splice(i,1);}};var lastSearchText="";var timerId=setInterval("aB()",500);function aB(){if(lastSearchText==document.getElementById("q").value)return;lastSearchText=document.getElementById("q").value;if(lastSearchText==""){suggestKeys=new Array();suggestions=new Array();ax();return;}bw(lastSearchText);};function ax(){var allWords=new Array();for(var i=suggestKeys.length-1;i>=0;--i){var keyword=suggestKeys[i];var suggestWords=suggestions[keyword];if(!suggestWords||suggestWords.length==0)continue;for(var iWord=0;iWord<suggestWords.length;++iWord){if(allWords.find(suggestWords[iWord])== -1)allWords.push(suggestWords[iWord]);}}allWords.sort();var suggestDivb=document.getElementById("bW");var queryWords=document.getElementById("q").value.split(" ");var suggestHtml="";for(var i=0;i<allWords.length;++i){suggestHtml+="<a ";if(queryWords.find(allWords[i])!= -1)suggestHtml+="class=\"word_used\" ";else if(queryWords.find("-"+allWords[i])!= -1)suggestHtml+="class=\"word_excluded\" ";else suggestHtml+="class=\"word_norm\" ";suggestHtml+="href=\"javascript:bu('"+allWords[i]+"')\">"+TextToHtml(allWords[i])+"</a>";suggestHtml+=" . ";}if(suggestHtml.length>3){suggestHtml=suggestHtml.substr(0,suggestHtml.length-3);suggestHtml='<div class="dc">Click a word to <font color="#00BB00">add</font> it to the search query. Click a word twice to <font color="#CC0000">exclude</font> search results that mention it:</div>'+'<div style="height:8px"></div>'+suggestHtml;suggestHtml='<table border="0" cellspacing="0" cellpadding="0" width="100%" height="100%"><tr><td>'+suggestHtml+"</td></tr></table>";}suggestDivb.innerHTML=suggestHtml;};function bu(word){var queryWords=document.getElementById("q").value.split(" ");var i=queryWords.find(word);if(i!= -1){queryWords[i]="-"+word;}else{i=queryWords.find("-"+word);if(i!= -1){queryWords.splice(i,1);}else if(queryWords.length>0&&queryWords[queryWords.length-1]==word.substr(0,queryWords[queryWords.length-1].length)){queryWords[queryWords.length-1]=word;}else{queryWords.push(word);}}var queryString="";for(var i=0;i<queryWords.length;++i){queryString+=queryWords[i];if(i!=(queryWords.length-1))queryString+=" ";}document.getElementById("q").value=queryString;am();aB();ax();};function bL(){var engine=document.getElementById("engine_list").value;ak("engine",engine);if(engine=="live"){document.getElementById("date_range").style.display='none';document.getElementById("ca").style.display='none';}else{document.getElementById("date_range").style.display='block';document.getElementById("ca").style.display='inline';}am();};function bM(){var engine=aj("engine");if(!engine)return;var list=document.getElementById("engine_list");for(var i=0;i<list.options.length;++i){if(list.options[i].value==engine){list.selectedIndex=i;return;}}};function aV(conf){var region=document.getElementById("region").value;ak(conf+"_region",region);am();};function aZ(conf){var lang=document.getElementById("language").value;ak(conf+"_lang",lang);am();};function aX(conf){var zip=document.getElementById("zip_text").value;ak(conf+"_zip",zip);am();};function bb(){document.getElementById("cK").style.display='block';document.getElementById("region").focus();};function bB(){aT();aV("cur");StarSelectedProfile();};function bC(){};function bd(){document.getElementById("language_sel_cont").style.display='block';document.getElementById("language").focus();};function bH(){aS();aZ("cur");StarSelectedProfile();};function bE(){};function bI(zip){if(zip==null)zip="";ae_prompt(bg,'Please enter a ZIP Code, Postal Code, or City (ex. 90210):',zip);};function bg(zip){if(zip==null)return;if(zip.length>30){alert("Please enter a valid ZIP or Postal Code or City.");return;}if(zip!="")document.getElementById("zip_text").value=zip;else document.getElementById("zip_text").value=anyCity;aX("cur");StarSelectedProfile();am();};function aG(conf){var region=aj(conf+"_region");if(region==null)region="";var cn=document.getElementById("region").options;for(var i=0;i<cn.length;++i){if(cn[i].value==region){cn.selectedIndex=i;break;}}aT();};function aT(){var list=document.getElementById("region").options;document.getElementById("cN").innerHTML='<a class="drop_link" href="#" onclick="bb();return false;">'+list[list.selectedIndex].text+'</a>';};function aH(conf){var lang=aj(conf+"_lang");if(lang==null)lang="";var langList=document.getElementById("language").options;for(var i=0;i<langList.length;++i){if(langList[i].value==lang){langList.selectedIndex=i;break;}}aS();};function aS(){var list=document.getElementById("language").options;document.getElementById("language_link").innerHTML='<a class="drop_link" href="#" onclick="bd();return false;">'+list[list.selectedIndex].text+'</a>';};function aF(conf){var zip=aj(conf+"_zip");if(zip==null)zip=anyCity;};function am(){clearInterval(timerId);aB();var engine="google";var submitUrl;submitUrl="q="+encodeURIComponent(document.getElementById("q").value);var zip=document.getElementById("zip_text").value;if(zip!=null&&zip!=""&&zip!=anyCity)submitUrl+=encodeURIComponent(" "+zip);if(engine=="google"){var fromDate=GetDateFrom();var toDate=GetToDate();if(!fromDate&&toDate)fromDate=new Date(1970,1,1);if(fromDate&& !toDate)toDate=new Date();if(fromDate&&toDate){submitUrl=submitUrl+encodeURIComponent(" daterange:"+Math.floor(calculateJD(fromDate))+"-"+Math.floor(calculateJD(toDate)));}}var custSites=au();if(document.getElementById("incexctype_2")==undefined|| !document.getElementById("incexctype_2").checked){for(var i=0;i<incExcSites.length;++i){var img=document.getElementById(incExcSites[i][0]);if(img!=undefined){if(GetElementClass(img)=="searchsite_red")submitUrl=submitUrl+" -site:"+encodeURIComponent(incExcSites[i][2]);}}for(var i=0;i<custSites.length;++i){var img=document.getElementById("custsite_"+i);if(img!=undefined){if(GetElementClass(img)=="searchsite_red")submitUrl=submitUrl+" -site:"+encodeURIComponent(custSites[i]);}}}else{for(var i=0;i<incExcSites.length;++i){var img=document.getElementById(incExcSites[i][0]);if(GetElementClass(img)=="searchsite_green")submitUrl=submitUrl+" site:"+encodeURIComponent(incExcSites[i][2])+" OR";}for(var i=0;i<custSites.length;++i){var img=document.getElementById("custsite_"+i);if(GetElementClass(img)=="searchsite_green")submitUrl=submitUrl+" site:"+encodeURIComponent(custSites[i])+" OR";}if(submitUrl.substr(submitUrl.length-3,3)==" OR")submitUrl=submitUrl.substr(0,submitUrl.length-3);}for(var i=0;i<filetypes.length;++i){var img=document.getElementById("filetype_"+filetypes[i][0]);if(GetElementClass(img)=="bY")submitUrl=submitUrl+" filetype:"+filetypes[i][0]+" OR";}var customTypes=at();for(var i=0;i<customTypes.length;++i){var img=document.getElementById("filetype_"+customTypes[i]);if(GetElementClass(img)=="bY")submitUrl=submitUrl+" filetype:"+customTypes[i]+" OR";}if(submitUrl.substr(submitUrl.length-3,3)==" OR")submitUrl=submitUrl.substr(0,submitUrl.length-3);submitUrl+="&num="+document.getElementById("ca").value;var region=document.getElementById("region").value;if(region!="")submitUrl+="&cr="+region;var lang=document.getElementById("language").value;if(lang!="")submitUrl+="&lr="+lang;submitUrl+="&cx="+encodeURIComponent(document.getElementById("cx").value);submitUrl+="&cof="+encodeURIComponent(document.getElementById("cof").value);submitUrl+="&ie="+encodeURIComponent(document.getElementById("ie").value);$("iframe[name='googleSearchFrame']").attr('src',"http://www.google.com/cse?"+submitUrl+"&incexctype=only&ad=w9&num=10&rurl="+getBaseUrl()+"/index.html?"+submitUrl+"");if(document.getElementById("q").value!=''){$("iframe[name='googleSearchFrame']").height(document.getElementById("ca").value*90);jQuery.each(jQuery.browser,function(i,val){if(i=="safari"&&val==true)$("iframe[name='googleSearchFrame']").height(document.getElementById("ca").value*110);});}};function getBaseUrl(){documentBasePath=document.location.href;if(documentBasePath.indexOf('?')!= -1)documentBasePath=documentBasePath.substring(0,documentBasePath.indexOf('?'));documentBasePath=documentBasePath.substring(0,documentBasePath.lastIndexOf('/'));return(documentBasePath);};function resetDate(){numSlideYears=20;numSlideMonths=10*12;if(today.getMonth()<=4)numSlideMonths-=(4-today.getMonth());else numSlideMonths+=(today.getMonth()-4);baseDateSlideDays=new Date(today.getFullYear(),today.getMonth(),1);numSlideDays=today.getDate();for(var i=0;i<4;++i){baseDateSlideDays.prevMonth();numSlideDays+=DaysInMonth(baseDateSlideDays.getFullYear(),baseDateSlideDays.getMonth());}baseDateSlideMonths=new Date(baseDateSlideDays);for(var i=0;i<numSlideMonths;++i)baseDateSlideMonths.prevMonth();baseDateSlideYears=new Date(baseDateSlideMonths.getFullYear()-numSlideYears,0,1);if(document.getElementById("q").value==""){bX="def";document.getElementById("bZ").selectedIndex=0;}SetRangeSince(400,0);aY("cur",bX);$('#date_from').datepicker({changeMonth:true,changeYear:true,dateFormat:dateFormatString,minDate:baseDateSlideYears,onClose:function(newDate){OnPickDate(0,1,newDate);}});var from=new Date(baseDateSlideYears);var defaultFromDate=GetConfigDate(bX,0,from);$('#date_from').datepicker('setDate',defaultFromDate);$('#date_to').datepicker({changeMonth:true,changeYear:true,dateFormat:dateFormatString,minDate:baseDateSlideYears,onClose:function(newDate){OnPickDate(1,0,newDate);}});var defaultToDate=GetConfigDate(bX,1,today);$('#date_to').datepicker('setDate',defaultToDate);$("#date_slider").slider({range:true,min:0,max:(numSlideYears+numSlideMonths+numSlideDays),values:[SliderFromDate(defaultFromDate),SliderFromDate(defaultToDate)]});DisplayFromDate(SliderFromDate(defaultFromDate));$('#date_slider').bind('slide',function(event,ui){var fromDate=DateFromSlider(ui.values[0]);var toDate=DateFromSlider(ui.values[1]);$('#date_to').datepicker('setDate',toDate);SetConfigDate("cur",1,toDate);DisplayFromDate(ui.values[0]);$('#date_from').datepicker('setDate',fromDate);SetConfigDate("cur",0,fromDate);StarSelectedProfile();return true;});}