﻿function addFlash(m_width,m_height,m_style,m_src,m_flashvars)
{
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width="+m_width+" height="+m_height+" style=\"margin:0px;"+m_style+"\">");
    document.write("<param name='movie' value='"+m_src+"' />");
    document.write("<param name='quality' value='high' />");
    document.write("<param name='menu' value='false' />");
    document.write("<param name='wmode' value='transparent' /> ");
    document.write("<param name='flashvars' value='"+m_flashvars+"' /> ");    
    document.write("</object>");
}

//收藏
function mark(){
	bookmark(window.location,document.title);
}
function bookmark(sURL, sTitle)
{
    try {    
        window.external.AddFavorite(sURL, sTitle);
    }
    catch (e){
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
//设为首页
function setHome(This){
    This.style.behavior='url(#default#homepage)';
    This.setHomePage(window.location);
}


function flashNew(width,height,pics,titles,links){
    //csdn:addFlash(width,height,"background:#000000","/res/pic.swf","pic_width="+width+"&pic_height="+height+"&pics="+pics+"&links="+links+"&texts="+titles+"&show_text=0&txtcolor=000000&bgcolor=666666&button_pos=4&stop_time=3000&border=0");
    if (titles.length > 6) {
        addFlash(width, height, "background:#eeeeee","/content/pixviewer.swf",
            "borderwidth=" + width + "&borderheight=" + (height - 18) + "&pics=" + pics + "&links=" + links + "&texts=" 
            + titles + "&textheight=18&curhref=http://www.sina.com.cn");
    } else {
        addFlash(width, height, "background:#eeeeee", "/content/pixviewer.swf",
            "borderwidth=" + width + "&borderheight=" + height + "&pics=" + pics + "&links=" + links + "&texts=" 
            + titles + "&textheight=0&curhref=http://www.sina.com.cn");
    }
  //pics=&links=&texts=&borderwidth=306&borderheight=169&textheight=0&curhref=
}


//BannerShow
function BannerShow() {
    this.mID = null;
    this.timer = null;
    this.mHtml = "";
    this.Img = new Array();
    this.Title = new Array();
    this.Address = new Array();
    this.index = -1;
    //添加图片
    this.AddImage = function(img, title, address) {
        this.Img[this.Img.length] = img;
        this.Title[this.Title.length] = title;
        this.Address[this.Address.length] = address;
    }
    //开始播放
    this.playNext = function() {

        this.index++;
        if (this.index >= this.Img.length) this.index = 0;
        for (var i = 0; i < this.Img.length; i++) {
            if (i == this.index) {
                document.getElementById(this.mID + "img" + i).filters.blendTrans.apply();
                document.getElementById(this.mID + "img" + i).style.visibility = "visible";
                document.getElementById(this.mID + "img" + i).filters.blendTrans.play();
            } else {
                document.getElementById(this.mID + "img" + i).filters.blendTrans.apply();
                document.getElementById(this.mID + "img" + i).style.visibility = "hidden";
                document.getElementById(this.mID + "img" + i).filters.blendTrans.play();
            }
        }
    }
    //开始构建
    this.create = function(id, width, height) {
        this.mID = id;
        this.mHtml = "<div id='" + id + "' style='width:" + width + "px;height:" + height + "px;position:relative;overflow:hidden;'>";
        for (var i = 0; i < this.Img.length; i++) {
            this.mHtml = this.mHtml + "<a href='" + this.Address[i] + "' title='" + this.Title[i] + "' target='_blank'><img alt='" + this.Title[i] + "' id='" + id + "img" + i + "' src='" + this.Img[i] + "' style='width:100%;height:100%;position:absolute;top:0px;left:0px;margin:0px;FILTER: blendTrans(duration=1);border:0px;"
            if (i != 0) this.mHtml = this.mHtml + "visibility:hidden;"; //将第一个设为可见
            this.mHtml = this.mHtml + "' /></a>";
        }
        this.mHtml = this.mHtml + "</div>";
        document.write(this.mHtml);
    }
    //播放
    this.play = function() {
        if (this.timer == null) {
            var self = this;
            this.timer = setInterval(function() { self.playNext(); }, 5000);
        }
    }
    //停止
    this.stop = function() {
        clearInterval(this.timer);
        this.timer = null;
    }
    //调用构建


}
 

//===================禁止选择网页内容，屏蔽右键==========
//调用方式：<script>DeSelect();</script>
function DeSelect() {
    this.__szft_empty=function() {
        document.selection.empty();
    }
    this.__szft_return_false = function() {
        return false;
    }
	this.__EventsBind=function(){
		try{
			document.body.oncontextmenu = this.__szft_return_false;
			document.body.ondragstart = this.__szft_return_false;
			document.body.onselectstart = this.__szft_return_false;
			document.body.onselect = this.__szft_empty;
			document.body.oncopy = this.__szft_empty;
			document.body.onbeforecopy = this.__szft_return_false;
			document.body.onmouseup = this.__szft_empty;
		}
		catch(e){
			//屏蔽失败
		}
	}
	this.__EventsBind();
}
