﻿// JScript File
$(function(){

$('.auto-submit-star').rating({ 
callback: function(value, link){ 
    $.ajax({
       type: "GET",
       cache: false,
       url: host + "AJ/GetData.aspx?a=ratemovie&s="+ value.split('|')[1] + "&r=" + value.split('|')[0],
       success: function(msg){
         
       }
     });
},
focus: function(value, link){ 
var tip = $('#hover-test'); 
tip[0].data = tip[0].data || tip.html(); 
tip.html(link.title || 'value: '+title); 
}, 
blur: function(value, link){ 
var tip = $('#hover-test'); 
$('#hover-test').html(tip[0].data || ''); 
}  
});

//create links
$("#accordionDetails").accordion({ 
            header: "h3", 
            animated: "bounceslide",
            autoHeight: true,
            icons: {
                 header: "ui-icon-arrow-1-e",
                 headerSelected: "ui-icon-arrow-1-s"
               }
            });
});

function clearMovie()
{
    $("#divMovieDetails").hide();
    $("#divDetailsPlayer").html("");
}

function writeComment(mid)
{
    if(document.getElementById('txtNewTitle').value.length > 0 && document.getElementById('txtNewComment').value.length > 0)
    {
        $('#imgWriteLoading').show("fast");
        $.ajax({
           type: "GET",
           cache: false,
           url: host + "AJ/write.aspx?a=writecomment&m="+ mid + "&t=" + document.getElementById('txtNewTitle').value + "&c=" + document.getElementById('txtNewComment').value,
           success: function(msg){
             $('#imgWriteLoading').hide("slow");
             $("#divWriteComment").html("<div style='padding: 20px; font-weight: bold; font-size: 14px;'>Successfully added your comment. Thanks !!<div>");
             setTimeout('$("#divWriteComment").hide("slow")', 3000);
           }
         });
    }
    else
        alert("Please enter all fields and try again!");
}

function reportBadComment(id)
{
    if(id)
    {
        $.ajax({
           type: "GET",
           cache: false,
           url: host + "AJ/write.aspx?a=reportBadComment&s="+ id,
           success: function(msg){
             $("#div" + id).html(msg);
           }
         });
    }
}