
// JavaScript Document
function $(s){return document.getElementById(s);}

//点击出现文本框
function editCell (cell) {
	cell.readOnly = false;
	cell.className="enableEdit";
} 
function cancelEdit (cell) {
	cell.readOnly = true;
	cell.className="disEnableEdit";
} 
//---------
var which, which2,div_id;
div_id=null;
//层隐藏
function hidden_div(id){
	var which = document.getElementById(id);
			which.style.display="none";
}
//----------------------------
//选择分类层显示
function show_div_class(id,el,isRoot){
	dypopLayer = document.getElementById(id);
	dypopLayer.style.left=getPos(el,"Left");
	dypopLayer.style.top=getPos(el,"Top")+21;
	

	if (dypopLayer.style.display=="none")
	{
		if(div_id == null || id != "select_class" || !isRoot)
		dypopLayer.style.display="";
		$('top_img').className='dropdownboximg_up';
		if (id == "select_class"){
			var object = dypopLayer.style;
			if (navigator.userAgent.indexOf("Firefox") != -1) {
				opacity = 99.9999; // This is majorly retarded
			}
			
			object.filter = "alpha(opacity=" + 100 + ")"; // IE/Win
			object.opacity = 1;
		}
	}else{
		dypopLayer.style.display="none";
		$('top_img').className='dropdownboximg';
	}
	if (div_id!=null && id == "select_class")
		{
			hidden_div(div_id);
			$('top_img').className='dropdownboximg';
			div_id=null;
		}
}

//分页层显示
function show_div_select(id,el,isRoot){
	dypopLayer = document.getElementById(id);
	dypopLayer.style.left=getPos(el,"Left")+1;
	dypopLayer.style.top=getPos(el,"Top")+27;
	

	if (dypopLayer.style.display=="none")
	{
		dypopLayer.style.display="";
	}else{
		dypopLayer.style.display="none";
	}
}

//回复留言层显示
function show_div_reply(id,MegId,el){
	MessageId = document.getElementById('M_Id');
	dypopLayer = document.getElementById(id);
	dypopLayer.style.left=getPos(el,"Left")-300;
	dypopLayer.style.top=getPos(el,"Top")+20;
	MessageId.value=MegId;

	if (dypopLayer.style.display=="none")
	{
		dypopLayer.style.display="";
	}else{
		dypopLayer.style.display="none";
	}

}
//-----------------------------------------
//回复留言层显示
function show_tender(id,el){
	dypopLayer = document.getElementById(id);
	dypopLayer.style.left=getPos(el,"Left");
	dypopLayer.style.top=getPos(el,"Top")+70;

	dypopLayer.style.display="";

}
//-----------------------------------------
//得到光标位置
function getPos(el,sProp) {
	var iPos = 0;
	while (el!=null) {
		iPos+=el["offset" + sProp];
		el = el.offsetParent;
	}
	return iPos;
}
//-------------------------------
//两个层替换效果
function select_div(div1,div2){
	if(marqueeInterval[0])
		clearInterval(marqueeInterval[0]);
	count = 0;
	var which0 = document.getElementById('class_box');
	which = document.getElementById(div1);
	which2 = document.getElementById(div2);
	
	show_div_select(div2,which0, false);
	div_id=div2;
	//which2.style.display="";
	initOpacity(which2);
	marqueeInterval[0]=setInterval("scrollMarquee(which2, which)",40);
	//hidden_div(div1);
}
//----------------------------------------
//内容显示层
function show_content(id){
	if ($("info_"+id).style.display=="none")
	{
		$("info_"+id).style.display="";
		$("img_"+id).src="images/icon-sortarr_up.gif";

	}else{
		$("info_"+id).style.display="none";
		$("img_"+id).src="images/icon-sortarr.gif";
	}
}
//-------------------------
//评论显示/关闭
function show_comment(id){
	if ($("comment_"+id).style.display=="none")
	{
		$("comment_"+id).style.display="";
		$("comment_img").src="i/select.gif";
	}else{
		$("comment_"+id).style.display="none";
		$("comment_img").src="i/icon.gif";
	}
}
//------------------------------
//渐隐渐消效果
var count = 0;
var marqueeInterval=new Array();  //定义一些常用而且要经常用到的变量
function initOpacity(initObj){
	var object = initObj.style;
	object.filter = "alpha(opacity=" + 0 + ")"; // IE/Win
	object.opacity = 0;
}

