// JavaScript Document
//Modified by atom
//2009-2-3

//Clean the cache
$.ajaxSetup ({
    cache: false 
});
$(window).scroll(function () {
	currentScrollTop = $(window).scrollTop(); 
	if (200< currentScrollTop ){
		$("#simplified_out").fadeIn();
	}else{
		$("#simplified_out").fadeOut();
	}
});
function imgFunction(){
	var left = document.getElementById("imgCache").offsetLeft;
	var top = document.getElementById("imgCache").offsetTop;
	var imgs=document.getElementById("hotornot_a1_xin");
	imgs.style.position='absolute';
	//imgs.style.background='../images/hotornot_xin_one.png';
	imgs.style.top=top-5+'px';
	imgs.style.left=left-40+'px';
	imgs.style.display='block';
	//var left=getElementLeft(this);
	//var top=getElementTop(this);
	//var width=this.offsetWidth;
	//var height=this.offsetHeight;

}
//meet_me
function load_meet(id){
    $("#login").html('');
	$.fn.skygqbox.Default = {
		title		: "聯絡我",
		shut		: "×",
		index		: 2000,
		opacity		: 1,
		width		: "570",
		height		: "325",
		autoClose	: 0,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "middle"
	};
		$.ajax({
				type: "post",
				url:  "pop_meet.php?id="+id,
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;數據載入中，請稍侯...</font>');
				},
				success: function(html){
					
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
				},
				error: function(){
				}
			}); 
	$('#login').skygqbox();
}
function close_meet()
{
	$.skygqbox.hide();
}
function contact_me(id){
	$.ajax({
			  type: "post",
			  url: "function/add_contact_me.php",
			  data: "id="+id,
			  cache: false,
			  beforeSend: function(XMLHttpRequest){
					//$("#get_pwd_status").html('系統處理中....');
					//$("#get_pwd").attr("disabled",true); 
					},
			  success: function(html){
				var myHtml = eval('(' + html + ')'); 
				 if(myHtml['result']=='ok')
				 {
					
				 }
				 if(myHtml['result']=='scoreerror'){
					alert(myHtml['message']);
				 }
				 if(myHtml['result']=='scoreok'){
					var socet = $('.main_body_left_loginin_points span').text();
					var newSocet = socet-1;
					$('.main_body_left_loginin_points span').text(newSocet);
					//alert(myHtml['message']);
					window.location.href=myHtml['url'];
				 }
				 if(myHtml['result']=='error'){
					load_login();
				 }
				 //else
				// {
					//如果未登录则弹出登录界面
					// load_login();
				 //}
				
			  },
			  complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
			  },
			  error: function(){
				//	alert("error");
					}
			
			}); 	
}
//模拟回车键--用户登录
function LoginKeyDown(){
 if (event.keyCode == 13){
	 event.returnValue=false;  //不刷新界面
     //document.form1.loginsubmit.click(); //使用表单提交
     Js_userloginlocal();
	 }
}

//模拟回车键提交注册
function quick_user_reg(evt){
   evt = (evt) ? evt : ((window.event) ? window.event : "") //兼容IE和Firefox获得keyBoardEvent对象
	var key = evt.keyCode?evt.keyCode:evt.which; //兼容IE和Firefox获得keyBoardEvent对象的键值
	if(key == 13){ //判断是否是回车事件。
	//根据需要执行某种操作。
	user_reg();
	return false;   //return false是为了停止表单提交，如果return true或者不写的话，表单照样是会提交的。
	   }
}

//模拟回车键提交登录
function quick_user_login(evt){
   evt = (evt) ? evt : ((window.event) ? window.event : "") //兼容IE和Firefox获得keyBoardEvent对象
	var key = evt.keyCode?evt.keyCode:evt.which; //兼容IE和Firefox获得keyBoardEvent对象的键值
	if(key == 13){ //判断是否是回车事件。
	//根据需要执行某种操作。
	user_login();
	return false;   //return false是为了停止表单提交，如果return true或者不写的话，表单照样是会提交的。
	   }
}

