//头部导航JS文件

	var timer,timerB,timerC;//公用定时器
	<!---导航区左下拉菜单--->
	function PictureHide(id,zhuId){
		$('#'+id).hide();
		$('#'+zhuId).css("backgroundColor","#48AB0D");
		$('#'+zhuId).css("color","#ffffff");
	}
	function PictureShow(id,zhuId){
		clearInterval(timer);
		clearInterval(timerB);
		clearInterval(timerC);
		$('#'+id).show();
		$('#'+zhuId).css("backgroundColor","#ffffff");
		$('#'+zhuId).css("color","#000000");
	}
	<!--充值按纽-->
	function head_show(id){
		clearInterval(timer);
		$('#'+id).show();
	}
	function head_hide(id){
		$('#'+id).hide();
	}
	<!---导航区左标题-->
	function colorChangeOver(id,divId){
		clearInterval(timer);
		clearInterval(timerB);
		clearInterval(timerC);
		$('#head_div1').hide();
		$('#head_div2').hide();
		$('#head_div4').hide();
		$('#head_picture').hide();
		$('#head_money').hide();
		$('#daohang_div').hide();
		$('#head_index').css("backgroundColor","#48AB0D");
		$('#head_index').css("color","#ffffff");
		$('#head_file').css("backgroundColor","#48AB0D");
		$('#head_file').css("color","#ffffff");
		$('#Picture').css("backgroundColor","#48AB0D");
		$('#Picture').css("color","#ffffff");
		$('#head_source').css("backgroundColor","#48AB0D");
		$('#head_source').css("color","#ffffff");
		$('#'+id).css("backgroundColor","#ffffff");
		$('#'+id).css("color","#000000");
		$("#"+divId).show();
	}
	function colorChangeOut(id,divId){
		timerB=setTimeout("$('#"+id+"').css('backgroundColor','#48AB0D')",600);
		timerC=setTimeout("$('#"+id+"').css('color','#ffffff')",600);
		timer=setTimeout("$('#"+divId+"').hide()",600);
	}
	<!---充值下拉菜单--->
	function moneyOver(divId){
		clearInterval(timer);
		clearInterval(timerB);
		clearInterval(timerC);
		$('#head_index').css("backgroundColor","#48AB0D");
		$('#head_index').css("color","#ffffff");
		$('#head_file').css("backgroundColor","#48AB0D");
		$('#head_file').css("color","#ffffff");
		$('#Picture').css("backgroundColor","#48AB0D");
		$('#Picture').css("color","#ffffff");
		$('#head_source').css("backgroundColor","#48AB0D");
		$('#head_source').css("color","#ffffff");
		$('#head_div1').hide();
		$('#head_div2').hide();
		$('#head_div4').hide();
		$('#guanli_div').hide();
		$('#head_picture').hide();
		$('#head_money').hide();
		$('#'+divId).show()
	}
	function moneyOut(divId){
		timer=setTimeout("$('#"+divId+"').hide()",600);
	}
	//搜索函数
	function so(){
	clickCount(1301);
	var kw = $("#kw").val();
	kw = encodeURI(kw);    
	if(kw == ''){
		alert("请输入要查找的关键词");
		return false;
	}
	
	var r =  new Date();
		r = r.getTime();
        var url ="http://user.ooopic.com/dealtest.php?kw="+kw+"&r="+r+"&lx=keywordid&callback=?";
		$.getJSON(url,function(date){
			date = parseInt(date);
			
			if(date>0){
				location.href="http://so.ooopic.com/sousuo/"+date+"/";
			}else{
				location.href="http://so.ooopic.com/search-"+kw+"--______oo__.html";
			}
		});              
		
}

//点击统计


<!-----------搜索下拉文本框---------------->

function s_over(){
	$("#select_kid").addClass("h_19_hover");
}
function s_out(){
	$("#select_kid").removeClass("h_19_hover");
}
function s_click(){
	$("#select_kid2").toggle();	
}
function s_over2(id){

	$("#kid_"+id).addClass("h_22");
	
}
function s_out2(id){
	
	$("#kid_"+id).removeClass("h_22");
}
function s_click2(id){
	$("#select_kid").html(id);
	$("#select_kid2").hide();
	
}
function s_hide(){
	$("#select_kid2").hide();
}

    /*orderby*/