function scrollMarquee(showObj, hideObj) {
	count+=10;
	setOpacitys(showObj, hideObj, count);
    if(count == 100){
        clearInterval(marqueeInterval[0]);
		setOpacitys(showObj, hideObj, 100);
		count = 0;
		hideObj.style.display="none";
        }
    }

function setOpacitys(showObj, hideObj, opacity) {
	
	var object = showObj.style;
	if (navigator.userAgent.indexOf("Firefox") != -1) {
		if (opacity == 100) { opacity = 99.9999; } // This is majorly retarded
	}
	
	object.filter = "alpha(opacity=" + opacity + ")"; // IE/Win
	object.opacity = (opacity / 100);                 // Safari 1.2, Firefox+Mozilla

	var object1 = hideObj.style;
	if (object1)
	{
		if (navigator.userAgent.indexOf("Firefox") != -1) {
			if (opacity == 100) { opacity = 100-99.9999; } // This is majorly retarded
		}
		
		object1.filter = "alpha(opacity=" + (100-opacity) + ")"; // IE/Win
		object1.opacity = (100-opacity) / 100;  
	}
}
//-------------

//产品层替换
function display_product(id,count){
	for(i=1;i<=count;i++){
		document.getElementById("li_"+i).className="out";
		document.getElementById("class_"+i).style.display="none";
		document.getElementById("pro_pages_"+i).style.display="none";
	}
	//if (id>1)
	//{
		//i=1;
	//}else{
	//	i=2;
	//}
	document.getElementById("li_"+id).className="over";
	document.getElementById("pro_pages_"+id).style.display="";
	
	//which=document.getElementById("class_"+i);
	which2 = document.getElementById("class_"+id);
	which2.style.display="";
	//var object = which2.style;
		//	if (navigator.userAgent.indexOf("Firefox") != -1) {
		//		opacity = 99.9999; // This is majorly retarded
		///	}
			
		//	object.filter = "alpha(opacity=" + 100 + ")"; // IE/Win
		//	object.opacity = 1;
	//initOpacity(which2);
	//marqueeInterval[0]=setInterval("scrollMarquee(which2, which)",40);
}

function display_product_default(id,count){
	for(i=1;i<=count;i++){
		document.getElementById("li_"+i).className="out";
		document.getElementById("class_"+i).style.display="none";
	}
	//if (id>1)
	//{
		//i=1;
	//}else{
		//i=2;
	//}
	document.getElementById("li_"+id).className="over";
	//which = document.getElementById("class_"+i);
	which2 = document.getElementById("class_"+id);
	which2.style.display="";

	//var object = which2.style;
			//if (navigator.userAgent.indexOf("Firefox") != -1) {
			//	opacity = 99.9999; // This is majorly retarded
			//}
			
			//object.filter = "alpha(opacity=" + 100 + ")"; // IE/Win
			//object.opacity = 1;
	//initOpacity(which2);
	//marqueeInterval[0]=setInterval("scrollMarquee(which2, which)",40);
}

//---------------------------
//选择分类
function selected(id,name){
	var which = document.getElementById('ClassId');
	var which2 = document.getElementById('ClassName');
	
	which.value=id;
	which2.innerHTML=name;

	if (div_id!=null)
	{
		hidden_div(div_id);
		div_id=null;
	}else
		hidden_div("select_class");
}
//-------------
//图片显示层
function display_pic(src,el){
	dypopLayer = document.getElementById('pic_display');
	dypopLayer.style.left=getPos(el,"Left")+150;
	dypopLayer.style.top=getPos(el,"Top");
	dypopLayer.style.display="";
	document.getElementById('pic').src=src;
}
//--------------

//选择分页
function select_page(url){
    hidden_div("page_number");
	document.location.href=url;
}
//-------------
//选择分页
function select_page_pro(url,id){
    hidden_div("page_number_"+id);
	document.location.href=url;
}
//-------------

function check_empty(text){
	if (text.length>0)
		return false;
	else
		return true;
}

function trim(str)
{
	return str.replace(/(^\s*)|(\s*$)/g, "");
}

