// JavaScript Document
//获取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 change_menu(index){
	for(var i=1;i<=num;i++){
		if(GetObj("con"+i)&&GetObj("menu"+i)){
			GetObj("con"+i).style.display = 'none';
			GetObj("menu"+i).className = "";
		}
	}
	if(GetObj("con"+index)&&GetObj("menu"+index)){
		GetObj("con"+index).style.display = 'block';
		GetObj("menu"+index).className = "on";
	}
	cur_index=index;
	if(cur_index<num){cur_index++;}else{cur_index=1;}
	settime=setTimeout("change_menu(cur_index)",2500)
}
function menu(c_index){clearTimeout(settime);change_menu(c_index);} 
//顶部菜单自动变
function topMenu(index, index_count){
	for(var i=0;i<=index_count;i++){
		if(GetObj("topMenu_"+i)){GetObj("topMenu_"+i).className = '';}
	}
	if(GetObj("topMenu_"+index)){GetObj("topMenu_"+index).className = 'on';}
}
//顶部菜单自动变
function ProClass(index){
	if(GetObj("ProClass_"+index).style.display=='none'){
		GetObj("ProClass_"+index).style.display = 'block';
		GetObj("ProImg_"+index).src = '../images/left_class02.gif';
	}else{
		GetObj("ProClass_"+index).style.display = 'none';
		GetObj("ProImg_"+index).src = '../images/left_class01.gif';
	}
}
//自动改变高度
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 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 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 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-23 + "px";
	obj.style.left= (windowWidth/2 - (divWidth/2)) + "px";
	obj.style.top= (windowHeight/2 - (divHeight/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";}
//加载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 +"\">");
	document.write("<param name=\"movie\" value=\"" + url + "\" />");		   
	document.write("<param name=\"quality\" value=\"high\" />");		   
	document.write("<param name=\"wmode\" value=\"transparent\" />");		   
	document.write("<embed src=\"" + url + "\" width=\""+ width +"\" height=\""+ Height +"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></embed>");		   
	document.write("</object>");
}
// JavaScript Document
function Launch(page, width, height) { 
    OpenWin = this.open(page, "webstudio", "toolbar=no, menubar=no ,location=no, scrollbars=yes, resizable=no, width=" + width + ", height=" + height + ", top=0, left=0\""); 
}
function loadimg(obj){
	var w=700,h=600;
	if(obj.complete!=true)	{
		setTimeout('loadimg('+obj+');',300);
	}else{
		if(obj.width>w||obj.height>h){if(obj.width/w>obj.height/h){obj.width=w;}else{obj.height=h;}}
	}
}
function SearchData(thisObj) {
	if (thisObj.key.value==''||thisObj.key.value=='请输入关键字') {
		alert("请输入关键字，然后再进行搜索...");
		thisObj.key.focus();
		return false;
	}
	///
	return true;
}
function en_SearchData(thisObj) {
	if (thisObj.key.value==''||thisObj.key.value=='Please enter a keyword') {
		alert("Please enter a keyword Then search...");
		thisObj.key.focus();
		return false;
	}
	///
	return true;
}
