﻿function e(objid){
	var div = document.getElementById(objid)
	return div;
}

function liSet(obj,num,class1,class2){
	for(var i=1;e(obj + i);i++){
		if(i == num){
			e(obj+i).className = class1
		}else{
			e(obj+i).className = class2
		}
	}
}

function liSet1(obj,num){
	for(var i=1;e(obj + i);i++){
		if(i == num){
			e(obj+i).style.display = 'block'
		}else{
			e(obj+i).style.display = 'none'
		}
	}
}

function setTab(name,cursel){
    for(i=1;e(name+i);i++){
        var menu=e(name+i);
        var con=e("con_"+name+"_"+i);
        menu.className=i==cursel?"hover":"";
        con.style.display=i==cursel?"block":"none";
    }
}

function AddOption(obj,value,text){
   var objOption=document.createElement("OPTION");
   objOption.value=value;
   objOption.text=text;
   obj[obj.length]=objOption;
}

function setSearchForm(obj){
    switch(e("SearchType").value){
        case "0":
             obj.action = "/hy/gqlist.aspx";
             break;
        case "1":
             obj.action = "/hy/prolist.aspx";
             break;
        case "2":
             obj.action = "/hy/comlist.aspx";
             //alert(this.action); 
             break;
        case "3":
             obj.action = "/hy/newslist.aspx";
             break;
        case "4":
             obj.action = "/hy/hnewslist.aspx";
             break;
    }  
   
  return true;  
} 

function shareTo(flag,title){
    if(!title) title = document.title
    switch(flag){
        case "Qzone":
            window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=" + window.location);
            break;
        case "renren":
            window.open("http://share.renren.com/share/buttonshare.do?link=" + window.location + "&title=" + title);
            break;
        case "itieba":
            window.open("http://tieba.baidu.com/i/app/open_share_api?link=" + window.location);
            break;
        case "weibo":
            window.open("http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_56_weibo&appkey=1117062404&url=" + window.location + "&title=" + title + "&source=gyl.cn&sourceUrl=http://www.gyl.cn&content=utf8&pic=http://www.gyl.cn/images/logo.gif");
            break;
        case "126":
            window.open("http://t.163.com/article/user/checkLogin.do?link=http://www.gyl.cn/&source=%E6%88%91%E4%B9%90%E7%BD%91&info=" + title + " " + window.location + "&1292227399195");
            break;
    }
}

fadeUp=function(element,red,green,blue){
    if(element.fade){
        window.clearTimeout(element.fade);
    }
    var cssValue = "rgb("+red+","+green+","+blue+")";
    element.style.backgroundColor = cssValue;
    //$(element).css("background-color",cssValue);
    if(red == 255 && green == 255 && blue == 255){
        return;
    }
    var newRed = red + Math.ceil((255-red)/10);
    var newGreen = green + Math.ceil((255-green)/10);
    var newBlue = blue + Math.ceil((255-blue)/10);
    var repeat = function(){
        fadeUp(element,newRed,newGreen,newBlue);
    };
    element.fade=window.setTimeout(repeat,100);
}

var repeat = function(){
        fadeUp(element,newRed,newGreen,newBlue);
    };
 


function MoveTextDiv(obj,obj1,action,anum){//上下移动层
	if(action=="up"){
		UpMove(obj,obj1,anum);
	}
	else{
		DownMove(obj,obj1,anum);
	}
}
function UpMove(obj,obj1,anum){
	if(obj1.offsetTop<0){
		obj1.style.pixelTop+=anum;
	}
}
function DownMove(obj,obj1,anum){
	if(obj1.offsetTop>(obj.offsetHeight-obj1.offsetHeight)){
		obj1.style.pixelTop-=anum;
	}
}




