
function chkLogin(frm)
{
	if(!notEmpty(frm.UserName,"User Name"))
	return false;
	if(!notEmpty(frm.Pwd,"Password"))
	return false;
	else
	return true;
}

function interFrmSubmit()
{
	frm = document.paypal_form;
	//alert(frm);
	frm.submit();
	return false;
}

function chkChangePass(frm)
{
	if(!notEmpty(frm.txtOldPass,"Old Password"))
	return false;
	if(!notEmpty(frm.txtNewPass,"New Password"))
	return false;
	if(frm.txtNewPass.value != frm.txtNewPassConf.value)
	{
		alert("Password doesn't match!");
		frm.txtNewPassConf.focus();
		return false;
	}
	else
	return true;
}

function chkEnquiryForm(frm)
{
	if(!notEmpty(frm.txtName,"Name"))
	return false;
	if(!notEmpty(frm.txtEmail,"Email"))
	return false;
	if(!notRadioSelected(frm.rdGender,"Gender"))
	return false;
	if(!notEmpty(frm.txtAddress,"Address"))
	return false;
	if(!notEmpty(frm.txtSuburb,"Suburb"))
	return false;
	if(!notEmpty(frm.txtCity,"City"))
	return false;
	if(!notEmpty(frm.txtState,"State"))
	return false;
	if(!notEmpty(frm.txtZipcode,"Zipcode"))
	return false;
	if(!notSelected(frm.txtCountry,"Country"))
	return false;
	if(!notEmpty(frm.txtEnquiry,"Enquiry"))
	return false;
	else
	return true;
}

function chkCustomerIno(frm)
{
	if(!notEmpty(frm.txtFirstName,"First Name"))
	return false;
	if(!notEmpty(frm.txtLastName,"Last Name"))
	return false;
	if(!notEmpty(frm.txtEmail,"Email"))
	return false;
	if(!notRadioSelected(frm.rdGender,"Gender"))
	return false;
	if(!notEmpty(frm.txtAddress,"Address"))
	return false;
	if(!notEmpty(frm.txtSuburb,"Suburb"))
	return false;
	if(!notEmpty(frm.txtCity,"City"))
	return false;
	if(!notEmpty(frm.txtState,"State"))
	return false;
	if(!notSelected(frm.txtCountry,"Country"))
	return false;
	if(!notRadioSelected(frm.rdPayOpt,"Payment Option"))
	return false;
	else
	return true;
}

function chkAddTreatment(frm,isEdit)
{
	//txtTreatmentName, txtShortDesc, txtDetDesc, txtPrice, flImage, slStatus

	if(!notEmpty(frm.txtTreatmentName,"Treatment Name"))
	return false;
	if(!notEmpty(frm.txtShortDesc,"Short Description"))
	return false;
	/*
	if(!notEmpty(frm.txtDetDesc,"Description"))
	return false;
	*/
	if(!notEmpty(frm.txtPrice,"Treatment Price"))
	return false;
	else if(!notCurrency(frm.txtPrice,"Treatment Price"))
	return false;
	if(!isEdit)
	{
	//if(!noFileSelected(frm.flImage,"Image"))
	//return false;
	}
	if(!notSelected(frm.slStatus,"Status"))
	return false;
	else
	return true;
}

function chkAddProduct(frm,isEdit)
{
	//txtTreatmentName, txtShortDesc, txtDetDesc, txtPrice, flImage, slStatus

	if(!notEmpty(frm.txtProductName,"Product Name"))
	return false;
	if(!notEmpty(frm.txtShortDesc,"Short Description"))
	return false;
	/*
	if(!notEmpty(frm.txtDetDesc,"Description"))
	return false;
	*/
	if(!notEmpty(frm.txtPrice,"Product Price"))
	return false;
	else if(!notCurrency(frm.txtPrice,"Product Price"))
	return false;
	if(!isEdit)
	{
	if(!noFileSelected(frm.flImage,"Image"))
	return false;
	}
	if(!notSelected(frm.slStatus,"Status"))
	return false;
	else
	return true;
}

