﻿function js__General(){}

 onerror=handleErr;
                                
function handleErr(msg,url,l)
{
        var txt='';
        txt='There was an error on this page.\n\n';
        txt+='Error: '+ msg + '\n';
        txt+='URL: ' + url + '\n';
        txt+='Line: ' + l + '\n\n';
        txt+='Click OK to continue.\n\n';
        //alert(txt);
        return true;
}
function setMedias(url)
{

    window.setTimeout('asyncsetMedias("' + url + '");', 1000);
 
}
function trackDownload(guid,title)
{
    try
    {
        _gaq.push(['_trackEvent', 'Outgoing', 'Download', title]);
    }
    catch(e){}
}
var selectedPlayerID = null;
var medias = null;
function asyncsetMedias(url)
{
    try {

        $.fn.media.defaults.flashvars = {  backcolor: '364876', frontcolor: 'ffffff', lightcolor: 'FF7F00', screencolor: 'FFFFFF', skin: '' + url + 'Pics/swf/stylish_slim.swf' };
        $.fn.media.defaults.flvPlayer = url + 'Pics/swf/player.swf';
        $.fn.media.defaults.mp3Player = url + 'Pics/swf/player.swf';

        medias = $('a.media');
        
        for (var i = 0; i < medias.length; i++) {
            var media = medias[i];
            var thumb = '';

            try {
                thumb = media.getAttribute('thumb');
            }
            catch (ee) { }
            selectedPlayerID = media.id;
            
                $(media).media({
                    params: { allowfullscreen: 'true', wmode: 'opaque' },
                    flashvars: { image: '' + thumb ,id:media.id}
                });
               
        }
    }
    catch (e) { alert(e.description); }
}
var numOfPlayer = 0;
var playerReady = function(thePlayer) {
try {
        
        var spanAccessible = $(document.createElement('span')).attr('class', 'Accessible');
        var inputAccessible = $(document.createElement('input'))
                                    .attr('type', 'button')
                                    .attr('Play', 'false')
                                    .bind('click',
                                        function(e) {

                                            var isPlaying = $(this).attr('Play');
                                            if ('' + isPlaying == 'false') {
                                                $(this).attr('Play', 'true');
                                                $(this).attr('title', 'הפסק ניגון')
                                                $(this).attr('value', 'הפסק ניגון');
                                                document.getElementById(thePlayer.id).sendEvent('PLAY');
                                            }
                                            else {
                                                $(this).attr('Play', 'false');
                                                $(this).attr('title', 'המשך לניגון')
                                                $(this).attr('value', 'המשך לניגון');
                                                document.getElementById(thePlayer.id).sendEvent('PLAY');
                                            }
                                        })
                                    .attr('title', 'לחץ לניגון')
                                    .attr('value', 'לחץ לניגון');
        if(thePlayer!=null)
        {
            var players = $('.pnlAudioPlayer');
            if(players.length>0)
            {   
                for(var i=0;i<players.length  ;i++)
                {
                   
                if($('#'+players[i].id + ' object').length>0)
                {
                
                   //alert(i+": "+thePlayer.id+" "+($(players[i]).find('object')[0].id));
                    
                   if(thePlayer.id==($(players[i]).find('object')[0].id))
                   {    $(players[i]).append(spanAccessible);
                        spanAccessible.append(inputAccessible);
                       
                   }
                   }
                }
            }
        }
    }
    catch (e) { }
}
function setMedia(url,thumbnail)
{

}
function fillMedia(btnSaveAudioVideoID,txtAudioVideoID,url)
{
    
    var txtAudioVideo = document.getElementById(txtAudioVideoID);
    var btnSaveAudioVideo = document.getElementById(btnSaveAudioVideoID);
    if(btnSaveAudioVideo!=null && txtAudioVideo!=null)
    {
        showNewsDialog(url);
       
    }
}

