  
function MoveDownInMenu(tbl_obj)
{
if(tbl_obj.rows.length==0)
{
return;
}
var anchor=tbl_obj.rows[0].cells[0].firstChild
//var anchor=tbl_obj.rows[1].cells[0].firstChild;
anchor.focus();



//alert(anchor.innerHTML)
//td.style.backgroundColor='red';
	 /*if (!e) var e = window.event;

        if (e.keyCode)
        { code = e.keyCode; }
        else if (e.which)
        { code = e.which; }
        alert(code)*/
}

function ComponentImageHref(link,target){
    if(target =='_blank')
    {    
        var w=window.open(link,'','toolbar=no, location=no, resizable=yes, menubar=no, width=500, height=500, modal=no');
        //w.moveTo(200,100);
    }
    else
        location.href=link;

}

function OpenWeekPic(href_obj,flag)
{
 var rel=href_obj.getAttribute('rel');

if(rel == null || rel== undefined)
{ 
 
return;
}

    
 //var img=href_obj.firstChild;
 /*if(img.src==null || img.src== undefined )
        return;*/
 //window.open(href_obj.rel,'','width=536,height=550,left=150,top=5,resizable=yes,scrollbars =no');
 if(flag==1)
 window.open(rel);
 else
 {
 
 window.open('/Raanana/console/ShowPicDetails.aspx?guid='+rel,'','width=532,height=550,left=150,top=5,resizable=no,scrollbars =no');
 }


}

function ShowDiv1(obj,arrow,right,is_hp)
  {
  if( my_dir=='left')
  {
  ShowDiv1_Eng(obj,arrow,right,is_hp);
  return;
  }
  for(var tt=1;tt<=9;tt++)
  {
	if( document.getElementById('DivMenu'+tt)!=null)
	{	
	document.getElementById('DivMenu'+tt).style.display='none';
	}
		
  }
  
   obj.style.right = document.body.clientWidth - arrow.offsetLeft  +  'px';
   obj.style.top =arrow.offsetTop + arrow.offsetHeight  +  'px';//- 2;
   obj.style.display='block';
   
    var gap=12;
   if(is_hp==1)
      gap=12;
      
   if (right == 1)
   obj.style.right = (parseInt(obj.style.right) - arrow.offsetWidth+gap) + 'px';
  else
    obj.style.right = (parseInt(obj.style.right) - obj.clientWidth)+ 'px';
    

  }

function ShowDiv1_Eng(obj,arrow,right,is_hp)
  {
  
  for(var tt=1;tt<=9;tt++)
  {
	if( document.getElementById('DivMenu'+tt)!=null)
	{	
	document.getElementById('DivMenu'+tt).style.display='none';
	}
		
  }
  
   obj.style.left = obj.offsetLeft;// arrow.offsetLeft;
   obj.style.top =arrow.offsetTop + arrow.offsetHeight ;//- 2;
   obj.style.display='block';
   
   var gap=-9;
   /*if(is_hp==1)
      gap=-9;*/
   
   if (right == 1)
    obj.style.left =arrow.offsetLeft+gap;// parseInt(obj.style.left) - arrow.offsetWidth ;//-10
   else
    obj.style.left = parseInt(obj.style.left) - obj.clientWidth;
  }

function HideDiv1(obj)    
  {
  if (obj==null)
	return;
	
   obj.style.display='none'; 
  }
  
  function GoToURL(url,target)
  {
  if(target=="_blank")
  window.open(url);
  else
  location.href=url;
  }

function Shift_Color(obj,bg,class_name)
  {
	obj.style.backgroundColor=bg;
	obj.className=class_name;
  }
  
  function ShowMenu(num)
  {
  }



function OpenPrint()
{
	var url=location.href+"&print=true";
	if(url.indexOf('?')<0)
		url=url.replace("&print=true","?print=true")
	window.open(url,null,'modal=1,top=50,left=50,height=600,width=820,status=no,scrollbars=yes,toolbar=yes,menubar=yes,location=no,resizable=yes');
}


