﻿function showFlash(src, width, height){ 
	var s = '';//flash phải có width, height
	if(!width || width <= 0)
		width = 100;
	if(!height || height <= 0)
		height = 100;
	if(width > 0)
		s += ' width=" ' + width + '"';
	if(height > 0)
		 s += ' height="' + height + '"';
	document.writeln('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" ' + s + '">');
	document.writeln('<param name="movie" value="' + src + '"/>');
	document.writeln('<param name="quality" value="high"/>');
	document.writeln('<embed src="' + src + '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" ' +
			'type="application/x-shockwave-flash"' + s + '></embed>');
	document.writeln('</object>');
}
function showImage(source,width,height){
	var s = '<img class="img-advR" src="' + source + '"';
	if(width > 0) 
		s += ' width="' + width + '"';
	if(height > 0)
		 s += ' height="' + height + '"';
	s += ' alt=""/>';
	document.write(s);
}
function kiemtraImage(filename){	
	var i = filename.lastIndexOf('.');
	var extention = (filename.substring(i+1,filename.length)).toLowerCase();	
	return extention;
}
function show(source,width,height,heightImg){
    var ext;
    try{
	    ext = kiemtraImage(source);
	    if (ext == 'swf' || ext == 'flv')
		    showFlash (source,width,height);
	    else if ( ext =='gif' || ext =='jpg' || ext == 'jpeg' || ext == 'png' || ext == 'bmp')
		    showImage(source,width,heightImg);
    }catch(ex){}
}
function OpenFile(psUrl) {
    try{
        var lWin, lSW, lSH, lTop = 0, lLeft = 0;
        try{
            lSW = window.screen.width;
            lSH = window.screen.height;
            lTop = (lSH - 400)/ 2;
            lLeft = (lSW - 600)/ 2;
        }catch(e){}
        if((!lLeft) || lLeft <= 0)
            lLeft = 100;
        if((!lTop) || lTop <= 0)
            lTop = 100;
        lWin = window.open("", 'Image', 'width=600,height=400,top=' + lTop + ',left=' + lLeft + ',directories=no,toolbar=no,scrollbars=yes');
        lWin.document.open();
        lWin.document.write('<html><head><title>' + psUrl + '</title></head><body><table style="width:100%;height:100%"><tr><td valign="middle" align="center"><img src="' + psUrl + '" /></td></tr></table></body></html>');
        lWin.document.close();
        lWin.focus();
    }catch(ex){}
}