function o_click(){
	$("#selectorder2").toggle();	
}
function o_hide(){
	$("#selectorder2").hide();	
}
function order_over(){
	$("#selectorder").addClass("h_19_hover");
}
function order_out(){
	$("#selectorder").removeClass("h_19_hover");
}


function shoucang(id,title,picurl,xj){

	window.open('http://user.ooopic.com/index.php?com=show&action=picsc&id='+ id +'','','status=no,scrollbars=no,top=200,left=365,width=520,height=140')

}


var searchFocus = 0;
var searchfocus1 = 0;
$(document).ready(function(){
	
	$("#kw").focus(function() {
		Phfocus = false;
		searchfocus1 = false;
		searchFocus = true;
	}).blur( function() {
		searchFocus = false;
		Phfocus = false;
	});
	$("#kw1").focus(function() {
		searchfocus1 = true;
		
	}).blur( function() {
		searchfocus1 = false;
		
	});
	
	
 });

//关闭搜索提示
function keyup_close(){
	$("#keyup_d").hide();
	
}
//
function keyup_over(id){
	$("#u_"+id).css("background-color","#0000CC");$("#l_"+id).css("color","#fff");
}
function keyup_out(id){
	$("#u_"+id).css("background-color","#fff");$("#l_"+id).css("color","#000");
}
function keyup_click(id){
	$("#keyup_d").hide();
	var kw=$("#l_"+id).html();
	 kw = encodeURI(kw);    
	 var kid = 0;
	var kname=$("#select_kid").html();
	
	if(kw == ''){
		alert("请输入要查找的关键词");
		return false;
	}
	      
	var r =  new Date();
		r = r.getTime();
        var url ="http://user.ooopic.com/dealtest.php?kw="+kw+"&r="+r+"&lx=keywordid&callback=?";
		$.getJSON(url,function(date){
			date = parseInt(date);
			
			if(date>0&&kid==0){
				location.href="http://so.ooopic.com/sousuo/"+date+"/";
			}else{
				location.href="http://so.ooopic.com/search-"+kw+"-"+kid+"-______oo__.html";
			}
		});    
	
	location.href="http://so.ooopic.com/search-"+kw+"-"+kid+"-______oo__.html";
}


function keyup(event){
	if(window.event){
	var key =window.event.keyCode;
	}else{
	
	 var key =event.which;
	}

	if(key!=38&&key!=40&&key!=13){
	
		var kw=$("#kw").val();
		//跨域获取搜索提示
		var url ="http://user.ooopic.com/dealtest.php?kw="+kw+"&callback=?";
		$.getJSON(url,function(data){
			if (data!='') {
				$("#keyup_d").html(data+'<ul class="sokeyup_4"><li id="l_0" style="display:none;"></li><li class="sokeyup_5" onclick="keyup_close()">关闭</li></ul>');
				$("#keyup_d").show();
			} else {
				$("#keyup_d").hide();
			}
		}
	);
	}
}

var ul_id=0;
$(document).keydown(function(event){
	if(window.event){
		var key =window.event.keyCode;
	}else{
		 var key =event.which;
	}

	if (key==13) {
		if (searchFocus) {
			so();
			return false;
		} 
		if (searchfocus1) {
			so_search_new1();
			return false;
		} 
		
		
	}
	
	
	var ulcount=$("#keyup_d ul").size()-1;
	if($("#keyup_d").css("display")=="block"){
		//向上
		$("#l_0").html($("#kw").val());

		if (key==38) {
			ul_id--;
			if(ul_id<0){
				ul_id = ulcount;
				keyup_over(ul_id);
			}else{
				keyup_out(ul_id+1);
				keyup_over(ul_id);
			}
			
			$("#kw").val($("#l_"+ul_id).html());
			return false;
			
		}
		//向下
		if (key==40 ) {
			$("#l_0").html($("#kw").val());
			ul_id++;
			if(ul_id>ulcount){
				ul_id=0;
				keyup_out(ulcount);
			}else{
				keyup_out(ul_id-1);
				keyup_over(ul_id);
			}
			$("#kw").val($("#l_"+ul_id).html());
			return false;
		}
	}
});


		function so_search_new1(){
			var kw1 = $("#kw1").val();
			var kid1 = 0;

			
			var jvalue;
			$("input[type=radio]").each(function(){
					if(this.checked==true)
					jvalue = this;
					
			});
				
			var valradio = jvalue.value;
			
			if(valradio == 1){
				kid1 = 10;
			}else if(valradio == 2){
				kid1 = 6;
			}else if(valradio == 3){
				kid1 = 7;
			}else if (valradio == 4) {
				kid1 = 20;
			}else if (valradio == 5) {
				kid1 = 37;
			}
			
			if(kw1 == ''){
				alert("请输入要查找的关键词");
			}else{	
				kw1 = encodeURI(kw1);                      
				location.href="http://so.ooopic.com/search-"+kw1+"-"+kid1+"-______oo__.html";	   
			}	
		}




