﻿function loadpage ()
{
showcookies ();
}

function setfocus(what)
{
document.getElementById(what).value = "";
}

function polclicked(what)
{
  document.location.href = "http://www.shoresh.org.il/spages/pol/main.aspx?vote=" + what;
}

function showmovie(url)
   {   
    var showit = '<object id=\"WMPlay\" width=\'282px\' height=\'200px\' classid=\"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" ';
    
    showit = showit + 'codebase =\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" ';
    showit = showit + 'standby=\"טוען את רכיב הצגת הסרט...\" type=\"application/x-oleobject\"> ';
    showit = showit + '<PARAM NAME=\"Fiyan150vleName\" VALUE=\"http://ttvv.tv/users/shoresh/videolessons/' + url + '\"> ';
    showit = showit + '<PARAM NAME=\"EnableFullScreenControls\" VALUE=\"1\"> ';
    showit = showit + '<PARAM NAME=\"DisplaySize\" VALUE=\"1\"> ';
    showit = showit + '<PARAM NAME=\"ShowControls\" VALUE=\"1\"> ';
    showit = showit + '<PARAM NAME=\"wmode\" VALUE=\"opaque\"> ';
    showit = showit + '<PARAM NAME=\"ShowStatusBar\" VALUE=\"0\"> ';
    showit = showit + '<PARAM NAME=\"ClickToPlay\" VALUE=\"1\"> ';
    showit = showit + '</object> ';

    document.getElementById("showvideotd").innerHTML = showit;
   }
   
function ShowTextInElement (element, text)
{
document.getElementById(element).innerHTML = text;
}

 function changemainvideo (i, movieName, Rabbi, Image, fileName)
 {
 for (var o=0; o<6; o++)
 {
    document.getElementById ("videoimage" + o).className = "videoimage";
}

    document.getElementById("videoimage" + i).className = "videoimageclicked";
    document.getElementById("textvideotd").innerHTML = movieName + "/ " + Rabbi;
    document.getElementById("showvideotd").innerHTML = "<IMG src='http://www.shoresh.org.il/usersfiles/hagimimages/big-" + Image + "' >"; 
    document.getElementById("showvideotd").onclick = function(){showmovie(fileName);};
    document.getElementById("textvideotd").onclick = function(){showmovie(fileName);};
 }
 
function opsclicked(what, img, text, id)
		{			
		if (what == 'firstop')
		{
		document.getElementById('firstop').className = "clickedtag";
		document.getElementById('secondop').className = "mainlink";
		}
		else
		{
		document.getElementById('secondop').className = "clickedtag";
		document.getElementById('firstop').className = "mainlink";
		}

		var str1
		str1 = "<IMG alt='' src='http://www.shoresh.org.il/usersfiles/wnimages/" + img + "'>"
		document.getElementById('opimage').innerHTML = str1;
		
		var str;
		str = "<A HREF='http://www.shoresh.org.il/spages/articles/main.aspx?ID=" + id + "' class='sublink'>" + text + "</A>"
		document.getElementById('optext').innerHTML = str;
	}
	
function changetext(i, header, url, subtext, image)
{
     document.getElementById("mainheadertext").innerHTML = header.replace(/qe/g, "\"").replace(/qe/g, "\'");
     document.getElementById("mainimageholder").innerHTML = "<IMG class = 'simpleimage' alt='" + header + "' src='http://www.shoresh.org.il/usersfiles/wnimages/" + image + "'>"
     document.getElementById("subtext").innerHTML = subtext.replace(/qe/g, "\"").replace(/qe/g, "\'");
     document.getElementById("mainheadertext").onclick = function(){moveto(url);};
     document.getElementById("mainimageholder").onclick = function(){moveto(url);};
     document.getElementById("subtext").onclick = function(){moveto(url);};
     document.getElementById("context").onclick = function(){moveto(url);};

      for (var o=0; o<4 ; o++ )
      {
        document.getElementById("leadlink" + o).className = "welcomeheader";
      }
     
      document.getElementById("leadlink" + i).className = "clickedlinks";
}

