// JavaScript Document
//城市
function getCity(thesub,value){
$.ajax({
url : "/ajax_php/get_city.php",
type : "POST",
dataType: "json",
data : "ID="+value,
success :function(jsonObj){
$("#" + thesub).children("option:gt(0)").remove();
for(k in jsonObj){
$("#" + thesub).append('');
}
}
});
}
//區域
function getArea(thesub,value){
$.ajax({
url : "/oper/oajax_php/get_area.php",
type : "POST",
dataType: "json",
data : "ID="+value,
success :function(jsonObj){
$("#" + thesub).children("option:gt(0)").remove();
for(k in jsonObj){
$("#" + thesub).append('');
}
}
});
}
//重新定位
function changLocate(this_1,this_2,top,left){
var span_top = this_1.offset().top;
var span_left = this_1.offset().left;
var span_width = this_1.width();
var span_height = this_1.height();
this_2.css({ 'position':'absolute',
'top':(span_top+top)+'px',
'left':(span_left+span_width+left)+'px'
});
}
//刪除資料
function delData(this_,value){
var ss = $(this_).text().split(",");
for( var i in ss){
if( ss[i] == value ){
ss.splice(i,1) ;
}
}
$(this_).text(ss.join(","));
}
$(document).ready(function(){
//=======================初始=======================//
//$(".member_modifytitle:not(:first)").next().hide();
//開合
$(".research_title").toggle(function(){
$(this).next().show();
$(this).attr("src","/member/images/i_arrow_up.png");
},function(){
$(this).next().hide();
$(this).attr("src","/member/images/i_arrow_d.png");
}
);
//=======================基本資料=======================//
$("#chang_password").toggle(function(){
$(this).after("
");
changLocate($(this),$("#password_content"),0,10);
$("#password_content").css({'background-color':'#fff',
'border':'1px solid #ccc',
'border-bottom-width':'3px',
'border-right-width':'2px',
'line-height':'32px',
'width':'250px',
'height':'100px',
'padding':'5px 10px 0px 10px'});
$("#password_content").append(" 舊 密 碼 :
新 密 碼 :
確認密碼 : ");
$("#send_pas").click(function(){
var error_str = "";
$("#password_content").children("input[type=password]").each(function(){
if( $(this).val() != "" ){
if( $(this).val().length < 6 ) {
error_str += $(this).attr("des") + " - 必須大於或等於六個字\n";
return false;
}
var number = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var string;
for(var i = 0;i <= $(this).val().length - 1;i++) {
string = $(this).val().substring(i,i + 1);
if(number.indexOf(string) == -1) {
$(this).css({"border-color":"#e60012"});
error_str += $(this).attr("des") + " - 只能輸入數字、大小寫英文字母\n";
}
}
}else{
$(this).css({"border-color":"#e60012"});
error_str += $(this).attr("des") + " - 必填\n";
}
});
if( error_str != "" ){
alert(error_str);
return false;
}
$.ajax({url : "/member/ajax/ajax_chang_pas.php",
data : "lo_pas="+$("#lo_pas").val()+"&new_pas="+$("#new_pas").val()+"&check_pas="+$("#check_pas").val(),
type : "POST",
success : function(html){
$("#password_content > input").css({"border-color":""});
if(html == "OK"){
alert("密碼修改成功")
$("#password_content").remove();
}else if(html == "CHECK"){
alert("請確認'新密碼'與'確認密碼'是否一樣");
$("#password_content").find("#new_pas ,#check_pas").css({"border-color":"#e60012"});
}else if(html == "ERROR"){
alert("舊密碼錯誤");
$("#password_content").find("#lo_pas").css({"border-color":"#e60012"});
}
}
});
});
},function(){
$("#password_content").remove();
}
);
//=======================關注主題=======================//
//新增
$(".Attention_Add").click(function(){
var add_keyword = $("#list").find("input[name=Attention_Name]").val();
if( add_keyword == "" )return false;
if($("#Attention_All").text() != "" ){
$("#Attention_Show").append(""+add_keyword+"
");
$("#Attention_All").append(","+add_keyword);
}else{
$("#Attention_Show").append(""+add_keyword+"
");
$("#Attention_All").append(add_keyword);
}
$("#list").find("input[name=Attention_Name]").val("");
});
//刪除
$(".del_attention_name").live("click",function(){
delData("#"+$(this).attr("thesub"),$(this).next().text());
$(this).parent().remove();
changLocate($("#Attention_Show").find(".Attention_name:last").find("a"),$("#Attention_Show").find(".Attention_name:last").find("span"),-10,-5);
});
//=======================能力與技巧=======================//
//新增
$(".Job_Add").click(function(){
var Job_Str = $(this).prev().val();
if( Job_Str == "" ) return false;
$(this).parents("li").find("ul").append(""+Job_Str+'');
if( $("#"+$(this).attr("thesub")).text() != "" ){
$("#"+$(this).attr("thesub")).append(","+Job_Str);
}else{
$("#"+$(this).attr("thesub")).append(Job_Str);
}
$(this).prev().val("");
});
//刪除
$(".del_job_name").live("click",function(){
delData("#"+$(this).attr("thesub"),$(this).next().text());
$(this).parent().remove();
});
//=======================聯絡資訊=======================//
//城市
$("#Country_ID").change(function(){
var next_type = $(this).children(":selected").attr("next_type");
if( next_type == "是" ){
$("#CA_Data").show();
getCity($(this).attr("thesub"),$(this).val());
}else{
$("#CA_Data").hide();
}
});
$("#Main_Form").form_check();
$("#modify_send").click(function(){$("#Main_Form").submit();})
});