﻿
//           ------------------------------------------------------------------------------  "Keep in Touch"  -  On/Off
var KITsw = "";
function KIT() {
   if (KITsw == "1") {  clearInterval(KITinterv);
                               KITsw = "";
                               KITWin=window.open('icons/V.gif','KeepInTouch','left=0,top=0,width=110,height=110');
                               window.setTimeout('KITWin.close()',1000);  }
   else  {  KITWin=window.open('http://jove.prohosting.com/sooliman/icons/SFnwBIG.gif','KeepInTouch','left=0,top=0,width=110,height=110');
              window.setTimeout('KITWin.close()',1000);
              KITinterv=window.setInterval("KITLoadImg()",576000);
//   //   //  KITinterv=window.setInterval("KITLoadImg()",1150000);
              KITsw = "1";  }
}
function KITLoadImg() {
   KITWin=window.open('http://jove.prohosting.com/sooliman/' + Math.random()*Math.pow(10,18).toString() + '.gif','KeepInTouch','left=0,top=0,width=110,height=110');
   KITWin=window.open('http://jove.prohosting.com/sooliman/icons/SFnw.gif','KeepInTouch','left=0,top=0,width=110,height=110');
   window.setTimeout('KITWin.close()',1000);
// document.images["SFNewWin"].src = "http://jove.prohosting.com/sooliman/" + Math.random()*Math.pow(10,18).toString() + ".gif";       // nonexistent.gif";
// onerror=window.status="";
// document.images["SFNewWin"].src = "http://jove.prohosting.com/sooliman/icons/SFnw.gif";
}

var HebrewAlphabet = "אבגדהוזחטיךכלםמןנסעףפץצקרשת";                                                                  //  Was also used in TransHem(), now only in  online_infout().
var HebrewUTF8 =      "909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AA";       //  UTF-8
var HebrewOLD  =      "E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF0F1F2F3F4F5F6F7F8F9FA";

var HebrewANikud =   "כְכֱכֲכֳכִכֵכֶכַכָכֹכּכֻ"                                                                                            // Nikud characters
var HebrewUNikud =   "B0B1B2B3B4B5B6B7B8B900BBBC";                                                         //  Nikud characters in UTF-8 (Exccept "SHIN" points)

var LowLatinEBCDIC = "&abcdefghijklmnopqrstuvwxyz";                                                                 //  Was used in TransHem(), now kept just in case.

//           ------------------------------------------------------------------------------  Baby Lon
function online_infout() {
  if (window.babylWin)  babylWin.close();
  var winH =334;
  var winD=screen.height-58-winH;
  babylWin=open("", "online", "menubar=0,toolbar=0,scrollbars=0,width=256,height="+winH+",left=0,top="+winD);
  babylWin.document.write("<html><head><title>Babylon online</title></head>");        // --  No body for the big city  ------------------------------------------------------------------------  -->
  babylWin.document.write("</body></html>");                                                           // --  No body for the big city  ------------------------------------------------------------------------  -->
  if (HebrewAlphabet.indexOf(document.onlineForm.showord.value.substr(0,1)) >= 0) {
     document.onlineForm.word.value = "";
     for (i = 0; i < document.onlineForm.showord.value.length; i++) {
          j = document.onlineForm.showord.value.length - 1 - i;
         document.onlineForm.word.value = document.onlineForm.word.value + document.onlineForm.showord.value.substr(j,1); } }
  else document.onlineForm.word.value = document.onlineForm.showord.value;
  online_info();
}

var pageloading=1;

