var pht_slide;
var initStatus = 0;
function initPhotoBox(num, obj) {
var num = num;
var sess_id = session_id;
var pict = $(obj).find('img');
initZeroLevel(); /* блокирующий слой */
var photos_DB = photo_db['g' + num];
var pict_w = photos_DB[0].w + 200;
var pict_h = photos_DB[0].h + 320;
getPhotosData(sess_id, num, pict_w, pict_h);
}
$(window).bind('resize', function() {
if (pht_slide == 1) {
if (initStatus == 5) {
initZeroLevel();
}
}
});
function initZeroLevel() {
var w = parseInt(getDocWidth());
var h = parseInt(getDocHeight());
if ($.browser.msie && $.browser.version < 7 || $.browser.msie && $.browser.version == 8) {
w = w - 21;
}
if ( $('#zeroLevel').length > 0 ) {
$('#zeroLevel').css({'width' : w + 'px' , 'height' : h + 'px', 'display' : 'block'});
if ($('#secondLevel').attr('save') != 1) {
preloadedText(w, h);
}
}
else {
var page = $('body');
$('
').attr('id', 'zeroLevel').css($.extend({}, {
display: 'none',
width: w + 'px',
height: h + 'px',
position: 'absolute',
left: '0px',
top: '0px',
zIndex: 1000
})).appendTo(page);
$('#zeroLevel').css('display', 'block');
preloadedText(w, h);
}
if ($('#secondLevel').length > 0) {
if ($('#secondLevel').css('display') == 'block') {
if ($('#endPhotosLevel').length > 0) {
}
else {
preloadedTextPosition(w);
}
}
}
if ($('#endPhotosLevel').length > 0) {
var box = parseInt($('#endPhotosLevel').width());
var w1 = (parseInt(getDocWidth()) - box)/2;
var $lefty = $('#endPhotosLevel');
if (parseInt($lefty.css('height')) > $(window).height()) {
var h1 = $(document).scrollTop();
}
else {
var h1 = parseInt($(window).height()) - parseInt($('#endPhotosLevel').height());
h1 = h1/2 + $(document).scrollTop();
}
$lefty.css({'left' : w1 + 'px' , 'top' : h1});
}
initStatus = 5;
}
function preloadedText(w, h) {
if ( $('#secondLevel').length > 0 ) {
$('#secondLevel').css({'width' : w + 'px' , 'height' : h + 'px', 'display' : 'block'});
preloadedTextPosition(w);
}
else {
var page = $('body');
$('').attr('id', 'secondLevel').css($.extend({}, {
display: 'none',
width: w + 'px',
height: h + 'px',
position: 'absolute',
left: '0px',
top: '0px',
zIndex: 1001
})).appendTo(page);
$('#secondLevel').css('display', 'block');
var message = '';
$('#secondLevel').php(message);
preloadedTextPosition(w);
if ($.browser.msie && $.browser.version == 8) {
$('#layerFlyModalIntro').css({'display' : 'block'});
}
else {
$('#layerFlyModalIntro').css({'clip':'rect(150px 200px 150px 200px)', 'display' : 'block'});
$('#layerFlyModalIntro').stop().animate({'clip':'rect(0px 400px 300px 0px)'}, 1500);
}
}
}
function preloadedTextPosition(w) {
var tm = (Math.floor($(window).height()) - 300)/2;
var top_t = $(document).scrollTop() + tm;
var top_w = Math.floor(((w-300)/2));
$('#layerFlyModalIntro').css({'top' : top_t + 'px'});
$('#layerFlyModalIntro').css({'left' : top_w + 'px'});
}
function getPhotosData(sess_id, num, pict_w, pict_h) {
var sess_id = sess_id;
var num = num;
$.ajax({
type: "GET",
url: '/frame.php',
cache: false,
data: "session=" + sess_id + '&cur_photos=' + num,
dataType: "html",
error: function() {},
success: function(html){
createBlock(html, pict_w, pict_h);
}
});
}
function pastePhotosTo($lefty, html) {
$('#endPhotosLevel').stopTime("waitTime");
var box = parseInt($('#endPhotosLevel').width());
var w1 = (parseInt(getDocWidth()) - box)/2;
if (parseInt($lefty.css('height')) > $(window).height()) {
var h1 = $(document).scrollTop();
}
else {
var h1 = parseInt($(window).height()) - parseInt($('#endPhotosLevel').height());
h1 = $(document).scrollTop() + (h1/2);
}
$lefty.css({'left' : w1 + 'px' , 'top' : h1});
$lefty.php(html);
$lefty.css('display', 'block');
initFrameSlider();
/* убираем пред_текст */
$('#secondLevel').css('display', 'none');
$('#secondLevel').attr('save', '1');
}
function createBlock(html, pict_w, pict_h) {
if ( $('#endPhotosLevel').length > 0 ) {
//$('#zeroLevel').css({'width' : w + 'px' , 'height' : h + 'px'});
}
else {
var page = $('body');
$('').attr('id', 'endPhotosLevel').css($.extend({}, {
display: 'none',
position: 'absolute',
left: '0px',
top: '0px',
float: 'left',
zIndex: 1002
})).appendTo(page);
}
var $lefty = $('#endPhotosLevel');
var pict_w = 880; /* переопределеяем */
$lefty.css({'width' : pict_w + 'px' , 'height' : pict_h + 'px'});
$('#endPhotosLevel').everyTime(500, "waitTime", function() {pastePhotosTo($lefty, html);});
}
function _closePhotosBox() {
initStatus = 0;
$('#secondLevel').attr('save', '0');
if ($('#zeroLevel').length > 0) {$('#zeroLevel').css('display', 'none');}
if ($('#secondLevel').length > 0) {$('#secondLevel').css('display', 'none');}
if ($('#endPhotosLevel').length > 0) {$('#endPhotosLevel').css('display', 'none');}
}
/* функции для получения ширины и высоты всей страницы */
function getDocHeight() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}
function getDocWidth() {
var D = document;
return Math.max(
Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
Math.max(D.body.clientWidth, D.documentElement.clientWidth)
);
}