﻿// JScript 文件
var $ = function (id) {
    return "string" == typeof id ? document.getElementById(id) : id;
};

var Class = {
  create: function() {
    return function() {
      this.initialize.apply(this, arguments);
    }
  }
}
Object.extend = function(destination, source) {
	for (var property in source) {
		destination[property] = source[property];
	}
	return destination;
}

function addEventHandler(oTarget, sEventType, fnHandler) {
	if (oTarget.addEventListener) {
		oTarget.addEventListener(sEventType, fnHandler, false);
	} else if (oTarget.attachEvent) {
		oTarget.attachEvent("on" + sEventType, fnHandler);
	} else {
		oTarget["on" + sEventType] = fnHandler;
	}
};


var Scroller = Class.create();
Scroller.prototype = {
  initialize: function(idScroller, idScrollMid, options) {
    var oScroll = this, oScroller = $(idScroller), oScrollMid = $(idScrollMid);
	
	this.SetOptions(options);
	this.Scroller = oScroller;	
	this.Speed = this.options.Speed;
	this.timer = null;
	this.Pause = 0;
	
	//用于上下滚动
	this.heightScroller = parseInt(oScroller.style.height) || oScroller.offsetHeight;
	this.heightList = oScrollMid.offsetHeight;
	
	//js取不到css设置的height和width
	
	oScroller.style.overflow = "hidden";
	oScrollMid.appendChild(oScrollMid.cloneNode(true));
	
	//方向设置
	switch (this.options.Side.toLowerCase()) {
		case "right" :
			if(this.widthList <= this.widthScroller) return;
			this.Scroll = this.ScrollLeftRight;
			this.side = -1;
			break;
		case "left" :
			if(this.widthList <= this.widthScroller) return;
			this.Scroll = this.ScrollLeftRight;
			this.side = 1;
			break;
		case "down" :
			if(this.heightList <= this.heightScroller) return;
			this.Scroll = this.ScrollUpDown;
			this.side = -1;
			break;
		case "up" :
		default :
			if(this.heightList <= this.heightScroller) return;
			this.Scroll = this.ScrollUpDown;
			this.side = 1;
	}
	
	addEventHandler(oScroller, "mouseover", function() { oScroll.Stop(); });
	addEventHandler(oScroller, "mouseout", function() { oScroll.Start(); });
	
	this.Start();
  },
  //设置默认属性
  SetOptions: function(options) {
    this.options = {//默认值
	  Step:			1,//每次变化的px量
	  Speed:		20,//速度(越大越慢)
	  Side:			"up",//滚动方向:"up"是上，"down"是下，"left"是左，"right"是右
	  PauseHeight:	0,//隔多高停一次
	  PauseWidth:	0,//隔多宽停一次
	  PauseStep:	5000//停顿时间(PauseHeight或PauseWidth大于0该参数才有效)
    };
    Object.extend(this.options, options || {});
  },  
  //上下滚动
  ScrollUpDown: function() {
	this.Scroller.scrollTop = this.GetScroll(this.Scroller.scrollTop, this.heightScroller, this.heightList, this.options.PauseHeight);
	
	var oScroll = this;
	this.timer = window.setTimeout(function(){ oScroll.Scroll(); }, this.Speed);
  },
  //获取设置滚动数据
  GetScroll: function(iScroll, iScroller, iList, iPause) {
	var oScroll = this, iStep = this.options.Step * this.side;
	
	if(this.side > 0){
		if(iScroll >= (iList * 2 - iScroller)){ iScroll -= iList; }
	} else {
		if(iScroll <= 0){ iScroll += iList; }
	}
	
	this.Speed = this.options.Speed;
	if(iPause > 0){
		if(Math.abs(this.Pause) >= iPause){
			this.Speed = this.options.PauseStep; this.Pause = iStep = 0;
		} else {
			this.Pause += iStep;
		}
	}
	
	return (iScroll + iStep);
  },
  //开始
  Start: function() {
	this.Scroll();
  },
  //停止
  Stop: function() {
	clearTimeout(this.timer);
  }
};

