function setCookie (name, value, expireDays, path, domain, secure) {	var today = new Date();
	var expire = new Date();
	if (expireDays==null || expireDays==0) expireDays=1;
	expire.setTime(today.getTime() + 3600000*24*expireDays);
	var expires=expire.toGMTString();

      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}


function addsmile(SmileCode){
        document.film_comment.comment.value += ' '+ SmileCode + ' ';
}
function add_smilie(scode, smid){
        surl = document.getElementById(smid).src;
        opener.emoticon( scode, '', surl );
}

function vote_film (film_id, vote, user_id, user_ip){    $.get('/_ajax.php', {'mode': 'vote_film', 'film_id': film_id, 'voting': vote, 'user_id': user_id, 'user_ip': user_ip}, function(data) {    	if (data == 'error') {
            alert('ошибка');
        }else if (data == 'already voted') {
            alert('Вы уже голосовали за этот фильм');
        }else if (data == 'need register') {
            alert('Для голосования нужно зарегистрироваться');
        }else if (data == 'done') {
            alert('Ваш голос принят. Большое спасибо.');
        }    });
    return false;
}

function vote_film2 (film_id, vote, user_ip){
    $.get('/_ajax.php', {'mode': 'vote_film2', 'film_id': film_id, 'voting': vote, 'user_ip': user_ip}, function(data) {
    	if (data == 'error') {
            alert('ошибка');
        }else if (data == 'already voted') {
            alert('Вы уже голосовали за этот фильм');
        }else if (data == 'done') {
            alert('Ваш голос принят. Большое спасибо.');
        }
    });
    return false;
}

function vote_actor (actor_id, vote, user_id, user_ip){
    $.get('/_ajax.php', {'mode': 'vote_actor', 'actor_id': actor_id, 'voting': vote, 'user_id': user_id, 'user_ip': user_ip}, function(data) {
    	if (data == 'error') {
            alert('ошибка');
        }else if (data == 'already voted') {
            alert('Вы уже голосовали');
        }else if (data == 'need register') {
            alert('Для голосования нужно зарегистрироваться');
        }else if (data == 'done') {
            alert('Ваш голос принят. Большое спасибо.');
        }
    });
    return false;
}

function vote_actor2 (actor_id, vote, user_ip){
    $.get('/_ajax.php', {'mode': 'vote_actor2', 'actor_id': actor_id, 'voting': vote, 'user_ip': user_ip}, function(data) {
    	if (data == 'error') {
            alert('ошибка');
        }else if (data == 'already voted') {
            alert('Вы уже голосовали');
        }else if (data == 'done') {
            alert('Ваш голос принят. Большое спасибо.');
        }
    });
    return false;
}

function SendComment(filmid, userid){
	var user_comment=document.getElementById('add_comment').value;
	var film_id=document.getElementById('film_id').value;
	var user_email=document.getElementById('user_email').value;
	var user_ip=document.getElementById('user_ip').value;
	var user_nickname=document.getElementById('user_nickname').value;
	var film_rating=document.getElementById('film_rating').value;

	if (user_comment==''){
		alert('Пустой комментарий');
	}else{
	    $.post('/add_comments.php', {'mode': "ajax", 'film_id': filmid, 'user_id': userid, 'comment': user_comment}, function(data) {
	    	if (data == 'error') {
	            return_mess = 'Ошибка';
	        }else if (data == 'no_comment') {
	        	return_mess = 'Пустой комментарий';
	        }else if (data == 'done') {
	        	return_mess = "<font color='green'>Отзыв добавлен. Большое спасибо</font>";
	        }
	        document.getElementById('div_'+filmid).innerHTML = return_mess;
	    });
    }
    return false;
}

function SendComment2(id){
	var user_id=document.getElementById('user_id').value;
	var user_ip=document.getElementById('user_ip').value;
	var user_nickname=document.getElementById('user_nickname').value;
	var comment=document.getElementById('add_comment').value;
	var film_id=document.getElementById('film_id').value;
	var film_rating=$("select[id*='film_rating']").find(':selected').val();

	if (comment==''){
		alert('Пустой комментарий');
	}else{
	    $.post('/_ajax.php', {'mode': "film_comment", 'film_id': film_id, 'film_rating': film_rating, 'user_id': user_id, 'user_ip': user_ip, 'user_nickname': user_nickname, 'comment': comment}, function(data) {
	    	if (data == 'error') {
	            return_mess = 'Ошибка';
	        }else if (data == 'no_comment') {
	        	return_mess = 'Пустой комментарий';
	        }else if (data == 'done') {
	        	return_mess = "<font color='green'>Отзыв добавлен. Большое спасибо</font>";
	        }
	        document.getElementById('div_'+id).innerHTML = return_mess;
	    });
    }
    return false;
}




function show_all_subcategories (show){	setCookie ('show_all_subcategories', '1', '365', '/', '.pornokino.ru');

    $.get('/_ajax.php', {mode: 'show_all_categories', show: show}, function(data) {    	$("#all_categories").html(data);
    });
    return false;
}

/* Click screen */
function cl_screen(id){
	$.get('/_ajax.php', {mode: "click_screen", id: id}, function(data) {});
    return false;
}

/* Click Pornstar photo */
function cl_star(id){
	$.get('/_ajax.php', {mode: "click_star", id: id}, function(data) {});
    return false;
}

/* go to Intimshop */
function open_sexshop(){
	window.open('http://intimshop.ru/?partner=5773','','fullscreen=1, location=1, menubar=1, resizable=1, scrollbars=1, status=1, titlebar=1, toolbar=1');
}

/* mark_translate */
function mark_translate(film_id){
	$.get('/_ajax.php', {"mode": "mark_translate", "film_id": film_id}, function(data) {});
	document.getElementById('metka_'+film_id).innerHTML = 'ok';
    return false;
}
