function Trim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g, "");}
function fnPaste(){event.returnValue=false;}

function isNull(obj,divid,msg)	{
	if(msg!="Password"){obj1=Trim(obj.value);}
	else{obj1=obj.value;}	
	if (obj1=="")	{
		obj.style.borderColor="red";
		document.getElementById(divid).style.display = "block"
		document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please enter your "+msg+"</font>";
		obj.onblur = function () {
			if(this.value!=""){
				this.style.borderColor="#cacaca";
			}
		};
		return true;
	} else {
		document.getElementById(divid).style.display = "none"
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}


function isNull_cp(obj,divid,msg)	{
	if(msg!="Password"){obj1=Trim(obj.value);}
	else{obj1=obj.value;}	
	if (obj1=="")	{
		obj.style.borderColor="red";
		document.getElementById(divid).style.display = "block"
		document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please confirm your "+msg+"</font>";
		obj.onblur = function () {
			if(this.value!=""){
				this.style.borderColor="#cacaca";
			}
		};
		return true;
	} else {
		document.getElementById(divid).style.display = "none"
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}


function isNull_noFocus(obj,divid,msg)
{
	if(msg!="Password"){obj1=Trim(obj.value);}
	else{obj1=obj.value;}	
	if (obj1=="")	{
		document.getElementById(divid).style.display="block";
		document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please enter the "+msg+"</font>";
		return true;
	} else {
		document.getElementById(divid).style.display="none";
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}

function isNull_Focus(obj,divid,msg)
{
	if(msg!="Password"){obj1=Trim(obj.value);}
	else{obj1=obj.value;}	
	if (obj1=="")	{
		document.getElementById(divid).style.display="block";
		document.getElementById(divid).innerHTML ="Please select the "+msg;
		return true;
	} else {
		document.getElementById(divid).style.display="none";
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}

function isNull_about(obj,divid,msg)	{
	if(msg!="Password"){obj1=Trim(obj.value);}
	else{obj1=obj.value;}	
	if (obj1=="")	{
		obj.style.borderColor="red";
		document.getElementById(divid).style.display = "block";
		document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please enter "+msg+"</font>";
		obj.onblur = function () {
			if(this.value!=""){
				this.style.borderColor="#cacaca";
			}
		};
		return true;
	} else {
		document.getElementById(divid).style.display = "none"
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}

function notChecked1(obj, divid, msg)	{
    obj.style.borderColor="red";
    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");return true;
	document.getElementById(divid).innerHTML ="Please Select Atleast One Record";}
}

function fnChkAlpha(obj,divid,msg)	{
	exp = (/(^([a-z]|[A-Z]|["."]|[\s])*$)/);
	if (!exp.test(obj.value))	{
		obj.style.borderColor="red";
		document.getElementById(divid).innerHTML ="Please enter only alphabets in "+msg;
		obj.focus();
		return true;
	} else {
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}	

function isNulltinymce(obj,divid,msg)	{
	if(msg!="Password"){obj1=Trim(obj.value);}
	else{obj1=obj.value;}	
	if (obj1=="")	{
		obj.style.borderColor="red";
		document.getElementById(divid).style.display="block";
		document.getElementById(divid).innerHTML="Please enter the "+msg;
		obj.onblur = function () {
			if(this.value!=""){
				this.style.borderColor="#cacaca";
			}
		};
		return true;
	} else {
		document.getElementById(divid).style.display = "none";
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}

function fnChkAlphaNum(obj,msg)	{
	exp = (/(^([a-z]|[A-Z]|[0-9])*$)/);
	if (!exp.test(obj.value))	{
		alert("Please enter only alphanumeric in "+msg);
		obj.focus();
		return true;
	}	else
		return false;
}

function notEmail(obj, divid, msg)	{
	var exp=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	if (!exp.test(obj.value))	{
		obj.style.borderColor="red";
		document.getElementById(divid).style.display = "block";
		document.getElementById(divid).innerHTML ="Please enter valid "+msg;
		obj.focus();
		obj.onblur = function () {
			if(exp.test(this.value)){
				this.style.borderColor="#cacaca";
			}
		};
		obj.focus();
		return true;
	} else {
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}

function notValideEmail(obj, divid, msg)	{
	if(msg!="Password"){obj1=Trim(obj.value);}
	else{obj1=obj.value;}	
	if (obj1=="")	{
		obj.style.borderColor="red";
		document.getElementById(divid).style.display = "block"
		document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please enter the "+msg+"</font>";
		obj.onblur = function () {
			if(this.value!=""){
				this.style.borderColor="#cacaca";
			}
		};
		return true;
	} else {
		var exp=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
		if (!exp.test(obj.value))	{
			obj.style.borderColor="red";
			document.getElementById(divid).innerHTML ="Please enter valid "+msg;
			obj.onblur = function () {
				if(exp.test(this.value)){
					this.style.borderColor="#cacaca";
				}
			};
			obj.focus();
			return true;
		} else {
			document.getElementById(divid).innerHTML ="";
			document.getElementById(divid).style.display = "none"	
			return false;
		}
	}
}

function is_valid_url(obj, divid, msg)	{
	var exp=/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/;
	if (!exp.test(obj.value))	{
		obj.style.borderColor="red";
		document.getElementById(divid).innerHTML ="Please enter valid "+msg;
		obj.focus();
		obj.onblur = function () {
			if(exp.test(this.value)){
				this.style.borderColor="#cacaca";
			}
		};
		obj.focus();
		return true;
	} else {
		document.getElementById(divid).innerHTML ="";
		return false;
	}
} 

function isSame1(obj1,obj2)	{
	if((Trim(obj1.value))!=(Trim(obj2.value)))	{
		obj2.style.borderColor="red";
		obj2.focus();
		obj2.onblur = function () {
			if(this.value!=""){
				this.style.borderColor="#cacaca";
			}
		};
		return true;
	} else {
		return false;
	}	
}	

function isNullHidden(obj,msg)	{
	if (obj.value=="")	{
		alert("Please enter the " +msg);
		return true;
	}	else
		return false;
}

function fnChkAlphaNumeric(obj,msg)	{
	var Alpha = /[a-zA-Z|]/;
	var Num = /[\d]/;
	if (!(Alpha.test(obj.value) && Num.test(obj.value)))	{
		alert("Please enter only alphanumeric in "+msg);
		obj.focus();
		return true;
	} else
		return false;
}

function notZipcode(obj,msg)	{
	exp = /[a-zA-Z|\d]-{1}/;
	if (!exp.test(obj.value))	{
		alert("Please enter valid "+msg);
		obj.focus();
		return true;
	}
	else
		return false;
}

function notChecked(obj, divid, msg)	{
	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))	{
		if(checked==false)	{
			document.getElementById(divid).style.display="block"
			document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please select the "+msg+"</font>";
			return  true;
		} else {
			document.getElementById(divid).innerHTML ="";
			document.getElementById(divid).style.display= "none";
			return false;
		}
	}
}
function notCheckeddeclare(obj, divid, msg)	{
	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))	{
		if(checked==false)	{
			document.getElementById(divid).style.display="block"
			document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please "+msg+"</font>";
			return  true;
		} else {
			document.getElementById(divid).innerHTML ="";
			document.getElementById(divid).style.display= "none";
			return false;
		}
	}
}

function notCheckedRadio(inputcontrols, divid, msg)	{
	myOption = -1;
	var rdo_length = inputcontrols.length;
	var rdo=rdo_length-1;
	for (i=rdo-1; i > -1; i--) {
		if (document.test_form.rdo1[i].checked==false) {
			myOption = i; i = -1;
		}
	}
	if (myOption == -1)	{
		document.getElementById(divid).style.display="block"
		document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please select the "+msg+"</font>";
		return  true;
	} else {
		document.getElementById(divid).innerHTML ="";
		document.getElementById(divid).style.display= "none";
		return false;
	}
}

function notSelected(obj, divid, msg)	{
	if ((obj.options[obj.selectedIndex].value)=="")	{
		var c=obj.options[obj.selectedIndex].value;
		document.getElementById(divid).style.display= "block";
		document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please select the "+msg+"</font>";
		return true;
	} else {
		document.getElementById(divid).innerHTML ="";
		document.getElementById(divid).style.display= "none";
		return false;
	}
}

function notSelected_new(obj, divid, msg)	{
	if ((obj.options[obj.selectedIndex].value)=="")	{
		var c=obj.options[obj.selectedIndex].value;
		document.getElementById(divid).style.display= "block";
		document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please select "+msg+"</font>";
		return true;
	} else {
		document.getElementById(divid).innerHTML ="";
		document.getElementById(divid).style.display= "none";
		return false;
	}
}
function notImageFile(obj, divid, msg)	{
	var exp = /^.+\.(jpg|gif|jpeg|JPG|JPEG|GIF)$/;
	if (!exp.test((obj.value).toLowerCase()))	{
		document.getElementById('divid').style.display='block'; 
		obj.style.borderColor="red";
		document.getElementById(divid).innerHTML ="Please choose jpg or gif file for "+msg;
		obj.focus();
		return true;
	} else {
		document.getElementById(divid).innerHTML ="";
		document.getElementById(divid).style.display="none";
		return false;
	}
}


function notreportfile(obj, divid, msg)	{ 
	var exp = /^.+\.(jpg|gif|jpeg|JPG|JPEG|GIF|DOC|doc|TXT|txt|XLS|xls|PDF|pdf)$/;
	if (!exp.test((obj.value).toLowerCase()))	{
		obj.style.borderColor="red";
		document.getElementById(divid).innerHTML ="Please choose jpg or gif or txt or doc or pdf file for "+msg;
	
		obj.focus();
		return true;
	} else {
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}
 
function notDocFile(obj,msg) {
	if(Trim(obj.value)!="") {
		var exp = /^.+\.(DOC|doc|TXT|txt)$/;
		if (!exp.test((obj.value).toLowerCase())) {
			alert("Please choose doc or txt file for "+msg);
			obj.value="";
			obj.focus();
			return true;
		} else
			return false;	
	}
	else
		return false;
}

function notPdfDocFile(obj,msg) {
	var exp = /^.+\.(pdf|doc|PDF|DOC)$/;
	if (!exp.test((obj.value).toLowerCase())) {
		alert("Please choose pdf or doc file for "+msg);
		obj.value="";
		obj.focus();
		return true;
	}
	else
		return false;
}

function notPdfFile(obj,msg) {
	var exp = /^.+\.(pdf|PDF)$/;
	if (!exp.test((obj.value).toLowerCase())) {
		alert("Please choose pdf file for "+msg);
		obj.value="";
		obj.focus();
		return true;
	} else
		return false;
}

function notPrice(obj,msg) {
	exp = /^[\d]*[\.]{0,1}[\d]{1,2}$/;
	if (!exp.test(obj.value)) {
		alert("Please enter valid "+msg);
		obj.focus();
		return true;
	} else
		return false;
}

function fnChkNum2(obj,msg) {
	exp = /^[\d]/;
	if (!exp.test(obj.value)) {
		obj.style.borderColor="red";
		obj.focus();
		obj.onblur = function () {
			if(exp.test(this.value)){
				this.style.borderColor="#cacaca";
			}
		};
		obj.focus();
		return true;
	} else
		return false;
}

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 isLen(obj,siz,msg)	{
	if(msg!="Password")	{
		obj1=Trim(obj.value);
	} else {
		obj1=obj.value;
	}	
	if(obj1!="") {
		var strLen=obj.value;
		if(strLen.length < siz) {
			alert(msg+" should be atleast " + siz + " characters");
			obj.focus();
			return true;  
		} 
	} else {
		return false;
	}	
}

function isSame(obj1,obj2,msg1,msg2) {
	if((Trim(obj1.value))==(Trim(obj2.value))) {
		alert(msg1+" is matched with the "+msg2);
		obj2.focus();
		return true;
	} else {
		return false;
	}	
}	
	
function isNotSame(obj1,obj2,msg1) {
	if((Trim(obj1.value))!=(Trim(obj2.value))) {
		alert(msg1+" does not match");
		obj2.focus();
		return true;
	} else {
		return false;
	}	
}

function isCorrect(obj1,obj2,msg1,msg2) {
	if((Trim(obj1.value)) > (Trim(obj2.value))) {
		alert(msg1+" should be less than "+msg2);
		obj2.focus();
		return true;
	} else {
		return false;
	}	
}	
	
function isNullEditor(obj,str) {
	if (Trim(obj.value)=="") {
		alert("Please enter the " + str);
		return true;
	} else
		return false;
}

function isTxtareaNull(obj,msg) {
	if(Trim(obj.innerText) == "") {
		alert("Please enter " + msg);
		obj.focus();
		return true;
	} else
		return false;
}

function isTxtareaLen(obj,msg) {
	if(obj.innerHTML.length > 255 ) {
		alert("Please enter below 256 characters in " + msg);
		obj.focus();
		return true;
	} else
		return false;
}

function fnShowDate(obj,msg)  {
	var retdate=window.showModalDialog("includes/calender.htm","","dialogHeight: 219px; dialogWidth: 273px;  center: Yes; help: No; resizable: No; status: No;titlebar:No");
	obj.value=retdate;
}
	
function isNullMulti(obj,msg) {
	if (Trim(obj.value)=="") {
		alert("Please select the " + msg);
		obj.focus();
		return true;
	} else
		return false;
}

function isNullCbo(obj,msg) {
	if (Trim(obj.value)=="") {
		obj.style.borderColor="red";
		obj.focus();
		obj.onblur = function () {
			if(this.value!=""){
				this.style.borderColor="#cacaca";
			}
		};
		obj.focus();
		return true;
	} else
		return false;
}

function fnChkNum(obj) {
	exp1 = /[^0-9]/;
	if (exp1.test(obj.value)) {
		alert("Only  numbers(0-9) are allowed");
		obj.value = "";
		obj.focus();
		return true;
	}
}

function fnChkNum(obj,divid,msg) {
	exp = /^[\d]/;
	if (!exp.test(obj.value)) {
		obj.style.borderColor="red";
		document.getElementById(divid).innerHTML ="Please enter only numeric in "+msg;
		obj.focus();
		obj.onblur = function () {
			if(exp.test(this.value)){
				this.style.borderColor="#cacaca";
			}
		};
		obj.focus();
		return true;
	} else {
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}

function isPassword(obj) { 
	if ((obj.value.length)<4) {
		alert("Password should have atleast 4 characters");
		obj.focus();
		return true;
	}
	exp=/[^a-zA-Z0-9]/;
	if(exp.test(obj.value)) {
		alert("Special characters not accepted");
		obj.focus();
		return true;
	}
	else
		return false;
}

function isNullAndLength(obj, divid, msg, word_limit) {
	if(msg!="Password"){obj1=Trim(obj.value);}
	else{obj1=obj.value;}	
	if (obj1!="")	{
		var str = obj.value;
		var strLength = str.length;
		if(strLength>word_limit)	{
			obj.style.borderColor="red";
			document.getElementById(divid).style.display = "block"
			document.getElementById(divid).innerHTML ="<font color='#FF0000'>Please enter the "+msg+"</font>";
			obj.focus();
			obj.onblur = function () {
				if(this.value!=""){
					this.style.borderColor="#cacaca";
				}
			};
			return true;
		} else {
			document.getElementById(divid).style.display = "none"
			document.getElementById(divid).innerHTML ="";
			return false;
		}
	}
}

function fnisphone(obj,divid,msg)	{
	exp = (/(^([0-9]|[(]|[)]|[-]|[ ])*$)/);
	if (!exp.test(obj.value))	{ 
		obj.style.borderColor="red";
		document.getElementById(divid).style.display = "block";
		document.getElementById(divid).innerHTML ="Please enter only numeric in "+msg;
		obj.focus();
		obj.onblur = function () {
			if(exp.test(this.value)){
				this.style.borderColor="#cacaca";
			}
		};
		obj.focus();
		return true;
	} else {
		document.getElementById(divid).style.display = "none";
		document.getElementById(divid).innerHTML ="";
		return false;
	}
}


