﻿var _box_shown = false;

function loaded(arg) {
  $(document).ready(function(){
	//alert('alive');
	if ($(window).width() < 1100) {
	  $('body').addClass('little_screen');
	}
	
	function mycarousel_initCallback(carousel)
	{
		 // Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});

		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});

		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};

	
	jQuery('#anahot').jcarousel({
		auto: 1,
        wrap: 'last',
		animation: 1700,
		easing:'linear',
		initCallback: mycarousel_initCallback		
    });
    // Auto submit exposed filters in jobs & management
    $("form#views-filters select").change(function() {
      $("form#views-filters").submit();
    });
    
    $('a[@rel*=lightbox]').lightBox({
      overlayBgColor: '#333333',
      overlayOpacity: 0.2,
      imageLoading: '/static/rimonim/images/lightbox/lightbox-ico-loading.gif',
      imageBtnClose: '/static/rimonim/images/lightbox/close.gif',
      imageBtnPrev: '/static/rimonim/images/lightbox/prev.gif',
      imageBtnNext: '/static/rimonim/images/lighbox/next.gif',
      containerResizeSpeed: 350,
      txtImage: 'תמונה',
      txtOf: 'מתוך'
    });
    
    //$('a[@rel*=facebox]').facebox();
    
    /*
    //popup window of guest book
    $("#gblink").append("<em></em>");
    $("#gblink").click(
    // mouse clicks the object
    
    function() {
      if(!_box_shown) {
        //$(this).find("em").animate({opacity: "show", top: "-222", left: "-122"}, "slow");
	$(this).find("em").animate({opacity: "show", top: "-222", left: "122"}, "slow");
        $(this).find("em").load("/node/add/guestbook?arg="+arg, 
          function() {
            $(this).prepend('<div id="close">X</div>');
            $("#close").click(
              function() {
                $("#gblink").find("em").animate({opacity: "hide", top: "-180"}, "slow");
                setTimeout('_box_shown = false', 1000);
              }
            )
          }
        );

        //$(this).find("em").text(hoverText);
        _box_shown = true;
      }
    });
    */
    /*$('#navigator').hover(function() {
        $(this).removeClass("opacitied");
      })*/
    
    $('#open_hotels').click(function(){
      $('#a-logo').show();
      $('ul.primary-links').show();
      $('#close_hotels').show();
      $(this).hide();
    });
    
    $('#close_hotels').click(function(){
      $('#open_hotels').show();
      $('#a-logo').hide();
      $('ul.primary-links').hide();
      $(this).hide();
    });
    
  });
  
  
 $("#webform-client-form-24 select[@name='submitted[hotels_fieldset][hotels][]'] option[@selected='selected']").css("background", "#e7e7e7");
 $("#edit-attachment").attr({size:41});
  
}

function rimonim_home_DoFSCommand(command, args) {
  $('#navigator').addClass("opacitied");
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<' + 'script language="vbscript"' + '>' + "\n");
	document.write('On Error Resume Next' + "\n");
	document.write('Sub rimonim_home_FSCommand(ByVal command, ByVal args)' + "\n");
	document.write('Call rimonim_home_DoFSCommand(command, args)' + "\n");
	document.write('End Sub' + "\n");
	document.write('<' + '/script' + '>' + "\n");
}

function op_div(div) {
  div='#'+div;
  if($(div).is(":visible"))
    $(div).hide("fast");
  else
    $(div).toggle("fast");
}