jQuery(document).ready(function($) {
	$('a[rel*=facebox]').facebox()
}) 
$(document).bind('beforeReveal.facebox', function(){$('select').hide()}) 
$(document).bind('close.facebox', function(){$('select').show()}) 

function sendlink() {
	var cname=$('#txtname').val()	
	var curl=$('#txturl').val()
	var ctel=$('#txttel').val()
	var cqq=$('#txtqq').val()
	
	if (cname=='' || curl=='' || ctel=='' || cqq=='') {
		alert('表单验证失败,请填写完整.')
	} else {
		$.ajax({
			   type: 'POST',
			   url: 'run.php',
			   data: 'type=6&cname='+cname+'&curl='+curl+'&ctel='+ctel+'&cqq='+cqq,
			   success: function(omsg) {
				   alert(omsg)
			   }
		})		
	}
}

function order_add() {
	var cname,cmail,ctel,cdt,ctime,ccon
	cname=$('#txtname').val()
	cmail=$('#txtmail').val()
	ctel=$('#txttel').val()
	ctype=$('#txtdt').val()
	ctime=$('#txttime').val()
	ccon=$('#txtcon').val()

	if (cname=='' || notMail(cmail) || notMobile(ctel) || notDate(ctime) || ccon=='' || ctype==0) {
		alert('表单验证失败,请填写完整.')
	} else {
		$.ajax({
			   type: 'POST',
			   url: 'run.php',
			   data: 'type=4&cname='+cname+'&cmail='+cmail+'&ctel='+ctel+'&ctime='+ctime+'&ccon='+ccon+'&ctype='+ctype,
			   success: function(omsg) {
				   alert(omsg)
				   window.location.reload()
			   }
		})		
	}
}

function order_reset() {
	$('#txtname').val('')
	$('#txtmail').val('')
	$('#txttel').val('')
	$('#txttime').val(new Date().getFullYear()+'-'+(new Date().getMonth()+1)+'-'+new Date().getDate())
	$('#txtcon').val('')
}

function gb_add() {
	var	cname,ccontent,ctype,ccode
	
	document.getElementById('txttype_0').checked?ctype=1:ctype=-1

	cname=$('#txtname').val()
	ccontent=$('#txtcon').val()
	ccode=$('#txtcode').val()
	
	if(cname=='' || ccontent=='' || ccode=='')
		alert('昵称,内容,验证码不能为空.')
	else {
		$.ajax({
			   type: 'POST',
			   url: 'run.php',
			   data: 'type=3&croot='+ctype+'&cname='+cname+'&ccontent='+ccontent+'&ccode='+ccode,
			   success: function(omsg) {
				   alert(omsg)
				   window.location.reload()
			   }
		})
	}
}

function gb_reset() {
	$('#txtname').val('')
	$('#txtcon').val('')
	$('#txtcode').val('')
}

function doctorlist_add(cid) {
	$.ajax({
		   type: 'POST',
		   url: 'run.php',
		   data: 'type=1&cid='+cid
	})
}

function storefrontlist_add(cid) {
	$.ajax({
		   type: 'POST',
		   url: 'run.php',
		   data: 'type=2&cid='+cid
	})
}

function find_doctor_list(){
	location.href='doctorlist_010'+$('#txttype').val()+'0'+$('#txtdt').val()+'0'+$('#txtsf').val()+'.html'
}

function stab(li){
	var tab=document.getElementsByName('tab')
	var content=document.getElementsByName('tabcontent')
	for(var i=0;i<tab.length;i++){
		tab[i].className='none'
		content[i].style.display='none'
		if(i==li){
			tab[i].className='select'
			content[i].style.display='block'
		}
	}
}

function clearnav() {
	var imgnj=document.getElementById('imgnj')
	var snli=document.getElementsByName('snli')
	imgnj.style.display='none'
	for(var j=0;j<snli.length;j++)snli[j].style.display='none'
}

var	navli
function njnav() {
	nav(navli)
}

function clearnjnav() {
	clearnav(navli)
}

function nav(li){
	if(typeof(li)=='undefined')return false
	navli=li
	var tab=document.getElementsByName('snav')
	var nj=document.getElementById('indexnj')
	var imgnj=document.getElementById('imgnj')
	var main=document.getElementById('indexsn')
	var snli=document.getElementsByName('snli')
	
	for(var j=0;j<snli.length;j++)snli[j].style.display='block'
	for(var i=0;i<tab.length;i++){
		tab[i].style.display='none'
		if(i==li){
			imgnj.style.display='block'
			switch(i){
				case 1:
					imgnj.style.marginLeft='70px'
					main.style.left='240px'
					break
				case 2:
					imgnj.style.marginLeft='155px'
					main.style.left='352px'
					break
				case 3:
					imgnj.style.marginLeft='230px'
					main.style.left='338px'
					break
				case 4:
					imgnj.style.marginLeft='304px'
					main.style.left='240px'
					break
				case 5:
					imgnj.style.marginLeft='379px'
					main.style.left='480px'
					break
				case 6:
					imgnj.style.marginLeft='454px'
					main.style.left='555px'
					break;
				default:
					imgnj.style.display='none'
					for(var j=0;j<snli.length;j++)snli[j].style.display='none'
			}
			
			tab[i].style.display='block'
		}
	}
}

function notDate(date) {
	var reg=/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})/
	if (reg.test(date)) {
		return false
	} else {
		alert('日期填写错误.')
		return true
	}
}

function notMail(mail) {
	var reg=/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/
	if (reg.test(mail)) {
		return false
	} else {
		alert('邮箱填写错误.')
		return true
	}
}

function notMobile(mobile){
	 var reg0=/^13\d{9}$/   //130--139。至少7位
	 var reg1=/^15\d{9}$/   //150--159。至少7位
	 var reg2=/^18\d{9}$/   //180--189。至少7位
	 var my=false
	 if (reg0.test(mobile))my=true
	 if (reg1.test(mobile))my=true
	 if (reg2.test(mobile))my=true
	 if (!my){
		alert('手机填写错误.')
		return true
	 }else{
		return false
	 }
}

function setWebSite(obj) {
	if (obj.value != '') location.href = obj.value
}