function DrawImage(ImgD,FitWidth,FitHeight,flag){
var image=new Image();

    image.src=ImgD.src;
    if(image.width>0 && image.height>0){
        if(image.width/image.height>= FitWidth/FitHeight){
            if(image.width>FitWidth){
                ImgD.width=FitWidth;
                ImgD.height=(image.height*FitWidth)/image.width;
                if(flag){
                    ImgD.onclick = function (){
                        window.open(ImgD.src)
                    }
                }
                ImgD.onmouseover = function (){
                this.style.cursor = "hand";
                }
            }else{
               ImgD.width=image.width;
               ImgD.height=image.height;
            }
            ImgD.alt="点击查看大图";
        }else{
            if(image.height>FitHeight){
                ImgD.height=FitHeight;
                ImgD.width=(image.width*FitHeight)/image.height;
            }else{
                ImgD.width=image.width;
                ImgD.height=image.height;
            }
            ImgD.alt="点击查看大图";
        }
    }
    image.delect
}

//**************************************************************************************************************************
//**************************************************************************************************************************

//左边
//var left_img='<a href=\"http:\/\/www.53hy.com\/stat\/stat.asp?siteKey=iecool&pageNO=1&urlCode=432b8db663bf55e561683b9a830af5ad\" target=\"_blank\"><img src=\"http:\/\/www.iecool.com\/ads\/53dns_100_100.gif\" width=\"100\" height=\"100\" border=\"0\"><\/a>';

//右边
//var right_img='<a href=\"http:\/\/www.53hy.com\/stat\/stat.asp?siteKey=iecool&pageNO=1&urlCode=432b8db663bf55e561683b9a830af5ad\" target=\"_blank\"><img src=\"http:\/\/www.iecool.com\/ads\/53dns_100_100.gif\" width=\"100\" height=\"100\" border=\"0\"><\/a>';

    var delta=0.15
	var collection;
	
	function floaters() {
		this.items	= [];
		this.addItem	= function(id,y)
				  {
					var newItem				= {};
					newItem.object			= document.getElementById(id);
					newItem.y				= y;

					this.items[this.items.length]		= newItem;
				  }
		this.play	= function()
				  {
					collection				= this.items
					setInterval('play()',10);
				  }
		}
		function play()
		{

			for(var i=0;i<collection.length;i++)
			{
				var followObj		= collection[i].object;
				//var followObj_x		= (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
				var followObj_y		= (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);

//				if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
//					var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
//					dx=(dx>0?1:-1)*Math.ceil(Math.abs(dx));
//					followObj.style.left=followObj.offsetLeft+dx;
//					}

				if(followObj.offsetTop!=(document.documentElement.scrollTop+followObj_y)) {
					var dy=(document.documentElement.scrollTop+followObj_y-followObj.offsetTop)*delta;
					dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy));
					followObj.style.top=followObj.offsetTop+dy;
					}
				followObj.style.display	= '';
			}
		}	


//添加到收藏夹，兼容火狐和ie
function addBookmark(url,title) {
if (window.sidebar) { 
window.sidebar.addPanel(title, url,""); 
} else if( document.all ) {
window.external.AddFavorite( url, title);
//} else if( window.opera && window.print ) {
//return true;
}
}



function MoveTextDiva(obj,obj1,action,anum){//左右移动层
	if(action=="left"){
		LeftMove(obj,obj1,anum);
	}
	else{
		RightMove(obj,obj1,anum);
	}
}
function LeftMove(obj, obj1, anum) {
	if(obj1.offsetLeft<0){
		obj1.style.pixelLeft+=anum;
	}
}
function RightMove(obj,obj1,anum){
	if(obj1.offsetLeft>(obj.offsetWidth-obj1.offsetWidth)){
		obj1.style.pixelLeft-=anum;

	}

}

function setRoll(id,id1,id2,speed){
    id2.innerHTML=id1.innerHTML//克隆demo1为demo2 
    var Marquee = function(){ 
        if(id2.offsetHeight-id.scrollTop<=0)//当滚动至demo1与demo2交界时 
            id.scrollTop-=id1.offsetHeight//demo跳到最顶端 
        else{ 
            id.scrollTop++ //如果是横向的 将 所有的 height top 改成 width left 
        } 
    } 
    var MyMar=setInterval(Marquee,speed)//设置定时器 
    id.onmouseover=function() {clearInterval(MyMar)}//鼠标移上时清除定时器达到滚动停止的目的 
    id.onmouseout=function() {MyMar=setInterval(Marquee,speed)}//鼠标移开时重设定时器
}