//判断是否是数字字串
function isNum(v){
	var i;
	for(i=0;i<v.length;i++)
		if(v.charAt(i)>'9' || v.charAt(i)<'0')
			return false;
	return true;
}

 function maxlength(str,minl,maxl) {
    if(str.length <= maxl && str.length >= minl){return true;}else{return false;}
 }
//检测评论
function check_comment(){
	if (check_empty(trim($('UserName').value))){
		alert("昵称不能为空！");
		$('UserName').focus();
		return false;
	}
	if (check_empty(trim($('ContactMethod').value))){
		alert("联系方式不能为空！");
		$('ContactMethod').focus();
		return false;
	}
	if (check_empty(trim($('Content').value))){
		alert("咨询问题不能为空！");
		$('Content').focus();
		return false;
	}
	document.comment_form.submit();
}
//-------------

//检测物流查询
function check_search(){
	if (check_empty(trim($('Name').value))){
		alert("姓名不能为空！");
		$('Name').focus();
		return false;
	}
	if (check_empty(trim($('ProductName').value))){
		alert("物流查询不能为空！");
		$('ProductName').focus();
		return false;
	}

	if (check_empty(trim($('details').value))){
		alert("明细不能为空！");
		$('details').focus();
		return false;
	}
	//document.s_form.submit();
}
//-------------
//检测关键字查询
function checkSearch(id){
	if (check_empty(trim($(id).value))){
		alert("关键字不能为空！");
		$(id).focus();
		return false;
	}
	return true;
}
//-------------
//检测订单提交
function check_order(){
	if (check_empty(trim($('LinkMan').value))){
		alert("联系人不能为空！");
		$('LinkMan').focus();
		return false;
	}	
	if (check_empty(trim($('LinkMethod').value))){
		alert("联系电话不能为空！");
		$('LinkMethod').focus();
		return false;
	}
	return true;
}
//-------------
//检测应聘提交
function check_resource(){
	if (check_empty(trim($('ResourceName').value))){
		alert("您的姓名不能为空！");
		$('ResourceName').focus();
		return false;
	}	
	if (check_empty(trim($('Works').value))){
		alert("应聘职位不能为空！");
		$('Works').focus();
		return false;
	}
	document.resource_form.submit();
}
//-------------
//更改字体大小
function SetFont(id,size)
{
	document.getElementById(id).style.fontSize=size
}
//-----------------------
//更改关键字
function keyword_re(id,val)
{
	if($(id).value==val)
	{
		$(id).value="";
	}
}
function keyword_re2(id,val)
{
	if($(id).value=="")
	{
		$(id).value=val;
	}
}

//-----------------------

//首页招聘信息显示
var marqueeId=0;
var marqueeDelay=6000; //显示延时
var marqueeHeight=24;// 滚动高度
var count = 0, changePage = 0;//count 渐变计数 change	Page 显示与隐藏计数
var scrollObj1, scrollObj2, nowShowObj;//需要显示的对象层

//接下来的是定义一些要使用到的函数
function initMarquee(bid1, bid2, par) {
	if(bid1&&bid2&&par){
		
		var str=marqueeContent[0];
		
		scrollObj1 = document.getElementById(bid1);
		var divW = document.getElementById(par).clientWidth - document.getElementById("hotnews").clientWidth - document.getElementById("newsnext").clientWidth - document.getElementById("newsprev").clientWidth;
		scrollObj1.style.width=divW+"px";
		scrollObj1.childNodes[0].innerHTML=str;
		scrollObj1.style.visibility="visible";
		nowShowObj = scrollObj1;
		if(marqueeContent.length < 2)
			return;
		scrollObj2 = document.getElementById(bid2);
		scrollObj2.style.width=divW+"px";
		marqueeId++;
		marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay);
	}
    }
function startMarquee() {
    clearInterval(marqueeInterval[1]);
	var str=marqueeContent[marqueeId];
    marqueeId++;
    if(marqueeId>=marqueeContent.length) marqueeId=0;
    if(changePage%2 == 0){
		if(scrollObj2.style.visibility!="visible"){
			scrollObj2.style.visibility="visible";
			initOpacity(scrollObj2);
		}
		scrollObj2.childNodes[0].innerHTML=str;
		if(changePage > 2)
		changePage = 0;
		nowShowObj = scrollObj2;
		marqueeInterval[1]=setInterval("scrollMarquee(scrollObj2, scrollObj1)",40);
	}else {
		if(scrollObj1.style.visibility!="visible"){
			scrollObj1.style.visibility="visible";
			initOpacity(scrollObj1);
		}
		scrollObj1.childNodes[0].innerHTML=str;
		if(changePage > 2)
		changePage = -1;
		nowShowObj = scrollObj1;
		marqueeInterval[1]=setInterval("scrollMarquee(scrollObj1, scrollObj2)",40);
	}
	changePage++;
    }
