var appPath;
appPath = './../';
String.prototype.trim = function() {

	var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}
function isEmailAddr(email)
{
  var result = false;
  var theStr = new String(email);
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}
function isNumeric(st)
{
	var Char;
	sText = st;
	var IsNumeric = true;
	var blnk = "0123456789.-";
	var blnkcnt = 0;
	for (i = 0; i < sText.length; i++)
	{
		Char = sText.charAt(i);
		if (blnk.indexOf(Char) == -1)
		{
			IsNumeric = false;
		}
	}
	return IsNumeric;
}
function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}
function addOption(selectbox, value, text )
{
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;

	selectbox.options.add(optn);
}
function isFilledText(textbox, spStr, errMsg)
{
	var strVal;
	strVal = textbox.value;
	strVal = strVal.trim();
	if((strVal=='') || (strVal==spStr))
	{
		alert(errMsg);
		textbox.focus();
		return false;
	}
	else
		return true;
}
function isFilledSelect(selectbox, spStr, errMsg, cmpOpt)
{
	// Possible values for cmpOpt are
	// 0 when values are supposed to be compared but in numbers, variable spStr is mentioned in number
	// 1 when text needs to be compared, variable spStr is mentioned in text
	// 2 when values are supposed to be compared but in text, variable spStr is mentioned in text
	var strVal;
	if(cmpOpt == 0)
	{
		strVal = selectbox.selectedIndex;
		if(strVal==spStr)
		{
			alert(errMsg);
			selectbox.focus();
			return false;
		}
		else
			return true;
	}
	else if(cmpOpt == 1)
	{
		strVal = selectbox.options[selectbox.selectedIndex].text;
		spStr = spStr.trim();
		if(strVal==spStr)
		{
			alert(errMsg);
			selectbox.focus();
			return false;
		}
		else
			return true;
	}
	else if(cmpOpt == 2)
	{
		strVal = selectbox.options[selectbox.selectedIndex].value;
		spStr = spStr.trim();
		if(strVal==spStr)
		{
			alert(errMsg);
			selectbox.focus();
			return false;
		}
		else
			return true;
	}
}
function isCBoxChecked(checkBox, numChecked, errMsg, countCBox)
{
	var numCBox, chkTemp, chkCount;	
	if(countCBox == 1)
	{
		if(checkBox.checked == false)
		{
			alert(errMsg);
			checkBox.focus();
			return false;
		}
		else
			return true;
	}
	else
	{
		chkTemp = false;
		chkCount = 0;
		numCBox = checkBox.length;
		for(i=0;i<numCBox;i++)
		{
			if(checkBox[i].checked == true)
			{
				chkCount++;
				if(chkCount==numChecked)
				{
					chkTemp = true;
				}
			}
		}
		if(chkTemp==false)
		{
			alert(errMsg);
		}
		return chkTemp;
	}
}
function clicknull()
{
	return false;
}
function makeStoryURL(obj, secName)
{
	var strVal = obj.value;
	var spChar = "~@#$%^&*()+=-`><?/';:{}[]\|.,!";
	var strFVal;
	strVal = strVal.trim();
	strVal = strVal.replace(/ /g, '_');
	strFVal = "";
	for(i=0; i<strVal.length; i++)
	{
		if(spChar.indexOf(strVal.charAt(i)) > -1)
			strFVal += "_";
		else
			strFVal += strVal.charAt(i);

	}
	strFVal = strFVal.replace(/ /g, '_');
	document.getElementById('txtStoryURL').value= 'site/' + strFVal.toLowerCase();
}
function makeVideosURL(obj)
{
	var strVal = obj.value;
	var spChar = "~@#$%^&*()+=-`><?/';:{}[]\|.,!";
	var strFVal;
	strVal = strVal.trim();
	strVal = strVal.replace(/ /g, '_');
	strFVal = "";
	for(i=0; i<strVal.length; i++)
	{
		if(spChar.indexOf(strVal.charAt(i)) > -1)
			strFVal += "_";
		else
			strFVal += strVal.charAt(i);

	}
	strFVal = strFVal.replace(/ /g, '_');
	var valType = document.getElementById('txtItemType').options[document.getElementById('txtItemType').selectedIndex].value;
	//alert(valType);
	if(valType== "videos")
		document.getElementById('txtVideoURL').value = 'videos/' + strFVal.toLowerCase();
	else
		document.getElementById('txtVideoURL').value = '';
}