//                     Center the window or open link in a new (centered) window
function MyWin(NeWin) {
  var winW = screen.width*0.81;
  var winH  = screen.height-58-(screen.height-58)*0.0662;
  var winD= screen.height*0.0456;
  var winL=(screen.width-winW)/2;
  if (NeWin != "") {
    if (NeWin.substr(3,4).indexOf(':') !=-1)  NewProt = "";
    else  NewProt= "http://";
    window.open(NewProt + NeWin , "",
    "width=" + winW + ",height=" + winH + ",directories,location,menubar,resizable,status,toolbar,scrollbars,left=" + winL + ",top=" + winD);
  }
  else {
    self.resizeTo(winW,winH);
    self.moveTo(winL,winD);
    if (pageloading == 1) history.go(0);  }
}

//           ------------------------------------------------------------------------------  animating the Dalmatian
Dalmatian1 =  new Image (76, 45);
Dalmatian2 =  new Image (76, 45);
Dalmatian1.src =  "images/DalmatImg.gif"
Dalmatian2.src =  "images/SFlanekDog.gif"
var Dalstate=1;
function Dalmate() {
  if (Dalstate==2) { document.images['Dalmatian'].src="images/DalmatImg.gif"; Dalstate=1; }
  else                   { document.images['Dalmatian'].src="images/SFlanekDog.gif"; Dalstate=2; }
}

//           ------------------------------------------------------------------------------  moving Sherlock
var tempos = 0, temperd = 0, ScrollTimer = "", ScrollPerd = "";
function scrollInvk() {
if (temperd == 0)  { ScrollTimer = setInterval("scrollBG(197)", 100);  temperd = 1; }
else { clearInterval(ScrollTimer); temperd = 0; }
}
function scrollBG(gifSize) {
tempos = tempos +1;
if (tempos > gifSize) tempos = 0;
document.body.style.backgroundPositionX = tempos;
}

//           --------------------------------------------------------------------------------- Poster window
function centerPoster() {
  if (screen.height<710) {                                    // 710 = 768 - 58
      winH = screen.height-58; }
  else    winH = 710;
  var winL=(screen.width-548)/2;
  posName=window.open("SFposter.html","_blank","top=0,left="+winL+",width=548,height="+winH+",menubar=no,scrollbars=1,statusbar=no,resizable=1");
}

//           --------------------------------------------------------------------------------- Poster Story window
function centerPostory() {
  if (screen.height<605) {                                    // 605 = 630 + 33 - 58
      winH = screen.height-33-58; }
  else    winH = 630;
  var winL=(screen.width-760)/2;
  posName=window.open("SFpostory.html","_blank","top=33,left="+winL+",width=760,height="+winH+",menubar=no,scrollbars=yes,statusbar=no,resizable=1");
}

//                     Search for a non-whitespace char. If found return false, else - true.
function nullcheck(s) {
  if (s=="") return false;
  var i; for (i = 0; i < s.length; i++) {var c = s.charAt(i); if (c != " ") return true;}
  return false; }


var HebIsots = ";/'קראטוןםפשדגכעיחלךף,זסבהנמצתץ.";
var EngIsots = "`qwertyuiopasdfghjkl;'zxcvbnm,./";
var trsw;

function TransHeb() {
  document.transtext.lattext.value = '';
  if (trsw == "eng")   {
  var i; for (i = 0; i < document.transtext.hebtext.value.length; i++) {
    j = HebIsots.indexOf(document.transtext.hebtext.value.substr(i,1));
    if (j < 0)  document.transtext.lattext.value = document.transtext.lattext.value + document.transtext.hebtext.value.substr(i,1);
    else       document.transtext.lattext.value = document.transtext.lattext.value + EngIsots.substr(j,1); }  }
  else  {
  var i; for (i = 0; i < document.transtext.hebtext.value.length; i++) {
    j = EngIsots.indexOf(document.transtext.hebtext.value.substr(i,1));
    if (j < 0)  document.transtext.lattext.value = document.transtext.lattext.value + document.transtext.hebtext.value.substr(i,1);
    else       document.transtext.lattext.value = document.transtext.lattext.value + HebIsots.substr(j,1); }  }
}

