var run_float_bnr = 1;

$(document).ready(function() {	
	$('.s-hp-link').click(function(){
		location = "/";
	})
	
	// side menu
	$('.s-men-side > div[@class^=s-men-side-lev], .s-men-album > div[@class^=s-men-album-lev]').each(function(){
		if ($(this).attr('status')=='ac'){
			$(this).css('background', '#8EB4E0');
			$(this).css('border-bottom', '1px solid #fff');					
			$(this).prev().css('border-bottom', '1px solid #fff');
			$('a', this).css('color', '#fff');
		}
		if ($(this).attr('status')=='dy')
			$(this).css('background', '');			
	});
	$('.s-men-side > div[@class^=s-men-side-lev], .s-men-album > div[@class^=s-men-album-lev]').hover(function(){
		if ($(this).attr('status')!='ac')
			$(this).css('background', '#EBF3F6');
	}, function(){
		if ($(this).attr('status')!='ac')
			$(this).css('background', '');	
	});
		
	// google search
	if (!window.goo_srch_type || window.goo_srch_type=='data')
		$($('.gsbox-1-opt').get(0)).attr('class', 'gsbox-1-opt-pr');
	else{
		$('.gsbox-1-opt').each(function(){
			if ($(this).attr('id')==window.goo_srch_type)
				$(this).attr('class', 'gsbox-1-opt-pr');
		});
	}
	$('.gsbox-1-opt, .gsbox-1-opt-pr').click(function(){
		$('.gsbox-1-opt-pr').attr('class', 'gsbox-1-opt');
		$(this).attr('class', 'gsbox-1-opt-pr');		
	});	
	
	$('.gsbox-1-opt').hover(function(){
		if ($(this).attr('class')=='gsbox-1-opt-pr')
			$(this).css('color', '#fff');
		else
			$(this).css('color', 'red');
	},function(){
		$(this).css('color', '');
	});	
	
	$('.popup').click(function(){	
		var html = '<b>test</b><br/>this is a test<br/><br/><br/><span class="prompt_close">Close</span>';
		$.prompt2(html, {
		    width:780,
			height:450,
			url: '/ask_the_agent/',
			scrolling: 'no'
		});
	});
	
	$('.popup2').click(function(){
		 $.prompt('Example 12<p>Save these settings?</p>eran<br/><br/><br/>eran<br/><br/><br/>eran<br/><br/><br/>',{
		      buttons:{ Apply:1,Maybe:2,Never:3 },
		      width:780,
		      height:350,
			  url: '/ask_the_agent/',
			  scrolling: 'no', 
			  opacity: 0.6,
		      prefix:'colsJqi',
		      show:'slideDown'
		      
		}).corner();
	});

	$('#tick_test1').click(function(){
		alert('aaa');
	});
	
	// floating banner	
	var screen_width = $(document).width();
	if (screen_width<1100)
		run_float_bnr = 0;
	if (run_float_bnr){		
		$(".flt-bnr").css('display', 'block');	
		$(window).scroll(function(){
			if  ($(window).scrollTop() > $(".flt-bnr-ext").offset({ scroll: false }).top){
		    	$(".flt-bnr").css("position", "fixed");
		    	$(".flt-bnr").css("top", "0");
			}
			if  ($(window).scrollTop() <= $(".flt-bnr-ext").offset({ scroll: false }).top){
		    	$(".flt-bnr").css("position", "absolute");
		   		$(".flt-bnr").css("top", $(".flt-bnr-ext").offset);
			}
		}); 		
	}
	else{
	}
});

function search_google(){
	var what = $('.gsbox-1-opt-pr').attr('id');
	$('#srch_type').val(what);
	var q = $('#q').val();		
	if (!q)
		return false;
	
	switch(what){
		case 'web':
				return true;
			break;
		case 'yahav':
				$('#sitesearch').val('www.yahav.org');
			break;
		default:
			$('#sitesearch').val('www.yahav.org');
			q = q + ' ' + goo_srch_options[what]
			$('#q').val(q)				
	}
}

function add_book_mark(){
	url = "http://www.yahav.org/";
	title = $('.ya-upper-in').attr('fav_lbl');
		
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}		
}

function clicks_counter(type, go_url, cur_url, type, col, dont_redirect){
	$.post("/_sys_app/clicks_counter/",
		{ target_url: go_url, current_url: cur_url, type: type, cc_col: col},
		function(data){
			//alert(data)
	  	}
	);
}