function DoSearch(document,tb_obj,msg,not_enough_msg){
//enter_pressed=0;
if (tb_obj.value=='' || Trim(tb_obj.value)==' ')
{
alert(msg)
return 
}



if (Trim(tb_obj.value).length<3)
{
alert(not_enough_msg)
return 
}


for(var i=0;i<document.forms.length;i++)
{
var theform=document.forms[i]
//alert(theform.id)
	//if(theform.id.indexOf('search_form')>=0)
	if(theform.current_posting !=null)
	{
		var path="/Raanana/console/show_results_page.aspx";
		
		//added: to allow multiple words in simple search
		var expression = tb_obj.value;
		if(expression != null && expression != undefined)
		{
		/*	if(expression.indexOf(' ')>=0)
			{
				path += "&Words=" + expression;
				path +="&is_words_title=" + theform.is_word_title.value;
			}
			else
			{*/
				path += "&ExactWord=" + expression;
				path +="&is_word_title=" + theform.is_word_title.value;
			//}
		}
					path +="&current_posting=" + theform.current_posting.value;

					path=path.replace("&","?")
					location.href=path;
					
	}
}
}






function Redirect2Page(my_direction,post_url,title,parameter1,parameter2,parameter3,back_guid)
 {
		try
		{
            if (post_url==null || post_url == "")
				return;

            var title_param  = ""
            var guid_param  = ""
            var dir_param  = "" //---שפת המסמך שתישלח אל המסמך
            var parameter1_param  = ""
            var parameter2_param  = ""
	    var parameter3_param  = ""
            var back_param  = ""

            if  (title != "") 
            {
               title_param = "&title=" + escape(title)

                if (post_url.indexOf("?") < 0) 
                    title_param = title_param.replace("&", "?")
                
                post_url += title_param
           }

            //--next_guid או prev_guid כאן השוני
            /*if (new_guid != "")
            {
                guid_param = "&guid=" + new_guid

                if (post_url.indexOf("?") < 0) 
                    guid_param = guid_param.replace("&", "?")
                
                post_url += guid_param
            }*/

            //---כתובת העמוד אליו יש לחזור
            if (back_guid != "")
            {
                back_param = "&backguid=" + back_guid

                if (post_url.indexOf("?") < 0)
                    back_param = back_param.replace("&", "?")
                
                post_url += back_param
           }


            //---פרמטר נוסף שיתווסף אל העמוד
            if (parameter1 != "")
            {
                parameter1_param = "&" + parameter1

                if (post_url.indexOf("?") < 0)
                    parameter1_param = parameter1_param.replace("&", "?")
               
                post_url += parameter1_param
           }

            //---פרמטר נוסף שיתווסף אל העמוד
            if (parameter2 != "" )
            {
                parameter2_param = "&" + parameter2

                if (post_url.indexOf("?") < 0 )
                    parameter2_param = parameter2_param.replace("&", "?")
                
                post_url += parameter2_param
            }

//---פרמטר נוסף שיתווסף אל העמוד
            if (parameter3 != "" )
            {
                parameter3_param = "&" + parameter3

                if (post_url.indexOf("?") < 0 )
                    parameter3_param = parameter3_param.replace("&", "?")
                
                post_url += parameter3_param
            }
            //---השפה שתישלח אל העמוד
            if (my_direction != "") 
            {
                dir_param = "&direction=" + my_direction

                if (post_url.indexOf("?") < 0) 
                    dir_param = dir_param.replace("&", "?")
                
                post_url += dir_param
			}

            location.href=post_url;
         }  
        catch(e)
         {
			alert('Redirect2Page:Error!')
         }
   }

function OpenDialog(path,obj,width,height){
var retVal=window.showModalDialog('/Raanana/Dialog_Matefet.aspx?path='+path.replace('?','&') ,'','dialogHeight:' + height + 'px; dialogWidth:'+ width +'px;  edge: Raised; center: yes; help: No; resizable: No; status: No;');
return retVal;
}


function OpenHTTPSDialog(serverName,path,obj,width,height){
//var win=window.open('http://'+ serverName +path,'','menubar=no,resizable=no,scrollbars=yes,width='+ width +',height='+ height );
//win.moveTo(200,300);
var retVal=window.showModalDialog('https://'+ serverName +'/Raanana/Dialog_Matefet_Secured.aspx?path='+path.replace('?','&') ,'','dialogHeight:' + height + 'px; dialogWidth:'+ width +'px;  edge: Raised; center: yes; help: No; resizable: No; status: No;');
//var retVal=window.showModalDialog('http://'+ serverName + path ,'','dialogHeight:' + height + 'px; dialogWidth:'+ width +'px;  edge: Raised; center: yes; help: No; resizable: No; status: No;');
return retVal;
}

