/*------------------------------------------------------------
	网站通用javascript
	开发类库为jquery版本1.3.2
/*----------------------------函数js--------------------------------*/
/*-----------限制字数js--------------------------------*/

function LimistByte(idName,num)
{
	if($('#' + idName).val().length > num)
	{
		var ByteNum = $('#' + idName).val();
		$('#' + idName).val(ByteNum.substr(0, num));
	}
}

function LimistByteSendInfo(idName,num)
{
	if(num != 0)
	{
		if($('#' + idName).val().length > num)
		{
			var ByteNum = $('#' + idName).val();
			$('#' + idName).val(ByteNum.substr(0, num));
		}
	}
}

function dom(id) {
	return document.getElementById(id);
}

//缩小图片并添加链接
function resizeImg(id,size) {
	var theImages = dom(id).getElementsByTagName('img');
	
	for (i=0; i<theImages.length; i++) {		
		theImages[i].onload = function() {
			
			if (this.width > size) {
				this.style.width = size + 'px';
				if (this.parentNode.tagName.toLowerCase() != 'a') {
					var zoomDiv = document.createElement('div');
					this.parentNode.insertBefore(zoomDiv,this);
					zoomDiv.appendChild(this);
					zoomDiv.style.position = 'relative';
					zoomDiv.style.cursor = 'pointer';
					
					this.title = '点击图片，在新窗口显示原始尺寸';
					
					var zoom = document.createElement('img');
					zoom.src = '/images/zoom.gif';
					zoom.style.position = 'absolute';
					zoom.style.marginLeft = size -28 + 'px';
					zoom.style.marginTop = '5px';
					this.parentNode.insertBefore(zoom,this);
					
					zoomDiv.onmouseover = function() {
						zoom.src = '/images/zoom_h.gif';
					}
					zoomDiv.onmouseout = function() {
						zoom.src = '/images/zoom.gif';
					}
					zoomDiv.onclick = function() {
						window.open(this.childNodes[1].src);
					}
				}
			}
		}

		theImages[i].src = theImages[i].src;
	}

}
/*-----------首页模板展示滑入滑出效果js-------------------*/


function HoverLi(n){
	for(var i=1;i<=4;i++){
		$('#tb_'+i).attr('class','normaltab');
		$('#tbc_0'+i).attr('class','undis');
	}
	$('#tbc_0'+n).attr('class','dis');
	$('#tb_'+n).attr('class','hovertab');
}

/*获取页面宽与高*/
function getBodySize(){
   var bodySize = [];
   with(document.documentElement) {
    bodySize[0] = (scrollWidth>clientWidth)?scrollWidth:clientWidth;
    bodySize[1] = (scrollHeight>clientHeight)?scrollHeight:clientHeight;
   }
   return bodySize;
} 
/*显示隐藏*/
function dandushow(tag){	
	$('#'+tag).show(); 
}
function danduhide(tag){
	$('#'+tag).hide();
}
/*-------------显示登录框-----------------*/
function show(tag){	
	var bodySize = getBodySize();
    height = bodySize[1] + 'px';	
	$('#fade').css('height',height);
	$('#fade').show();
	$('#'+tag).show(); 
}
function hide(tag){
	$('#fade').hide();
	$('#'+tag).hide();
}
/*---------网站QQ客服--------*/
// 漂浮广告
var lastScrollY=0;
function FloatingAd(value)
{
	diffY=document.documentElement.scrollTop;
	percent=0.1*(diffY-lastScrollY); 
	if(percent>0)
	{
		percent=Math.ceil(percent);
	}
	else
	{
		percent=Math.floor(percent);
	}
	document.getElementById(value).style.top=parseInt(document.getElementById(value).style.top)+percent+"px";
	lastScrollY=lastScrollY+percent;
}