function chkAddSoap(frm,isEdit)
{
	//txtTreatmentName, txtShortDesc, txtDetDesc, txtPrice, flImage, slStatus

	if(!notEmpty(frm.txtSoapName,"Soap Name"))
	return false;
	if(!notEmpty(frm.txtShortDesc,"Short Description"))
	return false;
	/* if(!notEmpty(frm.txtDetDesc,"Description"))
	return false; */
	if(!notEmpty(frm.txtPrice,"Soap Price"))
	return false;
	else if(!notCurrency(frm.txtPrice,"Soap Price"))
	return false;
	if(!isEdit)
	{
	if(!noFileSelected(frm.flImage,"Image"))
	return false;
	}
	if(!notSelected(frm.slStatus,"Status"))
	return false;
	else
	return true;
}

function chkAddTestimonial(frm,isEdit)
{
	//txtName, txtFeedback
	if(!notEmpty(frm.txtName,"Person's Name"))
	return false;
	/*
	if(!notEmpty(frm.txtFeedback,"Feedback"))
	return false;
	*/
	if(!isEdit)
	{
	//if(!noFileSelected(frm.flImage,"Image"))
	//return false;
	}
	if(!notSelected(frm.slStatus,"Status"))
	return false;
	else
	return true;
}

function chkAddFaq(frm,isEdit)
{
	//txtName, txtFeedback
	if(!notEmpty(frm.txtName,"Question"))
	return false;
	if(!notEmpty(frm.txtAnswer,"Answer"))
	return false;
	if(!notSelected(frm.slStatus,"Status"))
	return false;
	else
	return true;
}

function showAnswer(comId)
{
	x = document.getElementById(comId);
	if(x.style.display == 'none')
		x.style.display = '';
	else
		x.style.display = 'none';
	
	return true;
}

function chkPhoneFocus(comId)
{
	document.genEnq.rdContOpt[comId].checked=true;
	return true;
}

function showHideNote()
{
	x = document.getElementById("addNoteTr");
	y = document.getElementById("noteId");
	var curMode;
	curMode = x.style.display;
	if(curMode=='none')
	{
		x.style.display = '';
		y.innerHTML = 'Hide Add Note';
	}
	else
	{
		x.style.display = 'none';
		y.innerHTML = 'Add Note';
	}
}

function showHideViewNote()
{
	x = document.getElementById("viewNoteTr");
	y = document.getElementById("viewNoteId");
	var curMode;
	curMode = x.style.display;
	if(curMode=='none')
	{
		x.style.display = '';
		y.innerHTML = 'Hide View Notes';
	}
	else
	{
		x.style.display = 'none';
		y.innerHTML = 'View Notes';
	}
}


function chkAddNote(frm)
{
	if(!notEmpty(frm.txtNote,"Enquiry Note"))
	return false;
}

function chkQuickSearchTwo(frm)
{
	if(!notSelected(frm.slOpt,"Option"))
		return false;
	if(!notEmpty(frm.keyword,"Search Keyword"))
		return false;
	else
		return true;
}

function notChecked(obj,msg)
{
	var passObj = obj;
	var passMsg = msg;
	if(passObj.checked == false)
	{
		alert(msg);
		passObj.focus();
		return false;
	}
	return true;
}

function notEmpty(obj,msg)
{
	var passObj = obj;
	var passMsg = msg;
	if(!passObj.value)
	{
		alert('Please enter a value for ' + msg + ' Field !!');
		passObj.focus();
		return false;
	}
	return true;
}

function notCurrency(obj,msg)
{
	var passObj = obj.value;
	var passMsg = msg;
	var checkOK = "1234567890.";
	var matched = 0;
	for (p = 0;  p < passObj.length;  p++)
	{
		matched = 0;
		for (j = 0;  j < checkOK.length;  j++)
		{
			if(passObj.charAt(p) == checkOK.charAt(j))
			{
			matched = 1;
			break;
			}
		}
		if(matched==0)
		{
			alert("Please enter a valid " + msg);
			obj.focus();
			return false;
		}
	}
	return true;
}

function notNumber(obj,msg)
{
	var passObj = obj.value;
	var passMsg = msg;
	var checkOK = "1234567890";
	var matched = 0;
	for (p = 0;  p < passObj.length;  p++)
	{
		matched = 0;
		for (j = 0;  j < checkOK.length;  j++)
		{
			if(passObj.charAt(p) == checkOK.charAt(j))
			{
			matched = 1;
			break;
			}
		}
		if(matched==0)
		{
			alert("Please enter a valid " + msg);
			obj.focus();
			return false;
		}
	}
	return true;
}

