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)
		, 'dinamicContent'+box_id+'_'+poll_id);
	   var url = 'http://www.elle.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;
}

function submitRegister() 
{
	//document.register_form.submit();
	if(document.register_form.agree.checked != true)
	{
		alert('Pentru a fi inregistrat pe acest site trebuie sa fiti de acord cu termeni si conditiile acestui site!')
		return false;
	}
	else
	{
		document.register_form.submit();
	}
}

function searchDesigner()
{
	var submit_search_url = '/cautare-designer/';
	var keywords = $('input[name=q]').val();
	var keywords2 = $('input[name=q2]').val();
	if(keywords != '' || keywords2 != '')
	{
		if(keywords != '') submit_search_url = submit_search_url + keywords;
		else  submit_search_url = submit_search_url + keywords2;
		window.location = submit_search_url;
	}
	else
	{
		alert("Cautare invalida!");
	}
	return false;
}
function searchSite()
{
	var submit_search_url = '/cautare/';
	var keywords = $('input[name=q]').val();
	if(keywords != '')
	{
		if(keywords != '') submit_search_url = submit_search_url + keywords;
		window.location = submit_search_url;
	}
	else
	{
		alert("Cautare invalida!");
	}
	return false;
}
function searchTravel()
{
	var submit_search_url = '/cautare-travel/';
	var keywords = $('input[name=q]').val();
	if(keywords != '')
	{
		if(keywords != '') submit_search_url = submit_search_url + keywords;
		window.location = submit_search_url;
	}
	else
	{
		alert("Cautare invalida!");
	}
	return false;
}
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 resizeImagePopup2() {
        var img = document.getElementById('popImg');
        var width = img.width;                                                                                                                                       var height = img.height;

		window.moveTo(0,0);
		//console.error("Widtd: "+img.width+" Height: "+img.height);
        if (0 == img.width || 0 == img.height || img.width < 100) {
                var toWidth = 1130;
                var toHeight = 900;
        }
        else {
				var plusSize = document.getElementById('plusSize').innerHTML; 
				//console.error("plus: "+plusSize);
                var toWidth = parseInt(plusSize) + img.width; 
				//console.error("twidth: "+toWidth);
                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 checkit() 
{
  var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
  if (!(document.getElementById('nume_d').value > '')) {alert('Numele destinatarului nu este completat!');return false;}
  if (!(document.getElementById('nume_e').value > '')) {alert('Numele expeditorului nu este completat'); return false;}
  if (!pattern.test(document.getElementById('email_d').value)) {alert('Email-ul destinatarului nu este completat!');return false;}
  if (!pattern.test(document.getElementById('email_e').value)) {alert('Email-ul  expeditorului nu este completat'); return false;}
  return true;
}

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 = 0; i < total_cover_story; i++)
    {
		document.getElementById('main_' + i).style.display = 'none';
    }
    document.getElementById('main_' + 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);
    }
}
var showRegisterVar = 0;
function showRegister()
{
	if(showRegisterVar == 1)
	{
		document.getElementById('login').style.display='none';
		document.getElementById('preRegister').style.display='none';
		document.getElementById('register').style.display='block';
	}
}
function validate_form_pic()
{
	$pics = 0;
	for(i=1;i<=count;i++)
	{
		if (document.getElementById('1_attachments_1').value==null || document.getElementById('1_attachments_1').value=="")
		{ 
		}
		else
		{
			$pics++;
		}
	}
	if($pics == 0)
	{
		document.getElementById("error_pic").innerHTML="Trebuie sa introduci cel putin o poza!"; 
		return false;
	}
	return true;
}

function popup_idee()
{
	window.open('/trimite-idee', '_blank', 'height=700,width=550,resizable=yes,scrollbars=yes');
}
function popup_question()
{
	window.open('/trimite-intrebare', '_blank', 'height=450,width=550,resizable=yes,scrollbars=yes');
}