﻿function HighZ(contId)
{
     var liArr = $(contId).getElementsByTagName('li');
               
    topZ = 0;
    for (z=0;z<liArr.length;z++)
    {
         oldEl = liArr[z];
         topZ = Math.max(oldEl.style.zIndex,topZ)
    }
    return topZ ; 
 }
function openDropDown(objId,boxId,contId)
{
   
    var Obj=document.getElementById(objId);
    var box=document.getElementById(boxId);
    var highZ = HighZ(contId);    
    if(Obj.style.display=='none')
    {  
        box.style.zIndex = highZ+1;
        Obj.style.display='inline';
    }
    else
    {
        Obj.style.display='none';
        box.style.zIndex = highZ-1;
    }
}
function switchOnOff(obj)
{
    if(obj.className.indexOf("Off")!=-1)
    {
        obj.className=obj.className.replace("Off","On"); 
      }
    else
    {      
        obj.className=obj.className.replace("On","Off");  
    }
}
function setChoice(obj,objId)
 {
    document.getElementById(objId).innerHTML=obj.innerHTML;
 } 
 function openCloseMore(objId,img)
 {
    if(img.src.indexOf('Down')!=-1)
    {
        img.src=img.src.replace('Down','Left')
    }
    else{
        img.src=img.src.replace('Left','Down')
    }
    if($(objId).style.display=='none')
    {
        $(objId).style.display="inline";
    }
    else
    {
        $(objId).style.display="none";
    }
 }
 function switchOnOff(obj)
{
    if(obj.className.indexOf("Off")!=-1)
    {
        obj.className=obj.className.replace("Off","On");
    }
    else
    {
        obj.className=obj.className.replace("On","Off");
    }
}
function changeToActive(obj,contId)
{
    var divArr=$(contId).getElementsByTagName('div');
    for(i=0;i<divArr.length;i++)
    {
        if(divArr[i].className.indexOf('Active')!=-1)
        {
            divArr[i].className=divArr[i].className.replace('Active','Off')
        }
    }
    obj.className='tabButTop3Active';
}
function turnOn(obj)
{
    obj.className=obj.className.replace("On","Active");
}
function turnOff(obj)
{
    obj.className=obj.className.replace("Active","On");
}
function changeToOff(obj)
{
    
    obj.className=obj.className.replace('On','Off')
}
function changeToOn(obj)
{
    obj.className=obj.className.replace('Off','On')
}
function viewDetailsVideo(obj)
{

  var dark=$(obj.id+'Dark');
  if(dark.style.display=='none')
  {
    dark.style.display='inline';
  }
  else{
     dark.style.display='none';
  }
   
}

function PlayClip(File, Download){
    mediaFile=File;
    currentClipToDownload = Download;
    Play(); 
    NowPlaying=true;
}

currentClipToDownload = '';
PageThemePath = '';
function DownloadClip(DomId){
Stop();
NowPlaying = false;
    toggleDialogState(DomId,currentClipToDownload,605,450);
}

function ClickLinkButton(obj){
    try{obj.click();}
    catch (e){obj.onclick();}
}
function ServerClickLinkButton(objid){
    try{$get(objid).click();}
    catch (e){__doPostBack(objid,'')}
}
function toggleDialogState(theDomId,theFrmSrc,theFrmWidth,theFrmHeight)
    {
    	if(Dialog1.get_isShowing())
    	{
    		Dialog1.Close();
    	}
    	else
    	{
          $get(Dialog1.Id).className = $get(Dialog1.Id).className.replace("dNone","");
          var theIframe = $get("theInnerIframe")
          
          if(theIframe != null){
             theIframe.src = theFrmSrc;
             theIframe.style.border='0px';
             theIframe.width= theFrmWidth + 'px';
             theIframe.height=theFrmHeight + 'px';
          } 
          
          Dialog1.ShowTransition=3;				
		  Dialog1.CloseTransition=3;				
		  Dialog1.AnimationSlide=2;	  
          Dialog1.AnimationType='Live';
          Dialog1.AnimationType='Direct';
          
          Dialog1.AnimationDirectionElement = theDomId; 
          Dialog1.ModalMaskImage= PageThemePath + "/Images/bgModal.gif";
          Dialog1.AnimationDuration = 1000; 
          Dialog1.TransitionDuration = 500; 
          Dialog1.AnimationSlide = 1; 
          
    	  Dialog1.Alignment='MiddleCentre';
    	  Dialog1.Modal=true;
    	  try
    	  {
    	    Dialog1.Show(); 
    	  }
    	  catch(ex){}
    	  
    	  var theDialogDiv = $get(Dialog1.Id);
    	  theDialogDiv.style.width = theFrmWidth + 30 +'px';
    	  theDialogDiv.style.top = ((((screen.availHeight)/ 2) - (theDialogDiv.offsetHeight /2)) + document.documentElement.scrollTop + "px");
    	}
}

function GoToUrl(url, params){
    for (var i = 0; i < params.length; i++){        
        url = url.replace("{" + i + "}", params[i]);
    }
    window.location.href = url;    
}
var NowPlaying = false;

