var sidebarOrigTop;

// general settings
$(document).ready(function() { 
	sidebarOrigTop = $("#sidebar").offset().top;
	
	syncContentHeight();

	// search box - handle "default" text . right now only works on search box!
	var defaultSearchTxt = 'חפשו במאגר לפי שם חברה או תחום';
	$('.search_site .untouched').val(defaultSearchTxt);
	$('.untouched').focus(function() {
		if ($(this).val() == defaultSearchTxt) {
			$(this).removeClass('untouched');
			$(this).val('');
			$(this).blur(function() {
				if (!$(this).val()) {
					$(this).addClass('untouched');
					$(this).val(defaultSearchTxt);
				}
			});
		}
	});
	
	
});


// image rotation on index page
$('#mainImg').crossSlide({
  sleep: 2,
  fade: 1
}, [
  { src: 'images/homepage-img1.png' },
  { src: 'images/homepage-img2.png' }
]);


// make the sidebar scroll with the window
/*
$(window).scroll(function() {
	var min = sidebarOrigTop;
	var max = $("#footer").offset().top - $("#sidebar").height();
	var newTop = $(window).scrollTop()+sidebarOrigTop;
	if (newTop > max) newTop = max;
	if (newTop < min) newTop = min;
    $("#sidebar").css("top", newTop + "px");
});
*/


function syncContentHeight() {
	if ($('#cse').height() > 0)
		return;
	if ($('#sidebar').height() > $('#content').height())
		$('#content').height($('#sidebar').height());
//	if ($('#cse').height() > $('#content').height())
//		$('#content').height($('#cse').height());
}