function DoSearch ( type ) {
var searchTerm = document.getElementById ( 'SearchBox' ).value;
var searchType = $( '#search_type' ).val ();
if ( searchType == '') {
searchType = 'search_videos';
}
var targetURL = '';
if ( searchType === 'search_videos' ) {
targetURL = 'http://www.mojnet.com/tag/';
} else if ( searchType === 'search_blogs' ) {
targetURL = 'http://www.mojnet.com/tag/blogovi/';
} else if ( searchType === 'search_fotos' ) {
targetURL = 'http://www.mojnet.com/tag/slike/';
} else if ( searchType === 'search_albums' ) {
targetURL = 'http://www.mojnet.com/tag/albumi/';
} else if ( searchType === 'search_users' ) {
targetURL = 'http://www.mojnet.com/tag/korisnik/';
} else if ( searchType === 'search_games' ) {
targetURL = 'http://www.mojnet.com/tag/igre/';
}
if ( searchType === 'search_users' ) {
targetURL += searchTerm;
} else {
targetURL += searchTerm + '/';
}
if ( $( 'input[name=search_mode]:checked' ).val () != null ) {
if ( searchType !== 'search_users' ) {
var sort = $( '#search_sort' ).val ();
if ( sort == '' ) {
if ( searchType === 'search_albums' ) {
targetURL += "po-nazivu";
} else {
targetURL += "po-datumu";
}
} else {
targetURL += sort;
}
}
targetURL += '/' + $( 'input[name=search_mode]:checked' ).val ();
}
window.location = targetURL;
return false;
}
function MvGetMessage ( scriptName, params, msgDivID ) {
HideErrorMsg ( msgDivID );
MvGet (
scriptName,
params,
function ( response ) {
// 0_ -> error, 1_ -> msg
var isError = ( response.substr ( 0, 1 ) == '0' ) ? true : false;
ShowErrorMsg ( response.substr ( 2 ), isError, msgDivID );
}
);
}
function MvPostMessage ( scriptName, params, msgDivID ) {
HideErrorMsg ( msgDivID );
MvPost (
scriptName,
params,
function ( response ) {
// 0_ -> error, 1_ -> msg
var isError = ( response.substr ( 0, 1 ) == '0' ) ? true : false;
ShowErrorMsg ( response.substr ( 2 ), isError, msgDivID );
}
);
}
function HideErrorMsg ( targetID ) {
var msgDiv = $( '#' + targetID );
msgDiv.hide ( 0 );
msgDiv.removeClass ( 'AjaxError' );
msgDiv.removeClass ( 'AjaxMessage' );
}
function ShowErrorMsg ( text, isError, targetID ) {
var msgDiv = $( '#' + targetID );
msgDiv.html ( text );
if ( isError == false ) {
msgDiv.addClass ( 'AjaxMessage' );
} else {
msgDiv.addClass ( 'AjaxError' );
}
msgDiv.show ( 'slow' );
}
function MvGet ( scriptName, params, callback ) {
scriptName = baseUrl + 'ajax/' + scriptName;
$.get ( scriptName, params, callback );
}
function MvPost ( scriptName, params, callback ) {
scriptName = baseUrl + 'ajax/' + scriptName;
$.post ( scriptName, params, callback );
}
function OpenHelp ( helpKey, location, e ) {
$( '#HelpDivContainer' ).hide ();
var posx = 0;
var posy = 0;
if ( !e ) {
var e = window.event;
}
if ( e.pageX || e.pageY ) {
posx = e.pageX;
posy = e.pageY;
} else if ( e.clientX || e.clientY ) {
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
MvGet (
'get_help_text.php',
{
helpKey: helpKey
},
function ( content ) {
$( '#HelpDivText' ).html ( content );
if ( location == 'right' ) {
$( '#HelpDivContainer' ).css ( 'left', posx + 'px' );
$( '#HelpArrowImg' ).attr ( 'src', imagesUrl + 'help-right.gif' );
} else if ( location == 'center' ) {
$( '#HelpDivContainer' ).css ( 'left', ( posx - $('#HelpDivContainer').width () / 2 ) + 'px' );
$( '#HelpArrowImg' ).attr ( 'src', imagesUrl + 'help-middle.gif' );
} else { // left
$( '#HelpDivContainer' ).css ( 'left', ( posx - $('#HelpDivContainer').width () ) + 'px' );
$( '#HelpArrowImg' ).attr ( 'src', imagesUrl + 'help-left.gif' );
}
$( '#HelpDivContainer' ).css ( 'top', (posy + 10) + 'px' ).css ( 'z-index', '50' ).fadeIn ( 'slow' );
$( '#HelpDivContainer' ).bgiframe ();
}
);
}
function CloseHelp () {
$( '#HelpDivContainer' ).fadeOut ( 'fast' );
}
var addToUrl = null;
function OpenLoginDiv ( AddToUrl ) {
addToUrl = AddToUrl;
var videoHolder = document.getElementById ( 'VideoHolder' );
if ( videoHolder == null ) {
videoHolder = document.getElementById ( '_iprom_inStream' );
}
if ( videoHolder != null ) {
videoHolder.style.visibility = 'hidden';
}
$('.BlogVideo').css ( 'visibility', 'hidden' );
var loginBoxBg = document.getElementById ( 'loginBoxBg' );
var loginBoxPopUp = document.getElementById ( 'loginBoxPopUp' );
var divOffset = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
loginBoxBg.style.display = 'block';
loginBoxBg.style.top = divOffset + 'px';
loginBoxBg.style.height = (window.innerHeight || document.body.offsetHeight) + 'px';
if ( window.innerWidth ) {
loginBoxBg.style.width = ( window.innerWidth - 16 ) + 'px';
} else {
loginBoxBg.style.width = ( document.body.offsetWidth - 20 ) + 'px';
}
loginBoxBg.style.filter = 'Alpha(Opacity=80)';
loginBoxPopUp.style.display = 'block';
var popUpTop = 0;
if ( window.innerHeight ) {
popUpTop = ( window.innerHeight / 2 ) - ( loginBoxPopUp.offsetHeight / 2 );
} else {
popUpTop = ( document.documentElement.clientHeight / 2 ) - ( loginBoxPopUp.offsetHeight / 2 );
}
loginBoxPopUp.style.top = ( popUpTop + divOffset ) + 'px';
var popUpLeft = 0;
if ( window.innerWidth ) {
popUpLeft = ( ( window.innerWidth - 16 ) / 2 ) - ( loginBoxPopUp.offsetWidth / 2 );
} else {
popUpLeft = ( ( document.body.offsetWidth - 20 ) / 2 ) - ( loginBoxPopUp.offsetWidth / 2 ) - 5;
}
loginBoxPopUp.style.left = ( popUpLeft) + "px";
document.getElementById ( 'lb_user_name' ).focus ();
}
function CloseLoginDiv () {
var videoHolder = document.getElementById ( 'VideoHolder' );
if ( videoHolder == null ) {
videoHolder = document.getElementById ( '_iprom_inStream' );
}
if ( videoHolder != null ) {
videoHolder.style.visibility = 'visible';
}
$('.BlogVideo').css ( 'visibility', 'visible' );
document.getElementById ( 'loginBoxBg' ).style.display = 'none';
document.getElementById ( 'loginBoxPopUp' ).style.display = 'none';
}
function PerformLogin () {
var userName = document.getElementById ( 'lb_user_name' );
var userPassword = document.getElementById ( 'lb_password' );
var autoLogin = document.getElementById ( 'lb_autologin' );
if ( userName.value == '' || userPassword.value == '' ) {
ShowErrorMsg ( 'Molimo upišite korisničko ime i/ili lozinku.', true, 'LoginErrMsg' );
} else {
var doAutoLogin = '0';
if ( autoLogin.checked == true ) {
doAutoLogin = '1';
}
$('#loginStatusIndicator').html ( '
Prijavljujem' );
MvGet (
'perform_login.php',
{
UserName: userName.value,
Password: userPassword.value,
AutoLogin: doAutoLogin
},
function ( response ) {
if ( response == '1' ) {
if ( addToUrl != null ) {
window.location = window.location + '&action=' + addToUrl;
} else {
window.location.reload ( true );
}
} else {
$( '#loginStatusIndicator' ).hide ();
ShowErrorMsg ( response, true, 'LoginErrMsg' );
}
}
);
}
return false;
}
function addToQuickPlayList ( videoId, onViewVideo ) {
onViewVideo = ( onViewVideo !== undefined && onViewVideo === true ? true : false );
var postData = { VideoId: videoId };
if ( onViewVideo === true ) {
postData.ReturnData = true;
}
MvPost (
'playlist/add_to_quick.php',
postData,
function ( response ) {
$( '#AddToQuickPlayListLink_' + videoId ).hide ();
$( '#RemoveFromQuickPlayListLink_' + videoId ).show ();
var addedOverLay = $( '