var SITE_PATH='/',PRE_FIX='zzz_';
function get_province(){var province=$("#Province").val();var id=$("#Province").find("option:selected").data('id');$.post(SITE_PATH+"form/?getjson",{'table':'region','col':'title,rid,telcode,zipcode','where':'pid='+id},function(result){$("#City").empty().append('<option value="" selected>请选择</option>');$("#District").empty();$.each(result,function(i,data){$("#City").append("<option value="+data.title+" data-id="+data.rid+" data-zip="+data.zipcode+" data-tel="+data.telcode+">"+data.title+"</option>");});},'json');}
function get_city(){var zip=$("#City").find("option:selected").data('zip');var tel=$("#City").find("option:selected").data('tel');var id=$("#City").find("option:selected").data('id');$("#zipcode").val(zip);$("#telcode").val(tel);$.post(SITE_PATH+"form/?getjson",{'table':'region','col':'title,pid,telcode,zipcode','where':'pid='+id},function(result){$("#District").empty().append('<option value="" selected>请选择</option>');$.each(result,function(i,data){$("#District").append("<option value="+data.title+" data-zip="+data.zipcode+" data-tel="+data.telcode+">"+data.title+"</option>");});},'json');}
function set_face(face){$.post(SITE_PATH+"form/?editface",{'face':face,'type':'json'},function(result){layer.alert(result.return_msg,function(index){location.href=result.return_url})},'json');}
function set_code(){var zip=$("#District").find("option:selected").data('zip');var tel=$("#District").find("option:selected").data('tel');$("#zipcode").val(zip);$("#telcode").val(tel);}
function writeClear(o){if(o.val().length>0){o.parent().addClass('write');}else{o.parent().removeClass('write');};btnCheck(o.parents('form'));}
function btnCheck(form){var btn=true;form.find('input.inp').each(function(){if($(this).hasClass('no-follow')){return;};if($(this).val().length==0){btn=false;}});if(btn){form.find('.btn').removeAttr("disabled").parent().addClass('ok');}else{form.find('.btn').attr("disabled",true).parent().removeClass('ok');}}
function set_sookie(_name,val,expires){var d=new Date();d.setDate(d.getDate()+expires);document.cookie=PRE_FIX+_name+"="+val+";path=/;expires="+d.toGMTString();}
function get_cookie(_name){var cookie=document.cookie;var arr=cookie.split("; ");for(var i=0;i<arr.length;i++){var newArr=arr[i].split("=");if(newArr[0]==PRE_FIX+_name){return newArr[1];}}}
function del_cookie(_name){var exp=new Date();exp.setTime(exp.getTime()-1);var cval=getCookie(_name);if(cval!=null)document.cookie=_name+"="+cval+"; path=/;expires="+exp.toGMTString();}
$(function(){changeCode();$("#SeedCode").click(function(){changeCode();});$('.input-del').click(function(){$(this).parent().removeClass('write').find('input').val('');btnCheck($(this).parents('form'));});});function changeCode(){var timenow=new Date().getTime();$('#SeedCode').attr('src',SITE_PATH+"inc/imgcode.php?"+timenow);}
function openurl(url,width,height){layer.open({type:2,title:false,maxmin:true,area:[width,height],content:url});}