/*
' Copyright (c) 2007 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	: AFF_reUsed
 File Name		: properties.php
 Description	: 
' Created By	: Roshani de Silva
' Created Date	: 05-Dec-2011
' 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;
}

//===================== Start of Date validation =============================
function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
currDate = new Date();
var d = currDate.getDate();
var m = currDate.getMonth()+1;
var y = currDate.getFullYear();
monthNames = new Array();
monthNames[1] = "January"
monthNames[2] = "February"
monthNames[3] = "March"
monthNames[4] = "April"
monthNames[5] = "May"
monthNames[6] = "June"
monthNames[7] = "July"
monthNames[8] = "August"
monthNames[9] = "September"
monthNames[10] = "October"
monthNames[11] = "November"
monthNames[12] = "December"

monthMax= new Array(31,31,29,31,30,31,30,31,31,30,31,30,31);

function findMonthIndex(str) {
if (str=="January") return 1
else if (str=="February") return 2
else if (str=="March") return 3
else if (str=="April") return 4
else if (str=="May") return 5
else if (str=="June") return 6
else if (str=="July") return 7
else if (str=="August") return 8
else if (str=="September") return 9
else if (str=="October") return 10
else if (str=="November") return 11
else if (str=="December") return 12
else return m;

}

// date validation part
function inRange (inputStr, lo, hi) {
	var num = parseInt(inputStr, 10)
	if (num<lo || num>hi) {
		return false
	}
	return true
}

function inRangeSameMonth (inputStr, lo, hi) {
	var num = parseInt(inputStr, 10)
	if (num>lo || num>hi) {
		return false
	}
	return true
}
//===================== End of Date validation =============================

////////////////////////////


//Captcha Image

  function reloadCaptcha(imageName)
  {
    var randomnumber=Math.floor(Math.random()*1001); // generate a random number to add to image url to prevent caching
    document.images[imageName].src = document.images[imageName].src + '&amp;rand=' + randomnumber; // change image src to the same url but with the random number on the end
  }