function sroll(){
	new Scroller("idScroller", "idScrollMid",{ Side:"up", PauseHeight:30 });
	tabs();
	
}

/*
EASY TABS 1.2 Produced and Copyright by Koller Juergen
www.kollermedia.at | www.austria-media.at
Need Help? http:/www.kollermedia.at/archive/2007/07/10/easy-tabs-12-now-with-autochange
You can use this Script for private and commercial Projects, but just leave the two credit lines, thank you.
*/

//EASY TABS 1.2 - MENU SETTINGS
//Set the id names of your tablink (without a number at the end)
var tablink_idname = new Array("tablink")
//Set the id name of your tabcontentarea (without a number at the end)
var tabcontent_idname = new Array("tabcontent") 
//Set the number of your tabs
var tabcount = new Array("3")
//Set the Tab wich should load at start (In this Example:Tab 2 visible on load)
var loadtabs = new Array("1")  
//Set the Number of the Menu which should autochange (if you dont't want to have a change menu set it to 0)
var autochangemenu = 1;
//the speed in seconds when the tabs should change
var changespeed = 50;
//should the autochange stop if the user hover over a tab from the autochangemenu? 0=no 1=yes
var stoponhover = 0;
//END MENU SETTINGS

/*Swich EasyTabs Functions - no need to edit something here*/
function easytabs(menunr, active) 
{if (menunr == autochangemenu)
{currenttab=active;}
if ((menunr == autochangemenu)&&(stoponhover==1)) 
{stop_autochange()} 
else if ((menunr == autochangemenu)&&(stoponhover==0))  
{counter=0;}menunr = menunr-1;
for (i=1; i <= tabcount[menunr]; i++)
{document.getElementById(tablink_idname[menunr]+i).className='tab'+i;
document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';}
document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';
document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';}
var timer; counter=0; 
var totaltabs=tabcount[autochangemenu-1];
var currenttab=loadtabs[autochangemenu-1];
function start_autochange()
{counter=counter+1;
timer=setTimeout("start_autochange()",1000);
if (counter == changespeed+1) 
{currenttab++;
if (currenttab>totaltabs) 
{currenttab=1}easytabs(autochangemenu,currenttab);restart_autochange();}}
function restart_autochange()
{clearTimeout(timer);counter=0;start_autochange();}
function stop_autochange()
{clearTimeout(timer);counter=0;}

function tabs(){
var menucount=loadtabs.length; var a = 0; var b = 1; do {easytabs(b, loadtabs[a]);  a++; b++;}while (b<=menucount);
if (autochangemenu!=0){start_autochange();}
}

function showJsAd()
{
alimama_pid="mm_11686374_1397110_3239932"; 
alimama_titlecolor="0000FF"; 
alimama_descolor ="000000"; 
alimama_bgcolor="FFFFFF"; 
alimama_bordercolor="E6E6E6"; 
alimama_linkcolor="008000"; 
alimama_bottomcolor="FFFFFF"; 
alimama_anglesize="0"; 
alimama_bgpic="0"; 
alimama_icon="0"; 
alimama_sizecode="13"; 
alimama_width=265; 
alimama_height=85; 
alimama_type=2; 
}


function FlashNew(PicPath,PicLink)
	{
	var focus_width=330;
	var focus_height=250;
	var text_height=0;
	var swf_height = focus_height+text_height	;
	var pics=PicPath;
    var links=PicLink;
	var texts='|||';
	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="/playswfnew.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="/playswfnew.swf" wmode="opaque" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'" menu="false" bgcolor="#C5C5C5" 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>');
	//-->
	}
	function chkIe()
	{
     	//alert(navigator.userAgent.indexOf("Mozilla/5."));
	 if(navigator.userAgent.search("Opera")>-1)
    {
        return "Opera";
    }
    if(navigator.userAgent.indexOf("Mozilla/5.")>-1)
    {
		document.getElementById("iframeName").height="238";
        return "Firefox";
    }
    if(navigator.userAgent.search("MSIE")>0)
    {
        return "IE";
    }	

	}
