﻿function LoadImage(Img,pw,ph){
var image=new Image();
image.src=Img.src;
if(image.width>0 && image.height>0){
if(image.width/image.height>= pw/ph){
if(image.width>pw){
Img.width=pw;
Img.height=(image.height*pw)/image.width;
}else{
Img.width=image.width;  
Img.height=image.height;
}
}
else{
if(image.height>ph){
Img.height=ph;
Img.width=(image.width*ph)/image.height;
}else{
Img.width=image.width;
Img.height=image.height;
}
}
}
}
function LoadPageImg(Img,pw){
if (pw < 750) {
var images = new Image();
images.src = Img.src;
if (Img.offsetWidth > pw) {
Img.style.width = pw;
Img.style.height = (images.height * pw) / images.width;
}
if (Img.style.width) {
if (parseInt(Img.style.width.replace(/px/i,"")) > pw) {
Img.style.width = pw;
Img.style.height = (images.height * pw) / images.width;
}
}
}
}

function getPage(){
var strInPageObj = document.getElementById("InPageObj");
var strOutPageObj = document.getElementById("OutPageObj");
var strLeftPageObj = document.getElementById("LeftPageObj");
var strPdInfoPageObj = document.getElementById("PdInfoPageObj");
var strInPageEmbed = document.getElementById("InPageEmbed");
if (strInPageObj) {
if (strInPageObj.offsetWidth > InPagew) {strInPageObj.style.width = InPagew;}
for(i=0; i<InPageObj.length; i++) {
if (InPageObj[i].offsetWidth > InPagew) {InPageObj[i].style.width = InPagew;}
}
}
if (strOutPageObj) {
if (strOutPageObj.offsetWidth > OutPagew) {strOutPageObj.style.width = OutPagew;}
for(i=0; i<OutPageObj.length; i++) {
if (OutPageObj[i].offsetWidth > OutPagew) {OutPageObj[i].style.width = OutPagew;}
}
}
if (strLeftPageObj) {
if (strLeftPageObj.offsetWidth > InfoPagew) {strLeftPageObj.style.width = InfoPagew;}
for(i=0; i<LeftPageObj.length; i++) {
if (LeftPageObj[i].offsetWidth > InfoPagew) {LeftPageObj[i].style.width = InfoPagew;}
}
}
if (strPdInfoPageObj) {
if (strPdInfoPageObj.offsetWidth > PdInfoPagew) {strPdInfoPageObj.style.width = PdInfoPagew;}
for(i=0; i<PdInfoPageObj.length; i++) {
if (PdInfoPageObj[i].offsetWidth > PdInfoPagew) {PdInfoPageObj[i].style.width = PdInfoPagew;}
}
}
if (strInPageEmbed) {
if (strInPageEmbed.offsetWidth > InPagew) {strInPageEmbed.style.width = InPagew;}
for(i=0; i<InPageEmbed.length; i++) {
if (InPageEmbed[i].offsetWidth > InPagew) {InPageEmbed[i].style.width = InPagew;}
}
}
}

function TPageLoad(){
var TPage2 = document.getElementById("TPage2");
TPage2.style.top = (document.body.scrollTop) + (document.body.clientHeight / 2) - (TPage2.offsetHeight / 2);
setTimeout("TPageLoad()",100);
}
function GetLoading(str){
var TPage = document.getElementById("TPage");
var TPage2 = document.getElementById("TPage2");
var bdClientWidth = document.body.clientWidth;
var bdClientHeight = document.body.clientHeight;
TPage.style.display = "";
TPage2.style.display = "";
TPage.style.top = 0;
TPage.style.left = 0;
TPage.style.width = bdClientWidth;
TPage.style.height = document.getElementById("bodyPage").offsetHeight;
TPage2.style.width = bdClientWidth;
TPage2.style.height = bdClientHeight;
TPage2.style.left = (bdClientWidth / 2) - (TPage2.offsetWidth / 2); 
TPage2.style.top = (document.body.scrollTop) + (bdClientHeight / 2) - (TPage2.offsetHeight / 2);
document.getElementById("StrTPage").innerHTML = str;
setTimeout("TPageLoad()",100);
}

function GetLoadPage(str){
var TPage2 = document.getElementById("TPage2");
var bdClientWidth = document.body.clientWidth;
var bdClientHeight = document.body.clientHeight;
bodyPage.style.display = "none";
TPage2.style.display = "";
TPage2.style.backgroundColor = "#FFFFFF";
TPage2.style.left = 0;
TPage2.style.top = 0;
TPage2.style.width = bdClientWidth;
TPage2.style.height = bdClientHeight;
document.getElementById("StrTPage").innerHTML = str;
}

