jQuery.fn.LoadImage=function(scaling,width,height,loadpic){
    if(loadpic==null)loadpic="/images/loading.gif";
	return this.each(function(){
		var t=$(this);
		var src=$(this).attr("src")
		var img=new Image();
		//alert("Loading...")
		img.src=src;
		var autoScaling=function(){
			if(scaling){
			
				if(img.width>0 && img.height>0){ 
			        if(img.width/img.height>=width/height){ 
			            if(img.width>width){ 
			                t.width(width); 
			                t.height((img.height*width)/img.width); 
			            }else{ 
			                t.width(img.width); 
			                t.height(img.height); 
			            } 
			        } 
			        else{ 
			            if(img.height>height){ 
			                t.height(height); 
			                t.width((img.width*height)/img.height); 
			            }else{ 
			                t.width(img.width); 
			                t.height(img.height); 
			            } 
			        } 
			    } 
			}	
		}
		if(img.complete){
		    //alert("getToCache!");
			autoScaling();
		    return;
		}
		$(this).attr("src","");
		var loading=$("<img alt=\"loading...\" title=\"loading...\" src=\""+loadpic+"\" />");
		
		t.hide();
		t.after(loading);
		$(img).load(function(){
			autoScaling();
			loading.remove();
			t.attr("src",this.src);
			t.show();
			//alert("finally!")
		});
		
	});
}

$(document).ready(function(){
	if($("#ssnews").length){ 
		$("#ssnews").ready(function(){loadrollnews("#ssnews");});
		setInterval('AutoScroll("#rollnews")',3500);
	}
	if ($("#program").length){$("#program").ready(function(){var c = $("#program").attr("channle");loadprogram(c);});}
	if ($("#stype").length)
	{
		$("#stype").change(function(){
			var sv = $("#stype").val();
			switch (sv)
			{
			case "1" : 
				$("#keyword1").css("display","block");
				$("#keyword2").css("display","none");
				$("#keyword3").css("display","none");
				break;
			case "2" :
				$("#keyword1").css("display","none");
				$("#keyword2").css("display","block");
				$("#keyword3").css("display","none");
				break;
			case "3" :
				$("#keyword1").css("display","none");
				$("#keyword2").css("display","none");
				$("#keyword3").css("display","block");
				break;
			default :
				break;
			}
		});
	}
//	if ($("#loginformdiv").length){	$('#loginformdiv').corners();}
});//main

//rolltxt
function AutoScroll(obj){
        $(obj).find("ul:first").animate({
                marginTop:"0px"
        },500,function(){
                $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
        });
}
//
function loadrollnews(obj){
	$.ajax({
	type:"post",
	url:"/include/dynamic/rollnews.asp",
	data:"r=" + Math.random(),
	success:function(msg){
		$(obj).html(msg);
	}
	});
}
function loadprogram(c){
	$.ajax({
	type:"post",
	url:"/include/dynamic/program.asp",
	data:"t=" + c,
	success:function(msg){
		$("#program").html(msg);
	}
	});
}
function getvideo(){
	var tmp = "";
	$.ajax({
		type:"post",
		url: "/include/dynamic/getflvvideo.asp",
		data:"reg=1",
		async:false,
		success:function(msg){
			tmp = msg;
		}
	});
return tmp;
}

function goplayflash(stype,url){
	//seturl(url);
	//flvP();
	if (stype == 1)
	{
	var flashpath = "/flash/flvplayer.swf";
	var w         = 275;
	var h         = 170;
	}else{
	var flashpath = "/flash/sflvplayer.swf";
	var w         = 235;
	var h         = 170;
	}

//	$('#HotVcr').flash(
//		{ src: flashpath + "?f_path=" + url + "&r=" + Math.random(),
//		  width: w,
//		  height: h,
//		  allowFullScreen:true },
//		{ version: 8 }
//	);

var objstr = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" name="subflash" width="' + w + '" height="' + h + '" id="videoflv">';
objstr += '<param name="movie" value="' + flashpath + '?f_path=' + url + '&r=' + Math.random() + '" />';
objstr += '<param name="quality" value="high" />';
objstr += '<param name="wmode" value="transparent" />';
objstr += '<param name="allowFullScreen" value="true" />';
objstr += '<embed src="' + flashpath + '?f_path=' + url + '&r=' + Math.random() + '" width="' + w + '" height="' + h + '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" name="subflash" wmode="transparent"></embed>';
objstr += '</object>';
$('#HotVcr').html(objstr);
}

function showindexprogram(){
	var tmp = "";
	$.ajax({
		type:"post",
		url: "/include/dynamic/index_program.asp",
		data:"",
		async:false,
		success:function(msg){
			tmp = msg;
		}
	});
return tmp;
}