//模拟回车键提交找回密码
function quick_get_pwd(evt){
   evt = (evt) ? evt : ((window.event) ? window.event : "") //兼容IE和Firefox获得keyBoardEvent对象
	var key = evt.keyCode?evt.keyCode:evt.which; //兼容IE和Firefox获得keyBoardEvent对象的键值
	if(key == 13){ //判断是否是回车事件。
	//根据需要执行某种操作。
	get_pwd();
	return false;   //return false是为了停止表单提交，如果return true或者不写的话，表单照样是会提交的。
	   }
}

//模拟回车键提交删除账户
function quick_delete_account(evt){
   evt = (evt) ? evt : ((window.event) ? window.event : "") //兼容IE和Firefox获得keyBoardEvent对象
	var key = evt.keyCode?evt.keyCode:evt.which; //兼容IE和Firefox获得keyBoardEvent对象的键值
	if(key == 13){ //判断是否是回车事件。
	//根据需要执行某种操作。
	delete_account();
	return false;   //return false是为了停止表单提交，如果return true或者不写的话，表单照样是会提交的。
	   }
}






//新版的js





//搜索返回 
function do_search(){

	var keywords = $("#keywords").val();
	if(keywords=='')
	{
		alert('請輸入關鍵字');
		return false;
		}
	else
	{
		document.forms['search'].submit();
		}	
    

   
}



//载入登录界面
function load_login(pid){
	window.scrollTo(0,0);

	//alert("登录界面");
	$.fn.skygqbox.Default = {
		title		: "登錄",
		shut		: "×",
		index		: 2000,
		opacity		: 1,
		width		: "517",
		height		: "1",
		
		autoClose	: 0,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "top_middle"
	};
	
	$.ajax({
				type: "post",
				url:  "get_login.php?pid="+pid,
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;數據載入中，請稍侯...</font>');
				},
				success: function(html){
					
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
				//	alert("error");
				}
			}); 
	$('#login').skygqbox();
}
function close_login()
{
	//alert("asdasd");
	$.skygqbox.hide();
	}
	
	

//登录提交
function user_login(pid)
{
	
	var login_username = $("#login_username").val();
	var login_password = $("#login_password").val();
	var rem_pwd = 0;
	
	//var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	if(login_username=='')
	{	
	alert('請輸入使用者名稱或信箱');
	
	 return false;
	}
	
	//验证密码
	if(login_password=='')
	{	
	
	  alert('請輸入密碼');
	   return false;
	   //$("#login_button").attr("disabled",true);
	
	}
	if($("#remember_password").attr("checked")==undefined) 
	{
		rem_pwd = 0;
		}
	else
	{
		rem_pwd = 1;
		}
	
   //异步登录
	
	 if(login_username!='' && login_password!='')
   {
	   
	   
  $.ajax({
  type: "get",
  url: "user_login.php",
  data: "email=" + login_username + "&pwd=" + login_password+ "&rem_pwd=" + rem_pwd,
  cache: false,
  beforeSend: function(XMLHttpRequest){
		//$("#login_status").val("登錄驗證中..."); 
		},
  success: function(html){
	  html = html.replace(/[\r\n]/g, "");
	
	   //$("#login_status").html(html+'<font color=green>恭喜！登陆成功</font>');
	if(html == "ok"){
	 
	  //$("#login_status").html('<font color=green>恭喜！登錄成功</font>');
	//  alert('恭喜！登錄成功');

	   location.reload() ;
		

	 // window.location.href="index.html";
	}
	
	if(html=="error"){
	 //$("#login_status").html('<font color=red>登錄失敗!用戶名或密碼錯誤,請重新輸入</font>'); 
	   alert('登入失敗!使用者名稱或密碼錯誤,請重新輸入');
	}
	
	
  },
  complete: function(XMLHttpRequest, textStatus){
		//$("#subbutton").val("Submit"); 
  },
  error: function(){
	//	alert("error");
		}

}); 
	   
	   
	   }
	
}