function setMedia(linkID,btnSaveAudioVideoID,txtAudioVideoID)
{

    try
    {  
        
        var val =($('#'+linkID)[0].value);
        var oppener = window.dialogArguments;
        if(oppener!=null && val!=null)
        {
            var btnSaveAudioVideo = oppener.document.getElementById(btnSaveAudioVideoID);
            var txtAudioVideo = oppener.document.getElementById(txtAudioVideoID);
            if(txtAudioVideo!=null && btnSaveAudioVideo!=null)
            {
                txtAudioVideo.value = val;
                btnSaveAudioVideo.click();
                self.close();
            }
        }
    }
    catch(e){}
}
// JScript File
var timerImageID = '';

var editMode = false;
function getElementsByClassName(cls, tag, node) {

	var i, j, re, elm, elms, ismatch;

	var results = new Array();

	if (!document.getElementsByTagName) return results;

	// check type and validity of cls param

	if (typeof cls == 'string') cls = cls.split(' ');

	if (cls.length == 0) return results;

	// covert array of classnames to array of regexp objects matching classnames

	// doing this allows RegExp objects to be created just once

	for (i=0; i<cls.length; i++) {

		cls[i] = new RegExp('(^| )'+cls[i]+'( |$)');

	}

	// grab all the elements in node of type tag

	if (tag == null) tag = '*';

	elms = (tag == '*' && document.all) ? document.all : node.getElementsByTagName(tag); // IE5 does not like getElementsByTagName('*')

	// find matching elements

	for (i=0; elm=elms[i]; i++) {

		for (j=0; re=cls[j]; j++) {

			ismatch = true;

			if (!re.test(elm.className)) {

				ismatch = false;

				break;

			}

		}

		if (ismatch) results[results.length] = elm; // no Array.push in IE5

	}

	return results;

}
function newWebForm_SetElementX(element, x) {
    var found = false;
    if (element && element.style) {
        //alert(element.id);
         // set x to side menu
        if(element && element.id.toLowerCase().indexOf('topmenu')>0)
        {
            var TopMenuDynamicMenuStyleDivs = getElementsByClassName('TopMenuDynamicMenuStyle', 'div', document);
            //alert(TopMenuDynamicMenuStyleDivs.length);
            element.style.left = (4+x) + "px";
            found= true;
        }
        // set x to side menu
        if(element && element.id.toLowerCase().indexOf('sidemenu')>0)
        {
            var SideMenuDynamicMenuStyleDivs = getElementsByClassName('SideMenuDynamicMenuStyle', 'div', document);
            var SideMenu = document.getElementById(SideMenuID);
            if(SideMenuDynamicMenuStyleDivs!=null && SideMenu!=null)
            {
                
                for(var i=0;i<SideMenuDynamicMenuStyleDivs.length;i++)
                {
                    if(element == SideMenuDynamicMenuStyleDivs[i])
                    {
                        element.style.left = (x - SideMenu.clientWidth - SideMenuDynamicMenuStyleDivs[i].clientWidth) + "px";
                        found= true;
                    }
                   // alert( SideMenuDynamicMenuStyleDivs[0].id);
                   // ss.style.left = ss.style.left - SideMenu.clientWidth;
                   // 
                }
            
            }
        }
        if(found==false)
        {
            element.style.left = x + "px";
        }

    }

}
var oldWebForm_SetElementX;
function fixHebrew()
{
    //oldWebForm_SetElementX = WebForm_SetElementX;
    //WebForm_SetElementX = newWebForm_SetElementX;
    //alert(WebForm_SetElementX);
    
}