function notPhone(obj,msg)
{
	var passObj = obj.value;
	var passMsg = msg;
	var checkOK = "1234567890-()+ ";
	var matched = 0;
	for (p = 0;  p < passObj.length;  p++)
	{
		matched = 0;
		for (j = 0;  j < checkOK.length;  j++)
		{
			if(passObj.charAt(p) == checkOK.charAt(j))
			{
			matched = 1;
			break;
			}
		}
		if(matched==0)
		{
			alert("Please enter a valid " + msg);
			obj.focus();
			return false;
		}
	}
	return true;
}

function notCompare(obj,secobj,msg)
{
	var passObj = obj;
	var passObjSec = secobj;
	var passMsg = msg;
	if(passObj.value != passObjSec.value)
	{
		alert(msg);
		passObjSec.focus();
		return false;
	}
	return true;
}
function notSelected(obj,msg)
{
	var passObj = obj;
	var passMsg = msg;
	if(!passObj.value)
	{
		alert('Please select a value for ' + msg + ' Field !!');
		passObj.focus();
		return false;
	}
	return true;
}


function noFileSelected(obj,msg)
{
	var passObj = obj;
	var passMsg = msg;
	if(!passObj.value)
	{
		alert('Please select ' + msg + ' !!');
		passObj.focus();
		return false;
	}
	return true;
}

function notRadioSelected(obj,msg)
{
	var passObj = obj;
	var passMsg = msg;
	var noOfEle = obj.length;
	var found = 0;
	
	for(i=0;i<noOfEle;i++)
	{
		if(obj[i].checked == true)
		{
			found = 1;
			break;
		}
	}
	if(found==0)
	{
		alert('Please select an option for ' + msg);
		return false;
	}
	return true;
}

////////////////////////////////////////////////////////////////////
// SHOPPING CART function
////////////////////////////////////////////////////////////////////

function addToCart(prdId,prdtype)
{
	frmobj = document.frmshoppingcart;
	document.frmshoppingcart.itmid.value = prdId;
	document.frmshoppingcart.itmtype.value = prdtype;
	document.frmshoppingcart.action.value = "Add";
	document.frmshoppingcart.submit();
	return true;
}

function removeProduct(prdId,prdtype)
{
	frmobj = document.frmshoppingcart;
	document.frmshoppingcart.itmid.value = prdId;
	document.frmshoppingcart.itmtype.value = prdtype;
	document.frmshoppingcart.action.value = "Remove";
	document.frmshoppingcart.submit();
	return true;
}

function chkCartUpdate(frm)
{
	//alert(frm);
	var noOfProducts;
	var comObj;
	noOfProducts = frm.hidProducts.value;
	for(i=1;i<=noOfProducts;i++)
	{
		comObj = eval("frm.txtqty_" + i);
		if(!notEmpty(comObj,"Quantity"))
		return false;
		else if(!notPosNumber(comObj,"Quantity"))
		return false;
	}
	return true;
}

function chkCartDelete(frm)
{
	//alert(frm);
	var noOfProducts;
	var comObj;
	var noOfChecked = 0;
	noOfProducts = frm.hidProducts.value;
	for(i=1;i<=noOfProducts;i++)
	{
		comObj = eval("frm.chkPrd_" + i);
		if(comObj.checked == true)
		{
			noOfChecked = noOfChecked + 1;
		}
	}
	if(noOfChecked==0)
	{
		alert("Please select atleast one product to delete!!");
		return false;
	}
	else
		return confirm("Are you sure you want to remove selected "+ noOfChecked +" product(s)");
}

function notPosNumber(obj,msg)
{
	var passObj = obj.value;
	var passMsg = msg;
	var checkOK = "1234567890";
	var matched = 0;
	for (p = 0;  p < passObj.length;  p++)
	{
		matched = 0;
		for (j = 0;  j < checkOK.length;  j++)
		{
			if(passObj.charAt(p) == checkOK.charAt(j))
			{
			matched = 1;
			break;
			}
		}
		if(matched==0)
		{
			alert("Please enter a valid " + msg);
			obj.focus();
			return false;
		}
	}
	if(passObj <= 0)
	{
			alert("Please enter a valid " + msg);
			obj.focus();
			return false;
	}
	return true;
}