/*****登录框/管理框***
*	
*/

var m_s;//管理框interval
var l_s;//登录框interval
var e_s;//错误提示interval
var p_s;//充值框interval
var face = "";//用户头像
var xj ="";//用户星级

//登陆框html代码
var box_text = '<div id="login_box"></div><iframe id="dealframe" name="dealframe" style="display:none;"></iframe><div id="login_main" style="position:absolute;"><form name="loginform" method="post" action="" target="dealframe"><ul><li style="width:35px; float:right;"><img id="hide_login" onclick="hide_box(\'login_box\',\'login_main\',\'l_s\');" src="http://img.ooopic.cn/image/login_close.gif" title="隐藏登录窗口" style="cursor:pointer;" /></li><li style="margin-top:8px;"><b>用户名：</b><input class="login_input" maxlength="15" type="text" id="username_new" name="username_new" /></li><li><b>密&nbsp;&nbsp;码：</b><input class="login_input" type="password" id="password_new" name="password_new" /></li><li id="login_error" style="padding:0px; color:red; height:14px; line-height:14px; text-align:center;"></li><li style="padding:0px; height:1px; line-height:1px; font-size:1px; _margin-bottom:5px;"><img src="http://img.ooopic.cn/image/login_pad.gif" /></li><li><input type="submit" style="cursor:pointer;" value=" 登录 " onclick="check_login();" />&nbsp;&nbsp;<input type="radio" name="cookietime" value="8760" />永久<input type="radio" name="cookietime" value="720" checked="checked" />一个月<input type="radio" name="cookietime" value="24" />一天<input type="radio" name="cookietime" value="1" />一小时</li></ul></form></div>';

//管理框html代码
var m_text = '<div id="m_main" onmouseover="if (m_s) {clearTimeout(m_s);}" onmouseout="m_s = setTimeout(\'hide_box(\\\'m_box\\\',\\\'m_main\\\',\\\'m_s\\\')\', 500);" style="position:absolute;"><iframe id="m_box" src="http://www.ooopic.com/iframe/guanli.html" frameborder="0" scrolling="no" width="190" height="750" allowtransparency="true" style="display:none;"></iframe></div>';

//充值框html代码
var p_text = '<div id="p_main" onmouseover="if (p_s) {clearTimeout(p_s);}" onmouseout="p_s = setTimeout(\'hide_box(\\\'p_box\\\',\\\'p_main\\\',\\\'p_s\\\')\', 500);" style="position:absolute;"><iframe id="p_box" src="http://www.ooopic.com/iframe/chongzhi.html" frameborder="0" scrolling="no" width="110" height="auto" allowtransparency="true" style="display:none;"></iframe></div>';

function openSpace() {
	var space = "http://hi.ooopic.com/"+$("#login_username").html()+"/";
	window.open(space);
}

/**显示半透明边框box
*	bg_obj:半透明背景
*	main_obj:浮动层主体
*	p_obj:定位对象
*	top_offset:顶部偏移值
*	left_offset:左边偏移值
*/
function show_m(bg_obj,main_obj,p_obj,top_offset,left_offset) {
	initCSS();
	hide_box('','p_main','p_s');
	hide_box('','m_main','m_s');
	var top_p=0;   
	var left_p=0;
	top_box = $("#"+p_obj).offset().top + top_offset;//box顶部偏移
	left_box = $("#"+p_obj).offset().left + left_offset;//box左边偏移
	var m_main = $('#'+main_obj);//半透明浮动背景对象
	var m_box = $('#'+bg_obj);//iframe
	left_main = left_box;
	top_main = top_box;
	
	if (bg_obj == 'login_box') {
		top_main = top_box + 5;
		left_main = left_box + 5;
		//调整浮动层的位置
		m_box.css("filter","alpha(opacity=50)");
		m_box.css("opacity","0.5");
		m_box.css("z-index","10001");
		m_box.css("left",left_box + "px");
		m_box.css("top",top_box + "px"); 
		m_main.css("z-index","10001");
	}

	m_main.css("z-index","10001");
	m_main.css("left",left_main + "px");
	m_main.css("top",top_main + "px"); 
	
	//显示浮动层
	m_box.show();
	m_main.show();
}
/**隐藏box
*	box:半透明背景
*	main:层主体
*	interval:setTimeout()对象
*/
function hide_box(box,main,interval) {
	if (box != '') {
		$("#"+box).fadeOut(200);
	}
	$("#"+main).fadeOut(200);
	if (interval) {clearTimeout(interval);}
}

