function optionSelect(opt,val)
{
   for(var ui = 0; ui<opt.length ; ui++)
   {
      if(opt.options[ui].value == val)               
      {
	  opt.options[ui].selected = true;
	  break;
      }
   } 
}
function selAll(opt)
{
   for(var ui = 0; ui<opt.length ; ui++)
   {
     opt.options[ui].selected = true;
   } 
}
function getSel(opt)
{  
	if(opt != null && opt != 'undefined' && opt != "")
	  return  opt.options[opt.options.selectedIndex].value; 
}
function getSelection(opt)
{
	if(opt != null && opt != 'undefined' && opt != "")
		return  opt.options[opt.options.selectedIndex].value; 
}
function getSelText(opt)
{  
	if(opt != null && opt != 'undefined' && opt != "")
	  return  opt.options[opt.options.selectedIndex].text; 
}
function getStrSelection(opt)
{
  return  opt.options[opt.options.selectedIndex].value; 
} 
function checkVisa(visaObj,ctObj)
{
  if(parseInt(getSelection(ctObj)) != parseInt(getVRegion(visaObj)))
  {
    alert("Your Citizen of Country and Visa Country must be same.\nIf you want to select only Citizen of country means use Simple Filter\n else if you want only Visa Type means reset the Country selection to no Selection");
    ctObj.focus();
    return (false);
  }
}

function getVRegion(visaObj)
{
  var str = getSelection(visaObj);
  return (str.substring(0,str.indexOf("@")));  
}
function trim(strMessage)
{
	var strResult;
	var charTemp;
	var i;

	strResult = "";

	//remove the left space
	for ( i = 0; i < strMessage.length; i++ )
	{
		charTemp = strMessage.charAt(i);
		if ( charTemp != " " )
		{
			strResult = strMessage.substring(i);
			break;
		}
	}

	//remove the right space
	for ( i = strResult.length-1; i >= 0; i = i -1 )
	{
		charTemp = strResult.charAt(i);
		if ( charTemp != " " )
		{
			strResult = strResult.substring(0,i+1);
			break;
		}
	}
	return (strResult);
}


function setValue(obj,val)
{
  if(obj != null && obj.type == 'select-one')
  optionSelect(obj,val);
  else if(obj != null)
  obj.value = val;  
}

function cotsTakeCare(str)
{
 while(str.indexOf('\'') != -1)
 {
	str = str.replace('\'',' ');
 }
 while(str.indexOf('\"') != -1)
 {
 	str = str.replace('\"',' ');
 }
 return str;
}
function eMess()
{
  alert(arguments[0]);
  if(arguments[1].disabled)
  {  
  arguments[1].disabled = false;
  arguments[1].focus();
  arguments[1].disabled = true;
  }
  else
  arguments[1].focus();
  return (false);
}
