function searchForNews(stringToCompare, errorMsg, lang)
{
	var searchForm 					= document.getElementById("searchForm").value;
	var SearchNumberOfRecorsPerPage = document.getElementById("SearchNumberOfRecorsPerPage").value;
	var SearchSortBy 				= document.getElementById("SearchSortBy").value;

	if ((searchForm=="") || (searchForm==stringToCompare))
	{
		alert(errorMsg);
		document.getElementById("searchForm").focus();
		document.getElementById("searchForm").value="";
		return false;
	}
	
//	searchForm = searchForm.replace(/+/gi, 'plus');
	searchForm = searchForm.replace(/ /gi, '+');
	SearchSortBy = SearchSortBy.replace(/ /gi, '+');
	
	if (lang=="en")
		document.location = 'http://news.u-trade.org/search/recsperpage_'+SearchNumberOfRecorsPerPage+'/sort_by_'+SearchSortBy+'/page_1/'+searchForm;
	else
		document.location = 'http://stiri.u-trade.ro/cautare/inregistrari_pe_pagina_'+SearchNumberOfRecorsPerPage+'/sortare_dupa_'+SearchSortBy+'/pagina_1/'+searchForm;
}

var windowWidthX  = 0;

function postComment()
{
	document.getElementById('commentPlace').style.display='none';
	document.getElementById('post_comment_link').style.display='';
	contentToAdd = '<div class="titleComment">'+numeComment+'</div><div class="contentComment">'+contentComment+'</div><br />';
	document.getElementById("existingComments").innerHTML = contentToAdd + document.getElementById("existingComments").innerHTML;
}

function loadSmyle(code_smile)
{
	browser = navigator.userAgent.toLowerCase();
	
	if (browser.indexOf('firefox') != -1)
	{
		selStart   = document.getElementById("contentComment").selectionStart;
		selEnd     = document.getElementById("contentComment").selectionEnd;
		allContent = document.getElementById("contentComment").value;
		selBefore  = allContent.substring(0, selStart);
		selAfter   = allContent.substring(selEnd, allContent.length);

		document.getElementById("contentComment").value = selBefore+code_smile+selAfter
	}

	if (browser.indexOf('msie') != -1)
		alert("We are sorry but this function is disabled in Internet Explorer or similar due to of some existing bugs found. You may still insert smilyes using codes from image title.")
}

function showOpi(Contacteaza)
{
	document.write('<a href="ymsgr:sendim?utrade_org" title="'+Contacteaza+'"><img border="0" src="http://opi.yahoo.com/online?u=utrade_org&amp;m=g&amp;t=5=us" width="12" height="12" alt="'+Contacteaza+'" title="'+Contacteaza+'" /></a>');
}
function showMenuSubdomains()
{
	if (document.getElementById("menuSubdomains").style.display == "none")
		document.getElementById("menuSubdomains").style.display = "block";
	else
		document.getElementById("menuSubdomains").style.display = "none";
}
function goTo(place)
{
	document.location = place
}
function getInfo(address)
{
	document.location = (address);	
}

function verificaForm(component, reWriteContent, mod)
{
	actualContent = document.getElementById(component).value;

	if (mod == "focus")
	{
		if (actualContent == reWriteContent)
			document.getElementById(component).value = "";
	}
	if (mod == "blur")
	{
		if (actualContent == "")
			document.getElementById(component).value = reWriteContent;
	}
}

function checkHelpAndSupport(language)
{
	if (document.getElementById("support").value == "")
	{
		if (language == 'ro') alert("Campul mesaj nu este completat !");
		if (language == 'en') alert("Message field is not filled !");
		document.getElementById("support").focus();
		return false;
	}
	
	sir = document.getElementById('email').value;
	tmp = sir.indexOf("@", 1);
	tmp2 = sir.indexOf(".", 1);
	if (tmp == -1) {
		if (language == 'ro') alert("Adresa de e-mail incorecta !");
		if (language == 'en') alert("E-mail address is incorect !");
		document.getElementById('email').focus();
		return false;
	}
	if (tmp2 == -1) {
		if (language == 'ro') alert("Adresa de e-mail incorecta !");
		if (language == 'en') alert("E-mail address is incorect !");
		document.getElementById('email').focus();
		return false;
	}
}