function changesublinks(s)
{
cleanrows();

Slide();

var arr = new Array;
var arr1 = new Array;

arr = createnamesarray(s);
arr1 = createlinksarray(s);

 var tbl = document.getElementById("sublinkstable");
		   var lastRow = tbl.rows.length;
           var row = tbl.insertRow(lastRow);
           var counter = 0;
            
          for (var i = 0; i < arr.length; i++) 
               
               {
                  var cell = row.insertCell(counter);
                  var inhtm;
                  inhtm = "<IMG src='http://www.shoresh.org.il/menu/icons/" + arr[i] + ".gif' height='20' alt='' width='20' border='0'>";
                  cell.innerHTML = inhtm;
                  
				  var cell2 = row.insertCell(counter + 1);
                  cell2.innerHTML = "&nbsp;";
                  cell2.className = "sepline";
                  cell2.Width = "1";
                  
                  var cell1 = row.insertCell(counter + 2);
                  cell1.innerHTML = "<a href='" + arr1[i] + "' class='sublink'>" + arr[i] + "</a>";
                  
                  counter = counter + 3;
                  
                  if (i == 3 || i == 7)
                  {  
                  counter = 0;                
                  lastRow = tbl.rows.length;
                  row = tbl.insertRow(lastRow);
                  }
               }           
}

function createnamesarray(s)
{
var str;

switch (s)
{
case 0:
str = "שורש- מגזין,כתבות,דעות,ערוצים,מאמרים,תקשורש,פרשת השבוע,למורים- בעין חינוכית";
break;
case 1:
str = "כל הקהילות,פורומים,חדרי דיונים,שיעורים אינטר,בלוגים,הירשם לאתר,ערוך פרטים אישיים,נקודות שורש";
break;
case 2:
str = "מילון עברי- אנגלי,המרת תאריכים,אלבום התמונות,כרטיסי ברכה,ייעוץ אינטרנטי,קידום אתרים,מפתחות הראיה";
break;
case 3:
str = "אלבום התמונות,מדריך אתרים,דפי החגים,מפתחות הרב קוק,כרטסת היהדות,אינדקס שאל את הרב,תאריך עברי";
break;
case 4:
str = "שיעורים קוליים,שיעורים בוידאו,שיעורים כתובים,הנצחות וברכות,פרשת שבוע,פרשת שבוע- קולי,דפי אבות ובנים,דף עמדה תורני,שיעורי תורה לבית";
break;
case 5:
str = "למד תורה בבית,אופי השיעורים,איך מצטרפים,רשימת הקורסים,דוגמאות משיעורים,רשימת השיעורים";
break;
case 6:
str = "לדואר- מערכת חדשה,לדואר- מערכת קודמת,פתח תיבה בשורש,פורום התמיכה בדואר,שכחתי סיסמא- שחזור";
break;
default:
str = "";
break;
}

var arr = new Array;
arr = str.split(',');

return arr;
}

