
//This Function To Check if the given String is empty or not
//If the String is Empty return true otherwize return false
function isempty(searchstring){
	if (searchstring.length == 0) return(true);
	j = 0;
	for (var i = 0; i < searchstring.length; i++){
		if (searchstring.charAt(i) == " " || searchstring.charAt(i) == "\n" || searchstring.charAt(i) == "\t" || searchstring.charAt(i) == "\r")
		j++;
	}
	return(j == searchstring.length);
}

//This Function to check if the given string is number or not
//if the string is number return true otherwize return false
function isNumeric(Num){
	var len=Num.length;
	var i,count=0,dot=0;
	if (len == 0) return(false);
	for(i=0;i < len;i++){
		ch = Num.charAt(i);
		switch(ch){
			case '0' : count++;break;
			case '1' : count++;break;
			case '2' : count++;break;
			case '3' : count++;break;
			case '4' : count++;break;
			case '5' : count++;break;
			case '6' : count++;break;
			case '7' : count++;break;
			case '8' : count++;break;
			case '9' : count++;break;
		}
	}
	return(count == len);
}


//email validate Begin
function isValidEmail (emailStr) {
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
	//alert("Email address seems incorrect ");
	return false;
}
var user=matchArray[1];
var domain=matchArray[2];
if (user.match(userPat)==null) {
    //alert("The username doesn't seem to be valid.");
    return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
	  for (var i=1;i<=4;i++) {
	    if (IPArray[i]>255) {
	        //alert("Destination IP address is invalid!");
		return false;
	    }
    }
    return true;
}
var domainArray=domain.match(domainPat);
if (domainArray==null) {
	//alert("The domain name doesn't seem to be valid.");
    return false;
}
var atomPat=new RegExp(atom,"g");
var domArr=domain.match(atomPat);
var len=domArr.length;
if (domArr[domArr.length-1].length<2 || 
    domArr[domArr.length-1].length>3) {
   //alert("The address must end in a three-letter domain, or two letter country.");
   return false;
}
if (len<2) {
   //var errStr="This address is missing a hostname!";
  // alert(errStr);
   return false;
}
return true;
}
//  Email validate End

function ShowPictures() {
	width = 620;
	height = 450;
	var winsize = "'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,screenX=100,screenY=100,left=180,top=100";
	winsize += ",width=" + width + ",height=" + height + "'";
	
	winpopup = window.open ('ShowPictures.asp','Pictures',winsize);
	winpopup.focus();
}

function ZoomPictures(Path) {
	width = 620;
	height = 450;
	var winsize = "'menubar=no,status=no,toolbar=no,scrollbars=yes,resizable=yes,screenX=100,screenY=100,left=180,top=100";
	winsize += ",width=" + width + ",height=" + height + "'";
	
	winpopup = window.open (Path,'ZoomPictures',winsize);
	winpopup.focus();
}

function doTopicsSubmit(FID,FNameAr,FClose,FMod) {
	document.FrmFields.Page.value = ""; //This must be set to avoid errors in the new page
	document.FrmFields.FID.value = FID;
	document.FrmFields.FNameAr.value = FNameAr;
	document.FrmFields.FClose.value = FClose;
	document.FrmFields.FMod.value = FMod;
	document.FrmFields.action = "../../../Forum/Topics/Default.asp";
	document.FrmFields.submit();
}