var insertPhotoDialog=null;
var insertVideoDialog=null;
function insertPhoto(profileId){
        var baseurl='wafform.aspx?AJAX=1&_act=focus_picturealbums&Profile='+profileId;

        new Ajax.Updater('visiblejsdiv', baseurl, { evalScripts: true }); return false;
}

function insertVideo(profileId, page){
    if(typeof page=='undefined') page=0;
    var baseurl='wafform.aspx?AJAX=1&_act=focus_videos&Profile='+profileId+'&_lfv='+page;
    new Ajax.Updater('visiblejsdiv', baseurl, { evalScripts: true }); return false;
}

function loadAlbumPhotos(albumId){
    
    var baseurl='wafform.aspx?AJAX=1&_act=focus_picturealbum&_pky='+albumId;
    new Ajax.Updater('dialog-content',baseurl);    

    
}

function blogSrcPhoto(photoId, photoSrc) {
   
    tinyMCE.activeEditor.dom.add(tinyMCE.activeEditor.getBody(),
                                 'img',
                                 {
                                    'src': photoSrc,
                                    'width': 708
                                });
    $('login_overlay').hide();
    
}


function blogSrcVideo(videoEmbedCode, thumbSrc) {

     tinyMCE.activeEditor.setContent(videoEmbedCode);
     $('login_overlay').hide();
}

function blogSrcVideo2(videoEmbedCode, thumbSrc){
    $('video_code').innerHTML=videoEmbedCode;
    var width=640;
    var height=360;
    
    /*
      <img width="100" height="100" align="" title="src:'http://www.youtube.com/v/IV14sMB8qH0&rel=1',width:'100',height:'100'" class="mceItemFlash" mce_src="file://localhost/Users/oliviermoratin/Documents/Projects/Flavorus/tiny_mce/plugins/media/img/trans.gif" src="file://localhost/Users/oliviermoratin/Documents/Projects/Flavorus/tiny_mce/plugins/media/img/trans.gif"/>
    */
    var embeds=$$('#video_code EMBED');
    if(embeds.length==0) return false;
    var videoUrl=embeds[0].readAttribute('src');

    tinyMCE.activeEditor.dom.add(tinyMCE.activeEditor.getBody(),
                                 'img',
                                 {
                                    //'src': 'src="/waf/js/tiny_mce/plugins/media/img/trans.gif"',
                                    'src': thumbSrc,
                                    'height': height,
                                    'width': width,
                                    'title': "src:'"+videoUrl+"',width:'"+width+"',height:'"+height+"'",
                                    'class':"mceItemFlash",
                                    //'mce_src':'/waf/js/tiny_mce/plugins/media/img/trans.gif'
                                    'mce_src': thumbSrc
                                });
      $('login_overlay').hide();
}

function blogInsertLink(linkurl, targettype, title) {

    (/(http|https):\/\/.+/.test(linkurl)) ? '' : linkurl = 'http://' + linkurl;

    tinyMCE.activeEditor.dom.add(tinyMCE.activeEditor.getBody(),
                                 'a',
                                 {
                                     'href': linkurl,
                                     'target': targettype
                                 }, title);
    tinyMCE.activeEditor.dom.add(tinyMCE.activeEditor.getBody(),
                                 'br');
}

function openLink() {
    new Ajax.Updater('visiblejsdiv', 'wafform.aspx?AJAX=1&_act=openlinkdialog', { evalScripts: true }); return false;
}