//注册密码验证 
function user_reg(){
	//提交前验证	

	
	if($("#register_rule").attr("checked")==undefined) 
	{
		alert('您必須先同意註冊協議，才可以繼續註冊');
		return false;
		}
	var share=1;	
	if($("#share").attr("checked")==undefined) 
	{
		
		share=0;
		}

		
	//check_regpassword();
	//验证完毕 提交
   var reg_username = $("#reg_username").val();
   var reg_email = $("#reg_email").val();
	var password = $("#password").val();
    var repassword = $("#repassword").val();
	var share = $("#share").val();
	var captcha = $("#captcha").val();
	
		var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	if(!myreg.test(reg_email))
	{	
	//$("#regusername_status").html('請輸入正確的郵箱');
	alert('請輸入正確的郵箱');
	//$("#reg_username").focus();
	//myreg.focus();
	 return false;
	}
	
		
	if(password==''  )
 {
	// $("#regpassword_status").html('請輸入密碼');
	 alert('請輸入密碼');
	 //$("#reg_password").focus();
	 return false;
	 }

 if(repassword==''  )
 {
	
	//$("#regpassword_status").html('請輸入確認密碼');
	  alert('請輸入確認密碼');
	 
	 //$("#reg_confirm_password").focus();
	 return false;
	 }
 if(repassword!=password  )
 {
	// alert('两次输入密码不一致，请重新输入');
	// $("#regpassword_status").html('兩次輸入密碼不一致，請重新輸入');
	 alert('兩次輸入密碼不一致，請重新輸入');
	// $("#reg_password").attr('value','');
	// $("#reg_confirm_password").attr('value','');
	// $("#reg_password").focus();

	 return false;
	 }
	if(reg_username.length<2 || reg_username.length>16)
	{
		alert('用戶名長度為2-16個字');
		 return false;
		
	}
	 

	$.ajax({
			  type: "get",
			  url: "user_register.php",
			  data: "reg_username=" + reg_username + "&reg_email=" + reg_email+ "&pwd=" + password+ "&share=" + share+ "&captcha=" + captcha,
			  cache: false,
			  beforeSend: function(XMLHttpRequest){
					//$("#register_status").val("數據處理中..."); 
					},
			  success: function(html){
				  html = html.replace(/[\r\n]/g, "");
				  // $("#register_status").html(html+'<font color=green>恭喜！注册成功</font>');
				   //$("#login_status").html(html+'<font color=green>恭喜！登陆成功</font>');
				if(html == "ok"){
				 
				 // $("#register_status").html('<font color=green>恭喜！註冊成功</font>');
				   alert('恭喜！註冊成功');
				   window.location.href="registration_step2.php";
				}
				
				else if(html=="hasbeen"){
					alert('郵箱已被佔用,請重新輸入');
				// $("#register_status").html('<font color=red>郵箱已被佔用,請重新輸入</font>'); 
				}
				
				else if(html=="unpass"){
					alert('密碼為空,請重新輸入');
				 //$("#register_status").html('<font color=red>密碼為空,請重新輸入</font>'); 
				}
				else
				{
				alert(html);	
					}
				
				
				
			  },
			  complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
			  },
			  error: function(){
					//alert("error");
					}
			
			}); 
	   

   
}