function closingFormScript()
{
// set the form height to 100%
    
    setFormHeight();
    setSessionTimerAlive();
}
function setSessionTimerAlive()
{
    var timerImage = document.getElementById(timerImageID);
    if(timerImage!=null)
    {
        window.setInterval('reloadImage("'+timerImage.id+'");',5*60*1000);
    }
}
function reloadImage(timerImageID)
{
 
    var timerImage = document.getElementById(timerImageID);
    if(timerImage!=null)
    {
        //timerImage.src = 
       
        var rand_no = Math.random();
        var origsrc = (timerImage.attributes["origsrc"].value);
        timerImage.src = origsrc+"?"+rand_no;
        

    }
}
function checkSearchText(EmptyTextBox)
{
    var val = EmptyTextBox.val();
    var EmptyText = EmptyTextBox.attr('EmptyText');
    if(val!=null && EmptyText!=null)
    {
        if(val==EmptyText){
            EmptyTextBox.val('');
            EmptyTextBox.addClass('NonEmptyText').removeClass('EmptyText');
        }
    } 
}
function emptySearchText(EmptyTextBox)
{
    var val = EmptyTextBox.val();
    var EmptyText = EmptyTextBox.attr('EmptyText');
    if(val!=null && EmptyText!=null)
    {
        if(val.length==0)
        {
            EmptyTextBox.val(EmptyText);
            EmptyTextBox.addClass('EmptyText').removeClass('NonEmptyText');
        }
        else{
            EmptyTextBox.addClass('NonEmptyText').removeClass('EmptyText');
        }
    } 
}
var resizeTimer = null;
function doSomething() {    setFormHeight();}; 
$(function() {
    try
    {
      var EmptyTextBoxes = $('.EmptyTextBox');
      for(var i=0;i<EmptyTextBoxes.length;i++)
      {
        var EmptyTextBox = $(EmptyTextBoxes[i]);
        if(EmptyTextBox!=null)
        {
            var val = EmptyTextBox.val();
            var EmptyText = EmptyTextBox.attr('EmptyText');
            if(val.length==0 && EmptyText!=null)
            {
                EmptyTextBox.val(EmptyText)
                              .bind('focus',function(e){ checkSearchText(EmptyTextBox);})
                              .bind('blur',function(e){ emptySearchText(EmptyTextBox);});
                
            }
        }
      }
       $(window).bind('resize', function() {    if (resizeTimer) clearTimeout(resizeTimer);    resizeTimer = setTimeout(doSomething, 6000);});
     
    }catch(e){}
});
function setFormHeight()
{

    //if(editMode)return;
    // set the form height to 100%
    try
    {
       
        var screenHeight = getSize(false);
        
          // now make the height to be like side bar 
        var innerHeight = jQuery('#tblGeneralContentTable').height();
        var sideHeight = jQuery('#tblGeneralContentRightBodyDiv').height();
        if(sideHeight>innerHeight)
        {
            jQuery('#tblGeneralContentTable').height(sideHeight);
        }
        var innerHeight = jQuery('#tblGeneralContentTable').height();
        
        if(screenHeight>innerHeight)
        {

            //alert('resizing to '+screenHeight);

            var tblGeneralContentTable = document.getElementById('tblGeneralContentTable');

            if(tblGeneralContentTable!=null)

            {

                // remove header and footer heights

                var newGeneralContentTableHeight = screenHeight - 100 - 55;

                if(newGeneralContentTableHeight<0) newGeneralContentTableHeight = 0;
                //var docHeight = 
                // set to new size
                var jQuerydocHeight = jQuery(document).height();
                //window.status = screenHeight+' doc:'+jQuerydocHeight+' new:'+newGeneralContentTableHeight;
                if(screenHeight>=jQuerydocHeight)
                {
                    jQuery('#tblGeneralContentTable').height(newGeneralContentTableHeight);
                }
                
               
                
            }

        }
      
        
    }
    catch(e){}

}