function MailingList(){
location.href='/Raanana/console/mail_login.aspx';
/*if(document.all)
	window.showModalDialog('/Raanana/Dialog_Matefet.aspx?path=console/mail_login.aspx','','dialogHeight: 570px; dialogWidth:570px;  edge: Raised; center: yes; help: No; resizable: No; status: No;');

else
	window.open('/Raanana/Dialog_Matefet.aspx?path=console/mail_login.aspx',null,"modal=1,top=200,left=200,height=570,width=570,status=no,toolbar=no,menubar=no,location=no,resizable=no");*/
}

function UKtoISO8601(St) //dd/mm/yyyy
 { return St.split('/').reverse().join('') }

  function UStoISO8601(St) //mm/dd/yyyy
 { return St.replace(/(\d+)\/(\d+)\/(\d+)/, '$3-$1-$2') }


function Trim(TRIM_VALUE){

if(TRIM_VALUE.length < 1){
return"";
}
TRIM_VALUE = RTrim(TRIM_VALUE);
TRIM_VALUE = LTrim(TRIM_VALUE);
if(TRIM_VALUE==""){
return "";
}
else{
return TRIM_VALUE;
}
} //End Function

function RTrim(VALUE){
var w_space = String.fromCharCode(32);
var v_length = VALUE.length;
var strTemp = "";
if(v_length < 0){
return"";
}
var iTemp = v_length -1;

while(iTemp > -1){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(0,iTemp +1);
break;
}
iTemp = iTemp-1;

} //End While
return strTemp;

} //End Function

function LTrim(VALUE){
var w_space = String.fromCharCode(32);
if(v_length < 1){
return"";
}
var v_length = VALUE.length;
var strTemp = "";

var iTemp = 0;

while(iTemp < v_length){
if(VALUE.charAt(iTemp) == w_space){
}
else{
strTemp = VALUE.substring(iTemp,v_length);
break;
}
iTemp = iTemp + 1;
} //End While
return strTemp;
} //End Function


function isHour(s) {
    if (!(/^\d{2,2}:\d{2,2}$/.test(s))) { return false; }
    var a = s.split(":");
    a[0] = Number(a[0]);
    a[1] = Number(a[1]);
    return a[0] >= 0 && a[0] <= 23 &&
        a[1] >= 0 && a[1] <= 59;
}

var dtCh= '/';
var minYear=1900;
var maxYear=2100;

function UKtoISO8601(St) //dd/mm/yyyy
	{ return St.split('/').reverse().join('') }

function UStoISO8601(St) //mm/dd/yyyy
	{ return St.replace(/(\d+)\/(\d+)\/(\d+)/, '$3-$1-$2') }

function isInteger(s){
	var i;
	for (i = 0; i < s.length; i++){
	var c = s.charAt(i);
	if (((c < '0') || (c > '9'))) return false;
	}
	return true;
}

function stripCharsInBag(s, bag){
	var i;
	var returnString = '';
	for (i = 0; i < s.length; i++){
	var c = s.charAt(i);
	if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}

function daysInFebruary (year){
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
	this[i] = 31
	if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
	if (i==2) {this[i] = 29}
	}
	return this
}

function isDate(dtStr){
    if (dtStr=='')
    return true
    var daysInMonth = DaysArray(12)
    var pos1=dtStr.indexOf(dtCh)
    var pos2=dtStr.indexOf(dtCh,pos1+1)
    var strDay=dtStr.substring(0,pos1)
    var strMonth=dtStr.substring(pos1+1,pos2)
    var strYear=dtStr.substring(pos2+1)
    strYr=strYear
    if (strDay.charAt(0)=='0' && strDay.length>1) strDay=strDay.substring(1)
    if (strMonth.charAt(0)=='0' && strMonth.length>1) strMonth=strMonth.substring(1)
    for (var i = 1; i <= 3; i++) {
    if (strYr.charAt(0)=='0' && strYr.length>1) strYr=strYr.substring(1)
    }
    month=parseInt(strMonth)
    day=parseInt(strDay)
    year=parseInt(strYr)
    if (pos1==-1 || pos2==-1){
    alert('dd/mm/yyyy :התאריך צריך להיות בפורמט')
    return false
    }
    if (strMonth.length<1 || month<1 || month>12){
    alert('נא להקליד חודש חוקי')
    return false
    }
    if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
    alert('נא להקליד יום חוקי')
    return false
    }
    if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
    alert('נא להקליד שנה חוקית בת 4 ספרות בין '+minYear+' ל- '+maxYear )
    return false
    }
    if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
    alert('נא להקליד תאריך חוקי')
    return false
    }
    return true
    }