function get_pwd(){
	
	var reg_username=$("#login_username").val();
	if(reg_username=='')
	{
		alert('請輸入郵箱')
		return false;
		}
		$.ajax({
			  type: "post",
			  url: "get_pwd_success.php",
			  data: "email="+reg_username,
			  cache: false,
			  beforeSend: function(XMLHttpRequest){
					//$("#get_pwd_status").html('系統處理中....');
					//$("#get_pwd").attr("disabled",true); 
					},
			  success: function(html){
				  //html = html.replace(/[\r\n]/g, "");
				 if(html=='ok')
				 {
				 alert('操作成功,您的密碼已經發送至您的郵箱，請查收.');	
				 location.reload() ;
				 //$("#get_pwd_status").html('操作成功,您的密碼已經發送至您的郵箱，請查收.');
				 //$("#get_pwd").attr("disabled",true);
				 }
				 else
				 {
					 alert('操作失敗，請檢查您的郵箱是否正確.');
				// $("#get_pwd_status").html('操作失敗，請檢查您的郵箱是否正確.');
				// $("#get_pwd").attr("disabled",false); 
					 }
				   //$("#login_status").html(html+'<font color=green>恭喜！登陆成功</font>');
				  // alert('保存成功')
				  // window.location.href='index.php';
				
			  },
			  complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
			  },
			  error: function(){
				//	alert("error");
					}
			
			}); 

	

}

function add_comment(pid){
	
	var comment=$("#comment").val();
	var attachment=$("#attachment").val();

	if(comment=='')
	{
		alert('請輸入評論內容')
		return false;
		}
		$.ajax({
			  type: "post",
			  url: "function/add_comment_s.php",
			  data: "id="+pid+"&comment="+comment+"&attachment="+attachment,
			  cache: false,
			  beforeSend: function(XMLHttpRequest){
					//$("#get_pwd_status").html('系統處理中....');
					//$("#get_pwd").attr("disabled",true); 
					},
			  success: function(html){
				  //html = html.replace(/[\r\n]/g, "");
				var myHtml = eval('(' + html + ')'); 
				 if(myHtml['result']=='ok')
				 {
				// alert('操作成功,您的密碼已經發送至您的郵箱，請查收.');	 
				 // alert('操作成功,您的密碼已經發送至您的郵箱，請查收.');	 
				  //alert('評論提交成功，感謝您的參與');
				  //alert(myHtml['message']);
				  //location.reload() ;
				  //document.getElementById("comments").innerHTML = myHtml['message'];
				  $("#comments").prepend(myHtml['message']);
				 //$("#get_pwd").attr("disabled",true);
				 }
				 else
				 {
					 alert(myHtml['message']);
				// $("#get_pwd_status").html('操作失敗，請檢查您的郵箱是否正確.');
				// $("#get_pwd").attr("disabled",false); 
					 }
				   //$("#login_status").html(html+'<font color=green>恭喜！登陆成功</font>');
				  // alert('保存成功')
				  // window.location.href='index.php';
				
			  },
			  complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
			  },
			  error: function(){
				//	alert("error");
					}
			
			}); 

	

}

//载入注册界面
function load_notice(){

	//window.location.href='notice.php';
	$.fn.skygqbox.Default = {
		title		: "通告",
		shut		: "×",
		index		: 2000,
		opacity		: 1,
		width		: "960",
		height		: "582",
		autoClose	: 0,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "middle"
	};
	$.ajax({
				type: "post",
				url:  "notice.php",
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					//window.location.href='reg.php';
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
				//	alert("error");
				}
			}); 
	$('#login').skygqbox();
}



//新版新增 功能
function upload_img()
{
	var url=$("#url").val();
	var subject=$("#subject").val();
	$.ajax({
				type: "post",
				url:  "function/upload_img.php",
				data: "url="+url+"&subject="+subject ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					//$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					
					//window.location.href='reg.php';
					//$("#login").html(html);
					alert(html+'上传成功');
					
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
					//alert("error");
				}
			}); 
	
	
	}