function findPos(obj) {
			
            var curleft = curtop = 0;

            if (obj.offsetParent) {

                        curleft = obj.offsetLeft

                        curtop = obj.offsetTop

                        while (obj = obj.offsetParent) {

                                    curleft += obj.offsetLeft

                                    curtop += obj.offsetTop

                        }

            }
            return [curleft,curtop];

    }
function SubmitSearch(val, searchUrl){
    if (val != 'חפש באתר')
    {
        GoToUrl(searchUrl, [val]);
    }
}
function SubmitOnEnter(val, SearchUrl, e){
    var evt = e || window.event;
    var keyPressed = evt.which || evt.keyCode;
	if (keyPressed == 13) 
        SubmitSearch(val, SearchUrl);                     
}
function rollTabsOnMask(maskId)
{
    var currIndex=maskId.replace('mask','');
   
    ShowObj(currIndex);
}
function rollTabsOffMask(maskId)
{
     var currIndex=maskId.replace('mask','');
   
    HideObj(currIndex);
}
    
function ShowObj(id){       
        $get('divTab'+id+'Off').style.display = 'none';
        $get('divTab'+id+'On').style.display = '';
        $get('divTab'+id+'On').style.visibility = '';
    }
    function HideObj(id){
        $get('divTab'+id+'Off').style.display = '';
        $get('divTab'+id+'On').style.display = 'none';
    }
function SubmitSearch(val, searchUrl){
    if (val != 'חפש באתר')
    {
        GoToUrl(searchUrl, [val]);
    }
}
function SubmitOnEnter(val, SearchUrl, e){
    evt = e || window.event;
    var keyPressed = evt.which || evt.keyCode;
	if (keyPressed == 13) 
        SubmitSearch(val, SearchUrl);                     
}
function flashSlide(id)
    {  
        var obj = document.getElementById(id);        
        var Sid = "#"+id;
            $j('.FlashTab:visible').hide();
            $j(obj).show();
            return false;       
    }
    function ShowHideByAttribute2(container, itemClassName, attributeName,attributeValue)
    {
        var count = 0;
        var obj=$(container);
        var arrList=obj.getElementsByClassName(itemClassName);
        var lastSep;
        if(arrList.length > 0)
        {
            for(i=0;i<arrList.length;i++)
            {
                if (attributeValue == arrList[i].getAttribute(attributeName))
                {
                    arrList[i].style.display = '';
                    count++;    
                    lastSep = arrList[i].id.replace('divServItemParent', '');                    
                }
                else
                    arrList[i].style.display = 'none';
            }
        }        
        $get('divSep' + lastSep).style.display = 'none';    
        $get('divAdvServItems').style.width = 180 * count + 'px'; 
        
        var varOffsetLeft1=findPos(document.getElementById('pane1'));
        int1=parseInt( varOffsetLeft1 )+21;
        
        $j('#pane1').jScrollHorizontalPane({scrollId:1,showArrows:true,arrowSize:17,offsetLeft:int1});
        scrollWidth1 = $get('divScroll1').style.width;
    }
    function ShowHideByAttribute(container, itemClassName, attributeName,attributeValue)
    {
        var count = 0;
        var obj=$(container);
        var arrList=obj.getElementsByClassName(itemClassName);
        
        if(arrList.length > 0)
        {
            for(i=0;i<arrList.length;i++)
            {
                if (attributeValue == arrList[i].getAttribute(attributeName))
                {
                    arrList[i].style.display = '';
                    count++;                        
                }
                else
                    arrList[i].style.display = 'none';
            }
        }        
        
        $get('divImagesFolder').style.width = 87 * count + 'px';
        
        var varOffsetLeft2=findPos(document.getElementById('pane2'));
        int2=parseInt( varOffsetLeft2 )+21;
        

        $get('divImagesFolder').style.marginLeft="0px";        
        $j('#pane2').jScrollHorizontalPane({scrollId:2,showArrows:true,arrowSize:17,offsetLeft:int2})
        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
         var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
         if (!(ieversion<7)){
            $get('divImagesFolder').style.marginLeft="21px";
            }
            else
            $get('divImagesFolder').style.marginLeft="10px";
        }
        else
        $get('divImagesFolder').style.marginLeft="21px";

        
        scrollWidth2 =$get('divScroll2').style.width;
    }
function pageLoadSettings(){
/*var myStartEffect = function(element) {
     element._opacity = Element.getOpacity(element);
     new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});
     new Effect.Highlight(element, {});
   }   
   $j(function() {
       var originalSizes = new Array();
    });*/
    flashSlide('flashTab0');
    isHomepage = true;
    //Sortable.create('sort1', {starteffect: myStartEffect});
}

function switchClassById(id, suffix){
    if ($get(id).className.indexOf(suffix) > -1)
        $get(id).className = $get(id).className.replace(suffix,'');
    else
        $get(id).className = $get(id).className+suffix;
}
var lastOpenId = '';
function switchClassById2(id, suffix, alternate){
    
    if ($get(id).className == suffix)
        $get(id).className = alternate;
    else{
        
        if (lastOpenId != '' && $get(lastOpenId))
            $get(lastOpenId).className = alternate;
        lastOpenId = id;$get(id).className = suffix;
        }
        
    
        
}

