﻿var minWidth = 900;
var minHeight = 492;

$(function()
{
	$(window).wresize(doResize);
	doResize();
});

function doResize()
{
	// 页面整体缩放
	var jWindow = $(window);
	var currentWidth = jWindow.width();
	var currentHeight = jWindow.height();
	currentWidth = currentWidth > minWidth ? currentWidth : minWidth;
	currentHeight = currentHeight > minHeight ? currentHeight : minHeight;
	var contentHeight = currentHeight - $("#nav").innerHeight();
	var wrapper = $("#wrapper");
	wrapper.width(currentWidth);
	wrapper.height(currentHeight);
	var content = $("#content");
	content.height(contentHeight);
	// 缩放比例
	var widthRate = parseFloat(currentWidth) / 1280;
	var heightRate = parseFloat(currentHeight) / 700;
	var currentRate = widthRate > heightRate ? heightRate : widthRate;
	// 右侧图片缩放
	var listImg = $("#listImg");
	var listImgWidth = parseInt(420 * currentRate);
	var listImgHeight = parseInt(560 * currentRate);
	showImgWidth = listImgWidth;
	showImgHeight = listImgHeight;
	showImgWidth_Big = showImgWidth * 2 + 20;
	listImg.width(listImgWidth);
	listImg.height(listImgHeight);
	var listImgPic = $("img", listImg);
	listImgPic.width(listImgWidth);
	listImgPic.height(listImgHeight);
	listImgInit(true);
	// 图片弹出层缩放
	showImgWrapperWidth = showImgWidth * 2 + 20 * 2;
	var popupShow = $("#popupShow");
	var showWrapperWidth = showImgWrapperWidth;
	var showWrapperHeight = showImgHeight + 20;
	var showWrapper = $(".showWrapper", popupShow);
	showWrapper.width(showWrapperWidth);
	showWrapper.height(showWrapperHeight);
	var showInnerWrapper = $(".showInnerWrapper", showWrapper);
	$(".img", showInnerWrapper).each(function(i)
	{
		var img = $(this);
		img.width(showImgWidth);
		img.height(showImgHeight);
	});
	$(".bigImg", showInnerWrapper).each(function(i)
	{
		var img = $(this);
		img.width(showImgWidth_Big);
	});
	showInnerWrapper.css("width", showImgPageCount * showImgWrapperWidth);
	showWrapper.scrollLeft((showImgCurrentPage - 1) * (showImgWidth + 20) * 2);
	var showLink = $(".showLink", popupShow);
	showLink.height(showWrapperHeight);
	showLink.css("top", showWrapperHeight * -1);
	var popupWidth = showWrapperWidth;
	var popupHeight = showWrapperHeight + 15 + 10; 	/* title的高度和title的marin */
	var popupMarginTop = (popupHeight + 35) / 2 * -1;
	var popupMarginLeft = (popupWidth + 20) / 2 * -1;
	popupShow.width(popupWidth);
	popupShow.height(popupHeight);
	popupShow.css("margin-top", popupMarginTop);
	popupShow.css("margin-left", popupMarginLeft);
	// 右下角弹出框缩放
	var popupShowInfo = $("#popupShowInfo");
	popupShowInfo.width(popupWidth);
	popupShowInfo.height(popupHeight);
	popupShowInfo.css("margin-top", popupMarginTop);
	popupShowInfo.css("margin-left", popupMarginLeft);
	var ifrmInfo = $("#ifrmInfo", popupShowInfo);
	ifrmInfo.width(popupWidth - 20);
	ifrmInfo.height(popupHeight - 20);
	// 媒体播放弹出层缩放
	var popupShowMedia = $("#popupShowMedia");
	popupShowMedia.width(popupWidth);
	popupShowMedia.height(popupHeight);
	popupShowMedia.css("margin-top", popupMarginTop);
	popupShowMedia.css("margin-left", popupMarginLeft);
	var playerWrapper = $("#playerWrapper", popupShowMedia);
	playerWrapperHeight = parseInt(402 * currentRate);
	playerWrapper.height(playerWrapperHeight);
	var mediaplayer = $("#mediaplayer", playerWrapper);
	playerWidth = parseInt(400 * currentRate);
	playerHeight = parseInt(327 * currentRate);
	playerMarginLeft = playerWidth / 2 * -1;
	mediaplayer.width(playerWidth);
	mediaplayer.height(playerHeight);
	mediaplayer.css("margin-left", playerMarginLeft);
	var playerobject = $("object", playerWrapper);
	playerobject.attr("width", playerWidth);
	playerobject.attr("height", playerHeight);
	playerobject.width(playerWidth);
	playerobject.height(playerHeight);
	var playerembed = $("embed", playerWrapper);
	playerembed.attr("width", playerWidth);
	playerembed.attr("height", playerHeight);
	playerembed.width(playerWidth);
	playerembed.height(playerHeight);
	showMarqueeWrapperWidth = parseInt(820 * currentRate);
	showMediaImgWidth = parseInt(150 * currentRate);
	showMediaImgHeight = parseInt(100 * currentRate);
	showMediaInnerWrapperWidth = showMediaImgWidth + 1 * 2 + 6 * 2;
	showMarqueeWidth = showMediaInnerWrapperWidth * 4;
	while (showMarqueeWidth + showMediaInnerWrapperWidth < showMarqueeWrapperWidth)
	{
		showMarqueeWidth += showMediaInnerWrapperWidth
	}
	showMarqueeHeight = showMediaImgHeight + 1 * 2 + 6 * 2;
	var showMarquee = $("#showMarquee", popupShowMedia);
	$("img", showMarquee).each(function(i)
	{
		var img = $(this);
		img.width(showMediaImgWidth);
		img.height(showMediaImgHeight);
	});
	$(".showMarqueeWrapper", popupShowMedia).width(showMarqueeWrapperWidth - 5);
	var showMarquee = $("#showMarquee", popupShowMedia);
	showMarquee.width(showMarqueeWidth);
	showMarquee.height(showMarqueeHeight);
	$(".sorrow_left", popupShowMedia).height(showMediaImgHeight + 2);
	$(".sorrow_right", popupShowMedia).height(showMediaImgHeight + 2);
}
