function showName(showId) {
	try
	{
		var contentDiv = document.getElementById("names"); 
		var allContainedElements = contentDiv.getElementsByTagName("div"); 
		for (var i = 0; i < allContainedElements.length; i++) { 
			var div = allContainedElements[i]; 
			if(div.className == "numeCopiiDisplay") { div.className = "numeCopiiNotDisplay"; }
			if(div.className == "numeCopiiDescDisplay") { div.className = "numeCopiiDescNotDisplay"; }
		}
		document.getElementById(showId).className = "numeCopiiDisplay";
	}
	catch(err)
	{
		//Handle errors here
	}
}

function change_article(total_cover_story)
{
    if (getNextStory == 1)
    {
	nextCoverStory = (currentCoverStory + 1) > total_cover_story ? 1 : (currentCoverStory + 1);
	select_cover_story(nextCoverStory, total_cover_story);
    }
    window.clearTimeout(timeoutId);
    timeoutId = window.setTimeout('change_article(' + total_cover_story + ')', time);
}

function select_cover_story(current_cover_story, total_cover_story)
{
    for (var i = 1; i <= total_cover_story; i++)
    {
	document.getElementById('cover_story_' + i).style.display = 'none';
    }
    document.getElementById('cover_story_' + current_cover_story).style.display = 'block';
    currentCoverStory = current_cover_story;
    if (total_cover_story > 1)
    {
	window.clearTimeout(timeoutId);
	timeoutId = window.setTimeout('change_article(' + total_cover_story + ')', time);
    }
}
	 
function openPopup (url, name, w, h) 
{
	pictures = window.open(url, name, 'width='+ w +',height='+ h +',top='+ (screen.height/2-h/2) +',left='+ (screen.width/2-w/2) +',toolbar=0,resizable=1,scrollbars=yes');
}

function resizeImagePopup() {
        var img = document.getElementById('popImg');
        var width = img.width;                                                                                                                                       var height = img.height;

		window.moveTo(0,0);

        if (0 == img.width || 0 == img.height) {
                var toWidth = 1130;
                var toHeight = 900;
        }
        else {
                var toWidth = 200 + img.width;
                var toHeight = 250 + img.height;
                if (toWidth > screen.width) {
                        toWidth = screen.width;
                }
                if (toHeight > screen.height) {
                        toHeight = screen.height;
                }
        }
        top.resizeTo(toWidth, toHeight);
	
		x = (screen.height -  toHeight)/2;
		y = (screen.width - toWidth)/2;

		window.moveTo(x,y);
}

function showNameDescription(showId) {
	try
	{
		var contentDiv = document.getElementById("names"); 
		var allContainedElements = contentDiv.getElementsByTagName("div"); 
		for (var i = 0; i < allContainedElements.length; i++) { 
			var div = allContainedElements[i]; 
			if(div.className == "numeCopiiDescDisplay") { div.className = "numeCopiiDescNotDisplay"; }
		}
		document.getElementById(showId).className = "numeCopiiDescDisplay";
	}
	catch(err)
	{
		//Handle errors here
	}
}

function pollVote(box_id, poll_id) {
	xmlAsyncRequestText ('/ajax?'+box_id+'&submit=1&itemID='+poll_id+'&service_type=PollContest'
		+'&rnd='+Math.random()
		, Form_MakeQueryString('fp'+poll_id+'_'+box_id)
		, 'dinamicContent'+box_id+'_'+poll_id); 
	
	    var url = 'http://www.viva.ro';
	    if($('#members_only').val() == 1)
		{
			if(getCookie('user_name') > "")
			{
				if($('#refresh').val() == 'yes')
				{
					if($('#curent_page').val() < $('#count_pages').val())
					{
						var next = parseInt($('#curent_page').val()) + 1;
						window.location = url+$('#cms_url').val()+'&p='+next+'#concurs';
					}
				}
			}
		}
		else
		{
			if($('#refresh').val() == 'yes')
			{
				if($('#curent_page').val() < $('#count_pages').val())
				{
					var next = parseInt($('#curent_page').val()) + 1;
					window.location = url+$('#cms_url').val()+'&p='+next+'#concurs';
				}
			}
		}
	return false;
}
function pollShowResults(box_id, poll_id) {
	xmlAsyncRequestText ('/ajax?'+box_id+'&submit=1&itemID='+poll_id+'&service_type=PollContest&output=results'
		+'&rnd='+Math.random()
		, ''
		, 'dinamicContent'+box_id+'_'+poll_id);
	return false;
}

/*folosita profil */
function validProfile() 
{
	var errStr = "Numele si/sau prenumele contin caractere nepermise";
	var str1 = document.getElementById("last_name").value;
	var str2 = document.getElementById("first_name").value;
	var regStr = "^[a-zA-Z]"; //neaparat sa inceapa cu litera
	var reg = new RegExp(regStr);
	if (reg.test(str1) && reg.test(str2)) 
	{
		return true;
	}
	else
	{
		alert(errStr);
		return false;
	}

}

function check_form (obj) {
  if (obj.agree.checked)
  {
    if(validProfile()) 
	{
		return true;
	}
	else
	{
		return false;
	}
  }
  else
  {
    alert('Pentru a fi inregistrat pe acest site trebuie sa fiti de acord cu termeni si conditiile acestui site!')
    return false
  }
}