function PDwin(link,wname,w,h) {
wname=window.open(link,wname,'resizable=yes,width='+w+',height='+h+',top='+(screen.availHeight/2-h/2)+',left='+(screen.availWidth/2-w/2));
wname.focus();
}
function myWin(link,wname,w,h,Sresizable,Sscrollbars,Sstatus) {
newWin = window.open(link,wname,'resizable='+Sresizable+',scrollbars='+Sscrollbars+',status='+Sstatus+',width='+w+',height='+h+',top='+(screen.availHeight/2-h/2)+',left='+(screen.availWidth/2-w/2));
newWin.focus();
}
function ColorWin(link,wname) {
sColorWin = window.open(link,wname,'resizable=0,scrollbars=0,status=0,width=310,height=230,top='+(screen.availHeight/2-230/2)+',left='+(screen.availWidth/2-310/2));
sColorWin.focus();
}

function RdShowTD(str1,str2){
var str1s = str1.split(",");
var str2s = str2.split(",");
for (var i = 0; i < str1s.length; i++) {
if (document.getElementById(str1s[i])){
document.getElementById(str1s[i]).style.display = "";
}
}
for (var x = 0; x < str2s.length; x++) {
if (document.getElementById(str2s[x])){
document.getElementById(str2s[x]).style.display = "none";
}
}
}

function CbShowTD(Obj,str){
var str1 = str.split(",");
if (Obj.checked){
for (var i = 0; i < str1.length; i++) {
document.getElementById(str1[i]).style.display = "";
}
}else{
for (var i = 0; i < str1.length; i++) {
document.getElementById(str1[i]).style.display = "none";
}
}
}

function Checken(String) {
var i;
var Str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_.";
for(i = 0; i < String.length; i ++){
if (Str.indexOf(String.charAt(i)) < 0){return false;}
}
return true;
}

function Checknumber(String) {
var i;
var Str = "1234567890";
for(i = 0; i < String.length; i ++){
if (Str.indexOf(String.charAt(i)) < 0){return false;}
}
return true;
}

function Checktoc(String) {
var i;
var Str = "1234567890.";
for(i = 0; i < String.length; i ++){
if (Str.indexOf(String.charAt(i)) < 0){return false;}
}
return true;
}

function CheckCn(String) {
var arr = String.match(/[^\x00-\xff]/ig);
if(arr!=null){
return false;
}
return true;
}

function CheckEmail(email) {
var i;
var emails = email.split("@");
if (emails.length != 2) {return false;}
var Mail = emails[1].split(".");
var Str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_.@";
for(i = 0; i < email.length; i ++){
if (Str.indexOf(email.charAt(i)) < 0){return false;}
if (i == email.length - 1 && email.charAt(i) == "."){return false;}
}
if (emails[1].indexOf(".") < 0) {return false;}
if (Mail.length < 2) {return false;}
for(i = 0; i < Mail.length; i ++){
if (Mail[i].length < 2) {return false;}
}
return true;
}

function GetTopBanner(w,h,p,n) {
var str;
var obj;
var strp;
var stri;
var strTBannerTd;
var tw = document.getElementById('topBanner').offsetWidth;
var th = document.getElementById('topBanner').offsetHeight;
var strN = n.split("|");
if (p == 0) {strp = ""} else {strp = "../"}
for (i = 0 ; i < strN.length; i++) {
stri = i + 1;
strTBannerTd = "TBannerTd" + stri;
obj = document.getElementById(strTBannerTd);
str = "<object style='position:absolute;' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='" + tw + "' height='" + th + "'>";   
str += "<param name='movie' value='" + strp + "images/swf/topflash_0" + strN[i] + ".swf'>";
str += "<param  name='menu' value='false'>";
str += "<param  name='quality' value='high'>";
str += "<param name='wmode' value='transparent'>";
str += "<param name='scale' value='exactfit'>";
str += "<embed src='" + strp + "images/swf/topflash_0" + strN[i] + ".swf' width='" + tw + "' height='" + th + "' type='application/x-shockwave-flash' menu='false' quality='high' wmode='transparent'></embed>"
str += "</object>";
obj.style.top = document.getElementById("TBanner").offsetTop;
obj.style.left = (document.body.clientWidth / 2) - (OutPagew / 2);
obj.style.display = "";
obj.innerHTML = str;
}
}

var newWin;
var sColorWin;
function CloseWindow() {
if (newWin != null) newWin.close();
}
function winFocus() {
if (newWin != null) {
if (!newWin.closed) {
newWin.window.focus();
}
}
}
function CloseColorWindow() {
if (sColorWin != null) sColorWin.close();
}
function ColorWinFocus() {
if (sColorWin != null) {
if (!sColorWin.closed) {
sColorWin.window.focus();
}
}
}
