function GE(o){
	return document.getElementById(o);
}

function addfavorite(sURL, sTitle)
{	
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
function sethome(obj,vrl){
        try{
                obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
        }
        catch(e){
                if(window.netscape) {
                        try {
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                        }
                        catch (e) {
                                alert("此操作被浏览器拒绝！");
                        }
                        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                        prefs.setCharPref('browser.startup.homepage',vrl);
                 }
        }
}

function show_newsph(o){
	for(i=1; i<6; i++){
		GE("news_d"+i).style.display = "none";
		GE("url_p"+i).className="STYLE0";
	}
	GE("news_d"+o).style.display ="block";
	GE("url_p"+o).className="STYLE1";
}

function show_pic(o){
	for(i=0; i<=3; i++){
		GE("shp_"+i).className = "m_shp_tjrm_ndiv";
		GE("shp_img").getElementsByTagName("img")[i].className = "m_shp_tjimg_no";
	}
	var id_name = o.name;
	GE(id_name).className = "m_shp_tjrm_div";
	o.className = "m_shp_tjimg_in";
}

function sh_div(o){
	var img_name_src = o.src;
	var img_name_n = img_name_src.lastIndexOf("/");
	var img_name = img_name_src.substring(img_name_n+1);
	if(img_name == "shp_jian.gif"){
		GE("show_spdiv").className = "shp_l_mm_no";
		var img_url = img_name_src.substring(0,img_name_n+1)+"sp_jia.gif";
		o.src = img_url;
	}else{
		GE("show_spdiv").className = "shp_l_mm";
		var img_url = img_name_src.substring(0,img_name_n+1)+"shp_jian.gif";
		o.src = img_url;
	}
}

function img_jzh(o,p,q){
	var imgs=GE(q).getElementsByTagName("img");
	var MAX_WIDTH=o;
	var MAX_HEIGHT=p;
	var bl=MAX_WIDTH/MAX_HEIGHT;
	for(i=0;i<imgs.length;i++){
		var img_width=imgs[i].offsetWidth;
		var img_height=imgs[i].offsetHeight;
		var wh=img_width/img_height;
		var hw=img_height/img_width;
		if(wh>bl){
			imgs[i].style.width=MAX_WIDTH+"px";
			imgs[i].style.height=MAX_WIDTH*hw+"px";
			imgs[i].style.marginTop=(MAX_HEIGHT-MAX_WIDTH*hw)/2+"px";
			imgs[i].style.marginLeft="0px";
		}
		else{
			imgs[i].style.height=MAX_HEIGHT+"px";
			imgs[i].style.width=MAX_HEIGHT*wh+"px";
			imgs[i].style.marginTop="0px";
			imgs[i].style.marginLeft=(MAX_WIDTH-MAX_HEIGHT*wh)/2+"px";
		}
	}
};


function news(o){
	GE("img_one").style.display = "none";
	GE("img_two").style.display = "none";
	GE(o).style.display = "block";
	if(o == "img_one"){
		GE("news_1").className = "one_div_ltt_on";
		GE("news_2").className = "one_div_ltd";
	}else{ 
	GE("news_1").className = "one_div_ltt";
	GE("news_2").className = "one_div_ltt_on"; 
	}
}

var time_pic = "img_one";
function img_goon(){
	if(time_pic=="img_two"){ 
		news("img_one");
		time_pic = "img_one";
	}else{
		news("img_two");
		time_pic = "img_two";
	}
}

function start_img(){
	chang_pic = setInterval("img_goon()",3000);
}
function no_chpic(){
	clearInterval(chang_pic);
}

function jy_show(o){
	var div_n = GE("grjy_main").getElementsByTagName("div");
	for(i=0; i<div_n.length; i++){
		if(div_n[i].className == "jy_xx"){
			div_n[i].style.display = "none";
		}
		if(div_n[i].className == "jy_jl"){
			div_n[i].style.display = "block";
		}
	}
	var this_div = o.getElementsByTagName("div");
	for(i=0; i<this_div.length; i++){
		if(this_div[i].className == "jy_xx"){
			this_div[i].style.display = "block";
		}
		if(this_div[i].className == "jy_jl"){
			this_div[i].style.display = "none";
		}
	}
}

function img_css(o){
	var MAX_WIDTH=150;
	var MAX_HEIGHT=113;
	var bl=MAX_WIDTH/MAX_HEIGHT;
	var img_width=o.offsetWidth;
	var img_height=o.offsetHeight;
	var wh=img_width/img_height;
	var hw=img_height/img_width;
	if(wh>bl){
		o.style.width=MAX_WIDTH+"px";
		o.style.height=MAX_WIDTH*hw+"px";
		o.style.marginTop=(MAX_HEIGHT-MAX_WIDTH*hw)/2+"px";
		o.style.marginLeft="0px";
	}
	else{
		o.style.height=MAX_HEIGHT+"px";
		o.style.width=MAX_HEIGHT*wh+"px";
		o.style.marginTop="0px";
		o.style.marginLeft=(MAX_WIDTH-MAX_HEIGHT*wh)/2+"px";
	}
}

function bk_img(o){
	var MAX_WIDTH=100;
	var MAX_HEIGHT=75;
	var bl=MAX_WIDTH/MAX_HEIGHT;
	var img_width=o.offsetWidth;
	var img_height=o.offsetHeight;
	var wh=img_width/img_height;
	var hw=img_height/img_width;
	if(wh>bl){
		o.style.width=MAX_WIDTH+"px";
		o.style.height=MAX_WIDTH*hw+"px";
		o.style.marginTop=(MAX_HEIGHT-MAX_WIDTH*hw)/2+"px";
		o.style.marginLeft="0px";
	}
	else{
		o.style.height=MAX_HEIGHT+"px";
		o.style.width=MAX_HEIGHT*wh+"px";
		o.style.marginTop="0px";
		o.style.marginLeft=(MAX_WIDTH-MAX_HEIGHT*wh)/2+"px";
	}
}

function js_css(o){
	var MAX_WIDTH=600;
	var MAX_HEIGHT=450;
	var bl=MAX_WIDTH/MAX_HEIGHT;
	var img_width=o.offsetWidth;
	var img_height=o.offsetHeight;
	var wh=img_width/img_height;
	var hw=img_height/img_width;
	if(wh>bl){
		o.style.width=MAX_WIDTH+"px";
		o.style.height=MAX_WIDTH*hw+"px";
		o.style.marginTop=(MAX_HEIGHT-MAX_WIDTH*hw)/2+"px";
		o.style.marginLeft="0px";
	}
	else{
		o.style.height=MAX_HEIGHT+"px";
		o.style.width=MAX_HEIGHT*wh+"px";
		o.style.marginTop="0px";
		o.style.marginLeft=(MAX_WIDTH-MAX_HEIGHT*wh)/2+"px";
	}
}

function news_img(o){
	var MAX_WIDTH=200;
	var MAX_HEIGHT=150;
	var bl=MAX_WIDTH/MAX_HEIGHT;
	var img_width=o.offsetWidth;
	var img_height=o.offsetHeight;
	var wh=img_width/img_height;
	var hw=img_height/img_width;
	if(wh>bl){
		o.style.width=MAX_WIDTH+"px";
		o.style.height=MAX_WIDTH*hw+"px";
		o.style.marginTop=(MAX_HEIGHT-MAX_WIDTH*hw)/2+"px";
		o.style.marginLeft="0px";
	}
	else{
		o.style.height=MAX_HEIGHT+"px";
		o.style.width=MAX_HEIGHT*wh+"px";
		o.style.marginTop="0px";
		o.style.marginLeft=(MAX_WIDTH-MAX_HEIGHT*wh)/2+"px";
	}
}

window.onload = function(){
	if(GE("button_on")){
		var img_button = GE("button_on").getElementsByTagName("img");
		for(var i=0;i<img_button.length;i++){
			var img_old_src = img_button[i].src;
			var img_name_onn = img_old_src.lastIndexOf("/");
			var img_old_name = img_old_src.substring(img_name_onn+1);
			if(img_old_name.substring(0,2) != "on"){
				img_button[i].onmouseover = function(){
					var img_src = this.src;
					var img_name_nn = img_src.lastIndexOf("/");
					var img_name = img_src.substring(img_name_nn+1);
					var new_name = "on_"+img_name;
					var new_src = img_src.replace(img_name,new_name);
					this.src = new_src;
				}
				img_button[i].onmouseout = function(){
					var img_src = this.src;
					var img_name_nn = img_src.lastIndexOf("/");
					var img_name = img_src.substring(img_name_nn+4);
					var new_name = "on_"+img_name;
					var new_src = img_src.replace(new_name,img_name);
					this.src = new_src;
				}
			}
		}
	}
}

function b_img(o){
	var MAX_WIDTH=o.parentNode.parentNode.offsetWidth-2; 
	var MAX_HEIGHT=o.parentNode.parentNode.offsetHeight-2;
	var bl=MAX_WIDTH/MAX_HEIGHT;
	var img_width=o.offsetWidth;
	var img_height=o.offsetHeight;
	var wh=img_width/img_height;
	var hw=img_height/img_width;
	if(img_width<=MAX_WIDTH && img_height<=MAX_HEIGHT){
		o.style.marginTop=(MAX_HEIGHT-img_height)/2+"px";
		o.style.marginLeft=(MAX_WIDTH-img_width)/2+"px";
	}
	if(img_width>MAX_WIDTH || img_height>MAX_HEIGHT){
		if(wh>bl){
			o.style.width=MAX_WIDTH+"px";
			o.style.height=MAX_WIDTH*hw+"px";
			o.style.marginTop=(MAX_HEIGHT-MAX_WIDTH*hw)/2+"px";
			o.style.marginLeft="0px";
		}else {
			o.style.height=MAX_HEIGHT+"px";
			o.style.width=MAX_HEIGHT*wh+"px";
			o.style.marginTop="0px";
			o.style.marginLeft=(MAX_WIDTH-MAX_HEIGHT*wh)/2+"px";
			}
		}
}
