function actionWhenLoad() {
}
string_to_do_when_close = '';

function setCookie(name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function show_info_bubble(textBlockId) {	
	
	jQuery('#infoBubble').find('.bubbleMessage').css('max-height', '400px').css('overflow', 'scroll');
	
	var textH = jQuery('#textBlock_' + textBlockId + ' .textBlockHeader').html();
	jQuery('#infoBubble').find('.bubbleHtext').html(textH);
	var textC = jQuery('#textBlock_' + textBlockId + ' .textBlockContent').html();
	jQuery('#infoBubble').find('.bubbleMessage').html(textC);
	
	
	jQuery('#infoBubble').jqmShow();
}

jQuery(window).load(function(){
		var modWinWidth = jQuery("#modNewMansNL .modBody").width();	
	//на левую и правую полосы - по 60px
	modWinWidth_active = modWinWidth - 2 * 60; 
	modNewMansNL_photoCount = 2 * Math.floor(modWinWidth_active / 237);
	
	
	
	if ((getCookie('modNewMansNL_photoCount') == null) || ((getCookie('modNewMansNL_photoCount') != null) && (getCookie('modNewMansNL_photoCount') != modNewMansNL_photoCount))) {
		setCookie('modNewMansNL_photoCount', modNewMansNL_photoCount);
		setCookie('modNewMansNL_page', 1);
	} else {
		if (getCookie('modNewMansNL_page') == null) {
			setCookie('modNewMansNL_page', 1);			   
		} 			
	}
	window.modNewMansNL_page = getCookie('modNewMansNL_page');	
	window.modNewMansNL_photoCount = getCookie('modNewMansNL_photoCount');	
	

	modNewMansNL_fn_show();
							 
})

jQuery(document).ready(function(){
	
	
	
	
	jQuery('#infoBubble').jqm({
		closeClass: 'ajaxInfoBubbleClose',
		trigger: 'InfoBubbleJqModal'						   
	})
	
	
	
	
})
function my_modNewMansNL_fn_show(modNewMansNL_page, modNewMansNL_photoCount) {
	
	setCookie('modNewMansNL_page', modNewMansNL_page);
	setCookie('modNewMansNL_photoCount', modNewMansNL_photoCount);	
	modNewMansNL_fn_show();
}

jQuery(window).resize(function() {
  	
	var modWinWidth = jQuery("#modNewMansNL .modBody").width();	
	modWinWidth_active = modWinWidth - 2 * 60; 
	modNewMansNL_photoCount = 2 * Math.floor(modWinWidth_active / 237);
	
	if ((getCookie('modNewMansNL_photoCount') == null) || ((getCookie('modNewMansNL_photoCount') != null) && (getCookie('modNewMansNL_photoCount') != modNewMansNL_photoCount))) {
		setCookie('modNewMansNL_photoCount', modNewMansNL_photoCount);	
	}	
	window.modNewMansNL_photoCount = getCookie('modNewMansNL_photoCount');	
	
	modNewMansNL_fn_show();
});


function check_if_all_loaded_01() {
	window.toLoadCount_01 = window.toLoadCount_01 - 1;
	if (window.toLoadCount_01 == 0) {
					  var topmiladyresponse = window.if_all_loaded_parameters.topmiladyresponse;
		
		
		
					  jQuery('#modNewMansNL #forPhotosWr').css('background', 'none');
					  jQuery('#modNewMansNL #forPhotos').html(topmiladyresponse.htmlContent);
					  if (topmiladyresponse.beforepage_nl != '') {
						 jQuery('#modNewMansNL #beforeLinkCell').html('<a href="javascript:my_modNewMansNL_fn_show(\'' + topmiladyresponse.beforepage_nl + '\', \'' + topmiladyresponse.photoCount + '\')"><img src="images/spacer.gif" style="width:32px; height:708px;" /></a>'); 
					  } else {
						 jQuery('#modNewMansNL #beforeLinkCell').html('&nbsp;');  
					  }
					  if (topmiladyresponse.nextpage_nl != '') {
						 jQuery('#modNewMansNL #afterLinkCell').html('<a href="javascript:my_modNewMansNL_fn_show(\'' + topmiladyresponse.nextpage_nl + '\', \'' + topmiladyresponse.photoCount + '\')"><img src="images/spacer.gif" style="width:32px; height:708px;" /></a>'); 
					  } else {
						 jQuery('#modNewMansNL #afterLinkCell').html('&nbsp;');    
					  }
		
		
	}
};



function modNewMansNL_fn_show() {	
	
	
	
	
	var diff = jQuery(document).height() - jQuery('#gnl_main_heading').height();
	var m_top = Math.ceil((diff - 1400) / 2);
	if (m_top > 0) {
		jQuery('#modNewMansNL .modBody').css('margin-top', '' + m_top + 'px');
	}
	
	jQuery('#modNewMansNL #forPhotosWr').css('background-color', '#ffffff');
	jQuery('#modNewMansNL #forPhotos').html('<div style="width:300px; height:250px; text-align:center; vertical-align:middle; margin:auto; color:#660000; margin-top:300px;">Загрузка ...<br><img src="images/ajax-loaderFull.gif" align="middle" style="margin:auto;" /></div>');
	
	jQuery.ajax({
				   type: "POST",
				   url:  "ajax_mod_new_mans_nl.php",
				   data: "pagesize=" + encodeURIComponent(getCookie('modNewMansNL_photoCount')) + '&page=' + encodeURIComponent(getCookie('modNewMansNL_page')),
				   success: function(response_json) {					 
					  topmiladyresponse = eval('(' + response_json + ')');
					  window.if_all_loaded_parameters = [];
					  window.if_all_loaded_parameters.topmiladyresponse = topmiladyresponse;
					 
					  var photos_arr = topmiladyresponse.photos_arr;					 
					  window.toLoadCount_01 = photos_arr.length;
						jQuery.each(photos_arr, function(i, val) {								
								jQuery('<img />').attr('src', val).load(function(){
        							check_if_all_loaded_01();      
    							});								
						});
					  
					 
					  
					  
					 
					   
				   }
				})
}
