
// voting
var responseSuccessFunVot = function(o)
{
		document.getElementById('vote_container').innerHTML = o.responseText;
};

var responseFailureFunVot = function(o)
{
	//alert('error');
}
var callbackFunVot =
{
	success:responseSuccessFunVot,
	failure:responseFailureFunVot
};

function submit_fun_vot(direction, section_id)
{
	var request = YAHOO.util.Connect.asyncRequest('GET', '/ajax/vote.php?record_id='+section_id+"&direction="+direction, callbackFunVot); 
}
// end voting



function add_to_site_favorites(fun_location, url_location, titlu_location, msg_not_logged)
{
	if (loginState)
		showHint_ultimate(fun_location+'ajax/add_to_favorites.php?link='+url_location+'&title='+titlu_location, 'favorites')
	else
		document.getElementById("favorites_and_vots").innerHTML = msg_not_logged;
}
	
function searchRecords(cautareText, paginaText)
{
	var searchContent = document.getElementById('search').value
	var denied_chars  = ["~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "+", "=", ",", "<", ">", ".", "?", "/", ":", ";", "\"", "'"];
	for (i=0;i<denied_chars.length;i++)
	{
		if (searchContent.indexOf(denied_chars[i])!=-1)
		{
			alert("Cautarea contine caractere nepermise. Va rugam sa folositi numai litere si cifre.");
			return false;
		}
	}
	searchContent = searchContent.replace(/ /gi, "_");
	document.location='[fun]'+cautareText+'_'+searchContent+'/'+paginaText+'_1.html';
}
valCode = "";
var responseSuccess = function(o)
{
	var numeComment		= document.getElementById('numeComment').value;
	var contentComment  = document.getElementById('contentComment').value;
	if (o.responseText=="The validation code is incorrect. Please try again.")
	{
		Recaptcha.reload();
		alert(valCode)
	}
	else
	{
		document.getElementById('commentPlace').innerHTML = o.responseText;
		contentToAdd = '<div class="titleComment">'+numeComment+'</div><div class="contentComment">'+contentComment+'</div><br />';
		document.getElementById("existingComments").innerHTML = contentToAdd + document.getElementById("existingComments").innerHTML;
	}
};

var responseFailure = function(o)
{
	//alert('error');
}
var callback =
{
	success:responseSuccess,
	failure:responseFailure
};
function submit_form(formObject, errName, errComment, validationCode)
{
	valCode = validationCode
	if (document.getElementById("numeComment").value=="")
	{
		alert(errName + " !");
		document.getElementById("numeComment").focus();
		return false;
	}
	if (document.getElementById("contentComment").value=="")
	{
		alert(errComment + " !");
		document.getElementById("contentComment").focus();
		return false;
	}

	YAHOO.util.Connect.setForm(formObject);
	var cObj = YAHOO.util.Connect.asyncRequest('POST', '/ajax/post_comment.php', callback);
}

function trimiteMail(destination_address)
{
	if (document.getElementById("numeMail").value=="")
	{
		alert("Please complete the name field !");
		document.getElementById("numeMail").focus();
		return false;
	}
	if (document.getElementById("addressMail").value=="")
	{
		alert("Please complete the subject field !");
		document.getElementById("addressMail").focus();
		return false;
	}

	var numeMail		= document.getElementById('numeMail').value;
	var addressMail		= document.getElementById('addressMail').value;
	var mesajMail  		= document.getElementById('mesajMail').value;
	
	var targetURL = destination_address;
	targetURL += "?numeMail="+numeMail;
	targetURL += "&addressMail="+addressMail;
	targetURL += "&mesajMail="+mesajMail;
	showHint_ultimate(targetURL, "email_result")
	
	document.getElementById('numeMail').value = "";
	document.getElementById('addressMail').value = "";
	document.getElementById('mesajMail').value = "";
}

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 show_de_ce_logat()
{
	if (document.getElementById("de_ce_logat").style.display=='none')
		document.getElementById("de_ce_logat").style.display = '';
	else
		document.getElementById("de_ce_logat").style.display = 'none';
}

function searchInSite(root, searchLabel)
{
	searchLocation 		= root+searchLabel;
	searchValue 		= document.getElementById("search").value;
	searchValue 		= searchValue.replace(/ /gi, '_');
	searchValue 		= searchValue.toLowerCase();
	document.location 	= searchLocation+'/'+searchValue+'.html';
}