function publish_replay(product_id,comment_id)
{

	var comment_replay=$("#replay_"+product_id+"_"+comment_id).val();
	var attachment_replay=$("#attachment_replay_"+comment_id).val();
	

	$.ajax({
				type: "post",
				url:  "function/add_comment_replay_s.php",
				data: "product_id="+product_id+"&comment_id="+comment_id+"&comment_replay="+comment_replay+"&attachment_replay="+attachment_replay ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					//$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					var myHtml = eval('(' + html + ')'); 
					//window.location.href='reg.php';
					//$("#login").html(html);
					if(myHtml['result']=='ok')
					{
					//alert(myHtml['message']);
					//alert('回覆發佈成功，謝謝參與')	;
					//location.reload() ;
						//var replays = 'replays_'+myHtml['insert_id'];
						//$("#"+replays).html(myHtml['message']);
						var replats_comment = 'replats_comment_'+myHtml['insert_id'];
						$("#"+replats_comment).append(myHtml['message']);
						
					}
					else
					{
						alert(myHtml['message']);
					}
					//alert(html+'评论发布成功');
					
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
					//alert("error");
				}
			}); 
	
	
	}
	
//载入注册界面
function load_reg(){
	//$.skygqbox.hide();
	//$.skygqbox.show();
	
    $("#login").html('');
	//window.location.href='notice.php';

	$.fn.skygqbox.Default = {
		title		: "通告",
		shut		: "×",
		index		: 2000,
		opacity		: 1,
		width		: "510",
		height		: "1",
		autoClose	: 0,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "top_middle"
	};
	$.ajax({
				type: "post",
				url:  "pop_reg.php",
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					//window.location.href='reg.php';
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
					//alert("error");
				}
			}); 
	$('#login').skygqbox();
}

//注册验证 -- 邮箱 
function check_email(){
	//验证邮箱
	var reg_email = $("#reg_email").val();
	var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	if(!myreg.test(reg_email))
	{	
		if(reg_email)
		{
	 $("#email_checkstatus").html('請輸入正確信箱'); 
		}
		else
		{
	$("#email_checkstatus").html('請輸入您的信箱'); 		
			}
	 $("#email_checkstatus").removeClass("input_note_right");//hide()
	 $("#email_checkstatus").addClass("input_note_err");//hide()
	}
	else
	{
		
	$.ajax({
			  type: "get",
			  url: "check_email.php",
			  data: "reg_email=" + reg_email,
			  cache: false,
			  beforeSend: function(XMLHttpRequest){
					//$("#email_checkstatus").html("數據處理中..."); 
					},
			  success: function(html){
				 
				   if(html=='ok')
				  {
					   $("#email_checkstatus").html(""); 
					   $("#email_checkstatus").addClass("input_note_right");//hide()
					  }
					 else
					 { 
				   $("#email_checkstatus").html(html); 
				   $("#email_checkstatus").removeClass("input_note_right");//hide()
				   $("#email_checkstatus").addClass("input_note_err");//hide()
					 }
				  				
			  },
			  complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
			  },
			  error: function(){
					//alert("error");
					}
			
			}); 
	}
}

//注册验证 - 用户名 
function check_username(){
	//验证邮箱
	var reg_username = $("#reg_username").val();
	
	if(reg_username.length>=2 && reg_username.length<=16 )
	{
	 
		
	$.ajax({
			  type: "get",
			  url: "check_username.php",
			  data: "reg_username=" + reg_username,
			  cache: false,
			  beforeSend: function(XMLHttpRequest){
					//$("#username_checkstatus").html("數據處理中..."); 
					},
			  success: function(html){
				  if(html=='ok')
				  {
					   $("#username_checkstatus").html(""); 
					   $("#username_checkstatus").addClass("input_note_right");//hide()
					  }
					 else
					 { 
				   $("#username_checkstatus").html(html); 
				   $("#username_checkstatus").removeClass("input_note_right");//hide()
				   $("#username_checkstatus").addClass("input_note_err");//hide()
					 }
			  },
			  complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
			  },
			  error: function(){
					//alert("error");
					}
			
			}); 
	}
	else
	{
	               $("#username_checkstatus").html('用戶名字數為2-16個字'); 
				   $("#username_checkstatus").removeClass("input_note_right");//hide()
				   $("#username_checkstatus").addClass("input_note_err");//hide()	
		}
}

