/* Faq
   Open and close functions
*/
var open_question_div = '';
var open_answer_div = '';

function open_faq(question_div, answer_div){
	if(open_answer_div == answer_div){
		$(question_div).className  = 'faq_question';
		$(answer_div).style.display = 'none';
		open_answer_div = '';
		open_question_div = '';
	}else{
		$(question_div).className = 'faq_question_open';
		$(answer_div).style.display = 'block';

		if(open_answer_div != '' && open_question_div != ''){
			$(open_answer_div).style.display = 'none';
			$(open_question_div).className = 'faq_question';
		}

		open_answer_div = answer_div;
		open_question_div = question_div;
	}
}

/* Send a friend
   Open the send a friend window
*/

function open_send_a_friend(){
	saf = $('send_a_friend');
	Effect.toggle('send_a_friend','slide', {duration: 0.3});
}

function validate_saf(){
	var valid = new Validation('saf_form', {onSubmit:false});
    var result = valid.validate();

    if(result){
    	document.forms['saf_form'].submit();	
    }

}


/*
	Javascript for star rating at photoalbum
*/

function star_rating_vote(vote, update, path)
{
	new Ajax.Updater(update, '/Ajax?module=StarRating&method=vote&vote='+vote+'&path='+path, { method : 'get', asynchronous : true });
}


var clicked = false;

function post_poll_vote(form_pollpath, check_div)
{
	var form = document.forms[form_pollpath];
	var checked_field = false;
	for (i=0; i<form.poll_answers.length; i++) {
		if (form.poll_answers[i].checked) {
			checked_field = form.poll_answers[i].value;
		}
	}
	if(checked_field){
		if(!clicked || clicked == undefined){
			clicked = true;
			new Ajax.Updater('poll_div', '/Ajax?module=Poll&method=Post_Answer&path=' + checked_field, {method: 'get'});
		}
	}else{
		var checkdiv = check_div;
		no_check(checkdiv);
	}
}

function get_results(path)
{
	new Ajax.Updater('poll_div', '/Ajax?module=Poll&method=Show_Results&path='+path,{method: 'get'});
}

function get_poll(path)
{
	new Ajax.Updater('poll_div', '/Ajax?module=Poll&method=Get_Poll&path='+path,{method: 'get'});
}

function no_check(check_div)
{
	$(check_div).style.visibility = 'visible';
	$(check_div).style.display = 'block';
}