﻿//$(function() {
//    var so = new SWFObject("flash/evolution.swf", "evolution", "650", "490", "8", "#FFffff");
//    so.addParam("scale", "noscale");
//    so.addParam("wmode", "opaque");
//    so.addParam("wmode", "transparent");
//    if (gethtmlVersion() != "true") {
//        so.write("flash_content_E");
//    }
//})

var currenPic = 0;
var popWinIndex;
var tempalteID = 0;
var width = 658;
var height = 919;
var left;
var scrollTop;
var midtop;
var midleft;
var winheight;
var winwidth;
var isOpen = false;

$(function () {
    $(".link > a > img").css("cursor", "pointer");
    $(".closepopAD > a").click(function () {
        $(".pop_box").animate({ "opacity": 0 }, 500);
        
        $(".pop_cont").animate({ "width": 0, "left": midleft, "top": midtop, "height": 0, "opacity": 0 }, 500, function () {
            $(".pop_box").hide();
            $(".pop_cont").hide();
        });
        isOpen = false;
    });
    //    $(window).resize(function() {
    //        if (isOpen) {
    //            var winheight = parseInt($(document).height());
    //            var winwidth = parseInt($("body").width());
    //            $(".pop_box").attr("style", "top:0px;width:" + winwidth + "px;height:" + winheight + "px;left:0px;opacity:0.5;display:block;filter:alpha(opacity=50);");
    //            top = parseInt(($.pageHeight() - height)) + $(document).scrollTop();
    //            left = parseInt(Math.ceil($("body").width()) / 2 - (parseInt(width) / 2));
    //            $(".pop_cont").attr("style", "top:" + top + "px;width:" + width + "px;height:" + height + "px;left:" + left + "px;opacity:1;display:block;filter:alpha(opacity=100);");
    //        }
    //    });
});

function openPopUp(index) {
    currenPic = 0;
    popWinIndex = index;
    $(".pop_cont > .popAD > img").hide();
    $("#Print_" + index + "_0").animate({ "opacity": 100 }, 0).show();
    $("#Print_" + index + "_1").animate({ "opacity": 0 }, 0).hide();
    $(".pop_box").animate({ "opacity": 0 }, 1);
    left = parseInt(Math.ceil($("body").width()) / 2 - (parseInt(width) / 2));
    scrollTop = $(document).scrollTop();
    winheight = parseInt($(document).height());
    midleft = parseInt(document.body.clientWidth) / 2;
    midtop = parseInt($.pageHeight()) + $(document).scrollTop();
    winwidth = parseInt($("body").width());
    $(".popAD").show();
    $(".pop_box").attr("style", "height:" + winheight + "px;width:" + winwidth + "px");
    $(".pop_box").animate({ "opacity": 0.5 }, 500);
    $(".pop_cont").attr("style", "top:" + midtop + "px;width:1px;height:1px;left:" + midleft + "px");
    $(".pop_cont").animate({ "width": width, "left": left, "top": scrollTop, "height": height, "opacity": 1 }, 500, function () {
        $('.closepopAD').css("top", (scrollTop + 11) + "px").show();
    });
    isOpen = true;
}

function closePopUp(index) {      
        $(".pop_box").animate({ "opacity": 0 }, 500);
        $(".closepopAD").animate({ "width": 0, "left": midleft, "top": midtop, "height": 0 }, 500); 
        $(".pop_cont").animate({ "width": 0, "left": midleft, "top": midtop, "height": 0, "opacity": 0 }, 500, function() {
            $(".pop_box").hide();
            $(".pop_cont").hide();
			$('.closepopAD').hide();
        });
        isOpen = false;
 }

function showPic(d) {
    var prePic = currenPic;
    if (d = "pre") {
        currenPic -= 1;
    }else {
        currenPic += 1;
    }
    currenPic = currenPic % 2;
    if (currenPic < 0) {
        currenPic = -currenPic;
    }
    $("#Print_" + popWinIndex + "_" + prePic).animate({ "opacity": 0 }, 0).hide();
    $("#Print_" + popWinIndex + "_" + currenPic).animate({ "opacity": 1 }, 500).show();
}
$.pageWidth = function() {
    return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

$.pageHeight = function() {
    return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}