//修改用户资料 - 用户基本信息 
function check_profile(){
	//验证邮箱
	var newpassword = $("#newpassword").val();
	var renewpassword = $("#renewpassword").val();
	var password = $("#password").val();
	if(newpassword!=renewpassword)
	{
		alert('新密码两次输入不一致');
		return false;
		}
		

}

function show_comments(id)
{
	
	 $('#img_'+id).css('opacity',0.9);
	 $('#edit_'+id).show();
	 $('#reply_'+id).show();
	//获取并显示第一条评论

	}
//隐藏投票条
function close_comments(id)
{
	$('#img_'+id).css('opacity',1.0);
	$('#edit_'+id).hide();
	 $('#reply_'+id).hide();
	}
	
function show_overlay()
{
	
	$('.content_list_left_img').css('opacity',0.9);
	//获取并显示第一条评论

	}
//隐藏投票条
function close_overlay()
{
	$('.content_list_left_img').css('opacity',1.0);
	
	}


function show_vote(id)
{
	//获取并显示投票数
	$.ajax({
			  type: "get",
			  url: "get_vote.php",
			  data: "item_id=" + id,
			  cache: false,
			  beforeSend: function(XMLHttpRequest){
					//$("#username_checkstatus").html("數據處理中..."); 
					},
			  success: function(html){
				 
				if(html != 'empty')
				{
					$(".box_feel_overlay").hide();
					$("#box_feel_overlay_"+id).html(html);
					
					$("#box_feel_overlay_"+id).show();
					
					}
				//  $("#username_checkstatus").html(html); 
				  				
			  },
			  complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
			  },
			  error: function(){
				//	alert("error");
					}
			
			}); 

	}
//隐藏投票条
function close_vote(id)
{
	//$("#box_feel_overlay_"+id).hide();
	$(".box_feel_overlay").hide();
	}
//显示上传图片层
function show_add_url()
{
	$("#add_url").show();
	}
//隐藏上传图片层
function close_add_url()
{
	
	$("#add_url").hide();
	}
//显示上传图片层
function show_upload_img()
{
	
	$("#upload_img").show();
	}
//显示上传图片层
function show_upload_img()
{
	
	$("#upload_img").show();
	}
//给隐藏域赋值
function upload_attachment()
{
	var attachment_tmp = $("#attachment_tmp").val();
	$("#attachment").attr('value',attachment_tmp);
	$("#upload_img").hide();
	}
//隐藏上传图片层
function close_upload_img()
{
	
	$("#upload_img").hide();
	}
//给隐藏域赋值
function add_attachment()
{
	var attachment_tmp = $("#attachment_tmp").val();
	$("#attachment").attr('value',attachment_tmp);
	$("#add_url").hide();
	}
//给隐藏域赋值
function show_replay(id)
{
	$("#commment_replay_"+id).show();
	}
//显示回复的上传图片
function add_url_replay(id)
{
	
	$("#add_url_"+id).show();
	}
//隐藏上传图片层
function close_add_url_replay(id)
{
	
	$("#add_url_"+id).hide();
	}
//显示回复的上传图片
function upload_img_replay(id)
{
	
	$("#upload_img_"+id).show();
	}
//隐藏上传图片层
function close_upload_img_replay(id)
{
	
	$("#upload_img_"+id).hide();
	}
//显示回复的上传图片
//给隐藏域赋值
function add_replay_attachment(id)
{
	var attachment_tmp = $("#attachment_tmp_"+id).val();
	
	$("#attachment_replay_"+id).attr('value',attachment_tmp);
	$("#add_url_"+id).hide();
	}
//隐藏评论
function hide_replay(id)
{
	
	
	$("#replay_"+id).hide();
	}
	