//           --------------------------------------------------------------------------------- ccTLD ///////////////////////////////////////////////////////////////////////////
//function findTLD() {
//  if (!nullcheck(fTLD.tldn.value)) return false;
//    location.href = "http://www.iana.org/root-whois/" + fTLD.tldn.value + ".htm";
//    return false;
//}

//           --------------------------------------------------------------------------------- WIKI
function whichwiki(mode) {
  if (isHebrew(searchform.search.value)) wikiname='he.wikipedia.org/wiki/';
  else  wikiname='en.wikipedia.org/wiki/';
  if (mode=='go') goAct(wikiname, searchform.search.value);
  else  goAct(wikiname + 'Special:Search?fulltext=Sch&search=', searchform.search.value);
  return false;
}

//           --------------------------------------------------------------------------------- Opening KALUACH window
function srchonCenter(url,nom,honW,honH,options) {
  var winD=(screen.height-honH)/2-screen.height*0.025;
  var winL=(screen.width-honW)/2;
  winName=window.open(url,nom,"top="+winD+",left="+winL+",width="+honW+",height="+honH+","+options);
}

//function Kullcheck() {                                                                                        // Not used in current SFhomarks   ======///////////////////////////////////////////
//  if (nullcheck(Ksearch.query.value)) {
//     document.Ksearch.submit(); }
//}

//                       If a Hebrew letter found submit to google.co.il, alse - to google.com.   Add  /  to the end of the argument to reverse the selection.
function SelectGoogle(sin) {
     if (!nullcheck(fGGL.q.value)) return false;
     DomainCC="com";
     Lang = "hl=en";
     reversel = document.fGGL.q.value.substr(fGGL.q.value.length-1,1) == '/';
     if (reversel) document.fGGL.q.value = fGGL.q.value.substr(0,document.fGGL.q.value.length-1);
     if (isHebrew(document.fGGL.q.value))  { DomainCC = "co.il";  Lang = "hl=iw"; }
     if (reversel) if  (DomainCC == "com")  { DomainCC = "co.il";  Lang = "hl=iw"; }
                     else { DomainCC = "com";  Lang = "hl=en"; }
     if (sin == 's') { host = "www.";  qmark = "/search?"; }
     else
        if (sin == 'i') { host = "images.";  qmark = "/images?"; }
        else            { host = "news.";  qmark = "/news?"; }
     goAct(host + "google." + DomainCC + qmark + Lang + "&scoring=d&q=", setUTF8(fGGL.q.value));
}

//           ---------------------------------------------------------------------------------   Convert to UTF-8 (?)
function setUTF8(arg) {
  if (!nullcheck(arg)) return false;
  var p = '';
  var i; for (i = 0; i < arg.length; i++)  { 
          if (arg.charAt(i) == ' ') p = p + '%20';
          else  if (arg.charAt(i) >= 'א' && arg.charAt(i) <= 'ת') { 
                     j = HebrewAlphabet.indexOf(arg.charAt(i));
                     p = p + '%D7%' + HebrewUTF8.substr(j*2, 2); }
                  else  { n = arg.charCodeAt(i).toString(10);
                            if (n >= 1456 && n <= 1468 && n != 1466) { 
                               j = n - 1456;
                               j = j * 2;
                               p = p + '%D6%' + HebrewUNikud.substr(j, 2); }
                            else if (n == 1473) p = p + '%D7%81';
                                   else if (n == 1474) p = p + '%D7%82';
                                          else if (arg.charAt(i) == '+') p = p + '%2B';                   // plus sign ('+') is handled separately
                                                 else p = p + arg.charAt(i); } }
  return(p);
}

//           ---------------------------------------------------------------------------------   Perform the "onSubmit"
function goAct(URL, arg) {
  p = URL + arg;
  checkShift(event, p);
  return false;
}
function checkShift(event, p)  {
  if (event.shiftKey){ window.open('http://' + p)  }
  else                     {  location.href = 'http://' + p;  }
}

