<%@ Page Language="C#" Inherits="Ycbw.Data.OleDbClient" %>

<script language="c#" runat="server">
private void Page_Load(object sender, EventArgs e)
{
	string script = "";
	
	script += "var focus_width  = "+ Request.QueryString["v1"] +";";
	script += "var focus_height = "+ Request.QueryString["v2"] +";";
	script += @"
		var text_height  = 20;
		var swf_height   = focus_height + text_height;
		var pics  = '';
		var links = '';
		var texts = '';
		var border_color='#ffffff';
		var round_corner=0;";
	
	string sql = "Select top 6 * from [v_articles] where picture like '%jpg'";
	
	if( Request.QueryString["id"] != null && Request.QueryString["id"] != "" )
	{
		int cid = Int32.Parse(Request.QueryString["id"]);

		sql += " and (cid = "+ cid +" or cid in (select id from [b_article_categories] where parent = "+ cid +"))";
	}
		
	this.Fill( sql + " order by state desc, addtime desc", "data_focus" );
	
	foreach(System.Data.DataRow dr in this.Data.Tables[0].Rows )
	{
		script += "pics  += '"+ dr["picture"].ToString() +"|';";
		script += "links += '../"+ dr["file"].ToString() +"-"+ dr["id"].ToString() +".aspx|';";
		script += "texts += '"+ dr["title"].ToString().Replace(" ","กก") +"|';";
	}
	
	script += @"
		pics = pics.substring(0,pics.length-1);
		links = links.substring(0,links.length-1);
		texts = texts.substring(0,texts.length-1);
		
		document.write('<div class=flashmoviebyGuo>');
		document.write('<style>.flashmoviebyGuo span{font:normal 0px/0px Arial;color:'+border_color+';background:'+border_color+';display:block;position:absolute;over-flow:hidden}</style>');
		document.write('<span style=height:1px;width:'+focus_width+'px>&nbsp;</span><span style=height:'+swf_height+'px;width:1px;margin-left:'+(focus_width-1)+'px>&nbsp;</span><span style=height:1px;width:'+focus_width+'px;margin-top:'+(swf_height-1)+'px>&nbsp;</span><span style=height:'+swf_height+'px;width:1px;>&nbsp;</span>');

		if(round_corner==1)
		{
			document.write('<span style=height:2px;width:3px>&nbsp;</span><span style=height:2px;width:3px;margin-left:'+(focus_width-3)+'px>&nbsp;</span><span style=height:2px;width:3px;margin-top:'+(swf_height-2)+'px>&nbsp;</span><span style=height:2px;width:3px;margin-left:'+(focus_width-3)+'px;margin-top:'+(swf_height-2)+'px>&nbsp;</span><span style=height:3px;width:2px>&nbsp;</span><span style=height:3px;width:2px;margin-left:'+(focus_width-2)+'px>&nbsp;</span><span style=height:3px;width:2px;margin-top:'+(swf_height-3)+'px>&nbsp;</span><span style=height:3px;width:2px;margin-left:'+(focus_width-2)+'px;margin-top:'+(swf_height-3)+'px>&nbsp;</span> ');
		}

		document.write('<object ID=focus_flash classid=clsid:d27cdb6e-ae6d-11cf-96b8-444553540000 codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0 width='+ focus_width +' height='+ swf_height +'>');
		document.write('<param name=allowScriptAccess value=sameDomain><param name=movie value=/images/focus.swf><param name=quality value=high><param name=bgcolor value=#ffffff>');
		document.write('<param name=menu value=false><param name=wmode value=opaque>');
		document.write('<param name=FlashVars value=pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'>');
		document.write('<embed ID=focus_flash src=/images/focus.swf wmode=opaque FlashVars=pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+' menu=false bgcolor=#FFFFFF quality=high width='+ focus_width +' height='+ swf_height +' allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer/>');
		document.write('</object></div>');
		";
	
	Response.Write( script );
}
</script>