function Trim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g, "");}

function isNull(obj,str)
{
	if (Trim(obj.value)=="")
	{
		alert("Please enter  " + str);
		obj.focus();
		return true;
	}
	else
		return false;
}



function isTxtareaNull(obj,str)
{
	if(Trim(obj.innerText) == "")
	{
		alert("Please enter the " +str);
		return true;
	}
	else
		return false;
}


function isUsername(obj)
{
	
	exp=/[^\W]/;
	if(!exp.test(obj.value))
	{alert("Special characters not accepted");
	obj.focus();
	return true;
	}
	else
		return false;
}



function isPassword(obj)
{
	
	if ((obj.value.length)<6)
	{
	alert("Password should have atleast 6 characters");
	obj.focus();
	return true;
	}
	exp=/[^\W]/;
	if(!exp.test(obj.value))
	{alert("Special characters not accepted");
	obj.focus();
	return true;
	}
	
	else
		return false;
}
function isCardNo(obj)
{
	
	exp=/^[0-9 ]+$/;
	if(!exp.test(obj.value))
	{alert("Please Enter The Valid Credit Card Number");
	obj.focus();
	return true;
	}
	if ((obj.value.length)<16)
	{
	alert("Credit Card Number should have 16 digits");
	obj.focus();
	return true;
	}
	
	else
		return false;
}
function isNotCVV2(obj)
{
	
	if ((obj.value.length)<4)
	{
	alert("Card Verification Number should have atleast 4 characters");
	obj.focus();
	return true;
	}
	exp=/^[0-9]+$/;
	if(!exp.test(obj.value))
	{alert("Special characters not accepted");
	obj.focus();
	return true;
	}
	
	else
		return false;
}


function isSpecial(obj)
{
	exp=/(^\w*$)/;
	if(!exp.test(obj.value))
	{
	alert("Special characters & space not accepted");
	obj.focus();
	return true;
	}

}

function notQty(obj)
{
	exp=/(^\d*$)/;

	if (!exp.test(obj.value))
	{
		alert("Please enter valid quantity");
		obj.focus();
		return true;
	}
	else
		return false;
}

function chkChar(obj,str)
{ 
exp=/^[a-zA-Z ]+$/; 
	if (!exp.test(obj.value))
	{
		alert("Invalid " +str+". Please enter a valid "+str);
		obj.focus();
		return true;
	}
	else
		return false;
}

function chkNum(obj,str)
{ 
//exp=/^\d[[\d]*[\-]{0,1}[\d]*]*\d$/ //format:0422-2403838,2403838
exp=/^[0-9 ]+$/; //format:044-044-044,0422-2403838,2403838
//exp=/^[\d]{3}[\-][\d]{3}-[\d]{4}$/

	if (!exp.test(obj.value))
	{
		alert("Invalid " +str+". Please enter a valid "+str);
		obj.focus();
		return true;
	}
	else
		return false;
}

function chkNumber(obj,str)
{ 
//exp=/^\d[[\d]*[\-]{0,1}[\d]*]*\d$/ //format:0422-2403838,2403838
exp=/^\d[\d]*/; //format:044-044-044,0422-2403838,2403838
//exp=/^[\d]{3}[\-][\d]{3}-[\d]{4}$/

	if (!exp.test(obj.value))
	{
		alert("Invalid " +str+". Please enter a valid "+str);
		obj.focus();
		return true;
	}
	else
		return false;
}




function notEmail(obj)
{
	
	if (Trim(obj.value)=="")
	{
				return false;
				
	}
	else
	{
	var exp=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/;
	if (!exp.test(obj.value))
	{
		alert("Please enter valid email address");
		obj.focus();
		return true;
	}
	else
		return false;
	}
}


function notChecked(obj,str)
{
	checked = false;
	if(obj.length)
	{
		for(i=0;i<obj.length;i++)
		{
			if(obj[i].checked)
			{checked = true;break;}
		}
	}
	else if(obj.checked)
		checked = true;

	if(!(checked))
	{
		alert("Please select the "+str);
		if(obj.length)
			obj[0].focus();
		else
			obj.focus();
		return true;
	}
}

function notChecked1(obj)
{
	checked = false;
	if(obj.length)
	{
		for(i=0;i<obj.length;i++)
		{
			if(obj[i].checked)
			{checked = true;break;}
		}
	}
	else if(obj.checked)
		checked = true;

	if(!(checked))
	{
		alert("Please select atleast one record");
		if(obj.length)
			obj[0].focus();
		else
			obj.focus();
		return true;
	}
}



