// JavaScript Document

//广告向上翻动
/**
* ul 要滚动的父节点
* delay 每次滚动的延迟时间，单位（毫秒）
* speed 翻滚的速度
* lh 滚动的行高，单位（像素）
*/

function slideLine(ul, delay, speed, lh, element, element_c) {
		//var slideBox = (typeof ul == 'string')?document.getElementById(ul):ul;
		//add by alineo
/*		var slideBox2 = (typeof ul == 'string')?document.getElementById(ul):ul;
		for(var i=0;i<slideBox2.childNodes.length;i++){
				if(slideBox2.childNodes[i].nodeType==1){
						if(slideBox2.childNodes[i].tagName == element)
								slideBox2 = slideBox2.childNodes[i];
								break;
				}
		}
		//infozone
*/		var slideBox2= document.getElementById(ul);
		var slideBox  = document.getElementById(ul);
		//alert(slideBox2);
		//var delay = delay, speed=speed, lh = lh;
		var tid = null, pause = false;
		var start = function() {
				tid=setInterval(slide, speed);
		}
		var slide = function() {
				if (pause) return;
				slideBox.scrollTop += 31;
				if (slideBox.scrollTop % lh == 0) {
						clearInterval(tid);
						slideBox2.appendChild(slideBox2.getElementsByTagName(element_c)[0]);
						slideBox.scrollTop = 0;
						setTimeout(start, delay);
				}
		}
		slideBox.onmouseover=function(){pause=true;}
		slideBox.onmouseout=function(){pause=false;}
		setTimeout(start, delay);
}

//点击清空str
function value_null(obj,str)
{
	if (obj.value == str)
	{
		obj.value = '';
	}
}
//层切换函数
function switchTag(obj)
{	
	var obj = obj;
	var tab1 = document.getElementById('user_panel_top_content_left');
	var tab2 = document.getElementById('user_panel_top_content_right');
	var tab_left = document.getElementById('user_panel_top_left');
	var tab_right = document.getElementById('user_panel_top_right');
	
	if (obj.id == "user_panel_top_left")
	{
		tab1.className = "";
		tab2.className = "hidecontent";
		tab_left.className = "user_panel_top_show";
		tab_right.className = "user_panel_top_hidden";
	}
	else
	{
		tab1.className = "hidecontent";
		tab2.className = "";
		tab_left.className = "user_panel_top_hidden";
		tab_right.className = "user_panel_top_show";
	}
}

function switchTag2(obj)
{	
	var obj = obj;
	var tab1 = document.getElementById('user_panel_bottom_content_left');
	var tab2 = document.getElementById('user_panel_bottom_content_right');
	var tab_left = document.getElementById('user_panel_bottom_left');
	var tab_right = document.getElementById('user_panel_bottom_right');
	
	if (obj.id == "user_panel_bottom_left")
	{
		tab1.className = "";
		tab2.className = "hidecontent";
		tab_left.className = "user_panel_bottom_show";
		tab_right.className = "user_panel_bottom_hidden";
	}
	else
	{
		tab1.className = "hidecontent";
		tab2.className = "";
		tab_left.className = "user_panel_bottom_hidden";
		tab_right.className = "user_panel_bottom_show";
	}
}

// add to favorite
function addfavorite(title)
{
	url = location.href;
	try {
		 if (document.all) {
    		window.external.addFavorite(url, title); 
	    } else if (window.sidebar) {
	    	window.sidebar.addPanel(title, url, ""); 
	    } else {
	    	var message = $message.get('home.header.addPage');
	    	alert(message);
	    } 
	} catch(e) {
	    var message = $message.get('home.header.addPage');
	    alert(message);
	}
}

/*
调用方法：
<img src=".." onload="img_zoom(this,边框宽,边框高)" width="0" height="0" border="0"/>
*/
function img_zoom(obj,frame_width,frame_height) 
{
	var img = null;
	img=document.createElement("img");
	img.src=obj.src;

	if (img.width/frame_width > img.height/frame_height)
	{
		obj.width = frame_width;
		obj.height = (frame_width * img.height)/img.width;
	}
	else
	{
		obj.width = (frame_height * img.width)/img.height;
		obj.height = frame_height;
	}
}

