
function addEditProductValidation(form) {
	with(form){
		
		if(txt_pd_name.value == ''){
			alert('Please specify  Product Name');
			txt_pd_name.focus();
			return  false;
		}
		
		if(txt_pd_price.value == '' || txt_pd_price.value <= 0){
			alert('Please specify  price greater then Zero');
			txt_pd_price.value = '';
			txt_pd_price.focus();
			return  false;
		}	
		
/*		if (isNaN(txt_pd_price.value)) {
			alert("Price must be numeric");
			return false;
		}*/
			
		if(txt_pd_qty.value == '' || txt_pd_qty.value <= 0){
			alert('Please specify quantity not Zero');
			txt_pd_qty.value = '';
			txt_pd_qty.focus();
			return  false;
		}
		
/*		if (isNaN(txt_pd_qty.value)) {
			alert("Quantity must be numeric");
			return false;
		}*/
	}	
}

function addEditUserValidation(form) {
	with(form){

		if(txt_password.value == ''){
			alert('Please specify Password!');
			txt_password.focus();
			return  false;
		}
	}	
}


function ALoginVal(form) {
	with(form){
		
		if(UserName.value == ''){
			alert('Please specify  User Name ');
			UserName.focus();
			return  false;
		}
		
		if(PassWord.value == ''){
			alert('Please specify  Password ');
			PassWord.focus();
			return  false;
		}
	}	
}


function searchCategory(form) {
	with(form){
		
		if(txt_search_category.value == ''){
			alert('Please specify Category Name');
			txt_search_category.focus();
			return  false;
		}
	}	
}

function searchProduct(form) {
	with(form){
		
		if(txt_search_product.value == ''){
			alert('Please specify Product Name');
			txt_search_product.focus();
			return  false;
		}
	}	
}

function searchUser(form) {
	with(form){
		
		if(txt_search_user.value == ''){
			alert('Please specify  User Name');
			txt_search_user.focus();
			return  false;
		}
	}	
}

/*function addEditHumanitarian(form) {
	with(form){
		
		if(txt_website.value == ''){
			alert('Please specify Website!');
			txt_website.focus();
			return  false;
		}
		if(txt_url.value == ''){
			alert('Please specify  Url!');
			txt_url.focus();
			return  false;
		}
	}	
}*/


function sendMail(form) {
	with(form){
		
		if(opt_teacher.value == ''){
			alert('Please specify Teacher!');
			opt_teacher.focus();
			return  false;
		}
		if(txt_comments.value == ''){
			alert('Please specify a Question!');
			txt_comments.focus();
			return  false;
		}
	}	
}

function reserveCatalog(form, catalogId) {
	with(form){
		
		txt_lib_catalogue_id.value = catalogId;
		return true;
	}	
}
// Javascript Numeric Validation (No decimal + No Character and Special Character and No Negative value will be allowed

// version: beta
// created: 2005-08-30
// updated: 2005-08-31
// mredkj.com
function extractNumber(obj, decimalPlaces, allowNegative)
{
	var temp = obj.value;
	
	// avoid changing things if already formatted correctly
	var reg0Str = '[0-9]*';
	if (decimalPlaces > 0) {
		reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	} else if (decimalPlaces < 0) {
		reg0Str += '\\.?[0-9]*';
	}
	reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	reg0Str = reg0Str + '$';
	var reg0 = new RegExp(reg0Str);
	if (reg0.test(temp)) return true;

	// first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');

	if (allowNegative) {
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
	}
	
	if (decimalPlaces != 0) {
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null) {
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
	}
	
	obj.value = temp;
}
function blockNonNumbers(obj, e, allowDecimal, allowNegative)
{
	var key;
	var isCtrl = false;
	var keychar;
	var reg;
		
	if(window.event) {
		key = e.keyCode;
		isCtrl = window.event.ctrlKey
	}
	else if(e.which) {
		key = e.which;
		isCtrl = e.ctrlKey;
	}
	
	if (isNaN(key)) return true;
	
	keychar = String.fromCharCode(key);
	
	// check for backspace or delete, or if Ctrl was pressed
	if (key == 8 || isCtrl)
	{
		return true;
	}

	reg = /\d/;
	var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
	var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
	
	return isFirstN || isFirstD || reg.test(keychar);
}

// Javascript Numeric Validation (No decimal + No Character and Special Character and No Negative value will be allowed End Here

function imageformat() {
			alert('Please specify proper image format');
			return  false;
}
