﻿var flag=false;
function LoadImage(ImgD,pw,ph){
var image=new Image();
image.src=ImgD.src;
if(image.width>0 && image.height>0){
flag=true;
if(image.width/image.height>= pw/ph){
if(image.width>pw){
ImgD.width=pw;
ImgD.height=(image.height*pw)/image.width;
}else{
ImgD.width=image.width;  
ImgD.height=image.height;
}
}
else{
if(image.height>ph){
ImgD.height=ph;
ImgD.width=(image.width*ph)/image.height;
}else{
ImgD.width=image.width;
ImgD.height=image.height;
}
}
}
}

function LoadPageImg(ImgD,pw){
if (ImgD.width > pw) {
ImgD.width = pw;
ImgD.height = (ImgD.height*pw)/ImgD.width;
}
}

function getPage(){
var strInPageObj = document.getElementById("InPageObj");
var strInPageEmbed = document.getElementById("InPageEmbed");
var strOutPageObj = document.getElementById("OutPageObj");
var strLeftPageObj = document.getElementById("LeftPageObj");
if (strInPageObj) {
if (strInPageObj.width > InPagew) {strInPageObj.width = InPagew;}
for(i=0; i<InPageObj.length; i++) {
if (InPageObj[i].width > InPagew) {InPageObj[i].width = InPagew;}
}
}
if (strInPageEmbed) {
if (strInPageEmbed.width > InPagew) {strInPageEmbed.width = InPagew;}
for(i=0; i<InPageEmbed.length; i++) {
if (InPageEmbed[i].width > InPagew) {InPageEmbed[i].width = InPagew;}
}
}
if (strOutPageObj) {
if (strOutPageObj.width > OutPagew) {strOutPageObj.width = OutPagew;}
for(i=0; i<OutPageObj.length; i++) {
if (OutPageObj[i].width > OutPagew) {OutPageObj[i].width = OutPagew;}
}
}
if (strLeftPageObj) {
if (strLeftPageObj.width > InfoPagew) {strLeftPageObj.width = InfoPagew;}
for(i=0; i<LeftPageObj.length; i++) {
if (LeftPageObj[i].width > InfoPagew) {LeftPageObj[i].width = InfoPagew;}
}
}
}

function GetLoading(str){
var bdClientWidth = document.body.clientWidth;
TPage.style.display = "";
TPage2.style.display = "";
TPage.style.top = 0;
TPage.style.left = 0;
TPage.style.width = bdClientWidth;
TPage.style.height = bodyPage.offsetHeight;
TPage2.style.width = bdClientWidth;
TPage2.style.height = document.body.clientHeight;
TPage2.style.left = (bdClientWidth / 2) - (TPage2.offsetWidth / 2); 
TPage2.style.top = (document.body.scrollTop) + (document.body.clientHeight / 2) - (TPage2.offsetHeight / 2);
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 Checken( String ) { 
var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_.";
var i;
var c;
if(String.charAt( 0 )=='-')
return false;
if( String.charAt( String.length - 1 ) == '-' )
return false;
for( i = 0; i < String.length; i ++ )
{
c = String.charAt( i );
if (Letters.indexOf( c ) < 0)
return false;
}
return true;
}

function Checkemailstr( String ) { 
var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_.@";
var i;
var c;
if(String.charAt( 0 )=='-')
return false;
if( String.charAt( String.length - 1 ) == '-' )
return false;
for( i = 0; i < String.length; i ++ )
{
c = String.charAt( i );
if (Letters.indexOf( c ) < 0)
return false;
}
return true;
}

function Checknumber( String ) { 
var Letters = "1234567890";
var i;
var c;
if(String.charAt( 0 )=='-')
return false;
if( String.charAt( String.length - 1 ) == '-' )
return false;
for( i = 0; i < String.length; i ++ )
{
c = String.charAt( i );
if (Letters.indexOf( c ) < 0)
return false;
}
return true;
}

function Checktoc( String ) { 
var Letters = "1234567890.";
var i;
var c;
if(String.charAt( 0 )=='-')
return false;
if( String.charAt( String.length - 1 ) == '-' )
return false;
for( i = 0; i < String.length; i ++ )
{
c = String.charAt( i );
if (Letters.indexOf( c ) < 0)
return false;
}
return true;
}