/*
只缩不放
*/
function img_zoom_re(obj,frame_width,frame_height) 
{
	var img=null;
	img=document.createElement("img");
	img.src=obj.src;
	if(img.width>frame_width || img.height>frame_height){
		if (img.width/frame_width > img.height/frame_height)
		{
			obj.width = frame_width;
			obj.height = (frame_width * img.height)/img.width;
		}
		else
		{
			obj.width = (frame_height * img.width)/img.height;
			obj.height = frame_height;
		}
	}
	else
	{
		obj.width = img.width;
		obj.height = img.height;
	}
}

/*去除html格式*/
function DelHtml(Word){
	Word = Word.replace(/&nbsp;/g,"");
	a = Word.indexOf("<");
	b = Word.indexOf(">");
	len = Word.length;
	c = Word.substring(0, a);
	if(b == -1)
		b = a;
	d = Word.substring((b + 1), len);
	Word = c + d;
	tagCheck = Word.indexOf("<");
	if(tagCheck != -1)
		Word = DelHtml(Word);
	return Word;
} 

/*ajax*/
function openUrl(url){   
	var objxml=new  ActiveXObject("Microsoft.XMLHttp")   
	objxml.open("POST",url,false);   
	objxml.send();   
	retInfo=objxml.responseText;   
	if   (objxml.status=="200"){   
		return  retInfo;
	}   
	else{   
		return   "-2";   
	}   
	delete objxml;
}

//选择行业分类
function PopupCatSel(info_type)
{
	var selProdWnd=window.open("Select_Sort.asp?info_type=" + info_type,"new","resizable=yes,width=910,height=340,top=0,left=0,scrollbars=yes");
	if(selProdWnd.opener== null) 
		selProdWnd.opener = self;
	return (false);
}

function open_window(link_add,x,y,w,h,s)
{
	window.open(link_add,'','top=' + x + ',left=' + y + ',width=' + w + ',height=' + h + ',scrollbars=' + s + ',z-look=yes,resizable=yes');
}

//去空格
function trim(inputString) 
{
	if (typeof inputString != "string") { return inputString; }
	var retValue = inputString;
	var ch = retValue.substring(0, 1);
	while (ch == " ") { 
//检查字符串开始部分的空格
			retValue = retValue.substring(1, retValue.length);
			ch = retValue.substring(0, 1);
	}
	ch = retValue.substring(retValue.length-1, retValue.length);
	while (ch == " ") {
		 //检查字符串结束部分的空格
		 retValue = retValue.substring(0, retValue.length-1);
		 ch = retValue.substring(retValue.length-1, retValue.length);
	}
	while (retValue.indexOf("  ") != -1) { 
//将文字中间多个相连的空格变为一个空格
		 retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
	}
	return retValue;
} 

//选中表单内所有复选框
function CheckAll(form) {
	for (var i=0;i<form.elements.length;i++) {
		var e = form.elements[i];
		if (e.name != 'chkall') e.checked = form.chkall.checked; 
	}
}

/*
调用方法：
onload="img_zoom(this,150,200)" onmouseover="cc1428(this,'<%=pic%>')"  onmouseout="document.all.pop1428.style.display='none'"
配合上面的使用
<div  id=pop1428  style="position:absolute;width:10;height:10;z-index:99;display:none;  border:  1px  solid  #808080;  background:  #ffffcc" onmouseover="document.all.pop1428.style.display=''" onmouseout="document.all.pop1428.style.display='none'"   >
</div>
*/
function  cc1428(tt,yy)  
{  
   var  daps    =  document.all.pop1428.style;  
   var  ttop    =  tt.offsetTop;          //TT控件的定位点高  
   var  tleft  =  tt.offsetLeft;        //TT控件的定位点宽  
   var  ttyp    =  tt.type;                    //TT控件的类型  
   while  (tt  =  tt.offsetParent){ttop+=tt.offsetTop;  tleft+=tt.offsetLeft;}  
   daps.top    =  ttop+50;  //层的  Y  坐标  
   daps.left  =  tleft-100 ;    //层的  X  坐标  
   daps.display  =  "";    //层显示
   document.getElementById("pop1428").innerHTML="<img src="+yy+" width=0 height=0 onload='img_zoom(this,600,600)'>"
}