function IsNumeric(sText)
{
    var ValidChars = '0123456789';
    var IsNumber=true;
    var Char;
    for (i = 0; i < sText.length && IsNumber == true; i++)
    {
    Char = sText.charAt(i);
    if (ValidChars.indexOf(Char) == -1)
    {
    IsNumber = false;
    }
    }
    return IsNumber;
}

function FormatYear(obj)
{
    var array=obj.value.split('/')
    if(array.length != 3)
    return false
    if( ! IsNumeric(array[0]) |  ! IsNumeric(array[1]) | ! IsNumeric(array[2]))
    return false
    var j,temp
    temp=''
    for (j = 0; j < 2; j++)
    {
    if (array[j].length ==1  )
    temp += '0'+ array[j] +'/'
    else if (array[j].length ==2  )
    temp += array[j] +'/'
    else
    return false
    }
    if (array[2].length == 2)
    temp += '20'+ array[j]
    else if (array[2].length ==4  )
    temp += array[j]
    else
    return false
    obj.value=temp
}



/**********************************album pics*************************************/
function CheckArrays(img_str,images,titles){
/*if (img_str.indexOf('@')< 0)
	return false;*/
if(img_str=='' || img_str==' '  )
	return false;	
if(images.length<=0)
	return false;
if(images.length != titles.length)
{
	alert('שגיאה ברכיב תמונות מתחלפות');
	return	false;
}
return true;
}


function ReplaceAll(str,old,new_ch){
//alert(str.indexOf(old))
while(str.indexOf(old) >= 0)
{
	str=str.replace(old,new_ch);
}
return str
}

function MainPic(img_str,titles_str,img_span,img_title){
var images=img_str.split('@');
var titles=titles_str.split('@');
var ans=CheckArrays(img_str,images,titles);
if(!ans)
	return;
if(img_span != null)
	img_span.innerHTML=ReplaceAll(images[index],"#&39","'") //.replace("#&39","'")//%(images.length)
if(img_title !=null)
	img_title.innerHTML=ReplaceAll(titles[index],"#&39","'")//.replace("#&39","'") //%(titles.length)
}

function ChangePic(num,img_str,titles_str,img_span,img_title){
var images=img_str.split('@');
var titles=titles_str.split('@');
var ans=CheckArrays(img_str,images,titles);
if(!ans)
	return
index=(eval(index+num))
if(index<0)
	index=eval(index)+(images.length)
index=(eval(index))%(images.length)
if(img_span !=null)
	img_span.innerHTML=ReplaceAll(images[index],"#&39","'") 
if(img_title !=null)
	img_title.innerHTML=ReplaceAll(titles[index],"#&39","'")

}



if (document.addEventListener){
        document.addEventListener('keydown', checkKey, false);
      }
      else if (document.attachEvent)
      {
      document.attachEvent('onkeydown', checkKey);
      }

      var started=true;
      //var enter_pressed=0;

      var code='';
	var firstTab=0;
