/* Copyright (c) 2000 Affno (Pvt) Ltd, . All rights reserved.

 This software is the confidential and proprietary information of        
 Affno  ("Confidential Information").  You shall not disclose such 
 Confidential Information and shall use it only in accordance with
 the terms of the license agreement you entered into with Affno.

Module Name		: QTMWEB1
File Name		: validation.js
Description		: Acceptable characters for fields v3.0 (Send by Rangika Wed 9/21/2005 10:03 AM)
Created By		: 
Created Date	: 
Modified By		: 
Modified Date	: 
Version			: 1.00.000

*/

// Empty or Null
function isEmpty(inputStr) {
	if ((inputStr == null) || (inputStr=="")) return true
	else return false
}

// Space
function isSpace(str) {
	pattern = /^[\s]+$/
        if (str.match(pattern)) return true
           else return false;
}

// Numbers only - (No of children, adults, passengers, rooms)
function isNumber(str) {
	pattern= /^[0-9]+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Numbers only - (No of children, adults, passengers, rooms)
function isRates(str) {
	pattern= /^[-\a-zA-Z0-9\s-]+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Numbers and dot
function isrates(str) {
	pattern= /^[0-9\.]+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Letters with Space
function isLetters(str) {
	pattern = /^[a-zA-Z\s]+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Numbers, Letters and Space - (Search, Identity card number, Passport number)
function isAlphaNu(str) {
	pattern = /^[a-zA-Z0-9\s]+$/
		if (!str.match(pattern)) return false
			else return true;
}

/* 
---- all cractors allowed --------	
	Address(postal, resident, mailing, shipping)
 	Zip code, postal code
 	Organization, Company
 	Message, remarks, comments, qualifications
*/	 

// Name - (first, last, full name)
function isName(str) {
	pattern = /^[a-zA-Z\s\-\.\']+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Email
function isEmail(str) {
     pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/
        if (str.match(pattern)) return true
           else return false;
}
// URL
function isUrl(str) {
     pattern = /^[a-zA-Z\s\:\.\/]+$/
        if (str.match(pattern)) return true
           else return false;
}

// Telephone
function isTelephone(str) {
	pattern =/^[0-9a-zA-Z\s\-\/\,\(\)\+\.\:]+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Fax
function isFax(str) {
	pattern =/^[0-9a-zA-Z\s\-\/\(\)\+\.]+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Mobile Number
function isMobile(str) {
	pattern =/^[0-9\s\-\/\+]+$/
		if (!str.match(pattern)) return false
			else return true;
}

// SMS No
function isSmsNo(str) {
	pattern =/^[0-9\+]+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Country
function isCountry(str) {
	pattern =/^[a-zA-Z\s\-\.\']+$/
		if (!str.match(pattern)) return false
			else return true;
}

// City, State, Province, Region
function isCity(str) {
	pattern = /^[0-9a-zA-Z\s\-\.\']+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Designation, Position, occupation
function isDesignation(str) {
	pattern = /^[0-9a-zA-Z\s\-\/\.\,\"\(\)\']+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Post applied for
function isPostApp(str) {
	pattern = /^[0-9a-zA-Z\s\-\/\.\:\?\!\;\,\"\(\)\']+$/
		if (!str.match(pattern)) return false
			else return true;
}

// Date (birth, arrival, departure, delivery)
function isSortDate(str) {
	pattern = /^[0-9\/\s]+$/
		if (!str.match(pattern)) return false
			else return true;
}

function isUName(str) {
	pattern = /^[a-zA-Z0-9\_]+$/
		if (!str.match(pattern)) return false
			else return true;
}

function isPwd(str) {
	pattern = /^[a-zA-Z0-9\_]+$/
		if (!str.match(pattern)) return false
			else return true;
}

function isValidPwd(str) {
	if (str.lastIndexOf(" ") == -1) {
				return true;
	} else {
				return false;
	}
}

//Decimal number
function isDecNumber(str, len) {
	//pattern=/^[0-9]+[\.]{0,1}[0-9]{0,2}$/
	pattern=/^[0-9]+[\.]{0,1}[0-9]{0,9}$/
	if (((str.indexOf("."))!=-1) && (str.indexOf(".") > 10)){
			return false
		}
	else if (((str.indexOf("."))==-1) && (str.length > 10)) {
	return false;
	}
	else return(str.match(pattern));
}


//Key word
function isKeyWord(str) {
	pattern = /^[a-zA-Z0-9\s\-\']+$/
		if (!str.match(pattern)) return false
			else return true;
}