//错误提示隐藏
function hide_error() {
	$("#login_error").html("");
	if (e_s) {clearInterval(e_s);}
}

//表单验证
function check_login() {
	if (e_s) {clearInterval(e_s);}
	if (l_s) {clearInterval(l_s);}
	var username = $("#username_new").val();
	var password = $("#password_new").val();
	var cookietime = $('input[name=cookietime][checked]').val(); 
	if (username == '') {
		$("#login_error").html("用户名不能为空");
		e_s = setInterval("hide_error()", 1500);
		return;
	}
	if (password == '') {
		$("#login_error").html("密码不能为空");
		e_s = setInterval("hide_error()", 1500);
		return;
	}
	$("#login_error").html("登录中...");
	var url ="http://user.ooopic.com/user/login.php?action=login&username="+ username + "&password=" + password + "&cookietime=" + cookietime + "&callback=?";
	$.getJSON(url,function(data){
			if (e_s) {clearInterval(e_s);}
			if (l_s) {clearInterval(l_s);}
			$("#login_error").html(data);
			if ($.trim(data)=="登录成功") {
				//隐藏登录框
				l_s = setInterval("hide_box('login_box','login_main','l_s')", 400);
				e_s = setInterval("hide_error()", 1500);
				//获取用户信息
				var url ="http://user.ooopic.com/user/login.php?action=getUserInfo&callback=?";
				$.getJSON(url,function(data){
					var arr = data.split(",");
					if (arr!='') {
						face = arr[0];
						xj = arr[1];
						//生成登录后信息
						show_logsuc(username,face,xj);
					}
				});
			} else {
				e_s = setInterval("hide_error()", 1500);
			}
		}
	);
}

//登录成功提示信息
function show_logsuc(username,face,xj) {

	//顶部登录信息更新
	if ($("#loginstate")) {location.reload();}
	
	//错误提示清空
	if ($("#login_error")) {$("#login_error").html("");}
}

/**初始化box样式
*
*/
function initCSS() {
	//登陆框
	$("#login_box").css({
	"display":"none","width": "352px", "height": "132px", "padding":"5px", "margin":"0px auto", "background-color":"#000", "z-index":"10001", "clear":"both", "filter":"alpha(opacity=50)", "opacity":"0.5", "position":"absolute"});
	$("#login_main").css({"display":"none","width":"350px", "height": "122px", "background-color":"#FFFFFF", "border":"1px solid #4b4b4b", "line-height":"32px", "color":"#1a6c0a", "padding-bottom":"8px", "z-index":"10002", "overflow":"hidden"});
	$("#login_main li").css({"padding-left":"20px"});
	$(".login_input").css({
	"width":"204px", "height":"18px", "padding":"3px 3px 0px 3px", "margin-top":"3px", "border":"1px solid #b5b8c8"});
	
	//管理框、充值框
	$("#m_main,#p_main").css({"width": "auto", "height": "auto", "background-color":"transparent", "display":"none"});
}



//添加登陆框和管理框
document.write(box_text);
document.write(m_text);
document.write(p_text);
//初始化样式
initCSS();




/**cookie操作函数*/
//写cookies函数
function setCookie(name,value){//两个参数，一个是cookie的名子，一个是值
	var Days = 30;
	var exp  = new Date();
	exp.setTime(exp.getTime() + Days*24*60*60*1000);
	document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
//取cookies函数 
function getCookie(name) {       
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null){
		return unescape(arr[2]);
	}
	return null;
}
//删除cookie
function delCookie(name) {
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval=getCookie(name);
	if(cval!=null){
		document.cookie= name + "="+cval+";expires="+exp.toGMTString();
	}
}



