﻿function select_title(strObj,strList)
{
    if(strList!="")
    {
        arrList = strList.split('_');
        for(i=0;i<arrList.length;i++)
        {
            $("#A_"+arrList[i]).attr("className","");
            $("#Div_"+arrList[i]).css("display","none");
        }
    }
    if(strObj!="")
    {
        $("#A_"+strObj).attr("className","sel");
        $("#Div_"+strObj).css("display","block");
    }
}

window.onload = function(){
    //alert($("div")[0].tagName);
    //alert($("#").attrlength);
}


function switchPlay(Url,P_Width,P_Height)
{
    if(Url.indexOf(".")!=-1)
    {
		var swf_width=P_Width;
		var swf_height=P_Height;
        var exTypeArr=Url.split(".");
        var exType=exTypeArr[exTypeArr.length-1].toLowerCase();
        var sfwString=".swf";
		var flvString=".flv";
        var mpString=".mp3,.mp4,.wmv,.avi,.mpeg,.wma";
        var rmString=".rm3,.rmvb";
        var picString=".jpg,.gif,.png,.bmp";
        if(sfwString.indexOf(exType)!=-1){
            document.writeln("<embed src=\""+Url+"\" width=\""+swf_width+"\" height=\""+swf_height+"\" type=\"application\/x-shockwave-flash\" menu=\"true\" play=\"true\" loop=\"true\"><\/embed>");
        }else if(flvString.indexOf(exType)!=-1){
			
			var texts = '';
			var files = Url;
			var config='0:自动播放|1:连续播放|100:默认音量|0:控制栏位置|2:控制栏显示|0x000033:主体颜色|60:主体透明度|0x66ff00:光晕颜色|0xffffff:图标颜色|0xffffff:文字颜色|:logo文字|:logo地址|:结束swf地址'
			document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='"+ swf_width +"' height='"+ swf_height +"'>");
			document.write("<param name='movie' value='vcastr2.swf'><param name='quality' value='high'>");
			document.write("<param name='menu' value='false'><param name='wmode' value='opaque'><param name='allowFullScreen' value='true' />");
			document.write("<param name='FlashVars' value='vcastr_file="+files+"&vcastr_title="+texts+"&vcastr_config="+config+"'>");
			document.write("<embed src='vcastr2.swf' wmode='opaque' FlashVars='vcastr_file="+files+"&vcastr_title="+texts+"&vcastr_config="+config+"' menu='false' quality='high' width='"+ swf_width +"' height='"+ swf_height +"' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"); 
			document.write("</object>");
		}else if(mpString.indexOf(exType)!=-1 || rmString.indexOf(exType)!=-1){
            document.writeln("<embed src=\""+Url+"\" width=\""+swf_width+"\" height=\""+swf_height+"\" type=\"application\/x-mplayer2\" autostart=\"true\" play=\"true\" loop=\"true\" menu=\"true\"><\/embed>");
        }else if(rmString.indexOf(exType)!=-1){
            document.writeln("<embed src=\""+Url+"\" width=\""+swf_width+"\" height=\""+swf_height+"\" type=\"audio\/x-pn-realaudio-plugin\" autostart=\"true\" play=\"true\" loop=\"true\" menu=\"true\"><\/embed>");
        }else if(picString.indexOf(exType)!=-1){
            document.writeln("<img border='0' src='"+Url+"' width=\""+swf_width+"\" height=\""+swf_height+"\">");
        }else{
        	document.writeln("<embed src=\""+Url+"\" width=\""+swf_width+"\" height=\""+swf_height+"\" type=\"application\/x-mplayer2\" autostart=\"true\" play=\"true\" loop=\"true\" menu=\"true\"><\/embed>");    
			
        }
    }
}



function resizeimg(ImgD,iwidth,iheight) {
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
        if(image.width/image.height>= iwidth/iheight){
           if(image.width>iwidth){
               ImgD.width=iwidth;
               ImgD.height=(image.height*iwidth)/image.width;
           }else{
                  ImgD.width=image.width;
                  ImgD.height=image.height;
                }
        }
        else{
                if(image.height>iheight){
                       ImgD.height=iheight;
                       ImgD.width=(image.width*iheight)/image.height;
                }else{
                        ImgD.width=image.width;
                        ImgD.height=image.height;
                     }
            }
    }
}