//载入注册界面
function load_delete_account(){
	//$.skygqbox.hide();
    $("#login").html('');
	//window.location.href='notice.php';
	$.fn.skygqbox.Default = {
		title		: "通告",
		shut		: "×",
		index		: 2000,
		opacity		: 1,
		width		: "517",
		height		: "1",
		autoClose	: 0,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "top_middle"
	};
	$.ajax({
				type: "post",
				url:  "pop_delete_account.php",
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					//window.location.href='reg.php';
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
				//	alert("error");
				}
			}); 
	$('#login').skygqbox();
}


//载入注册界面
function delete_account(){
	//$.skygqbox.hide();
  var login_username = $("#login_username").val();
  var login_password = $("#login_password").val();
  //alert(login_password);

	$.ajax({
				type: "post",
				url:  "delete_account.php",
				data:"email=" + login_username+"&pwd="+login_password,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					//$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					
					//return false;
					if(html=='ok')
					{
						window.location.href='index.php?tip=del_account_success';
					}
					else
					{
						alert(html);
						}
					//window.location.href='index.php?tip=del_success';
					//$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
				//	alert("error");
				}
			}); 

}

//账户已删除
function del_account_success()
{
	 $("#login").html('');
	//window.location.href='notice.php';
	$.fn.skygqbox.Default = {
		title		: "通告",
		shut		: "×",
		index		: 2000,
		opacity		: 0.0,
		width		: "178",
		height		: "1",
		autoClose	: 2000,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "top_middle_init"
	};
	$.ajax({
				type: "post",
				url:  "delete_account_success.php",
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					//window.location.href='reg.php';
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
					//alert("error");
				}
			}); 
	$('#login').skygqbox();
	}
	
//账户已删除
function reg_success()
{
	 $("#login").html('');
	//window.location.href='notice.php';
	$.fn.skygqbox.Default = {
		title		: "通告",
		shut		: "×",
		index		: 2000,
		opacity		: 0.0,
		width		: "800",
		height		: "1",
		autoClose	: 2000,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "top_middle"
	};
	$.ajax({
				type: "post",
				url:  "reg_success.php",
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					//window.location.href='reg.php';
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
				//	alert("error");
				}
			}); 
	$('#login').skygqbox();
	}
//账户已删除
function set_success()
{
	 $("#login").html('');
	//window.location.href='notice.php';
	$.fn.skygqbox.Default = {
		title		: "通告",
		shut		: "×",
		index		: 2000,
		opacity		: 0.0,
		width		: "320",
		height		: "1",
		autoClose	: 2000,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "top_middle_init"
	};
	$.ajax({
				type: "post",
				url:  "set_success.php",
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					//window.location.href='reg.php';
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
					//alert("error");
				}
			}); 
	$('#login').skygqbox();
	}
//显示子菜单
function show_my_menu()
{
	$("#my_menu").show();
	}
//显示子菜单
function hide_my_menu()
{
	$("#my_menu").hide();
	}

//显示子菜单
function show_cate_menu()
{
	$("#sys_cate").show();
	}
//显示子菜单
function hide_cate_menu()
{
	$("#sys_cate").hide();
	}
//显示子菜单
function show_vote_menu()
{
	$("#menu_nav_list_select2").show();
	}
//显示子菜单
function hide_vote_menu()
{
	$("#menu_nav_list_select2").hide();
	}

//显示子菜单
function show_sort_menu()
{
	$("#sort_menu").show();
	}
//显示子菜单
function hide_sort_menu()
{
	$("#sort_menu").hide();
	}
	
//显示子菜单
function show_time_menu()
{
	$("#time_menu").show();
	}
//显示子菜单
function hide_time_menu()
{
	$("#time_menu").hide();
	}
	
