/**
 * Creation date :-> 01-02-2009 [dd-mm-yyyy]
 * Last update   :-> 13-05-2009 [dd-mm-yyyy]
 */

function eburza_upload_progress() {
    if(valid.validate()) {
        if($('content_file').value != '') {
            Effect.Fade('content_form', { duration: 1 });
            Effect.Grow('upload_progress');
            eburza_upload_progress_status();
        }
        return true;
    } else {
        return false;
    }
} // end of 'eburza_upload_progress' function

function eburza_upload_progress_status() {
    var objID = 'upload_size';
    var myAjax = new Ajax.Updater({ success: objID }, './uploading.status.php', {
            method: 'get',
            onComplete: setTimeout('eburza_upload_progress_status()', 3000),
            onFailure: eburza_report_error
        }
    );
} // end of 'eburza_upload_progress_status' function

function eburza_preview_thumbs_show(myValue, myFile, myThumb) {
    var myAjax = new Ajax.Updater({ success: 'preview' }, 'include/preview.thumbs.php', {
            method: 'post',
            parameters: 'content=' + myValue,
            onFailure: eburza_report_error
        }
    );

    var iTVplayer = new SWFObject('player.swf','mpl','480','272','9');
    iTVplayer.addParam('allowscriptaccess','always');
    iTVplayer.addParam('allowfullscreen','true');
    iTVplayer.addVariable('enablejs','true');
    
    var embedCode = escape('<embed src="http://'+iTVcmsURL+'/cms/player.swf" width="'+iTVcmsPlayerWidth+'" height="'+iTVcmsPlayerHeight+'" bgcolor="000000" allowfullscreen="true" allowscriptaccess="always" flashvars="file='+myFile+'&image='+myThumb+'&backcolor=000000&frontcolor=57a6e1&lightcolor=FFFFFF&screencolor=000000&controlbar=over&abouttext=iTVcms&aboutlink=http://www.itvcms.com/"></embed>');
    
    iTVplayer.addParam('flashvars','file='+myFile+'&image='+myThumb+'&backcolor=000000&frontcolor=57a6e1&lightcolor=FFFFFF&screencolor=000000&controlbar=over&abouttext=iTVcms&aboutlink=http://www.itvcms.com/&plugins=embed-1&embed.code='+embedCode);
    iTVplayer.write('mediaspace');
    Effect.Appear('player', { duration: 2 });
} // end of 'eburza_preview_thumbs_show' function

function eburza_preview_thumbs_hide() {
    //Effect.Fade('preview', { duration: 1 });
} // end of 'eburza_preview_thumbs_hide' function

function eburza_player_hide() {
    $('preview').innerHTML = '';
    Effect.DropOut('player', { duration: 3 });
} // end of 'eburza_player_hide' function

function eburza_stars_rate(rate, my_id) {
    var objID = 'stars_rate';
    var myAjax = new Ajax.Updater({ success: objID }, 'stars.rate.php', {
            method: 'post',
            parameters: 'id=' + my_id + '&rate=' + rate,
            onFailure: eburza_report_error
        }
    );
} // end of the 'eburza_stars_rate()' function

function eburza_recommendations(rate, my_id) {
    var objID = 'recommendation';
    var myAjax = new Ajax.Updater({ success: objID }, 'recommendations.php', {
            method: 'post',
            parameters: 'id=' + my_id + '&rate=' + rate,
            onFailure: eburza_report_error
        }
    );
} // end of the 'eburza_recommendations()' function

function eburza_rotate_thumbs(thumb) {
    eval('$(\'thumb_'+thumb+'\').src = thumbs_array_'+thumb+'[thumbs_counter_'+thumb+']; thumbs_timer_'+thumb+'=setTimeout(\'eburza_rotate_thumbs('+thumb+')\', 800); thumbs_counter_'+thumb+'++; if(thumbs_counter_'+thumb+' == thumbs_array_'+thumb+'.length) { thumbs_counter_'+thumb+'=0;}');
} // end of the 'eburza_rotate_thumbs()' function

function eburza_get_file_extension(myValue) { 
    if(myValue.length == 0) return null;
    var dot = myValue.lastIndexOf("."); 
    if(dot == -1) return null; 
    var extension = myValue.substr(dot, myValue.length); 
    return extension; 
} // end of the 'eburza_get_file_extension()' function

function eburza_comments() {
    if(valid.validate()) {
        var objID = 'comments';
        var myAjax = new Ajax.Updater({ success: objID }, '/cms/comments.php', {
                method: 'post',
                parameters: 'id=' + $('comment_content').value + '&name=' + encodeURIComponent($('comment_name').value) + '&comment=' + encodeURIComponent($('comment_text').value) + '&visual=' + encodeURIComponent($('comment_visual').value),
                onFailure: eburza_report_error
            }
        );
        
        $('write_comment').hide();
        $('comment_name').value = '';
        $('comment_text').value = '';
        $('comment_visual').value = '';
        $('img_visual').src = '/cms/visual.php?seal='+eburza_make_visual();
    }
    
    return false;
} // end of the 'eburza_recommendations()' function

function eburza_make_visual() {
  var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
  var pass = "";
  var i = '';
  for(x=0;x<16;x++) {
    i = Math.floor(Math.random() * 62);
    pass += chars.charAt(i);
  }
  return pass;
} // end of the 'eburza_make_visual()' function

function eburza_report_error() {
    alert('The requested URL was not found on this server.');
} // end of the 'eburza_report_error()' function
