// JavaScript Document
function initScroll(element){   //传入其中一个需要滚动的容器名称

	var brandNav = document.getElementById(element);
	var brandParent = brandNav.parentNode;
	//var brandParentHeight = parseInt(brandParent.offsetHeight);
	brandParent.style.overflow = 'hidden';
	brandParent.style.position = 'relative';
	brandNav.style.position = 'absolute';
	brandNav.style.top = 0 + 'px';
	var brandNavHeight = parseInt(brandNav.scrollHeight);// + parseInt(brandNav.scrollTop);
	var brandNavClone = brandNav.cloneNode(true);
	brandNavClone.style.top = brandNavHeight + 'px';
	if(!brandParent)return false;
	brandNavClone.setAttribute("id","brandNavClone");
	brandParent.appendChild(brandNavClone);
	var execScroll = function(){
			
		var temp_time = 0;
		var scrollHeight = 20;
		var calltime = null;
		var time = setInterval(function(){
			brandNav.style.top = parseInt(brandNav.style.top) - 1 + 'px';
			brandNavClone.style.top = parseInt(brandNavClone.style.top) - 1 + 'px';
			temp_time++ ;
			if(parseInt(brandNav.style.top)<-1*brandNavHeight){
				brandNav.style.top = brandNavHeight + 'px';
			}
			if(parseInt(brandNavClone.style.top)<-1*brandNavHeight){
				brandNavClone.style.top = brandNavHeight + 'px';
			}
			if(temp_time>=scrollHeight){
				clearInterval(time);
			}
		},30);
		setTimeout(arguments.callee,1000);
	}
	setTimeout(execScroll,3000);
}
function imagesZoom(className,H_W){
	/*var imagesBox = document.getElementsByName(element);
	var images = new Array;
	for(var i=0;i < imagesBox.length ; i++){
		imagesBox[i].onmouseover = execZoom;
	}*/
	var limitTL = $(".jcbox").offset();
	var limit = {top:limitTL.top,left:limitTL.left,height:$(".jcbox").height(),width:$(".jcbox").width()};
	var H_W = H_W?H_W:{w:300,h:400};
	var imageBox = null;
	$(className).each(function(index,itm){
		 	if($(".imageBox").size()==0){
				$(document.body).append("<div class=\"imageBox\" style=\"display:none;\"><a href=\"javascrpt:void(0);\" target=\"_blank\"><img src=\"../images/bg.png\" /></a></div>");
				imageBox = $(".imageBox");
				imageBox.mouseout(function(){$(this).hide();});
			}else{
				imageBox = $(".imageBox");	
			}
			$(this).hover(function(idx,ite){
				var obj = $(this).offset();
				$("img:first-child",imageBox).attr('src',$("img:first-child",this).attr('bimg'));
				H_W.w>0?$("img:first-child",imageBox).width(H_W.w):'';
				H_W.h>0?$("img:first-child",imageBox).width(H_W.h):'';
				$("a:first-child",imageBox).attr('href',$("a:first-child",this).attr('href'));
				//$("p:last-child",imageBox).html($("img:first-child",this).attr('words'));
				//$("p:last-child",imageBox).css({width:H_W.w});
				imageBox.css({'top':obj.top,'left':obj.left,'display':''});
			});
	});
}
	