function checkLogin(msg)
{
	var usr  = document.getElementById("userForm").value;
	var pass = document.getElementById("passwordForm").value;
	if ((usr=="username") || (pass=="password") || (usr=="utilizator") || (pass=="parola") || (usr=="") || (pass==""))
	{
		alert(msg);
		return false;
	}
}
function checkSearchCompletition(stringToCompare, errorMsg)
{
	if ((document.getElementById("searchForm").value=="") || (document.getElementById("searchForm").value==stringToCompare))
	{
		alert(errorMsg);
		document.getElementById("searchForm").focus();
		document.getElementById("searchForm").value="";
		return false;
	}
}
function validateUserEdit(language)
{
	__messages_ro = ["Completati prenumele", "Completati numele", "Completati adresa de e-mail", "Completati telefonul", "Completati localitatea"];
	__messages_en = ["Fill firstname field", "Fill lastname field", "Insert e-mail address", "Fill phone field", "Fill locality field"];

	__type		  = ["", "", "", "", ""];
	__components  = ["firstname", "lastname", "email", "phone", "locality"];
	__minLength   = ["2", "2", "5", "5", "2"];
	__minField_ro = ["prenume", "nume", "e-mail", "telefon", "localitate"];
	__minField_en = ["firstname", "lastname", "e-mail", "phone", "locality"];

	for (i=0;i<__components.length;i++)
	{
		if (document.getElementById(__components[i]).value == __type[i])
		{
			if (language == 'ro') alert(__messages_ro[i]);
			if (language == 'en') alert(__messages_en[i]);
			document.getElementById(__components[i]).focus();
			return false;
		}
		if (__minLength[i] != "")
		{
			if ((document.getElementById(__components[i]).value).length < __minLength[i])
			{
				if (language == 'ro') alert("Campul "+__minField_ro[i]+" nu pare a fi corect completat.");
				if (language == 'en') alert("The "+__minField_en[i]+" field doesn't look to be correct.");
				document.getElementById(__components[i]).focus();
				return false;
			}
		}
	}
	__XElems	  = ["studies", "profession", "fromwhere"];
	__messageX_ro = ["studiile", "profesia", "de unde ati aflat de noi"];
	__messageX_en = ["studies", "profession", "from where do you here about us"];
	
	for (i=0;i<__XElems.length;i++)
	{
		if (document.getElementById(__XElems[i]).value == "X")
		{
			if ((document.getElementById(__XElems[i]+"_altele_form").value == "precizati aici") || (document.getElementById(__XElems[i]+"_altele_form").value == "describe here") || (document.getElementById(__XElems[i]+"_altele_form").value == ""))
			{
				if (language == 'ro') alert("Descrieti " + __messageX_ro[i]);
				if (language == 'en') alert("Describe " + __messageX_en[i]);
				document.getElementById(__XElems[i]+"_altele_form").focus();
				return false;				
			}
		}
	}
	
	sir = document.getElementById("email").value;
	tmp = sir.indexOf("@", 1);
	tmp2 = sir.indexOf(".", 1);
	if (tmp == -1)
	{
		if (language == 'ro') alert("Adresa de e-mail incorecta !");
		if (language == 'en') alert("E-mail address is incorect !");
		document.getElementById("email").focus();
		return false;
	}
	if (tmp2 == -1)
	{
		if (language == 'ro') alert("Adresa de e-mail incorecta !");
		if (language == 'en') alert("E-mail address is incorect !");
		document.getElementById("email").focus();
		return false;
	}
}

function goToTarget(place)
{
	switch (place)
	{
		case "google_docs":
			trgt = "http://docs.google.com/";
		break;
	}
	
	window.open(trgt);
}