function appendSymbol(symbol,target_field)
{
    var str = target_field.value.toUpperCase()
    
    var pos=str.match(symbol)
    if (pos)
    {
    
    } 
    else 
    {
      if (str.length <= 0)
      {
        target_field.value= target_field.value + symbol
      }  
      else
      {
        target_field.value= target_field.value + ' ' + symbol
      
      }
    }

}

function toggleDisplay(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}


function toggleDisplay2(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}


function toggleDisplay3(item)
{
	if (document.getElementById(item).style.display == 'none' )
	{
		document.getElementById(item).style.display = 'inline' ;

	}
	else 
	{
		document.getElementById(item).style.display = 'none' ;
    }
}


function hideBlock(item)
{
	document.getElementById(item).style.display = 'none' ;
}

function showBlock(item)
{
	document.getElementById(item).style.display = 'block' ;
}


function featuredBlock_hilite(item)
{
    $('featured_menu-'+item).className = "sub-nav-current";   
    showDisplay('featured_content-'+item);
}

function featuredBlock_dull(item)
{
    $('featured_menu-'+item).className = "";   
    hideBlock('featured_content-'+item); 
}



function showDisplay(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "block":"block";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "block":"block";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "block":"block";
	}
}

	function hideDisplay(whichLayer)
{
	if (document.getElementById)
	{
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"";
	}
	else if (document.all)
	{
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"";
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"";
	}
}

function showSymbols(id)
{
	hideBlock('expandsymbols_'+id);
	showBlock('hiddensymbols_'+id);
}

function countClick(e, url, aid, cid)
{	
	if (Event.isLeftClick(e)==true)
	{
		params='authenticity_token='+window._token+'&url='+url;
		if (aid)
			params=params+'&article_id='+aid;
		if (cid)
			params=params+'&cluster_id='+cid;	
		new Ajax.Request('/outboundlink/record/', {asynchronous:false, method:'post', parameters:params}); 
	}	
	return false;	
}

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function isValidUrl(str) {
	var regexp = /(|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
	return regexp.test(str);
}