//           --------------------------------------------------------------------------------- Perform the "onSubmit" for ANSI ? ? ? *** ? ? ?
function goANSI(URL, arg) {
  ANString ='';
  for (i = 0; i < arg.length; i++) {
      if (arg.substr(i,1) == ' ') { ANString = ANString + '+'; continue;}
      j = HebrewAlphabet.indexOf(arg.substr(i,1));
      ANString = ANString + '%' + HebrewOLD.substr(j*2, 2); }
  p = URL + ANString;
  checkShift(event, p);
  return false;
}

//           --------------------------------------------------------------------------------- Morfix search / dictionary
function setact(url) {
  if (!nullcheck(form1.n.value)) return false;
  Ma = url + ".morfix.co.il/";
  if (url == "www") {
     Mp = 'Default.aspx?matchMode=';
     if  (form1.num[0].checked)  Mp = Mp + "106";
     else  if  (form1.num[1].checked)  Mp = Mp + "101";
             else  if  (form1.num[2].checked)  Mp = Mp + "104";
                     else  if  (form1.num[3].checked)  Mp = Mp + "103";  }
  else Mp='?';
  goAct(Ma + Mp + "&q=", form1.n.value);
  return false;
}

//           --------------------------------------------------------------------------------- Wayne Magnuson has been removed.
//   Wayne Magnuson exists now ONLY in the Web Archive:  http://web.archive.org/web/20041126053057/http://home.t-online.de/home/toni.goeller/idiom_wm/

//           ------------------------------------------------------------------------- Bartleby's Dictionary word search  ///////////////////////////////////////////////////////
//function googlbartl() {
//  if (nullcheck(bartf1.query.value)) {
//     bartf2.as_q.value = bartf1.query.value + ' "American Heritage"';
//     return true;}
//  else return false;
//}

//           ------------------------------------------------------------------------- RAV-MILIM in a new window
var ravmipss = '';
function ravmiling() {
var pss=document.frmEntrance.txtPass.value;
if (location == "file:///C:/sf/SFhomarks.html" && pss == '' && frmEntrance.ravmilpss.value != '') pss = frmEntrance.ravmilpss.value;
if (pss.length < 2 || pss.length != pss.indexOf(pss.length) + 2) open("http://www.ravmilim.co.il/");
else {
   var winH =228;
   var winD=screen.height-58-winH;
   var parmilim="menubar=0,toolbar=0,scrollbars=0,status=0,resizable=1,width=796,height="+winH+",left=0,top="+winD;
   var usr="soolyman@017.net.il"; var rmP=document.frmEntrance.remPass.value;
   ravWin=open("http://www.ravmilim.co.il/naerr.asp?go=לרב-מילים&txtUser=" + usr +"&txtPass=" + pss + "&remPass=" + rmP, "RAVMILIM", parmilim);
   frmEntrance.ravmilpss.value = pss; }
}

//           -------------------------------------------------------------------------  goldword
var GWnewwin = null;
function GWtranslate() {
if (!nullcheck(gwolform.p.value)) return true;
if (GWnewwin != null) {
   GWnewwin.close();  }
var h=(isHebrew(document.gwolform.gwolp.value));
document.gwolform.gwolfl.value=h?"6":"0";
document.gwolform.gwoltl.value=h?"0":"6";
var winW=295, winH=300;
var winD=screen.height-58-winH, winL=screen.width-8-winW;
GWnewwin=window.open("about:blank", "goldword", "scrollbars=no,status=no,width="+winW+",height="+winH+",top="+winD+",left="+winL)
document.gwolform.gwolq.value=escape(document.gwolform.gwolp.value);
document.gwolform.submit();
if (GWnewwin != null) {
   GWnewwin.document.focus(); }
return false;
}