function createlinksarray (s)
{
var str;

switch (s)
{
case 0:
str = "http://www.shoresh.org.il/spages/articles/,http://www.shoresh.org.il/spages/articles/main.aspx?what=%d7%9b%d7%aa%d7%91%d7%95%d7%aa,http://www.shoresh.org.il/spages/articles/main.aspx?what=%d7%93%d7%a2%d7%95%d7%aa,http://www.shoresh.org.il/spages/articles/main.aspx?what=%d7%a2%d7%a8%d7%95%d7%a6%d7%99%d7%9d,http://www.shoresh.org.il/spages/articles/main.aspx?what=%d7%9e%d7%90%d7%9e%d7%a8%d7%99%d7%9d,http://www.shoresh.org.il/spages/articles/main.aspx?what=%d7%a2%d7%a8%d7%95%d7%a6%d7%99%d7%9d&cut=%d7%aa%d7%a7%d7%a9%d7%95%d7%a8%d7%a9";
str = str + ",http://www.shoresh.org.il/spages/articles/main.aspx?what=%d7%9e%d7%90%d7%9e%d7%a8%d7%99%d7%9d&cut=%d7%a4%d7%a8%d7%a9%d7%aa+%d7%a9%d7%91%d7%95%d7%a2,http://www.shoresh.org.il/spages/articles/main.aspx?what=%d7%9e%d7%90%d7%9e%d7%a8%d7%99%d7%9d&cut=%d7%91%d7%a2%d7%99%d7%9f+%d7%97%d7%99%d7%a0%d7%95%d7%9b%d7%99%d7%aa";
break;
case 1:
str = "http://www.shoresh.org.il/spages/forums/,http://www.shoresh.org.il/spages/forums/main.aspx?type=forums,http://www.shoresh.org.il/spages/forums/main.aspx?type=discu,http://www.shoresh.org.il/spages/forums/main.aspx?type=lesso,http://www.shoresh.org.il/spages/blogs/,http://www.shoresh.org.il/spages/users/signup.aspx,http://www.shoresh.org.il/spages/users/main.aspx?id=3,http://www.shoresh.org.il/spages/users/shoreshpoints.aspx";
break;
case 2:
str = "http://www.shoresh.org.il/spages/dictionary/,http://www.shoresh.org.il/spages/dates/,http://www.shoresh.org.il/spages/album/main.aspx,http://www.shoresh.org.il/spages/greetings/,http://www.shoresh.org.il/spages/ads/main.aspx?ID=8,http://www.shoresh.org.il/spages/advertise/main.htm?p=3,http://www.shoresh.org.il/spages/maftehot/";
break;
case 3:
str = "http://www.shoresh.org.il/spages/album/main.aspx,http://www.shoresh.org.il/spages/sites/main.aspx?what=cut,http://www.shoresh.org.il/spages/hagim/,http://www.shoresh.org.il/spages/maftehot/,http://www.shoresh.org.il/spages/carteset/,http://search.shoresh.org.il/shutindex.aspx,http://www.shoresh.org.il/spages/dates/";
break;
case 4:
str = "http://www.shoresh.org.il/spages/voicelessons/main.aspx,http://www.shoresh.org.il/spages/videolessons/,http://www.shoresh.org.il/spages/forums/main.aspx?type=lesso,http://www.shoresh.org.il/spages/netsach/main.aspx,http://www.shoresh.org.il/spages/articles/main.aspx?cut=%d7%a4%d7%a8%d7%a9%d7%aa+%d7%a9%d7%91%d7%95%d7%a2,http://www.shoresh.org.il/spages/voicelessons/main.aspx?cut=%d7%a4%d7%a8%d7%a9%d7%aa+%d7%a9%d7%91%d7%95%d7%a2,http://www.shoresh.org.il/spages/fathersandsons/main.aspx,http://www.yeshiva.org.il/midrash/hmidrash.asp?cat=5,http://www.shoresh.org.il/spages/homeshoresh/";
break;
case 5:
str = "http://www.shoresh.org.il/spages/homeshoresh/main.aspx,http://www.shoresh.org.il/spages/homeshoresh/main.aspx?page=2,http://www.shoresh.org.il/spages/homeshoresh/main.aspx?page=3,http://www.shoresh.org.il/spages/homeshoresh/main.aspx?page=5,http://www.shoresh.org.il/spages/homeshoresh/main.aspx?page=6,http://www.shoresh.org.il/spages/homeshoresh/main.aspx?page=7,https://www.shoresh.org.il/spages/homeshoresh/sighup.aspx";
break;
case 6:
str = "http://newmail.shoresh.org.il/,http://mail.shoresh.org.il/mail/openwebmail.pl,http://www.shoresh.org.il/spages/mymail/main.aspx,http://www.shoresh.org.il/spages/forums/,http://www.shoresh.org.il/spages/mymail/forgotpass.aspx/";
break;
default:
str = "";
break;
}

var arr = new Array;

arr = str.split(',');

return arr;
}

