/*
* Summary: File script adapter for sources crawler
* Author: manhlq@gmail.com, http://blog.manhlq.com
* E-Donald Solution for Crawler
*/

/*
 For video 24h.com
*/
function flashWrite(url,w,h,id,bg,vars){
	if(url.indexOf('com.vn/images')<0){
		url =  url.replace('/images','http://www16.24h.com.vn/images');
	}
	if(url.indexOf('com.vn/upload')<0){
		url =  url.replace('/upload','http://www16.24h.com.vn/upload');
	}
	//Added by manhlq@gmail.com, 17/03/2010
	url =  url.replace('http://img16.24h.com.vn/images/player24H2.swf','./common/player24H2.swf');
    var flashStr=
    "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' width='"+w+"' height='"+h+"' id='"+id+"' align='middle'>"+
    "<param name='allowScriptAccess' value='always' />"+
    "<param name='movie' value='"+url+"' />"+
    "<param name='FlashVars' value='"+vars+"' />"+
    "<param name='wmode' value='transparent' />"+
    "<param name='allowScriptAccess' value='sameDomain' />"+
    "<param name='menu' value='false' />"+
    "<param name='quality' value='high' />"+
    "<embed src='"+url+"' allowScriptAccess='sameDomain' FlashVars='"+vars+"' wmode='transparent' menu='false' quality='high' width='"+w+"' height='"+h+"' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"+
    "</object>";
    document.write(flashStr);
};

// 
/*
For Popup images 24h.com
*/

function openNewImage(file, imgText) {
    if (file.lang == 'no-popup') return;
    picfile = new Image();
    picfile.src = (file.src);
    width = picfile.width;
    height = picfile.height;

    if (imgText != '' && height > 0) {
        height += 40;
    }
    else if (height == 0) {
        height = screen.height;
    }
    winDef = 'status=no,resizable=yes,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(height).concat(',').concat('width=').concat(width).concat(',');
    winDef = winDef.concat('top=').concat((screen.height - height) / 2).concat(',');
    winDef = winDef.concat('left=').concat((screen.width - width) / 2);
    newwin = open('', '_blank', winDef);

    newwin.document.writeln('<style>a:visited{color:blue;text-decoration:none}</style>');
    newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
    newwin.document.writeln('<div style="width:100%;height:100%;overflow:auto;"><a style="cursor:pointer" href="javascript:window.close()"><img src="', file.src, '" border=0></a>');
    if (imgText != '') {
        newwin.document.writeln('<div align="center" style="padding-top:5px;font-weight:bold;font-family:arial,Verdana,Tahoma;color:blue">', imgText, '</div></div>');
    }
    newwin.document.writeln('</body>');
    newwin.document.close();
}


$("div.viewfull").ready(function() {
	//19/10/2009, manhlq@gmail.com, Fix video clip vietnamnet.vn
	if($('div.viewfull div.bold a').text() == 'Vietnamnet'){
		$('div.viewfull embed').attr("src","http://vietnamnet.vn/common/v4/player/player.swf");
		$('div.viewfull embed').addClass("video_vnn");
    }
	//24/10/2009, manhlq@gmail.com, Fix video clip autonet.vn
	if ($('div.viewfull div.bold a').text() == 'AutoNet') {
	    var src = $('div.viewfull embed').attr('src');
	    $('div.viewfull embed').attr("src", "http://www.autonet.com.vn" + src);
	    $('div.viewfull embed').addClass("video_autonet");
	}
	//09/12/2009, manhlq@gmail.com, Fix video clip http://www.thethaovanhoa.vn
	if ($('div.viewfull div.bold a').text() == 'TheThaoVanHoa') {
	    var src = $('div.viewfull embed').attr('src');
	    $('div.viewfull embed').attr("src", "http://www.thethaovanhoa.vn" + src);
	    $('div.viewfull embed').addClass("video_ttvh");
	}
	//22/03/2010, manhlq@gmail.com, Fix video clip http://www.thethaovanhoa.vn
	if ($('div.viewfull div.bold a').text() == 'Bee') {
	    var src = $('div.viewfull embed').attr('src');
	    if(src.indexOf('daily')<0){
	        $('div.viewfull embed').attr("src", "http://bee.net.vn" + src);
	        $('div.viewfull embed').addClass("video_bee");
	    }
	}
});