//           --------------------------------------------------------------- acronymfinder
function acronymfind() {
  if (nullcheck(findform.Acronym.value))
      if (findform.String.options[findform.String.selectedIndex].value == 'exact')
          goAct('www.acronymfinder.com/af-query.asp?Acronym=', findform.Acronym.value);
      else  goAct('www.acronymfinder.com/af-query.asp?String=on&Acronym=', findform.Acronym.value);
}

//           --------------------------------------------------------------- KIZURfinder
function kizurfind() {
  if (findform.String.options[findform.String.selectedIndex].value == 'exact')
      goAct('www.kizur.co.il/search_word.php?searchby=abbr&abbr=', abbrev.abbr.value);
  else  goAct('www.kizur.co.il/search_word.php?searchby=meaning&abbr=', abbrev.abbr.value);
}

//           --------------------------------------------------------------- Reference.com
function whichref() {
  if (!nullcheck(ft.q.value)) return false;
  for (i = 0; i < 3; i++) {
       if (ft.db[i].checked) goAct(ft.db[i].value + ".reference.com/browse/", ft.q.value) }
  return false;
}

//           --------------------------------------------------------------- Merriam-Webster
function MerriamWebster(){
if (nullcheck(query_list.va.value))
   if (query_list.mySelect[0].checked)
        goAct('www.merriam-webster.com/dictionary/', query_list.va.value);
   else goAct('www.merriam-webster.com/thesaurus/', query_list.va.value);
}

//           --------------------------------------------------------------- Multiple Form Clear
function multiClear(F1, F2) {
document.forms[F1].reset();
if (F2 != '') document.forms[F2].reset();
//                                                        Deleted:  if (F3 != '') document.forms[F3].reset();
}

//           --------------------------------------------------------------------------- Flip Hebrew
var flipSW = 0;
function FlipHebrew() {
// alert (b_vers + ' ' + flipSW);
  if (flipSW != 1) {
    if (b_vers < 5.5) { document.getElementById('areanm').rows=1; }
    flipSW = 1;
    if (b_vers >= 5.5) document.styleSheets[0].addRule("td.flipheb", "display:inline"); }
  else {
    if (b_vers < 5.5) { document.getElementById('areanm').rows=10; }
    flipSW = 0;
    if (b_vers >= 5.5) document.styleSheets[0].addRule("td.flipheb", "display:none");  }
}
function FlipText(input_text){
   var len = input_text.length; var nTest = "";
   if (! isHebrew(input_text))  nTest = input_text;
   else {
      for ( var i=0 ; i<len ; ++i) {
         var c = input_text.charAt(i);  nTest = c + nTest;} }
   return nTest;
}

//           --------------------------------------------------------------------------- isHebrew: If Hebrew return true
function isHebrew(input_text){
   var Heb = false;
   var len = input_text.length;
   for ( var i=0 ; i<len ; ++i) {
      var c = input_text.charAt(i);
      if ((c >= 'א') && (c <= 'ת'))  Heb = true;
      if (Heb)  break;}
   return Heb;
}

//           --------------------------------------------------------------------------- StartFlip
function StartFlip() {
   var newval="" , newline="" , lastLine='' , nTest = "";
   var val=document.flipf.areanm.value;
   var len=val.length;
   for ( var i=0 ; i<len ; ++i) {
        var c=val.charAt(i) ;
        var c0=val.charAt(i+1) ;
        if ( (c=='\r' && c0=='\n')) {
             if ( newval.length==0 )  newval = FlipText(nTest) + newline;
             else  if (lastLine.length == 0)  newval = newval + "\r\n" + FlipText(nTest) + newline;
                     else  newval = newval + "\r\n" + FlipText(nTest) + cutEndSpace(newline);
             lastLine = FlipText(nTest) + newline;
             newline="" ;
             nTest = "";
             ++i;  }
        else {
             if (c != ' ')  nTest = nTest + c;
             else {
                 newline = ' ' + FlipText(nTest) + newline;
                 nTest = "";  }  }  }
   if ( newval.length==0 )  newval = FlipText(nTest) + newline;
   else  if (lastLine.length == 0)  newval = newval + "\r\n" + FlipText(nTest) + newline;
           else  newval = newval + "\r\n" + FlipText(nTest) + cutEndSpace(newline);
   document.flipf.areanm.value=newval;
}
function cutEndSpace(line){
   var c = line.charAt(0);
   return line;
}