function pop_get_password()
{
	 $("#login").html('');
	//window.location.href='notice.php';
	$.fn.skygqbox.Default = {
		title		: "通告",
		shut		: "×",
		index		: 2000,
		opacity		: 0.8,
		width		: "506",
		height		: "1",
		autoClose	: 0,//弹出层等待多长时间自动关闭(单位：毫秒) 0或者负数不触发自动关闭
		position	: "top_middle"
	};
	$.ajax({
				type: "post",
				url:  "pop_get_password.php",
				data: "" ,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					//window.location.href='reg.php';
					$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
					//alert("error");
				}
			}); 
	$('#login').skygqbox();
	}

function change_img(id)
{
	var theImage = new Image(); 
	theImage.src = $( '#img_'+id).attr( "src"); 
	theImage.nowwidth = $( '#img_'+id).attr( "width"); 
	//alert( "Width: " + theImage.width); 
	//alert( "Height: " + theImage.height); 
	if(theImage.width>=500)
	{
		if(theImage.nowwidth=='250')
		{
			$( '#img_'+id).attr( "width",500);
			}
			else
			{
				$( '#img_'+id).attr( "width",250)
				}
		
		}
	if(theImage.width<500 && theImage.width>=250 )
	{
		if(theImage.nowwidth=='250')
		{
			$( '#img_'+id).attr( "width",theImage.width);
			}
			else
			{
				$( '#img_'+id).attr( "width",250)
				}
		
		}
	if(theImage.width<250)
	{
		if(theImage.nowwidth=='250')
		{
			$( '#img_'+id).attr( "width",theImage.width);
			}
			else
			{
				$( '#img_'+id).attr( "width",theImage.width)
				}
		
		}

	}
	
//载入注册界面
function send_invite_email(){
	//$.skygqbox.hide();
  var email_1 = $("#email_1").val();
  var email_2 = $("#email_2").val();
  var email_3 = $("#email_3").val();
  var email_4 = $("#email_4").val();
  var email_5 = $("#email_5").val();
  var email_content = $("#email_content").val();
  //alert(login_password);

	$.ajax({
				type: "post",
				url:  "send_invite_email.php",
				data:"email_1=" + email_1+"&email_2="+email_2+"&email_3="+email_3+"&email_4="+email_4+"&email_5="+email_5+"&email_content="+email_content,
				cache: false,
				beforeSend: function(XMLHttpRequest){
					//$("#login").html('<font style="color:#7C7C7C; font-size:12px;" >&nbsp;&nbsp;数据载入中，请稍后...</font>');
				},
				success: function(html){
					
					//return false;
					alert(html);
					//window.location.href='index.php?tip=del_success';
					//$("#login").html(html);
				},
				complete: function(XMLHttpRequest, textStatus){
					//$("#subbutton").val("Submit"); 
				},
				error: function(){
				//	alert("error");
				}
			}); 

}

// google analytics

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-18920745-8']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

//显示回复框
function reply_show(id){
	$('#reply_box_'+id).fadeIn(1000);
	var $container = $('#container');
    $container.imagesLoaded(function(){
      $container.masonry({
        itemSelector: '.main_body_right_content_box_div'
      });
    });
}

//添加评论
function reply_add(id){
	if($('#comment_'+id).val()==''){
		alert('評論不能為空');
	}else{
		$.post("function/add_comment.php", {id:id,comment: $('#comment_'+id).val()},
	   function(data){
		  if(data=='ok'){
			  reply_reload(id);
			  $('#comment_'+id).val("");
			}else{
				alert(data);
			}
	   });
	}
}


//重新加载评论
function reply_reload(id){
	$.post("function/get_comment_list.php", { item_id: id },
   function(data){
    $('#reply_list_'+id).html(data);
	$("#comment_count_"+id).load("function/get_vote_number_comment.php?item_id="+id); 
	$("#comment_num_"+id).html($("#comment_count_"+id).html());
	var $container = $('#container');
    $container.imagesLoaded(function(){
      $container.masonry({
        itemSelector: '.main_body_right_content_box_div'
      });
    });
   });
	
}

