// JavaScript Document

/* 加入收藏夹和设为主页的代码
html代码：
<a href="javascript:void(0);" onclick="addedFavorite()" >收藏</a> 
<a href="javascript:void(0);" onclick="makeHome()">设为首页</a>
*/

var weburl = location.href;
var webname = document.title;

function makeHome() {  // 设置首页 条件版
if (document.all) {
document.body.style.behavior = 'url(#default#homepage)';
document.body.setHomePage(weburl);
}
else if (window.sidebar) {
if (window.netscape) {
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch (e) {
alert("该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true");
}
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage', weburl);
}
} 

function addedFavorite() {// 加入收藏夹
//捕获异常版
try
{//document.all ie
window.external.addFavorite(weburl, webname);
}
catch (e)
{
try
{ //window.sidebar ff
window.sidebar.addPanel(webname, weburl, "");
}
catch (e)
{
alert("加入收藏失败，请使用Ctrl+D进行添加");
}
}
}

// JavaScript Document
/*
/网站制作/zhaodidong/焦点广告/demo17-图片轮转/
<div class="flash" id="flash"></div>
<script type="text/javascript">
div = "flash";
width= 300;
height= 100;
textheight = 0;
flash(div, width, height, textheight,src);
</script>
 */
function flash(div, width, height, textheight,src) {
    var swfvalue = "images/focus/focus1.swf";
    var focus_width = width;
    var focus_height = height;
    var text_height = textheight;
    var swf_height = focus_height + text_height;
    var pics = src;
	//var pics = 'images/01.jpg|images/02.jpg|images/03.jpg|images/04.jpg';
    var links = '链接1|链接2|链接3|链接3';
    var texts = '显示文字1|显示文字2|显示文字3';
    var flashstr = "";
    flashstr = flashstr + '<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="' + focus_width + '" height="' + swf_height + '">';
    flashstr = flashstr + '<param name="allowScriptAccess" value        ="sameDomain"><param name="movie" value="' + swfvalue + '"><param name=        "quality" value="high"><param name="bgcolor" value="#DADADA">';
    flashstr = flashstr + '<param name="menu" value="false"><param name=wmode        value="opaque">';
    flashstr = flashstr + '<param name="FlashVars" value=        "pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '">';
    flashstr = flashstr + '<embed src="' + swfvalue + '" wmode="opaque"        FlashVars=        "pics=' + pics + '&links=' + links + '&texts=' + texts + '&borderwidth=' + focus_width + '&borderheight=' + focus_height + '&textheight=' + text_height + '" menu="false" bgcolor="#DADADA" quality="high" width="' + focus_width + '" height="' + swf_height + '" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer%22/%3E';
    flashstr = flashstr + '</object>';
    document.getElementById(div).innerHTML = flashstr;
}


// JavaScript Document

function Marquee(direction,speed,id,id1,id2){	
  i=direction;
  var speed=speed
  var demo = document.getElementById(id);
  var demo1 = document.getElementById(id1);
  var demo2 = document.getElementById(id2);
  switch(i){
  case 1:
  MarqueeToTop(speed,demo,demo1,demo2);
  break;
  case 2:
  MarqueeToDown(speed,demo,demo1,demo2); 
  break;
  case 3: 
  MarqueeToLeft(speed,demo,demo1,demo2); 
  break;
  case 4:
  MarqueeToRight(speed,demo,demo1,demo2); 
  break;
  }
}

function MarqueeToTop(speed,demo,demo1,demo2){
//var speed=speed
//  var demo = document.getElementById(id);
//  var demo1 = document.getElementById(id1);
//  var demo2 = document.getElementById(id2);
var MyMarTop=setInterval(MarqueeTop,speed)
demo2.innerHTML=demo1.innerHTML
//原理是不断的向demoh2中填入demoh1中的内容，然后将已经看不见的清除
//用一个两行一列的表格，上一列再放一个装填有内容的表格，定义为demoh1，下一列是空的TD，定义为demoh2
//SPEED是用来控制速度的。
demo.onmouseover=function(){ clearInterval(MyMarTop) }
demo.onmouseout=function(){ MyMarTop=setInterval(MarqueeTop,speed) }
function MarqueeTop(){
if(demo2.offsetHeight-demo.scrollTop<=0)
demo.scrollTop-=demo1.offsetHeight
else{
demo.scrollTop++
}
}
}

function MarqueeToDown(speed,demo,demo1,demo2){
demo2.innerHTML=demo1.innerHTML
demo.scrollTop=demo.scrollHeight
var MyMarDown=setInterval(MarqueeDown,speed)
demo.onmouseover=function() {clearInterval(MyMarDown)}
demo.onmouseout=function() {MyMarDown=setInterval(MarqueeDown,speed)}
function MarqueeDown(){
if(demo1.offsetTop-demo.scrollTop>=0)
demo.scrollTop+=demo2.offsetHeight
else{
demo.scrollTop--
}
}
}

function MarqueeToLeft(speed,demo,demo1,demo2){
var MyMarLeft=setInterval(MarqueeLeft,speed)
demo2.innerHTML=demo1.innerHTML
demo.onmouseover=function() {clearInterval(MyMarLeft)}
demo.onmouseout=function() {MyMarLeft=setInterval(MarqueeLeft,speed)}
function MarqueeLeft(){
if(demo2.offsetWidth-demo.scrollLeft<=0)
demo.scrollLeft-=demo1.offsetWidth
else{
demo.scrollLeft++
}
}
}

function MarqueeToRight(speed,demo,demo1,demo2){
var MyMarRight=setInterval(MarqueeRight,speed)
demo2.innerHTML=demo1.innerHTML
demo.onmouseover=function() {clearInterval(MyMarRight)} 
demo.onmouseout=function() {MyMarRight=setInterval(MarqueeRight,speed)}
function MarqueeRight(){ 
if(demo.scrollLeft<=0) 
demo.scrollLeft+=demo2.offsetWidth 
else{ 
demo.scrollLeft-- 
} 
} 
}
function ejiaA1(o,a,b,c,d){
var t=document.getElementById(o).getElementsByTagName("tr");
for(var i=1;i<t.length;i++){
t[i].style.backgroundColor=(t[i].sectionRowIndex%2==0)?a:b;
t[i].onclick=function(){
if(this.x!="1"){
this.x="1";//本来打算直接用背景色判断，FF获取到的背景是RGB值，不好判断
this.style.backgroundColor=d;
}else{
this.x="0";
this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
}
}
t[i].onmouseover=function(){
if(this.x!="1")this.style.backgroundColor=c;
}
t[i].onmouseout=function(){
if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
}
}
}

 
function displaySubMenu(li) {
	var subMenu = li.getElementsByTagName("ul")[0];
	subMenu.style.display = "block";
}
function hideSubMenu(li) {
	var subMenu = li.getElementsByTagName("ul")[0];
	subMenu.style.display = "none";
}
<!--
//图片按比例缩放
var flag=false;
function DrawImage(ImgD,iwidth,iheight){
    //参数(图片,允许的宽度,允许的高度)
    var image=new Image();
    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
    flag=true;
    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;
        }
        ImgD.alt=image.width+"×"+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;
        }
        ImgD.alt=image.width+"×"+image.height;
        }
    }
}
//-->