var arrIndex=-1;
      
      function checkKey(e)
      {
 
 
 	

        if (!e) var e = window.event;

        if (e.keyCode)
        { code = e.keyCode; }
        else if (e.which)
        { code = e.which; }
        
	
       if(code==9)
	{
try
{
if(firstTab==0)
{
	if(document.getElementById("tab1")!=null)
		document.getElementById("tab1").focus();
	firstTab=1;
	return;
}
/*//var TabsArray......


arrIndex=(arrIndex+1)//%(TabsArr.length);
//if(arrIndex>TabsArr.length)
//return;
if(arrIndex==TabsArr.length)
{
var right_side=document.getElementById("right_side");
if(right_side !=null)
	right_side.focus();
return;
}


if(document.activeElement != null && document.activeElement.id !=null && document.activeElement.id=='middle1')
{

	if(document.getElementById("middle2")!=null)
	{
		document.getElementById("middle2").focus();
		return;
	}
}

if(document.activeElement != null && document.activeElement.parentNode !=null  && document.activeElement.parentNode.id !=null && document.activeElement.parentNode.id=='middle2')
{

	if(document.getElementById("middle3")!=null)
	{
		document.getElementById("middle3").focus();
		return;
	}
	
}

if(arrIndex<TabsArr.length && document.getElementById(TabsArr[arrIndex]) !=null)
	document.getElementById(TabsArr[arrIndex]).focus();
	
return;

			
		var cur_elm=window.event.srcElement;
		var parent_elm=null;
		if(cur_elm !=null)
			parent_elm=cur_elm.parentNode;

		if(parent_elm !=null)
		{
		   var cur_id=parent_elm.id;
		   if(cur_id!=null && cur_id !=undefined)
			{
alert(cur_id)
alert(TabsArr.toString().indexOf(cur_id))
var cur_index=TabsArr.toString().indexOf(cur_id);
var next_index=cur_index+cur_id.length;
alert(next_index);

return;
			   var cur_index=TabsArr.indexOf(cur_id);
		           alert(cur_index);
			   return;
				
			}
			
		}
		//alert(window.event.srcElement)
		
		//var tab_elm=document.getElementById(TabsArr[0]);
		//if(tab_elm !=null)
		//{	tab_elm.focus();
			//alert(tab_elm.id)
		//}*/
	     }
	     catch(e)
	     {
		alert("Tab EXCEPTION: "+e.message);
	     }
		
	}

        if (code == 19 )
        {
          StopStartMarquee(started);
/*if(started==true)
started=false;
else
started=true;*/
	 started = !started;	
	

        }
	
	if (code == 13  )
        {
		if(e.srcElement !=null && e.srcElement.id !=null && e.srcElement.id=='search_tb')	
		{
		var my_search_tb=document.getElementById('search_tb');

		if(my_search_tb ==null)
			return;
		if(document.all)
			    my_search_tb.blur();
		
		 var SrcElement=null;
		    if(document.all)
		        SrcElement=e.srcElement;
		        else 
		        SrcElement=e.target;
		    
		if(SrcElement !=null && SrcElement.id!=null && SrcElement.id=="search_tb" )
        	DoSearch(document,my_search_tb,search_msg,not_enough_search_msg);
		
        		
		}
	}
       
        
      }
      
      
      function StopStartMarquee(started)
      {
      
//stop start marquees
        var marquee = document.getElementsByTagName('marquee');
        for (i=0; i < marquee.length; i++)
         {
          if (started)
          {
           // alert(started)
           marquee[i].stop();
          }
          else
          {
          // alert(started)
            marquee[i].start();
          
          }
         //
         }

//stop start objects
if(document.all)
         try
{
          var marquee = document.getElementsByTagName('object');
        for (i=0; i < marquee.length; i++)
         {
          if (started)
          {
           // alert(started)
           marquee[i].stop();
          }
          else
          {
          // alert(started)
           marquee[i].play();
          
          }
         //
         }
}
catch(e)
{

}

}



function replaceBackground(id, className)
{            
    document.getElementById(id).className = className;
}       
  
        
function createMonth(year)
{
         var ctrl;
         var elem;
         var i;
         var tbl_year;
         
         elem = document.getElementById("div_month_" + year);
         
           if(elem.className == 'div-on')
                {
                    elem.className = 'div-off';
                    document.getElementById("newsdate_div_" + year).className = 'div-off';
                }
            else
              {            
               try
                  {
                   if(document.getElementById("tbl_monthes" + year) != null && document.getElementById("tbl_monthes" + year) != "")
                   {
                      document.getElementById("div_month_" + year).className = 'div-on';
                   }
                   else
                   {
                       document.getElementById("div_month_" + year).className = 'div-on';
                      
                       ctrl = document.createElement("table");
                       ctrl.id = "tbl_monthes" + year;
                       ctrl.cellspacing = "2";
                       ctrl.width = "390px";
                       
                       elem =  document.getElementById("div_month_" + year);
                       elem.appendChild(ctrl);
                            
                       var tbl = document.getElementById("tbl_monthes" + year);
                       var row = tbl.insertRow(-1);
                            
                      for(i=0; i < arrMonth.length; i++)
                         {
                             var cell = row.insertCell(-1);
                             var month = i+1;
                             cell.innerHTML = 'style="padding:1px;"';
                             //cell.innerHTML = '<a href="/Raanana/Console/display_news_by_date.aspx?year=' + year +'&month=' + month + '"> <img id="img_' + i + '" src="' + arrMonth[i] + '" alt="' + arrMonthName[i] + '" class="img-month"/> </a>';
                             if(isNaN(year))
                                year=-1;
                            if(isNaN(month))
                                month=-1;
                             cell.innerHTML ='<img onclick="javascript:ShowNews('+year+','+month+');" id="img_' + i + '" src="' + arrMonth[i] + '" alt="' + arrMonthName[i] + '" class="img-month" />';
                         }
                    }
                }
                catch(ex)
                {
                    alert(ex.message);
                } 
         }
    }
    
function OpenNews(url)
{
    if(url != "")
        location.href=url;
}   