//           ------------------------------------------------------------------------- Automotive Terms
function autochar() {
   autosuff = (motorm.firstchar.value=='') ? '' : motorm.firstchar.value+'a.htm';
   goAct('www.motorera.com/dictionary/', autosuff);
}

//           ------------------------------------------------------------------------- W3Schools
function subw3s(subj) {
  w3s.action = "www.google.com/search";
  var w3site = "www.w3schools.com";
  var w3sURL = w3site;
  var w3sBlank = ! nullcheck(w3s.shown_q.value);
  switch(subj) {
  case 1: if (w3sBlank) goAct(w3sURL, "/tags/default.asp");
              else {w3s.q.value = "intitle:" + w3s.shown_q.value + " site:" + w3site + " inurl:tags"; goAct(w3s.action + "?q=", w3s.q.value);} break;
  case 2: if (w3sBlank) goAct(w3sURL, "/css/css_reference.asp");
              else {w3s.q.value = "intitle:" + w3s.shown_q.value + " site:" +  w3site + " inurl:css"; goAct(w3s.action + "?q=", w3s.q.value);} break;
  case 3: if (w3sBlank) goAct(w3sURL, "/jsref/default.asp");
              else {w3s.q.value = w3s.shown_q.value +  " site:" + w3site +  " inurl:jsref OR inurl:js"; goAct(w3s.action + "?q=", w3s.q.value);} break;
  case 4: if ( ! w3sBlank)  {w3s.q.value = w3s.shown_q.value +  " site:" + w3site; goAct(w3s.action + "?q=", w3s.q.value);}
              else w3s.action="javascript:;"; break;
  default: goAct(w3sURL, '') }
}

//           ------------------------------------------------------------------------- Ynet calendar variables
function YnetCal() {
  var SFdate = new Date(), SFyear = SFdate.getFullYear();
  var YnetURL = 'http://go.ynet.co.il/long/content/'+SFyear+'/encCalendar';
  window.open(YnetURL,'YnetCal','toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,width=740,height=590,left=0,top=0');
}

//           ------------------------------------------------------------------------- Open Radio FAZ window
function LoadRadio() {
  var winW = 324;
  var winH  = 200;
  var winT= screen.height-winH-60;
  var winL=(screen.width-winW-9);
    window.open("http://www.faz.co.il/static/radio/main.htm", "fazrad",
                        "width=" + winW + ",height=" + winH + ",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0,resizable=1,left=" + winL + ",top=" + winT);
  }

//           ------------------------------------------------------------------------- Open CNN Radio window
function LoadCNN() {
  var winW = 355;
  var winH  = 222;
  var winT= screen.height-winH-57;
  var winL=(screen.width-winW-9);
    window.open("http://www.cnn.com/audio/radio/cnntv.html", "CNN",
                        "width=" + winW + ",height=" + winH + ",directories=0,location=0,menubar=0,scrollbars=0,status=0,toolbar=0,left=" + winL + ",top=" + winT);
  }

//           -------------------------------------------------------------------------  Nikud (inline)
function Add2Str(str) {
  if (document.selection) { nkdForm.q.focus(); sel = document.selection.createRange(); sel.text = str; }
  else { var startPos = nkdForm.q.selectionStart; var endPos = nkdForm.q.selectionEnd;
  nkdForm.q.value = nkdForm.q.value.substring(0, startPos) + str + nkdForm.q.value.substring(endPos, nkdForm.q.value.length); }
}


//           -------------------------------------------------------------------------  November 10, 2009 11:10