var starTimer = null; var starTextEl = null; var starStrings = Array (); starStrings[2] = 'loše'; starStrings[4] = 'prolazno'; starStrings[6] = 'dobro'; starStrings[8] = 'vrlo dobro'; starStrings[10] = 'odlično'; var inStar = Array (); inStar[2] = false; inStar[4] = false; inStar[6] = false; inStar[8] = false; inStar[10] = false; var videoID, rate, ratedBy; function StarMouseMove ( StarNum ) { if ( inStar[StarNum] == true ) { return; } else { inStar[StarNum] = true; } ClearStarTimer (); document.getElementById ( 'star_' + StarNum ).style.cursor = 'pointer'; if ( starTextEl == null ) { starTextEl = document.getElementById ( 'StarsText' ); } starTextEl.innerHTML = starStrings[StarNum]; for ( var i = 2; i <= 10; i += 2 ) { if ( i <= StarNum ) { document.getElementById ( 'star_' + i ).src = imagesUrl + 'star_big.gif'; } else { document.getElementById ( 'star_' + i ).src = imagesUrl + 'blank_star_big.gif'; } } } function StarMouseOut ( StarNum ) { inStar[StarNum] = false; starTimer = setTimeout ( 'GenerateStars ( ' + rate + ', ' + ratedBy + ', true )', 400 ); } function ClearStarTimer () { if ( starTimer ) { clearTimeout ( starTimer ); starTimer = null; } } function SaveVote ( VideoID, Mark ) { ClearStarTimer (); MvPost ( 'save_rate.php', { vid: VideoID, mark: Mark }, function ( Response ) { HideErrorMsg ( 'LinksMsg' ); if ( Response.substring ( 0, 2 ) != '0_' ) { ShowErrorMsg ( Response.substring ( 2 ), false, 'LinksMsg' ); GetStars ( videoID, false ); document.getElementById ( 'StarsStatus' ).innerHTML = 'video ocijenjen
'; } else { ShowErrorMsg ( Response.substring ( 2 ), true, 'LinksMsg' ); } } ); } function GetStars ( VideoID, EnableVote ) { videoID = VideoID; MvGet ( 'get_stars.php', { vid: VideoID }, function ( Response ) { rate = Response.substring ( 0, Response.indexOf ( ';' ) ); ratedBy = Response.substring ( Response.indexOf ( ';' ) + 1 ); GenerateStars ( rate, ratedBy, EnableVote ); } ); } function MakeStar ( StarsHolder, EnableVote, ImgName, Num ) { var newStar = document.createElement ( 'IMG' ); newStar.setAttribute ( 'id', 'star_' + Num ); newStar.setAttribute ( 'src', imagesUrl + ImgName ); if ( EnableVote == true ) { newStar.onclick = new Function ( "SaveVote('" + videoID + "', '" + Num + "');" ); newStar.onmousemove = new Function ( 'StarMouseMove ( "' + Num + '");' ); newStar.onmouseout = new Function ( 'StarMouseOut ( "' + Num + '");' ); } StarsHolder.appendChild ( newStar ); } function GenerateStars ( Rate, Votes, EnableVote ) { var starsHolder = document.getElementById ( 'Stars' ); starsHolder.innerHTML = ''; document.getElementById ( 'StarsText' ).innerHTML = 'ocjena: ' + Votes; ClearStarTimer (); Rate = Rate / 2; var wholeRate = Math.floor ( Rate ); var numOfStars = 0; var starNum = 2; for ( var i = 1; i <= wholeRate; i++ ) { MakeStar ( starsHolder, EnableVote, 'star_big.gif', starNum ); starNum += 2; numOfStars++; } var tmpRate = Rate + ''; var decimalRate = 0; if ( tmpRate.indexOf ( '.' ) > -1 ) { decimalRate = tmpRate.substring ( tmpRate.indexOf ( '.' ) + 1 ); decimalRate = '0.' + decimalRate; decimalRate = 1 * decimalRate; } if ( decimalRate > 0.25 && decimalRate <= 0.75 ) { MakeStar ( starsHolder, EnableVote, 'half_star_big.gif', starNum ); starNum += 2; numOfStars++; } else if ( decimalRate > 0.75 ) { MakeStar ( starsHolder, EnableVote, 'star_big.gif', starNum ); starNum += 2; numOfStars++; } else { if ( numOfStars < 5 ) { MakeStar ( starsHolder, EnableVote, 'blank_star_big.gif', starNum ); starNum += 2; numOfStars++; } } for ( var i = numOfStars; i < 5; i++ ) { MakeStar ( starsHolder, EnableVote, 'blank_star_big.gif', starNum ); starNum += 2; } } function SendPriporoci ( VideoID ) { HideErrorMsg ( 'LinksMsg' ); var email = $('#PriporociText').val (); var msg = $('#PriporociMsg').val (); if ( $.trim ( email ) == '' ) { ShowErrorMsg ( 'upišite e-mail ili korisničko ime', true, 'LinksMsg' ); } else { MvGet ( 'video_recommend.php', { vid: VideoID, email: email, msg: msg }, function ( Response ) { var isError = (Response.substr ( 0, 1 ) == '0' ) ? true : false; if ( isError == true ) ShowErrorMsg ( Response.substr ( 2 ), true, 'LinksMsg' ); else { $('#Priporoci').fadeOut('slow'); ShowErrorMsg ( Response.substr ( 2 ), false, 'LinksMsg' ); } } ); } } function SendPriporociAll ( VideoID ) { HideErrorMsg ( 'LinksMsg' ); var email = $('#PriporociTextAll').val (); var msg = $('#PriporociMsgAll').val (); var yourName = $('#PriporociYourName').val (); var yourEmail = $('#PriporociYourEmail').val (); if ( $.trim ( email ) == '' ) { ShowErrorMsg ( 'upišite e-mail primatelja', true, 'LinksMsg' ); } else if ( $.trim ( yourName ) == '' || $.trim ( yourEmail ) == '' ) { ShowErrorMsg ( 'Upišite vaše ime i e-mail', true, 'LinksMsg' ); } else { MvGet ( 'video_recommend_all.php', { vid: VideoID, email: email, msg: msg, yourName: yourName, yourEmail: yourEmail }, function ( Response ) { var isError = (Response.substr ( 0, 1 ) == '0' ) ? true : false; if ( isError == true ) ShowErrorMsg ( Response.substr ( 2 ), true, 'LinksMsg' ); else { $('#PriporociAll').fadeOut('slow'); ShowErrorMsg ( Response.substr ( 2 ), false, 'LinksMsg' ); } } ); } } function ReportAdult ( VideoID ) { $('#MarkAs').fadeOut('slow'); MvGetMessage ( 'report_adult.php', { vid: VideoID, Msg: $('#AdultReason').val () }, 'LinksMsg' ); } function ReportNeprimeren ( VideoID ) { $('#MarkAs').fadeOut('slow'); MvGetMessage ( 'report_neprimeren.php', { vid: VideoID, Msg: $('#NeprimerenReason').val () }, 'LinksMsg' ); } function ReportDuplicate ( videoId ) { HideErrorMsg ( 'LinksMsg' ); var originalUrl = $('#DuplicateUrl').val (); if ( originalUrl == '' ) { ShowErrorMsg ( 'upišite URL originalnog videa', true, 'LinksMsg' ); } else { MvGet ( 'view_video/report_duplicate.php', { vid: videoId, url: originalUrl }, function ( response ) { var isError = (response.substr ( 0, 1 ) == '0' ) ? true : false; if ( isError == true ) { ShowErrorMsg ( response.substr ( 2 ), true, 'LinksMsg' ); } else { $('#MarkAs').fadeOut ( 'slow' ); ShowErrorMsg ( response.substr ( 2 ), false, 'LinksMsg' ); } } ); } } function ViewVideoGetMessage ( scriptName, videoID ) { MvGetMessage ( scriptName, { vid: videoID }, 'LinksMsg' ); } function OpenReportAs ( which ) { if ( which == 'Neprimeren' ) { $('#MarkAsLinkNeprimeren').addClass ( 'MarkAsActive' ); $('#MarkAsLinkZaOdrasle').removeClass ( 'MarkAsActive' ); $('#MarkAsLinkReportDuplicate').removeClass ( 'MarkAsActive' ); $('#Neprimeren').fadeIn ( 'slow' ); $('#ZaOdrasle').hide (); $('#ReportDuplicate').hide (); } else if ( which == 'ZaOdrasle' ) { $('#MarkAsLinkZaOdrasle').addClass ( 'MarkAsActive' ); $('#MarkAsLinkNeprimeren').removeClass ( 'MarkAsActive' ); $('#MarkAsLinkReportDuplicate').removeClass ( 'MarkAsActive' ); $('#ZaOdrasle').fadeIn ( 'slow' ); $('#Neprimeren').hide (); $('#ReportDuplicate').hide (); } else { $('#MarkAsLinkReportDuplicate').addClass ( 'MarkAsActive' ); $('#MarkAsLinkNeprimeren').removeClass ( 'MarkAsActive' ); $('#MarkAsLinkZaOdrasle').removeClass ( 'MarkAsActive' ); $('#ReportDuplicate').fadeIn ( 'slow' ); $('#Neprimeren').hide (); $('#ZaOdrasle').hide (); } } function AddToFaceBook ( url ) { OpenWindow ( 'http://www.facebook.com/sharer.php?u=' + url, 620, 440 ); } function AddToTwitter ( url ) { OpenWindow ( 'http://twitter.com/home?status=' + url, 800, 600 ); } function AddToDigg ( url, title ) { OpenWindow ( 'http://digg.com/submit?phase=2&url=' + url + '&title=' + title, 1024, 650 ); } function AddToMySpace ( url, title ) { OpenWindow ( 'http://www.myspace.com/Modules/PostTo/Pages/?t=' + title + '&c=&u=' + url + '&l=2', 900, 500 ); } function OpenWindow ( url, width, height ) { window.open ( url, 'fb_share', 'status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=0,scrollbars=1,height=' + height + ',width=' + width ); } function AddToProfile ( videoId ) { HideErrorMsg ( 'LinksMsg' ); MvGetMessage ( 'settings/add_video_to_profile.php', { vid: videoId }, 'LinksMsg' ); } function addToPlayList ( videoId ) { HideErrorMsg ( 'LinksMsg' ); var playListId = $( "#sbPlayLists option:selected" ).val (); if ( playListId === undefined || playListId === '-1' ) { ShowErrorMsg ( 'nemate spremljenih listi', true, 'LinksMsg' ); } else { MvPost ( 'playlist/add_to_playlist.php', { VideoId: videoId, PlayListId: playListId }, function ( response ) { eval ( 'var response = (' + response + ')' ); if ( response.isError === true ) { ShowErrorMsg ( response.msg, true, 'LinksMsg' ); } else { $( '#AddToPlayList' ).fadeOut ( 'slow' ); ShowErrorMsg ( response.msg, false, 'LinksMsg' ); if ( response.addToList === true ) { addVideoToQuickList ( response.videoData ); } } } ); } } $( document ).ready ( function () { $( '#ShowFullDescriptionLink' ).click ( function () { $( '#ShowShortDescriptionLink' ).show (); $( this ).hide (); $( '#DescriptionShort' ).hide (); $( '#DescriptionFull' ).show (); return false; } ); $( '#ShowShortDescriptionLink' ).click ( function () { $( '#ShowFullDescriptionLink' ).show (); $( this ).hide (); $( '#DescriptionShort' ).show (); $( '#DescriptionFull' ).hide (); return false; } ); } );