// This function is used to provide the selection of web, images, video etc.
var showClick = 0; // added for +More Options to work
function AjandGenric() {
	this.YabhathFormat = numberFormat;
	this.getYabhathQuery = getQueryString;
	this.getYabhathHash = getHash;
	this.getYabhathFile = getFileName;
	this.setAjandCursor = setCursorAtEnd;
	this.setAjandCursorWord = setCursorAtEndOfCurrentWord;
	//This function formats numbers by adding commas
	function numberFormat(nStr, prefix) {
		var prefix = prefix || '';
		nStr += '';
		x = nStr.split('.');
		x1 = x[0];
		x2 = x.length > 1 ? '.' + x[1] : '';
		var rgx = /(\d+)(\d{3})/;
		while (rgx.test(x1))
			x1 = x1.replace(rgx, '$1' + ',' + '$2');
		return prefix + x1 + x2;
	}
	function getQueryString(val) {
		var fullDetail = window.location.search.substring(1);
		var queryValue = fullDetail.split("&");
		for (i = 0; i < queryValue.length; i++) {
			var strVal = queryValue[i].split("=");
			if (strVal[0] == val) {
				return strVal[1];
			}
		}
	}
	;

	function getHash(val) {
		var fullDetail = window.location.search.substring(1);
		var queryValue = fullDetail.split("#");
		for (i = 0; i < queryValue.length; i++) {
			var strVal = queryValue[i].split("=");
			if (strVal[0] == val) {
				return strVal[1];
			}
		}
	}
	;
	function getFileName() {
		var sPath = window.location.pathname;
		var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
		return sPage.split(".")[0];
	}
	function setCursorAtEnd(sTextboxID) {
		var oTextbox = document.getElementById(sTextboxID);
		if (oTextbox.createTextRange) {
			var r = (oTextbox.createTextRange());
			r.moveStart('character', (oTextbox.value.length));
			r.collapse();
			r.select();
		} else {
			if (oTextbox.selectionStart) {
				oTextbox.focus();
				oTextbox.setSelectionRange((oTextbox.value.length),
						(oTextbox.value.length));
			} else
				oTextbox.focus();
		}
	}
	function setCursorAtEndOfCurrentWord(sTextboxID) {
		var oTextbox = document.getElementById(sTextboxID);
		if (oTextbox.createTextRange) {
			var r = (oTextbox.createTextRange());
			// alert('current globalCursorPos='+globalCursorPos);//this was set
			// in
			// useSuggestion function
			r.moveStart('character', globalCursorPos);
			r.collapse();
			r.select();
		} else {
			if (oTextbox.selectionStart) {
				oTextbox.focus();
				oTextbox.setSelectionRange(globalCursorPos, globalCursorPos);
			} else
				oTextbox.focus();
		}
	}
}
