﻿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 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 CheckEmail(email) {
var i;
var emails = email.split("@");
if (emails.length != 2) {return false;}
if (emails[0] == "" || emails[1] == "") {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 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;
}

function CheckUrl(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 Subwin(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();
}