function execZoom(e){
	var ev = e?e:window.event;
	var el = ev.srcElement?ev.srcElement:ev.target;
	var tag = el.nodeName;
	var newDiv = null;
	var newImg = null;
	var ZoomSize = {w:300,h:400};
	if(!document.getElementById('imageBox')){
		newDiv = document.createElement('div');
		newDiv.setAttribute('id','imageBox');
		newDiv.style.cssText = 'position:absolute;width:' + ZoomSize.w + 'px; border:#CCC solid 4px ;overflow:hidden;line-height:'+(ZoomSize.h)+'px;text-algin:center;z-index:10;';
		newImg = document.createElement('img');
		newImg.style.cssText = 'border:#EEE solid 2px;width:'+ZoomSize.w+'px; cursor:pointer;';
		newDiv.appendChild(newImg);
		newDiv.onmouseout = function(){newDiv.style.display='none';newImg.src='../images/bg.png';}
		document.body.appendChild(newDiv);
	}else{
		newDiv = document.getElementById('imageBox');
		newImg = newDiv.firstChild;
	}
		
	if(tag.toLowerCase() == 'img'&&el.getAttribute('bimg')!=null){
		newImg.setAttribute('src',el.getAttribute('bimg'));
		var obj = $(el).offset();
		newDiv.style.left = obj.left + 'px';
		newDiv.style.top =  obj.top + 'px';
		newDiv.style.display = 'block';
		if(!newImg.onclick)
			newImg.onclick = function(){location.href = el.parentNode.href;}
	}
}
function switchModel(element){
	$(".jc0").hover(function(){
		$(".jc0").removeClass("jc1");
		$(this).addClass("jc1");
		$(".jcbox").addClass("hide");
		$("#"+$(this).attr('name')).removeClass("hide");
	});
	$(".jc0").removeClass("jc1");
	$(".jc0:last-child").addClass('jc1');
	$(".jcbox").addClass("hide");
	$("#"+$(".jc0:last-child").attr('name')).removeClass("hide");
}
function switchObderby(){
		$(".phbg div").hover(function(){
			$(".phbg div").css('fontSize','12px');
			$(this).css('fontSize','14px');
			$(".phbox[id^=magtb]").hide();
			$("#"+$(this).attr('name')).show();
		});
}

function friendLink(){
	$("#friend_link").click(function(){
		if($("#friend").size()==0){
			$(document.body).html("<div id=\"friendLink\"><h1><span>X</span>申请友情链接</h1><ul><li>网站名称：</li><li>Aleax：</li><li>网站简介：</li><li>联系人：</li></ul></div>");
		}
		var limitTF = $(this).offset();
		var friendLink = $("#friendLink");
		friendLink.css({'top':limitTF.top,'left':limitTF.left,'display':''});
		return false;
	});
}
function getUrl(){
	$.post('pageReadOnlineCount.php',{url:document.referrer,rnd:Math.random()*1000},function(result){;});
}



function CreateXMLHttp(){
	try{ 
		xmlhttp = new XMLHttpRequest();
	} 
	catch (e){ 
		try{ 
			xmlhttp = new ActiveXObject( "Msxml2.XMLHTTP");
		} 
		catch (e){ 
			try{ 
				xmlhttp = new ActiveXObject( "Microsoft.XMLHTTP"); 
			} 
			catch (failed){ 
				xmlhttp = false; 
			} 
		} 
	} 
	return xmlhttp; 
}

function flur(element,len,category){
	len = len ? len : 4;
	$.get('/newapp/app.php',{action:'setp5',rnd:Math.random(),len:len,category:category},function(result){
		$(element).html(result);
	},'json');
}

function nav(num){
	num = num?num:0;
	$(".dhbox2 div[id^=top]").addClass('show0').removeClass("show1").css('backgroundImage','');
	$(".dhbox2 div[id^=top]").eq(num).addClass('show1').css('backgroundImage','url(/images/nav_'+num+'.gif)');
}
function today(id){
	var time = new Date();
	var year = time.getFullYear();
	var month = time.getMonth()+1;
	var day = time.getDate();
	document.getElementById(id).innerHTML = year+'年'+month+'月'+day+'日';
}
function checkEmail(obj){flag = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/.test(obj.value)?true:false;if(flag){return true;}else{var pos = $(obj).offset();$('#message h6').html('输入错误');$('#message p').html('请输入您的邮箱.');$("#message").css({left:pos.left,top:pos.top+$(obj).outerHeight(),width:$(obj).outerWidth()-2});$("#message").show().fadeOut(3000);return false;}}