



var previd = "";
function showhideDiv(id,ancpos,offleft)
{
	if(previd!="")
		$('#'+previd).hide();
	previd = id;
	var anc = $('#'+ancpos);
	var offset = anc.offset();
	var divid = $('#'+id);
	divid.addClass('whtbg');
	divid.css({left:offset.left-offleft,top:offset.top});
	//divid.css({position:"absolute",width:"220px",background:"#fff", padding:"5px",color:"#000",border:"1px solid #000",left:offset.left+73,top:offset.top+3});
	divid.show();
}

function closeDiv(id)
{
	var divid = $('#'+id);
	divid.hide();
}

function trim(str)
{
    if(!str || typeof str != 'string'){
    	str="";
    	return str;
    }
    return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}

function isemail(str)
{
	if(str == "")
		return false;
		
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(str))
	{
		return false;
	}
	return true;
}

function radioButtValue(radioButtObj)
{	
	for (counter = 0; counter < radioButtObj.length; counter++)
	{
		if (radioButtObj[counter].checked){
			return radioButtObj[counter].value;
		}		
	}
	return "";
}

function checkBoxValue(checkBoxObj,delim)
{
	var c_value = "";
	for (var i=0; i < checkBoxObj.length; i++)
   	{
	  if (checkBoxObj[i].checked)
      {
	      c_value = c_value + checkBoxObj[i].value + delim;
      }
   }
   return c_value;
}
function checkedCheckboxLen(checkBoxObj,delim)
{
	var counter = 0;
	
	for (var i=0; i < checkBoxObj.length; i++)
   	{
	  if (checkBoxObj[i].checked)
      {
	      counter = counter + 1;
      }
   }
   return counter;
}
function wordCount(string)
{
	var a = string.split(/\s+/g);
	return a.length;
}
function isEmpty(val)
{	
	if(val == "")
		return true;
	else
		return false;
}
function unCheckAll(checkbox) 
{
	for (i = 0; i < checkbox.length; i++) 
	{
		checkbox[i].checked = false;
	}
}
function swapImage(imgId,status){
	var imageid = "#"+imgId;
	var imgPath = $("#"+imgId).attr('src');
	var arr = imgPath.split('images');
	imgPath = arr[0] + "images/"+imgId+"_"+status+".gif";
	var anclink = "#"+imgId+"_link";
	$(imageid).attr({src:imgPath});
	$(anclink).removeAttr("onmouseout");
}

function highLightToolBox(liName){
	$('#'+liName).addClass('active');
	
}