// 漂浮QQ
function FloatingQQ(value)
{
    if(value == "Show")
    {
        $("#FloatingQQLogo").hide();
	    $("#FloatingQQList").show();
	}
	else if(value == "Hide")
	{
	    $("#FloatingQQLogo").show();
	    $("#FloatingQQList").hide();
	}
}
/*----------首页下拉框特殊显示----------*/
/*function menuFix() {
	var sfEls = document.getElementById("yanse").getElementsByTagName("li");
	var sfEls2 = document.getElementById("industry").getElementsByTagName("li"); 
	var sfEls3 = document.getElementById("fengge").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls[i].onMouseDown=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls[i].onMouseUp=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");
		}
	} 
	for (var i=0; i<sfEls2.length; i++) {
		sfEls2[i].onmouseover=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls2[i].onMouseDown=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls2[i].onMouseUp=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls2[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");
		}
	}
	for (var i=0; i<sfEls3.length; i++) {
		sfEls3[i].onmouseover=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls3[i].onMouseDown=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls3[i].onMouseUp=function() {
			this.className+=(this.className.length>0? " ": "") + "sfhover";
		}
		sfEls3[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");
		}
	}
}*/

//正整数    
function isInteger (s) {   
    var reInteger = /^\d+$/   
    if (!reInteger.test(s) || parseInt(s,10)==0) return false;   
    return true  
}

function checkdomainsearform()
{
	var tc = 0;
	var resalert = '';
	if($("#domain").val() == '')	
	{		
		tc+=1;
		resalert += tc+'请输入域名'+'\n';
	}
	if(!arrname("suffix[]"))
	{
		tc+=1;
		resalert += tc+'请至少选择一个域名后缀名'+'\n';		
	}
	if(tc > 0)
	{
		alert(resalert);
		return false;	
	}
	return true;
}

function arrname(nam)
{
	var x=document.getElementsByName(nam);
	for(var i=0;i<x.length;i++)
	{
		if(x[i].checked)
		{
			return true;
		}
	}
	return false;
}

$(document).ready(function() {	
	//登录层的切换
	$("#dlfsuser").click(function(){					  
		$("#waytitle_login").html('登陆ID：');							  
	});	
	$("#dlfsemail").click(function(){
		$("#waytitle_login").html('邮箱名：');	
	});	
	//单独登录页的切换
	$("#dlfs_danuser").click(function(){					  
		$("#waytitle_danlogin").html('登陆ID：');							  
	});	
	$("#dlfs_danemail").click(function(){
		$("#waytitle_danlogin").html('邮箱名：');	
	});		
/*	if(way == 'user')
	{
		
	}else if(way == 'email'){
		$("#waytitle").html('邮箱地址：');	
	}	*/
	
	$('#i_01_menu0').hover(function () {
		$('#i_01_menucom0').show();
	  },function () {
		$('#i_01_menucom0').hide();
	  });
	
	$('#i_01_menu1').hover(function () {
		$('#i_01_menucom1').show();
	  },function () {
		$('#i_01_menucom1').hide();
	  });
	
	$('#i_01_menu2').hover(function () {
		$('#i_01_menucom2').show();
	  },function () {
		$('#i_01_menucom2').hide();
	  });
	
	$('#i_01_menucom0').hover(function () {
		$('#i_01_menucom0').show();
	  },function () {
		$('#i_01_menucom0').hide();
	  });
	
	$('#i_01_menucom1').hover(function () {
		$('#i_01_menucom1').show();
	  },function () {
		$('#i_01_menucom1').hide();
	  });
	
	$('#i_01_menucom2').hover(function () {
		$('#i_01_menucom2').show();
	  },function () {
		$('#i_01_menucom2').hide();
	  });
	  //鼠标移动到层上改变背景图
	$('.i_01_m').hover(function () {
		$(this).css("background-image","url(/templates/default/images/i_h_menu_bg.png)");
	  },function () {
		$(this).css("background-image","");
	 });
	$('.i_01ys_m').hover(function () {
		$(this).css("background-image","url(/templates/default/images/i_h_menuys_bg.png)");
	  },function () {
		$(this).css("background-image","");
	 });
}); 

function reloadcode(id){ 
	$('#'+id).attr('src','/codeimg.php?' + Math.random());
}