//背景变灰
function body_hide(){
var de=document.compatMode=="CSS1Compat"?document.documentElement:document.body;
        if($("#layer1").size()>0) {
            $("#layer1").css("display","block");
        } else {
            var div=document.createElement("div");
            div.id="layer1";
            div.style.cssText="position:absolute;z-index:10001;top:0;left:0;opacity:0.5;filter:alpha(opacity=50);background:#000000";
            div.style.width=Math.max(de.offsetWidth,de.scrollWidth)+"px";
            div.style.height=Math.max(de.offsetHeight,de.scrollHeight)+"px";document.title=de.offsetHeight+"|"+de.scrollHeight;      
			document.body.appendChild(div);
	   }        
        
	
	}

function body_show(){
	$("#layer1").css("display","none");
}
//错误提示
function ooopic_error(){

	body_hide();
	

$("body").append('<div style="position:absolute;z-index:20000;opacity:0.5;filter:alpha(opacity=50);background:#000; width:570px; height:230px;" id="e_1"></div><div style="width:550px; height:210px; margin-left:10; margin-top:10px; background-color:#FFFFFF;position:absolute;z-index:20001;" id="e_2"><ul style="height:30px; line-height:30px; margin:0;"><li style="float:right; color:#FF0000; font-weight:bold; font-size:14px; height:30px; line-height:30px; padding-right:7px; cursor:pointer;" onclick="ooopic_error_r()">×</li></ul><ul><li style="float:left; width:200px; text-align:center;"><img src="http://img.ooopic.cn/image/icon_error.jpg"></li><li style="color:#1A6C0A; font-size:14px; font-weight:bold; line-height:30px; text-align:left; float:left;">此功能暂停使用!<br />我们会尽快恢复服务!<br/><span style="color:#000000; cursor:pointer; font-weight:bold; font-size:12px" onclick="ooopic_error_r()">返回上一步操作</span></li></ul></div>');
var hh=(screen.height-450)/2;
var ww=(screen.width-570)/2;
	
	
	$("#e_1").css("top",hh+document.documentElement.scrollTop);
	$("#e_1").css("left",ww);
	
	$("#e_2").css("top",hh+document.documentElement.scrollTop);
	$("#e_2").css("left",ww);

}
//错误返回操作
function ooopic_error_r(){
history.go(-1);
}

//信息提示
function hi_tip_show(t,h){
	if($("#hi_tip").size()>0){
		$("#hi_tip").show();
	}else{
		$("body").append('<div id="hi_tip"><li class="hi_tip_icon"> </li><li id="hi_tip_content"></li></div>');
		$("#hi_tip").show();
	}
	
	var hh=(screen.height-200)/2;
	var ww=(screen.width-300)/2;
	
	
	$("#hi_tip").css("top",hh+document.documentElement.scrollTop);
	$("#hi_tip").css("left",ww);
	
	
	$("#hi_tip_content").html(t);
	$("#hi_tip").show();
	if(h == 1){
		setTimeout("hi_tip_hide()", 1500);
	}
	
}
function hi_tip_hide(){
	$("#hi_tip").hide();	
}

//按钮点击统计
function clickCount(id) {
	var r = new Date();
	r = r.getTime();

	if (id == '') {
		return false;
	} else {
	var ajaxUrl = "/getzt.php?action=clickCount&btid="+id+"&r="+r+"";
	$.get(ajaxUrl,function(html){});
	}
}

/*返回顶部*/
$(document).ready(function(){
	$(".foot").prepend('<div class="back_top" id="back_top"><img src="http://img.ooopic.cn/image/backtop.gif" /></div>');
	$("#back_top").hide();
	function backTop(btnId){
		var btn=document.getElementById(btnId);
		var d=document.documentElement;
		window.onscroll=set;
		btn.onclick=function (){
			window.onscroll=null;
			this.timer=setInterval(function(){
				d.scrollTop-=Math.ceil(d.scrollTop);
				if(d.scrollTop==0) clearInterval(btn.timer,window.onscroll=set);
			},10);
			btn.style.display="none";
		};
		function set(){btn.style.display=d.scrollTop?'block':"none"}
	}
	backTop('back_top');
});
