/***************************************
********** START RECIPE BANNER OVERLAY IN LISTINGS
*************************************************/

function rw_recipe_banner_overlay_list(){

		$('.rw_vid_overlay_list').each(function(){

			//get sibling image size
			var rw_overlay_sib_w = $(this).siblings('.rw_recipe_banner_pic').width();
			$(this).css({'width':rw_overlay_sib_w+'px'});

			

		});//close each

		

};//close rw_recipe_banner_overlay_list


/***************************************
********** END RECIPE BANNER OVERLAY IN LISTINGS
*************************************************/








					/***************************************
					********** START HANDLING OF RECIPE BANNERS
					*************************************************/

						function rw_recipe_pic_ht(){
							
							//.rw_recipe_paper_hold .rw_featured_banner .rw_left img
							//var rw_recipe_pic_ht = $('.rw_recipe_paper_hold').children('.rw_featured_banner').children('.rw_left')
							$('.rw_targ_banner').each(function(index){
									var rw_recipe_pic_ht = $(this).children('.rw_left').children('img').height();
									//console.log(rw_recipe_pic_ht);
									$(this).children('.rw_left').siblings('.rw_right').css({'height':rw_recipe_pic_ht+'px'})
							});//close each loop

							rw_font_perc_listen();


						};//rw_recipe_pic_ht function


						function rw_recipe_txt_center(){

								$('.rw_recipe_banner_txt').each(function(index){
										  var rw_recipe_txt_parent_ht = $(this).parent('.rw_right').height();
										  var rw_recipe_txt_ht = $(this).height();
										  var rw_recipe_txt_diff = rw_recipe_txt_parent_ht-rw_recipe_txt_ht;
										  var rw_recipe_txt_offset = rw_recipe_txt_diff/2;
										  $(this).css({'margin-top':rw_recipe_txt_offset+'px'})
								});//close each loop



						};//close recipe txt center function



					/***************************************
					********** END HANDLING OF RECIPE BANNERS
					*************************************************/



					/***** FONT CONTROL LISTENER ************/
					function rw_font_perc_listen(){

						$('.rw_font_targ').each(function(index){

								//grab the percentage of the scale of the font desired
								var rw_font_scale_factor = $(this).attr('rw_scale');

								var rw_update_font_size = rw_font_percent_control(rw_font_scale_factor);
								//alert(rw_update_font_size);
								$(this).css({'font-size':rw_update_font_size+'px'})


						});//close each loop

						rw_recipe_txt_center();

					};//close rw_font_perc_listen








					/********** FONT PERCENTAGE CONTROL BASED ON BASE FONT AND 1200 PIXEL WIDTH ************/

					function rw_font_percent_control(rw_scale_factor){

						  var rw_base_font = 12;
						  var rw_max_screen_width = 1200;

						  var rw_current_screen_width = $('#rw_main_hold').width();
						  var rw_screen_perc_diff = rw_current_screen_width/rw_max_screen_width;

						  if(rw_current_screen_width<rw_max_screen_width){

								//convert percentages to the goal fonts size desired
								var rw_goal_scale_factor = rw_scale_factor*rw_base_font;

								//find a perc of the goal font size based on perc of screen diff
								var rw_final_font_size = rw_goal_scale_factor*rw_screen_perc_diff;


						  }else{

								var rw_final_font_size = rw_scale_factor*rw_base_font;

						  };//close if screen width
						  return rw_final_font_size;



					};//close font percent control



/****************************************************
******** RECIPE PAGINATION
**************/

/*******************************************************************************/
/******** RECIPE PAGINATE FUNCTION ******************************************/

				  function rw_paginationFunction(rw_limit,rw_offset){
						  rw_offset=rw_offset*rw_limit;
						  //var rw_listview_filter_value = $("#rw_listview_filter").val();
						  //window.scrollTo(0,800);


						  $.ajax({
								method: "GET",
								url: "/listings/recipe-full-search",

								//rw_listview_filter_value_passed='+rw_listview_filter_value
								//rw_limitNumber='+limit
								//offset='+offset

								data: { rw_limitNumber: rw_limit, rw_offset: rw_offset}
						  })
							.done(function( msg ) {
								  //alert( "Data Saved: " + msg );
								  $('#rw_ajax_target').html(msg);
								  rw_recipe_pic_ht();
						   });//close ajax



				  };//close pagination function


















/*******************************************************************************/
/******** RECIPE PAGINATE FUNCTION OLD ******************************************/

				  function rw_paginationFunctionOLD(rw_limit,rw_offset){
						  rw_offset=rw_offset*rw_limit;
						  //var rw_listview_filter_value = $("#rw_listview_filter").val();
						  //window.scrollTo(0,800);


						  $.ajax({
								method: "GET",
								url: "/listings/recipe_main_paging_ajax_filter.php",

								//rw_listview_filter_value_passed='+rw_listview_filter_value
								//rw_limitNumber='+limit
								//offset='+offset

								data: { rw_limitNumber: rw_limit, rw_offset: rw_offset}
						  })
							.done(function( msg ) {
								  //alert( "Data Saved: " + msg );
								  $('#rw_ajax_target').html(msg);
								  rw_recipe_pic_ht();
						   });//close ajax



				  };//close pagination function









rw_recipe_pic_ht();


$(window).resize(function(){

	rw_recipe_pic_ht();
	rw_recipe_banner_overlay_list();

});//close resize


$(window).load(function(){

	function rw_rerun_pretty_photo_init(){

			$("a[rel^='prettyPhoto']").prettyPhoto();
			clearInterval(window.rw_recipe_prettyphoto_pause);
	};//pretty photo rerun



	
	rw_recipe_banner_overlay_list();
	clearInterval(window.rw_recipe_banner_overlay_list_pause);
    window.rw_recipe_banner_overlay_list_pause = setInterval(function(){rw_recipe_banner_overlay_list()},1500);
	
	clearInterval(window.rw_recipe_prettyphoto_pause);
    window.rw_recipe_prettyphoto_pause = setInterval(function(){rw_rerun_pretty_photo_init()},1500);
	

});//close load

