﻿//获取ID
function GetObj(objName){if(document.getElementById){return eval('document.getElementById("' + objName + '")');}else if(document.layers){return eval("document.layers['" + objName +"']");}else{return eval('document.all.' + objName);}}
//变幻菜单
function menu(index) {
	if (index == undefined || index == "") {index=0;};
	var uls= document.getElementById("home_news_title").getElementsByTagName("li");
	for(var i=0; i<uls.length; i++){
		if (index==i){
			uls[i].className = "on";
			GetObj("con"+i).style.display = "";
		}else{
			uls[i].className = "";
			GetObj("con"+i).style.display = "none";
		}
	}
}

function change_menu2(menu2_i) {
	if (menu2_i == undefined || menu2_i == "") {menu2_i=0;};
	var uls= document.getElementById("news_title").getElementsByTagName("li");
	for(var i=0; i<uls.length; i++){
		if (menu2_i==i){
			uls[i].className = "on";
			GetObj("con_"+i).style.display = "";
		}else{
			uls[i].className = "";
			GetObj("con_"+i).style.display = "none";
		}
	}
	cur_menu2_i=menu2_i;
	cur_menu2_i++;
	if(cur_menu2_i == uls.length){cur_menu2_i=0;}
	settime=setTimeout("menu2(cur_menu2_i)",6000);
}
function menu2(objName) {clearTimeout(settime);change_menu2(objName);}
//载入flash
function loadflash(url,width,height) {document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="'+ width +'" height="'+ height +'"><param name="movie" value="'+ url +'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="'+ url +'" wmode="transparent" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ width +'" height="'+ height +'"></embed></object>');}
//载入flash播放器
function loadflash_play(url,wmode,width,height,param){document.write('<embed src="' + url + '" FlashVars="'+param+'" wmode=' + wmode + ' quality="high" pluginspage=http://www.macromedia.com/go/getflashplayer type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed>');}
//跳转页面
function gotourl(url) {if (url!=="") {top.location = url;}}
//显示窗口
function openurl(url) {if (url!=="") {window.open (url);}}
//自动改变高度
function autoH(Obj,str) {if (exist(Obj)==true){GetObj(Obj).style.height = str+"px";autoWH("box_left","box_right");}}
//自动对齐高度
function autoWH(Obj,Obj2) {if (exist(Obj)==true && exist(Obj2)==true) {var left_h = GetObj(Obj).scrollHeight;var right_h = GetObj(Obj2).scrollHeight;if (left_h > right_h) {GetObj(Obj).style.height= left_h +"px";GetObj(Obj2).style.height= left_h +"px";}else{GetObj(Obj).style.height= right_h +"px";GetObj(Obj2).style.height= right_h +"px";}}}
//判断ID是否存在
function exist(id){var s=GetObj(id);if(s){return true}else{return false}}
//判断ID是否存在
//window.onload = function() {autoWH("box_left","box_right");}
//显示弹出层
function alertinfo(id,urlValue,divTitle,divWidth,divHeight){
	var obj = GetObj(id);
	//--------------------------------------------
	var pageWidth,pageHeight;
	var xScroll,yScroll;
	if(window.innerHeight&&window.scrollMaxY){
		xScroll=document.body.scrollWidth;
		yScroll=window.innerHeight+window.scrollMaxY;
	}else if(document.body.scrollHeight>document.body.offsetHeight){
		xScroll=document.body.scrollWidth;
		yScroll=document.body.scrollHeight;
	}else{
		xScroll=document.body.offsetWidth;
		yScroll=document.body.offsetHeight;
	}
	var windowWidth,windowHeight;
	if(self.innerHeight){
		windowWidth=self.innerWidth;
		windowHeight=self.innerHeight;
	}else if(document.documentElement&&document.documentElement.clientHeight){
		windowWidth=document.documentElement.clientWidth;
		windowHeight=document.documentElement.clientHeight;
	}else if(document.body){
		windowWidth=document.body.clientWidth;
		windowHeight=document.body.clientHeight;
	}
	if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
	if(xScroll<windowWidth){pageWidth=windowWidth;}else{pageWidth=xScroll;}
	//--------------------------------------------
	GetObj(id+"_title").innerHTML = divTitle;
	obj.style.display="block";
	obj.style.width= divWidth + "px";
	obj.style.height= divHeight + "px";
	GetObj(id+"_intro").style.height= divHeight-28 + "px";
	obj.style.left= (windowWidth/2 - (divWidth/2)) + "px";
	obj.style.top= (windowHeight/2 - (divHeight/2) -5) + "px";
	GetObj("bg").style.display="block";
	GetObj("bg").style.width=pageWidth + "px";
	GetObj("bg").style.height=pageHeight + "px";
	document.body.style.overflow='hidden';
	//--------------------------------------------
	GetObj("myIframe").src = urlValue;
}
//显示应聘些岗位层
function alertJob(id, urlValue){
	var obj = GetObj(id);
	//--------------------------------------------
	var pageWidth,pageHeight;
	var xScroll,yScroll;
	if(window.innerHeight&&window.scrollMaxY){
		xScroll=document.body.scrollWidth;
		yScroll=window.innerHeight+window.scrollMaxY;
	}else if(document.body.scrollHeight>document.body.offsetHeight){
		xScroll=document.body.scrollWidth;
		yScroll=document.body.scrollHeight;
	}else{
		xScroll=document.body.offsetWidth;
		yScroll=document.body.offsetHeight;
	}
	var windowWidth,windowHeight;
	if(self.innerHeight){
		windowWidth=self.innerWidth;
		windowHeight=self.innerHeight;
	}else if(document.documentElement&&document.documentElement.clientHeight){
		windowWidth=document.documentElement.clientWidth;
		windowHeight=document.documentElement.clientHeight;
	}else if(document.body){
		windowWidth=document.body.clientWidth;
		windowHeight=document.body.clientHeight;
	}
	if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}
	if(xScroll<windowWidth){pageWidth=windowWidth;}else{pageWidth=xScroll;}
	//--------------------------------------------
	obj.style.display="block";
	obj.style.left= (windowWidth/2 - (obj.scrollWidth/2)) + "px";
	obj.style.top= (windowHeight/2 - (obj.scrollHeight/2)) + "px";
	GetObj("bg").style.display="block";
	GetObj("bg").style.width=pageWidth + "px";
	GetObj("bg").style.height=pageHeight + "px";
	GetObj("myIframe").src = urlValue;
}
//关闭弹出层
function closediv(id){document.getElementById(id).style.display="none";document.getElementById("bg").style.display="none";var scrollstyle = scrolls();scrollstyle.style.overflowY = "auto";scrollstyle.style.overflowX = "hidden";}
//取浏览器类型
function scrolls(){var temp_h1 = document.body.clientHeight;var temp_h2 = document.documentElement.clientHeight;var isXhtml = (temp_h2<=temp_h1&&temp_h2!=0)?true:false;var htmlbody = isXhtml?document.documentElement:document.body;return htmlbody;}
//邮箱验证
function ismail(mail) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(mail)) return true;
	else {return false;}
}
//验证手机
function isMobel(value) {    
	if(/^13\d{9}$/g.test(value)||(/^15[0-35-9]\d{8}$/g.test(value))||(/^18[05-9]\d{8}$/g.test(value))){      
		return true;    
	}else{    
		return false;    
	}    
} 
//缩放图片到合适大小
function ResizeImages(){
   var myimg,oldwidth,oldheight;
   var maxwidth=400; 
   var maxheight=300;
   var imgs = document.getElementById('view_intro').getElementsByTagName('img'); 
 
   for(i=0;i<imgs.length;i++){
     myimg = imgs[i];
 
     if(myimg.width > myimg.height){
         if(myimg.width > maxwidth){
            oldwidth = myimg.width;
            myimg.height = myimg.height * (maxwidth/oldwidth);
            myimg.width = maxwidth;
         }
     }else{
         if(myimg.height > maxheight){
            oldheight = myimg.height;
            myimg.width = myimg.width * (maxheight/oldheight);
            myimg.height = maxheight;
         }
     }
   }
}
//自动比例缩小图片
function resizeimg(ImgD,iwidth,iheight) {
     var image=new Image();
     image.src=ImgD.src;
     if(image.width>0 && image.height>0){
        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;
			}
		ImgD.style.cursor= "pointer"; //改变鼠标指针
		//ImgD.onclick = function() { window.open(this.src);} //点击打开大图片
		if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE
			//ImgD.title = "请使用鼠标滚轮缩放图片，点击图片可在新窗口打开";
			//滚轮缩放
			//ImgD.onmousewheel = function img_zoom() {
			//var zoom = parseInt(this.style.zoom, 10) || 100;
			//zoom += event.wheelDelta / 12;
			//if (zoom> 0)　this.style.zoom = zoom + "%";
			//return false;
			//}
		} else { //如果不是IE
			//ImgD.title = "点击图片可在新窗口打开";
		}
    }
}
//定义一个运行代码的函数，
function runCode(obj) {
	var code=document.getElementById(obj).value;//即要运行的代码
	var newwin=window.open('','','');  //打开一个窗口并赋给变量newwin。
	newwin.opener = null // 防止代码对论谈页面修改
	newwin.document.write(code);  //向这个打开的窗口中写入代码code，这样就实现了运行代码功能。
	newwin.document.close();
}
//加入收藏
function AddFavorite(sURL, sTitle) {
    try {
        window.external.addFavorite(sURL, sTitle);
    } catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        } catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
//控制字体大小
function fonts(obj,font_size){
	for (var i=0;i<3;i++){
		if (i==obj){
			GetObj("font_"+i).style.color = "#f30";
		}else{
			GetObj("font_"+i).style.color = "#aaa";
		}
	}
	var divBody = document.getElementById("content_view");
	if(!divBody){return;}
	divBody.style.fontSize = font_size + "px";
	var divChildBody = divBody.childNodes;
	for(var i = 0; i < divChildBody.length; i++){
		if (divChildBody[i].nodeType==1){
			divChildBody[i].style.fontSize = font_size + "px";
		}
	}
}

