jQuery(document).ready(function(){
    jQuery('#article_img_container').click(function(){
        open_aawindow();
    });

    /*
    jQuery(this).keyup(function(e) {
        if (e.keyCode == 27) {
            close_aawindow();
        }
    });

    jQuery('#AAFLVPlayer').keyup(function(e) {
        if (e.keyCode == 27) {
            close_aawindow();
        }
    });
    */
});

function create_aa_lightwindow(id, width, height, title)
{
    var str_window = '';
    str_window += '<div id="BGImageTransparent" class="BGImageTransparent"></div>';
    str_window += '<div id="AALightWindow" class="AALightWindow">';
    str_window += '<div class="AALightWindow_container" style="width:'+ width +'px; height:'+ height + 'px;">'; 
    str_window += '<div class="v_p" id="' + id + '">';
    str_window += '</div>';
    str_window += '<div class="AALightWindow_topbar" style="width:'+ width +'px">';
    str_window += '<table border="0" cellpadding="0" cellspacing="0"><tr>';

    str_window += '<td width="auto"><h3 id="AALightWindow_title">' + title + '</h3></td>';
	str_window += '<td class="closeBtnContainer"><a class="AALightWindow_close_button" onclick="close_aawindow();">&nbsp;</a></td>';
    str_window += '</tr></table>';
    str_window += '</div>';
    
    str_window += '</div>';
    str_window += '</div>';
    str_window += '</div>';
    
    document.write(str_window);
}
/*
function create_aa_lightwindow_en(id, width, height, title)
{
    var str_window = '';
    str_window += '<div id="BGImageTransparent" class="BGImageTransparent"></div>';
    str_window += '<div id="AALightWindow" class="AALightWindow">';
    str_window += '<div class="AALightWindow_container" style="width:'+ width +'px; height:'+ height + 'px;">';
    str_window += '<div class="v_p" id="' + id + '">';
    str_window += '</div>';
    str_window += '<div class="AALightWindow_topbar" style="width:'+ width +'px">';
    str_window += '<table border="0" cellpadding="0" cellspacing="0"><tr>';
    str_window += '<td width="auto" style="text-align:left;"><h3 id="AALightWindow_title_en" style="direction:ltr;text-align:left;">' + title + '</h3></td>';
    str_window += '<td width="66"><div class="AALightWindow_close_button_en" onclick="close_aawindow();">&nbsp;</div></td>';
    str_window += '</tr></table>';
    str_window += '</div>';

    str_window += '</div>';
    str_window += '</div>';
    str_window += '</div>';

    document.write(str_window);
}
*/

function close_aawindow(){
    close_window_effects();
    stopVideoPlayer();
}


function open_aawindow() {
	    open_window_effects();
	   buildPlayer();
	}

function open_video(title,path,image) {
	
		firstTime = true; 
$('#AALightWindow_title').html(title);
    open_window_effects();
   
    
    options = {prerollAdTag:'http://ad.sa.doubleclick.net/pfadx/AlArabiyaNet/ar_vod;sz=580x435;ord='+ord+'?'};
	   loadVideo('flvPlayerContainer', path, image,options);
	   buildPlayer();
}

function open_window_effects() {
    jQuery('#AALightWindow').show();
}

function close_window_effects() {
    jQuery('#AALightWindow').hide();
}