function cleanrows()
{
 var tbl = document.getElementById("sublinkstable");
 var lastRow = tbl.rows;

 while(lastRow.length)
         tbl.deleteRow(lastRow - 1);
}

function replacetags(what, tablenum)
{
for (var i=0; i<4; i++)
{
document.getElementById("shimushitag" + i).className = "mainlink";
showhide("shimushitable" + i, "none");
}

document.getElementById(what).className = "clickedtag";
showhide("shimushitable" + tablenum, "block");
}

function showhide(what, hideorshow)
{
var ele = document.getElementById(what);

if (hideorshow == '')
{
if (ele.style.display == "none")
 {
 ele.style.display = "block";
 }
 else
 {
 ele.style.display = "none";
 }
 }
 else
 {
 ele.style.display = hideorshow;
 }
}

function closecontact ()
{
 top.window.location.reload(false);
}

function msg(what)
{
alert(what);

return false;
}

function videoover (i,text)
{
if (document.getElementById("videoimage" + i).className != "videoimageclicked")
{
mouseover('videoimage' + i, 'videoimageover');
}

document.getElementById("videotexttd").innerHTML = text;
}

function videoout(i)
{
if (document.getElementById("videoimage" + i).className != "videoimageclicked")
{
mouseout('videoimage' +i, 'videoimage');
}

document.getElementById("videotexttd").innerHTML = "";
}

function mouseover(item, cssclass)
{
 document.getElementById(item).className = cssclass;
}

function mouseout(item, cssclass)
{
document.getElementById(item).className = cssclass;
}