function getScrollXY(getScroll_X) {

	var scrOfX = 0, scrOfY = 0;

	if( typeof( window.pageYOffset ) == 'number' ) {

		scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;

	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {

		scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;

	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {

		scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;

	}

	//window.alert( 'Horizontal scrolling = ' + scrOfX + '\nVertical scrolling = ' + scrOfY );

	if(getScroll_X)

	{

	    return scrOfX;

	}

	else

	{

	    return scrOfY;

	}

}

function getSize(getWidth) {

  var myWidth = 0, myHeight = 0;

  if( typeof( window.innerWidth ) == 'number' ) {

    //Non-IE

    myWidth = window.innerWidth;

    myHeight = window.innerHeight;

  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {

    //IE 6+ in 'standards compliant mode'

    myWidth = document.documentElement.clientWidth;

    myHeight = document.documentElement.clientHeight;

  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {

    //IE 4 compatible

    myWidth = document.body.clientWidth;

    myHeight = document.body.clientHeight;

  }

  //window.alert( 'Width = ' + myWidth );

  //window.alert( 'Height = ' + myHeight );

  if(getWidth)

  {

    return myWidth;

  }

  else

  {

   return myHeight;

  }

}



function isDefined(varName)

{

    return ! (typeof varName == "undefined");

}
function toggle(eleid)
{
    var ele = document.getElementById(eleid);
    if(ele!=null)
    {
        ele.style.display = ele.style.display=='none'?'':'none';
    
    }

}
function hideshow(eleid,flag)
{
    var ele = document.getElementById(eleid);
    if(ele!=null)
    {
        ele.style.display = flag?'':'none';
    }
}
function flipExpandCollapse(img)
{
    if(img.src.indexOf("collapse.gif")>0)
    {
        img.src = "../Pics/expand.gif";
    }
    else
    {
        img.src = "../Pics/collapse.gif";
        
    }
    
}
function setCheckBoxClick(chkID,value,hidShowInSiteID)
{
   // debugger
    var chk = document.getElementById(chkID);
    var hidShowInSite = document.getElementById(hidShowInSiteID);
    if(chk!=null && hidShowInSite!=null)
    {
        chk.checked = value;
        hidShowInSite.value= value;
    }
}

function colorSearch(sSearchParam)
{
   
  
}

function hideTable(tableID)
{
     var dp_table = document.getElementById(tableID);
    if(dp_table!=null)
    {
        dp_table.style.display = 'none';
    }
}

// FCKeditor_OnComplete is a special function that is called when an editor
// instance is loaded ad available to the API. It must be named exactly in
// this way.
function FCKeditor_OnComplete( editorInstance )
{
    editorInstance.Events.AttachEvent( 'OnBlur'	, FCKeditor_OnBlur ) ;
	editorInstance.Events.AttachEvent( 'OnFocus', FCKeditor_OnFocus ) ;
    //editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ;
   window.setTimeout('timerCheck("'+editorInstance.Name+'");',100);
//    try    
//    {
//	   editorInstance.Events.AttachEvent( 'OnSelectionChange', DoSomething ) ;
//	}
//	catch(e){}
}

function FCKeditor_OnBlur( editorInstance )
{
	editorInstance.ToolbarSet.Collapse() ;
}

function FCKeditor_OnFocus( editorInstance )
{
	editorInstance.ToolbarSet.Expand() ;
}
var counter = 0 ;

function DoSomething( editorInstance )
{
    // This is a sample function that shows in the title bar the number of times
    // the "OnSelectionChange" event is called.
    //window.document.title = editorInstance.Name + ' : ' + ( ++counter ) ;
    if(editorInstance.IsDirty())
    {
        SetEditChange();
    }
}

function timerCheck(editorInstanceName)
{
    if(IsPageChanged==false)
    {
        if(typeof(FCKeditorAPI)!='undefined')
        {
             //window.status = ++counter ;
             var editorInstance = FCKeditorAPI.GetInstance(editorInstanceName) ;
             if(editorInstance.IsDirty())
             {
                SetEditChange();
             }
             else
             {
                // continue
                window.setTimeout('timerCheck("'+editorInstanceName+'");',1000);
             }
         }
     }
}
var IsPageChanged = false;
function SetEditChange()
{
    IsPageChanged = true;
//    var trModifyDate = document.getElementById('trModifyDate');
//    if(trModifyDate!=null)
//    {
//        trModifyDate.className = 'ModifyDateChanged';
//    }
}

function DiscardChanges()
{

    try
    {
        if (IsPageChanged==true)
        {
            return confirm('העמוד השתנה ללא ביצוע שמירה, האם ברצונך לאבד את הנתונים?');
        }
    }
    catch(e){}
    return true;
    
}

function checkBigImagePopup(behavID,ActiveImage)
{
    try
    {
        var isInside = ActiveImage.getAttribute('isInside');
        if(isInside=='true')
        {
            
            var _popupBehavior = $find(behavID)._popupBehavior;
            _popupBehavior.set_parentElement(ActiveImage);
            _popupBehavior.setupPopup();    
            //$find(behavID)._offsetX = -20;
            
            showHide(behavID,true,ActiveImage);
        }
    }
    catch(e){}
}
function showOnHoverAnimation(behavID,ActiveImage) 
{
    try
    {
    ActiveImage.setAttribute('isInside','true');
    // set delay
    window.setTimeout(function(){checkBigImagePopup(behavID,ActiveImage);},500);
    }
    catch(e){}
   
}
 function hideOnHoverAnimation(behavID,ActiveImage){
    try
    {
    ActiveImage.setAttribute('isInside','false');               
    // hide delay
    showHide(behavID,false,ActiveImage);  
    }
    catch(e){}              
 }
function showHide(behavID,flag,ActiveImage)
{
    try
    {
       var myPopup = $find(behavID);
       if(myPopup!=null)
       {
           var popupBehavior = myPopup._popupBehavior;
           if(popupBehavior!=null)
           {
                if(flag)
                {
                    $find(behavID)._popupBehavior.show();
                    
                }
                else
                {
                    $find(behavID)._popupBehavior.hide();
                }
           }
       }
    }
    catch(e){}  
}

function sizeIFrame(id) {

var helpFrame = jQuery("#"+id);
if(helpFrame!=null)
{
helpFrame.height(get_sizeIFrame(id));
}
}
function showNewsDialog(url)
{
     var frameHeight = (document.documentElement.offsetHeight || document.body.clientHeight) +'px';
     var frameWidth = (document.documentElement.offsetWidth || document.body.clientWidth) +'px';
       window.showModalDialog(url,window,'dialogLeft:10px;dialogTop:10px;resizable=1;center:1;dialogHeight:'+frameHeight+';dialogWidth:'+frameWidth);
  
    
}
function get_sizeIFrame(id) {
try
{

    var helpFrame = jQuery("#"+id);
    if(helpFrame!=null)
    {
        var innerDoc = (helpFrame.get(0).contentDocument) ? helpFrame.get(0).contentDocument : helpFrame.get(0).contentWindow.document;
        return innerDoc.body.scrollHeight + 35;
}
}
catch(e){}
return 600;
}
var myClose = function(hash){
                    hash.w.fadeOut('3000', function(){
                        hash.o.remove();
                    });
                };

function refreshFrame(frameID)
{
    var frame = document.getElementById(frameID);
    if(frame!=null)
    {
        if(typeof(frame.origSrc)=='undefined')
        {
            frame.origSrc = frame.src;
        }
        var rnd = Math.random();
        frame.src = ''+frame.origSrc+"&"+rnd;
    }
}

function saveOrder(hidID,bodyTableID)
{
   
    var bodyTable = document.getElementById(''+bodyTableID)
    var hidArticlesOrder = document.getElementById(''+hidID)
    var trItems = [];
    
    if(bodyTable!=null && hidArticlesOrder!=null)
    {
          for(var i=0;i<bodyTable.children.length;i++)
	      {
	         var child = bodyTable.children.item(i);
			 if(child!=null && typeof(child.guid)!='undefined')
             {   
			    trItems.push(child);    				    
			 }
	      }
	      hidArticlesOrder.value = '';
	      // find the item
	      for(var i=0;i<trItems.length;i++)
	      {
	         trItem = trItems[i];
	         if(hidArticlesOrder.value.length>0)
	         {
	            hidArticlesOrder.value += ',';
	         }
	         hidArticlesOrder.value += trItem.guid;
	      }
	      
	      
	}
}
function setItemOrder(guid, hid, bodyTableID, UpOrDown) {

    var bodyTable = document.getElementById('' + bodyTableID)
    var trItems = [];

    if (bodyTable != null) {
        while (bodyTable.children.length > 0) {
            var child = bodyTable.removeChild(bodyTable.children.item(0));
            if (child != null && typeof (child.guid) != 'undefined') {
                trItems.push(child);
            }
        }
        var lastIndex = -1;
        var trItem = null;

        // find the item
        for (var i = 0; i < trItems.length; i++) {
            trItem = trItems[i];
            if (trItem.guid == guid) {
                lastIndex = i;

                break;
            }
        }
        if (lastIndex != -1) {

            // remove old location
            trItems.splice(lastIndex, 1);
            // add new location
            if (UpOrDown == 'UP') {
                trItems.splice(lastIndex - 1, 0, trItem);
            }
            else {
                trItems.splice(lastIndex + 1, 0, trItem);
            }
        }

        for (var i = 0; i < trItems.length; i++) {

            bodyTable.appendChild(trItems[i]);

            var btnDown = document.getElementById(trItems[i].btnDownID);
            var btnUp = document.getElementById(trItems[i].btnUpID);
            if (btnDown != null && btnUp != null) {
                if (i == 0) {
                    btnDown.style.visibility = 'visible';
                    btnUp.style.visibility = 'hidden';
                }
                else {

                    if (i == (trItems.length - 1)) {
                        btnDown.style.visibility = 'hidden';
                        btnUp.style.visibility = 'visible';
                    }
                    else {
                        btnDown.style.visibility = 'visible';
                        btnUp.style.visibility = 'visible';
                    }

                }
            }
        }
        // fix CSS
        for (var i = 0; i < bodyTable.children.length; i++) {
            var row = bodyTable.children.item(i);
            if (row.guid == guid) {
                row.className = 'lastOrderItem';
            }
            else {
                row.className = 'notlastOrderItem';
            }
        }

    }
}
function checkSearchValid(oSrc, args) {

    if (args.Value.length > 0 && args.Value != 'חיפוש באתר') {
        args.IsValid = true;
    }
    else {
        args.IsValid = false;
    }
}

var AudioPlayer = function() { var H = []; var D; var F = ""; var A = {}; var E = -1; var G = "9"; function B(I) { if (document.all && !window[I]) { for (var J = 0; J < document.forms.length; J++) { if (document.forms[J][I]) { return document.forms[J][I]; break } } } return document.all ? window[I] : document[I] } function C(I, J, K) { B(I).addListener(J, K) } return { setup: function(J, I) { F = J; A = I; if (swfobject.hasFlashPlayerVersion(G)) { swfobject.switchOffAutoHideShow(); swfobject.createCSS("p.audioplayer_container span", "visibility:hidden;height:24px;overflow:hidden;padding:0;border:none;") } }, getPlayer: function(I) { return B(I) }, addListener: function(I, J, K) { C(I, J, K) }, embed: function(I, K) { var N = {}; var L; var J = {}; var O = {}; var M = {}; for (L in A) { N[L] = A[L] } for (L in K) { N[L] = K[L] } if (N.transparentpagebg == "yes") { J.bgcolor = "#FFFFFF"; J.wmode = "transparent" } else { if (N.pagebg) { J.bgcolor = "#" + N.pagebg } J.wmode = "opaque" } J.menu = "false"; for (L in N) { if (L == "pagebg" || L == "width" || L == "transparentpagebg") { continue } O[L] = N[L] } M.name = I; M.style = "outline: none"; O.playerID = I; swfobject.embedSWF(F, I, N.width.toString(), "24", G, false, O, J, M); H.push(I) }, syncVolumes: function(I, K) { E = K; for (var J = 0; J < H.length; J++) { if (H[J] != I) { B(H[J]).setVolume(E) } } }, activate: function(I, J) { if (D && D != I) { B(D).close() } D = I }, load: function(K, I, L, J) { B(K).load(I, L, J) }, close: function(I) { B(I).close(); if (I == D) { D = null } }, open: function(I, J) { if (J == undefined) { J = 1 } B(I).open(J == undefined ? 0 : J - 1) }, getVolume: function(I) { return E } } } ();
  
