
//TEXT MARE MIC
function textmic() {
var clase = document.getElementById('stireBox').className;
switch (clase) {
case 'txtmic1':
case 'txtmic2':
document.getElementById('stireBox').className = 'txtmic2';
break;
case 'txtmare1':
document.getElementById('stireBox').className = '';
break;
case 'txtmare2':
document.getElementById('stireBox').className = 'txtmare1';
break;
default:
document.getElementById('stireBox').className = 'txtmic1';
break;		
}
}
function textmare() {
var clase = document.getElementById('stireBox').className;
switch (clase) {
case 'txtmic1':
document.getElementById('stireBox').className = '';
break;
case 'txtmic2':
document.getElementById('stireBox').className = 'txtmic1';
break;
case 'txtmare1':
case 'txtmare2':
document.getElementById('stireBox').className = 'txtmare2';
break;
default:
document.getElementById('stireBox').className = 'txtmare1';
break;	
}
}

//COMENTARII
$(function() {
$("input[@type=button]").click(function() {
var name = $("#name").val();
var email = $("#emailc").val();
var id = $("#id").val();
var comment = $("#comment").val();
var website = $("#website").val();
var parametri1  = $("input[@type=text]").serialize();          
var parametri2  = $("textarea").serialize();
var parametri3  = $("#sel").serialize()
var dataString = parametri1+'&'+parametri2+'&'+parametri3+ '&name='+ name + '&id=' + id + '&website=' + website;	
if(name=='' || email=='' || comment=='')
{alert('Campurile marcate cu steluta sunt obligatorii!');}
else
{
$("#flash").show();
$("#flash").fadeIn(400).html('<img src="ajax-loader.gif" align="absmiddle">&nbsp;<span class="loading">Loading Comment...</span>');
$.ajax({
type: "POST",
url: "/assets/commentajax.php",
data: dataString,
cache: false,
success: function(html){
$("#update").append(html);
$("#update li:last").fadeIn("slow");
document.getElementById('emailc').value='';
document.getElementById('name').value='';
document.getElementById('comment').value='';
document.getElementById('website').value='';
$("#name").focus();
$("#flash").hide();
}
});
}
return false;
});
});
//VALID MAIL
$(document).ready(function() {
$("#email").keyup(function(){
var email = $("#email").val();
if(email != 0)
{
if(isValidEmailAddress(email))
{
$("#validEmail").css({"background-image": "url('validYes.png')"});
} else {
$("#validEmail").css({"background-image": "url('validNo.png')"});
}
} else {
$("#validEmail").css({"background-image": "none"});			
}
});
});
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}


//VOT MERGE
$(function(){
$("a.vote_up").click(function(){
//get the id
the_id = $(this).attr('id');
	
// show the spinner
$(this).parent().html("<img src='../imagini/spinner.gif'/>");
	
//fadeout the vote-count 
$("span#votes_count"+the_id).fadeOut("fast");
	
//the main ajax request
$.ajax({
type: "POST",
data: "action=vote_up&id="+$(this).attr("id"),
url: "/assets/votes.php",
success: function(msg)
{
$("span#votes_count"+the_id).html(msg);
//fadein the vote count
$("span#votes_count"+the_id).fadeIn();
//remove the spinner
$("span#vote_buttons"+the_id).remove();
}
});
});
	
$("a.vote_down").click(function(){
//get the id
the_id = $(this).attr('id');
	
// show the spinner
$(this).parent().html("<img src='../imagini/spinner.gif'/>");
	
//the main ajax request
$.ajax({
type: "POST",
data: "action=vote_down&id="+$(this).attr("id"),
url: "/assets/votes.php",
success: function(msg)
{
$("span#votes_count"+the_id).fadeOut();
$("span#votes_count"+the_id).html(msg);
$("span#votes_count"+the_id).fadeIn();
$("span#vote_buttons"+the_id).remove();
}
});
});
});	

//NEWSLETTER
function request_action(jurl,jdata,jtarget)	
{
	$(jtarget).html('Processing request...');
		
	$.ajax(
	{
	   type: "GET",
	   url: jurl,
	   data: jdata,
	   success: function(data)
	   {
	     $(jtarget).html(data);
	   }
	});
};

//ultima ora
//ultima ora
function slideUltimaOra(direccion){if (typeof idIntervalUltimaOra != "undefined")clearInterval(idIntervalUltimaOra);if (direccion != "+1" && direccion != "-1") direccion = "+1";var objSpan = document.getElementById("ultimaOra");var cStrong = objSpan.getElementsByTagName("strong");for (var i=0; i<cStrong.length; i=i+2){if (cStrong[i].style.display == ""){break;var er_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;}}var prefijo = "ultima_ora_titlu_";var textoId = cStrong[i].getAttribute("id");var index = textoId.substring(prefijo.length, textoId.length - 1);var index_sig = "";switch(direccion){case "+1":if (document.getElementById("ultimaOra_titlu_" + (parseInt(index) + 1)) != null)index_sig = parseInt(index) + 1;else index_sig = 0;break;case "-1":if (document.getElementById("ultimaOra_titlu_" + (parseInt(index) - 1)) != null)index_sig = parseInt(index) - 1;else index_sig = (cStrong.length / 2) - 1;break;}cStrong[2 * parseInt(index)].style.display = "none";cStrong[2 * parseInt(index) + 1].style.display = "none";cStrong[2 * parseInt(index_sig)].style.display = "";cStrong[2 * parseInt(index_sig) + 1].style.display = "";idIntervalUltimaOra = setInterval(function(){slideUltimaOra(direccion);}, 3000);}



function resetForm(id) {$('#'+id).each(function(){this.reset();});}
 