function scrollMarquee(showObj, hideObj) {
	count++;
	setOpacitys(showObj, hideObj, (100/marqueeHeight)*count);
    if(count%marqueeHeight==(marqueeHeight-1)){
        clearInterval(marqueeInterval[1]);
		setOpacitys(showObj, hideObj, 100);
		count = 0;
		hideObj.style.visibility="hidden";
        }
    }
function setOpacitys(showObj, hideObj, opacity) {
	
	var object = showObj.style;
	if (navigator.userAgent.indexOf("Firefox") != -1) {
		if (opacity == 100) { opacity = 99.9999; } // This is majorly retarded
	}
	
	object.filter = "alpha(opacity=" + opacity + ")"; // IE/Win
	object.opacity = (opacity / 100);                 // Safari 1.2, Firefox+Mozilla

	var object1 = hideObj.style;
	if (navigator.userAgent.indexOf("Firefox") != -1) {
		if (opacity == 100) { opacity = 100-99.9999; } // This is majorly retarded
	}
	
	object1.filter = "alpha(opacity=" + (100-opacity) + ")"; // IE/Win
	object1.opacity = (100-opacity) / 100;  
}
function initOpacity(initObj){
	var object = initObj.style;
	object.filter = "alpha(opacity=" + 0 + ")"; // IE/Win
	object.opacity = 0;
}
function changeDivPos(bid1, bid2, par){
	var parentPos = findElementPos(document.getElementById(par));
	var scrollObj1 = document.getElementById(bid1);
	var scrollObj2 = document.getElementById(bid2);
	scrollObj1.style.top = parentPos[1];
	scrollObj1.style.left = parentPos[0];
	
	scrollObj2.style.top = parentPos[1];
	scrollObj2.style.left = parentPos[0];
}
function findElementPos(elemFind, par)
{
	var elemX = 0;
	var elemY = 0;
	do {
		elemX += elemFind.offsetLeft;
		elemY += elemFind.offsetTop;
	} while ( elemFind = elemFind.offsetParent )

	//console.log("Found element "+elemFind+" at "+elemY+"/"+elemX);
	return Array(elemX, elemY);
}
function showFixContent(dir){
	clearInterval(marqueeInterval[0]);
	if(dir){
		marqueeId++;
		if(marqueeId>=marqueeContent.length) marqueeId=0;
	}else{
		marqueeId--;
		if(marqueeId < 0)
			marqueeId = marqueeContent.length-1;
	}
	nowShowObj.childNodes[0].innerHTML=marqueeContent[marqueeId];
	marqueeInterval[0]=setInterval("startMarquee()",marqueeDelay);
}
//--------------------------------------

//层的移动
  
 var dragClickX,dragClickY;

  
 function catchFlyBar(e){  
   
   
 var x=event.x+document.body.scrollLeft;  
   
 var y=event.y+document.body.scrollTop;  
   
 dragClickX=x-$('boardContent').style.pixelLeft;  
   
 dragClickY=y-$('boardContent').style.pixelTop;  
   
 //boardContent.setCapture();  
   
 document.onmousemove = moveFlyBar;  
   
 }  
  
 function releaseFlyBar(e){  
   

 document.onmousemove = null;  
   
 }  
   
 function moveFlyBar(e){  
   
   
  $('boardContent').style.left = event.x+document.body.scrollLeft-dragClickX;  
   
  $('boardContent').style.top = event.y+document.body.scrollTop-dragClickY;  
   
   
 }  
//----------------------------------
//销售网络层替换
function show_div_sales(id,count){
	for(i=1;i<=count;i++){
		document.getElementById("sales_"+i).style.display="none";
	}
	document.getElementById("sales_"+id).style.display="";
}
//-----------------------------------
