function evalScript(scripts)
{	
	try
	{	
		if(scripts != '')	
		{	
			var script = "";
			scripts = scripts.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){if (scripts !== null) script+=arguments[1]+'\n';return '';});
			if(script) (window.execScript) ? window.execScript(script) : window.setTimeout(script, 0);
		}
		return false;
	}
	catch(e)
	{	
		alert(e);
	}
}

function makeRequest(url,targetdiv) 
{
	var http_request = false;
	if (window.XMLHttpRequest)
	{ // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) 
		{
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} 
	else if (window.ActiveXObject) 
	{ // IE
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} 
		catch (e) 
		{
			try
			{
					http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e)
			{}
		}
	}

	if (!http_request)
	{
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function()
	{
		alertContents(http_request,targetdiv);
	};
	http_request.open('GET', url, true);
	http_request.send(null);

}

function alertContents(http_request,targetdiv) 
{

	if (http_request.readyState == 4)
	{
		if (http_request.status == 200) 
		{
			result=http_request.responseText;
			
			//document.getElementById(targetdiv).innerHTML="";
			document.getElementById(targetdiv).innerHTML=http_request.responseText;	
			evalScript(result);
		} 
		else
		{
			//alert('There was a problem with the request.');
		}
	}
}

//.............................................................
function check_rate_this_public(val,ident)
{
	for(i=1;i<=5;i++)
	{
		if(i<=val)
		{
			document.getElementById(ident+'star'+i).src='images/rating/star_over.png';
		}
		else
		{
			document.getElementById(ident+'star'+i).src='images/rating/star_off.png';
		}
	}	
}
function reset_rate_this_public(max,ident)
{
	for(i=1;i<=5;i++)
	{
		if(i<=max)
		{
			document.getElementById(ident+'star'+i).src='images/rating/star_on.png';
		}
		else
		{
			document.getElementById(ident+'star'+i).src='images/rating/star_off.png';
		}
	}	
}
function rate_this_public(val,id_entity,entity,ident)
{
	makeRequest('_rating_function.inc.php?star='+val+'&id_entity='+escape(id_entity)+'&entity='+escape(entity)+'&next='+Math.random(),ident+'_art_rating');
}	

//...............
function check_rate_this(val)
{
	for(i=1;i<=5;i++)
	{
		if(i<=val)
		{
			document.getElementById('star'+i).src='images/rating/star_over.png';
		}
		else
		{
			document.getElementById('star'+i).src='images/rating/star_off.png';
		}
	}	
}
function reset_rate_this(max)
{
	for(i=1;i<=5;i++)
	{
		if(i<=max)
		{
			document.getElementById('star'+i).src='images/rating/star_on.png';
		}
		else
		{
			document.getElementById('star'+i).src='images/rating/star_off.png';
		}
	}	
}
function rate_this(val)
{
	makeRequest('_rating.inc.php?star='+val+'&amp;next='+Math.random(),'art_rating');
}	
//...............

function currency_convert()
{
	makeRequest('_curs_valutar_convert.inc.php'
	+ '?currency_from_value='+ escape(document.getElementById('currency_from_value').value)
	+ '&currency_from_currency='+ escape(document.getElementById('currency_from_currency').value)
	+ '&currency_to_currency='+ escape(document.getElementById('currency_to_currency').value)
	,'curs_valutar_convert');
}

function make_hidden(elem)
{
	document.getElementById(elem).style.display='none';
}

function check_delete_selection(frm,elem)
{
	if(confirm('Delete selection?'))
	{
		document.getElementById(elem).value=1;
		document.getElementById(frm).submit();
	}
}

function show_hide(elem)
{
	if(document.getElementById(elem).style.display=='block')
	{
		document.getElementById(elem).style.display='none';
	}
	else
	{
		document.getElementById(elem).style.display='block';
	}
}