function notSelected(obj,str)
{
	if (obj.options[obj.selectedIndex].value == "")
	{
		alert("Please select the "+str);
		obj.focus();
		return true;
	}
	else
		return false;
}


function notImageFile(obj)
{
	var exp = /^.+\.(jpg|jpeg|gif|GIF)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose jpg or gif file");
		obj.focus();
		return true;
	}
	else
		return false;
}

function notAudioVideoFile(obj)
{
	var exp = /^.+\.(wav|au|wma|cda|mp3|DAT)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose Audio or Video file");
		obj.focus();
		return true;
	}
	else
		return false;
}

function notPdfDocFile(obj)
{
	var exp = /^.+\.(pdf|doc|jpg|gif|jpeg|bmp|txt|ppt|pps)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose pdf or doc file");
		obj.focus();
		return true;
	}
	else
		return false;
}

function isNullDescription(obj,str)
{
	if (Trim(obj.value)=="")
	{
		alert("Please enter  " + str);
		return true;
	}
	else
		return false;
}




function notPrice(obj)
{
	exp = /^[\d]*[\.]{0,1}[\d]{1,2}$/;
	if (!exp.test(obj.value))
	{
		alert("Please enter valid price");
		obj.focus();
		return true;
	}
	else
		return false;
}


function fnChkNum()
{
	if ((window.event.keyCode < 48) || (window.event.keyCode > 57))
	{
		window.event.keyCode = 0;
	}
}

function fnChkAlphaNum()
{
	if (((window.event.keyCode < 48) || (window.event.keyCode > 57)) && ((window.event.keyCode < 65) || (window.event.keyCode > 90)) && ((window.event.keyCode < 97) || (window.event.keyCode > 122)))
	{
		alert("Only Alphabets(A-Z, a-z) and Numbers(0-9) are allowed");
		window.event.keyCode = 0;
	}
}

function fnChkFolderName()
{
	if (((window.event.keyCode < 48) || (window.event.keyCode > 57)) && ((window.event.keyCode < 65) || (window.event.keyCode > 90)) && ((window.event.keyCode < 97) || (window.event.keyCode > 122)) && (window.event.keyCode != 95))
	{
		alert("Only Alphabets(A-Z, a-z), Numbers(0-9) and Underscore(_) are allowed");
		window.event.keyCode = 0;
	}

}
function showCalendar(ObjTxt)
	{
   	var winRetValue=window.showModalDialog("includes/calender.htm","","dialogHeight: 219px; dialogWidth: 273px;  center: Yes; help: No; resizable: No; status: No;titlebar:No");
   	if (winRetValue != "") 
   	ObjTxt.value = winRetValue;
  	}


function fnAddToCart(restaurant_id,description,certificate_price)
{	

qty="selqty-"+restaurant_id+"-"+description
document.thisform.action="add_to_cart.asp?action=addition&id="+restaurant_id+"&desc="+description+"&price="+certificate_price+"&selqty="+qty;
document.thisform.submit();
}

function fnAdd(restaurant_id,description,certificate_price)
{	

qty="selqty-"+restaurant_id+"-"+description
document.thisform.action="../add_to_cart.asp?action=addition&id="+restaurant_id+"&desc="+description+"&price="+certificate_price+"&selqty="+qty;
document.thisform.submit();
}



function fncertificate(rest_id,img_desc)
{
window.open ("certificatepage.asp?restaurant_id="+rest_id+"&img_description="+img_desc,"","width=650,height=750,top=0,left=0,scrollbars=yes");
}



function isPostalCode(obj,str)
{
exp=/^[A-Z]{1}|[a-z]{1}[\d]{1}[A-Z]{1}|[a-z]{1}[\s]{1}[\d]{1}[A-Z]{1}|[a-z]{1}[\d]{1}$/;
if (!exp.test(obj.value))
	{
		alert("Invalid postal code. Please enter a valid " + str);
		obj.focus();
		return true;
	}
	else
		return false;
}


function isValidDate(obj,str)
{
exp=/^[\d]{1,2}[\/]{1}[\d]{1,2}[\/]{1}[\d]{4}$/;
if (!exp.test(obj.value))
	{
		alert("Invalid Date. Please enter a valid " + str);
		obj.focus();
		return true;
	}
	else
		return false;
}

function stripEditorNull(obj)
{
	strTmp = obj.value;
	strTmp = strTmp.replace('<P>',"");
	strTmp = strTmp.replace('</P>',"");
	strTmp = strTmp.replace('<DIV>',"");
	strTmp = strTmp.replace('</DIV>',"");
	strTmp = strTmp.replace(/&nbsp;/g,"");
	return strTmp;
}


