function Trim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g, "");}

function isNull(obj,str)
{
	if (Trim(obj.value)=="")
	{
		alert("Please enter the " + str);
		obj.focus();
		return true;
	}
	else
		return false;
}
function isNaNm(obj,str)
{
//exp=/^\d[[\d]*[\-]{0,1}[\d]*]*\d$/ //format:0422-2403838,2403838
exp=/(^\d*$)/; //format:044-044-044,0422-2403838,2403838
//exp=/^[\d]{3}[\-][\d]{3}-[\d]{4}$/

	if (exp.test(obj.value))
	{
		alert(str+" is a not a Number. Please enter a valid "+str);
		obj.focus();
		return true;
	}
	else
		return false;
}



function isTxtareaNull(obj,str)
{
	if(Trim(obj.innerText) == "")
	{
		alert("Please enter the " +str);
		obj.focus();
		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 isChar(obj)
{
    exp=/[^\W]/;
	if(!exp.test(obj.value))
	{
	alert("Special characters & space not accepted");
	obj.focus();
	return true;
	}
}

function isSpecial(obj)
{
	exp=/(^\w*$)/;
	if(!exp.test(obj.value))
	{
	alert("Special characters & space not accepted");
	obj.focus();
	return true;
	}
}
function isSpecialChar(obj)
{
	exp=/(^\w*$)/;
	if(!exp.test(obj.value))
	{
	alert("Fractional Values 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 chkNumber(obj,str)
{ 
//exp=/^\d[[\d]*[\-]{0,1}[\d]*]*\d$/ //format:044-2403838,2403838
exp=/(^\d*$)/; //format:044-044-044,0422-2403838,2403838
//exp=/^[\d]{3}[\-][\d]{3}-[\d]{4}$/

	if (!exp.test(obj.value))
	{
		alert(str+" is Not a Number. Please enter a valid "+str);
		obj.focus();
		return true;
	}
	else
		return false;
}




function notEmail(obj)
{
	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|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 notPdfDocFile(obj)
{
	var exp = /^.+\.(pdf|doc|jpg|gif|jpeg|bmp|ppt|pps)$/;
	if (!exp.test((obj.value).toLowerCase()))
	{
		alert("Please choose pdf or doc file");
		obj.focus();
		return true;
	}
	else
		return false;
}
function notPdfDocFiles(obj)
{
	var exp = /^.+\.(pdf|PDF|doc|DOC)$/;
	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 the " + 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 fnChkNum(obj)
{
	if ((window.event.keyCode < 48) || (window.event.keyCode > 57) )
	{
		alert("Please Enter valid Number");
		window.event.keyCode = 0;
        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 GetCountry(defaultValue,isNotWithSelect)
{
	var sCountry="Andorra,Anguilla,Argentina,Aruba,Australia,Austria,Bahamas,Bahrain,Barbados,Belgium,Bermuda,Botswana,Brazil,British Virgin Islands,Brunei,Canada,Cape Verde,Cayman Islands,Chile,China,Costa Rica,Croatia,Cyprus,Czech Republic,Denmark,Dominican Republic,Ecuador,Estonia,Falkland Islands,Fiji,Finland,France,French Guiana,French Polynesia,Germany,Gibraltar,Greece,Guadeloupe,Hong Kong,Hungary,Iceland,India,Indonesia,Ireland,Israel,Italy,Jamaica,Japan,Jordan,Latvia,Liechtenstein,Lithuania,Luxembourg,Malaysia,Maldives,Malta,Martinique,Mayotte,Mexico,Montserrat,Namibia,Netherlands,Netherlands Antilles,New Caledonia,New Zealand,Norway,Philippines,Pitcairn Islands,Poland,Portugal,Qatar,Reunion,Russia,Samoa,Singapore,Slovakia,Slovenia,Solomon Islands,South Africa,South Korea,Spain,St. Helena,St. Kitts and Nevis,St. Lucia,St. Pierre and Miquelon,Sweden,Switzerland,Taiwan,Thailand,Togo,Tonga,Trinidad and Tobago,Tunisia,Turkey,Turks and Caicos Islands,Ukraine,United Arab Emirates,United Kingdom,United States,Uruguay,Venezuela,Vietnam,Wallis and Futuna Islands";
	var CountryV="AD,AI,AR,AW,AU,AT,BS,BH,BB,BE,BM,BW,BR,VG,BN,CA,CV,KY,CL,C2,CR,HR,CY,CZ,DK,DO,EC,EE,FK,FJ,FI,FR,GF,PF,DE,GI,GR,GP,HK,HU,IS,IN,ID,IE,IL,IT,JM,JP,JO,LV,LI,LT,LU,MY,MV,MT,MQ,YT,MX,MS,NA,NL,AN,NC,NZ,NO,PH,PN,PL,PT,QA,RE,RU,WS,SG,SK,SL,SB,ZA,KR,ES,SH,KN,LC,PM,SE,CH,TW,TH,TG,TO,TT,TN,TR,TC,UK,AE,GB,US,UY,VE,VN,WF";
	var xCountry=sCountry.split(",");
	var xCountryv=CountryV.split(",");
	var str="";
	if (!isNotWithSelect)str+="<option value='' selected>Select</option>\n";else str+="<option value='' selected>Doesn't Matter</option>\n";
	for(i=0;i<xCountry.length; i++)
	if(xCountry[i]==defaultValue)str+="<option value='"+xCountryv[i]+"' selected>"+xCountry[i]+"</option>\n";else str+="<option value='"+xCountryv[i]+"'>"+xCountry[i]+"</option>\n";
	document.write(str);
}

function oldGetCountry(defaultValue,isNotWithSelect)
{
	var sCountry="Afghanistan,Albania,Algeria,Andorra,Angola,Antigua & Barbuda,Argentina,Armenia,Australia,Austria,Azerbaijan,Bahamas,Bahrain,Bangladesh,Barbados,Belarus,Belgium,Belize,Benin,Bhutan,Bolivia,Bosnia & Herzegovina,Botswana,Brazil,Brunei Darussalam,Bulgaria,Burkina Faso,Burma,Burundi,Cambodia,Cameroon,Canada,Cape Verde,Central African Republic,Chad,Chile,China,Colombia,Comoros,Congo,Congo(Republic),Côte d'Ivoire,Croatia,Cuba,Cyprus,Czech Republic,Denmark,Djibouti,Dominica,Dominican Republic,Ecuador,East Timor,Egypt,El Salvador,England,Equatorial Guinea,Eritrea,Estonia,Ethiopia,Fiji,Finland,France,Gabon,Gambia,Georgia,Germany,Ghana,Great Britain,Greece,Grenada,Guatemala,Guinea,Guinea-Bissau,Guyana,Haiti,Honduras,Hungary,Iceland,India,Indonesia,Iran,Iraq,Ireland,Israel,Italy,Jamaica,Japan,Jordan,Kazakhstan,Kenya,Kiribati,Korea North,Korea South,Kuwait,Kyrgyzstan,Laos,Latvia,Lebanon,Lesotho,Liberia,Libya,Liechtenstein,Lithuania,Luxembourg,Macedonia,Madagascar,Malawi,Malaysia,Maldives,Mali,Malta,Marshall Islands,Mauritania,Mauritius,Mexico,Micronesia,Moldova,Monaco,Mongolia,Montenegro,Morocco,Mozambique,Myanmar,Namibia,Nauru,Nepal,Netherland,New Zealand,Nicaragua,Niger,Nigeria,Norway,Oman,Pakistan,Palau,Palestinian State*,Panama,Papua New Guinea,Paraguay,Peru,Philippines,Poland,Portugal,Qatar,Romania,Russia,Rwanda,St. Kitts & Nevis,St. Lucia,St. Vincent & The Grenadines,Samoa,San Marino,São Tomé & Príncipe,Saudi Arabia,Senegal,Serbia,Seychelles,Sierra Leone,Singapore,Slovakia,Slovenia,Solomon Islands,Somalia,South Africa,Spain,Sri Lanka,Sudan,Suriname,Swaziland,Sweden,Switzerland,Syria,Taiwan,Tajikistan,Tanzania,Thailand,Togo,Tonga,Trinidad & Tobago,Tunisia,Turkey,Turkmenistan,Tuvalu,Uganda,Ukraine,United Arab Emirates,United Kingdom,United States,Uruguay,Uzbekistan,Vanuatu,Vatican City (Holy See),Venezuela,Vietnam,Western Sahara*,Yemen,Zaire,Zambia,Zimbabwe,Other";
	var xCountry=sCountry.split(",");
	var str="";
	if (!isNotWithSelect)str+="<option value='' selected>Select</option>\n";else str+="<option value='' selected>Doesn't Matter</option>\n";
	for(i=0;i<xCountry.length; i++)
	if(xCountry[i]==defaultValue)str+="<option value='"+xCountry[i]+"' selected>"+xCountry[i]+"</option>\n";else str+="<option value='"+xCountry[i]+"'>"+xCountry[i]+"</option>\n";
	document.write(str);
}

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 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;
}