function addfavorite()
{
var title = "שורש, גולשים לתוכן";
var url = "http://www.shoresh.org.il/";

if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print)
{ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function searchselectchange(what)
{
    document.getElementById("insite").className = "unselectedsearch";
    document.getElementById("askrabi").className = "unselectedsearch";
    document.getElementById("images").className = "unselectedsearch";
    document.getElementById("products").className = "unselectedsearch";
    document.getElementById("sites").className = "unselectedsearch";
    
    document.getElementById(what).className = "selectedsearch";
     
	var sel1 = document.getElementById("sel");
    sel1.value = what;
}

function navigate()
{

if (document.getElementById('wordtosearch').value.length < 3)
{
alert ("לא ניתן לחפש מילה בת פחות משלוש אותיות");
return false
}

var sel1 = document.getElementById('sel').value;
var word = escape(document.getElementById('wordtosearch').value);
var path

if (sel1 == 'insite')
{
 path = "http://search.shoresh.org.il/main.aspx?word=";
}
if (sel1 == 'askrabi')
{
 path = "http://search.shoresh.org.il/main.aspx?what=shut&word=";
}
if (sel1 == 'images')
{
 path = "http://www.shoresh.org.il/spages/album/main.aspx?id=sear&word=";
}
if (sel1 == 'products')
{
 path = "http://www.shoresh.org.il/shoreshstore/resaults.aspx?word=";
}
if (sel1 == 'sites')
{
 path = "http://www.shoresh.org.il/spages/sites/main.aspx?what=search&word=";
}

 document.location.href = path + word; 
}

function showcookies()
{
var username;
var password;

if (readCookie ('ShoreshUserName'))
{
if (readCookie ('ShoreshUserName') != "אורח")
{
username= decodeURI (readCookie ('ShoreshUserName')).replace(/\+/g, " ");
password="****";
}
else
{
username="שם משתמש";
password="סיסמא";
}
}

document.getElementById ('UserName').value = username;
document.getElementById ('UserPassword').value = password;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	
	document.cookie = name + "=" + encodeURI (value) + expires + ";";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return "אורח";
}

function eraseCookie(name) {
	createCookie(name,"",-1);
	closecontact ();
}

function moveto(url)
{
 document.location.href = url;
}

function openNewWindow(what, url)
{
window.open(url ,"","80%, resizable, scrollbars");
}

function CreateActiveXFlash(FlashPath, FlashStyle, Alink)
{
    document.write('<OBJECT id="objFlash" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
    document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" ');
    document.write('style="' + FlashStyle + '" viewastext>');
    document.write('<PARAM NAME="movie" VALUE=http://' + FlashPath + ' ref>');
    document.write('<PARAM NAME="quality" VALUE="high">');
    document.write('<PARAM NAME="Menu" VALUE="0">');
    document.write('<PARAM NAME="Scale" VALUE="ExactFit">');
    document.write('<PARAM NAME="BGColor" VALUE="#495A74">');
       if (Alink != "")
    {        
    document.write('<PARAM NAME="flashvars" VALUE="alink1=' + escape(Alink) + '">');
    }
    document.write('<embed src=http://' + FlashPath + ' scale="ExactFit" quality="high" bgcolor="#495A74" ');
    document.write('type="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" ');
    document.write('style="' + FlashStyle + '" FlashVars="alink1=' + escape(Alink) + '"></embed>');
    document.write('</object>');
}

function sighin()
{
var name = document.getElementById("UserName").value;
var pass = document.getElementById("UserPassword").value;

if (name !="שם משתמש" && name !="" && name !="אורח" && pass !="סיסמא" && pass !="" && pass !="****")
{
makeRequest (name, pass);
}
else{
alert ("אנא הכניסו שם משתמש וסיסמא תקינים");
}
}

var http_request = false;
  
   function makeRequest(name, pass) 
   {
      http_request = false;
      if (window.XMLHttpRequest) 
      { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/plain');
         }
    } 
      else if 
       (window.ActiveXObject) { // IE
         try 
         {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } 
         catch (e) 
         {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      
      if (!http_request) 
      {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
 
      var theurl = "http://www.shoresh.org.il/newshoresh/go.aspx?what=users&name=" + escape(name) + "&pass=" + escape(pass);

      http_request.onreadystatechange = alertContents;
      http_request.open('GET', theurl, true);
      http_request.send(null);
   }
   
   function alertContents() 
{ 
if (http_request.readyState == 4) {
         if (http_request.status == 200) {
         var showgame;
         
         var xmldoc = http_request.responseText;

alert (xmldoc);

        var arr = new Array;
        arr = xmldoc.split('^');
        
        if (arr[0]!="none")
        {
       document.getElementById("UserName").value = arr[0]; 
       createCookie ("ShoreshUserName", arr[0], 30);
       showcookies() ;
       }
       else
       {
       alert ("שם המשתמש לא זוהה");
        document.getElementById("UserName").value = "אורח";
        }
         
   }  
 }    
}

var sliderIntervalId = 0;
var sliderHeight = 118;
var sliding = false;
var slideSpeed = 10;

function Slide()
{
   if(sliding)
      return;
   sliding = true;
   if(sliderHeight == 118)
      sliderIntervalId = setInterval('SlideUpRun()', 30);
   else
      sliderIntervalId = setInterval('SlideDownRun()', 30);
}

function SlideUpRun()
{
   slider = document.getElementById('sublinkstable');
   if(sliderHeight <= 0)
   {
      sliding = false;
      sliderHeight = 0;
      slider.style.height = '0px';
      clearInterval(sliderIntervalId);
      Slide();
   }
   else
   {
      sliderHeight -= slideSpeed;
      if(sliderHeight < 0)
         sliderHeight = 0;
      slider.style.height = sliderHeight + 'px';
   }
}

function SlideDownRun()
{
   slider = document.getElementById('sublinkstable');
   if(sliderHeight >= 118)
   {
      sliding = false;
      sliderHeight = 118;
      slider.style.height = '118px';
      clearInterval(sliderIntervalId);
   }
   else
   {
      sliderHeight += slideSpeed;
      if(sliderHeight > 118)
         sliderHeight = 118;
      slider.style.height = sliderHeight + 'px';
   }
}
