﻿//图片服务器地址
var ImgServerURL = 'http://www.dajiankang.com';
//网站图片后缀名
var ImgExtendName = '.jpg';
//新闻图片连接地址
var NewsImgUrl='http://news.dajiankang.com/';
//货到付款默认配送方式ID
var SystemPostTypeID = 1;

String.prototype.padLeft=function(len,ch){   
    ch=typeof(ch)==='undefined'?' ':ch;   
    var s=String(this);   
    while(s.length<len)   
        s=ch+s;   
    return s;   
} 

//切换标签  cfx
var cur_index=1
var num=5 //该值记录标签的个数
var settime
function GetObj(objName){
	if(document.getElementById){
		return eval('document.getElementById("' + objName + '")');
	}else if(document.layers){
		return eval("document.layers['" + objName +"']");
	}else{
		return eval('document.all.' + objName);
	}
}
function change_Menu(index,con,m,s,menu){
	for(var i=1;i<=num;i++){/* 最多支持8个标签 */
		if(GetObj(con+i)&&GetObj("m"+i)){
			GetObj(con+i).style.display = 'none';
			GetObj(m+i).className = menu+i+"Off";
			GetObj(s+i).className = "";
			
		}
	}
	if(GetObj(con+index)&&GetObj(m+index)){
		GetObj(con+index).style.display = 'block';
		GetObj(m+index).className = menu+index+"On";
		GetObj(s+index).className = "whiteword";
		
	}
	cur_index=index
	if(cur_index<num){
	   cur_index++
	  }
	else{
	    cur_index=1
	  }
	//settime=setTimeout("change_Menu(cur_index)",5000)//设置延迟时间
		
}
function Menu(index,con,m,s){
 // clearTimeout(settime)
  change_Menu(c_index)
 }    


//验证Email格式
function ValidateEmail(source)
{
    var patrn=/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	return patrn.exec(source);
}

//验证为数字
function ValidateNum(source)
{
    var patrn=/^\d+$/;
    return patrn.exec(source);    
}

//验证手机
function ValidateMobileTel(source)
{
    var patrn=/^(13[0-9]|14[0-9]|15[0-9]|18[0-9])\d{8}$/;
	return patrn.exec(source);
}

//验证电话
function ValidateTel(source)
{
    var patrn=/^((\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{3,}))?$/;
	return patrn.exec(source);
}

//获取Url传过来的值
function Request(name)
{
   var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i");
   var r = window.location.search.substr(1).match(reg);
   if (r!=null) return unescape(r[2]); return null;
}

//数字补0
function pad(num, n) {
  return Array(n>num?(n-(''+num).length+1):0).join(0)+num;
}

//验证中文加数字组合
function ValidateChinese(source)
{
    var patrn =/^[\u4E00-\u9FA5|0-9]{1,}?$/;
    return patrn.exec(source);
}


//分页
function Pager(pageindx,row_count,pageSize)
{
    $("[name=Pagination]").pagination(row_count, {
        callback: pageselectCallback,
        prev_text: '«上一页',
        next_text: '下一页»',
        items_per_page:pageSize,
        num_display_entries:6,
        current_page:pageindx,
        num_edge_entries:2
    });
}

//分页
function Pagers(pageindx,row_count)
{
    $("#Pagination").pagination(row_count, {
        callback: pageselectCallback,
        prev_text: '«上一页',
        next_text: '下一页 »',
        items_per_page:20,
        num_display_entries:6,
        current_page:pageindx,
        num_edge_entries:2
    });
}
function Pagersnews(pageindx,row_count)
{
    $("#Pagination").pagination(row_count, {
        callback: pageselectCallback,
        prev_text: '«上一页',
        next_text: '下一页 »',
        items_per_page:1,
        num_display_entries:6,
        current_page:pageindx,
        num_edge_entries:2
    });
}


//商品购买 
function BuyProduct(PID)
{
    $.ajax({ 
        type: "POST", 
        url: "/ServiceManager/ShowMyCart.ashx", 
        data:"Command=BuyProduct&PID="+PID,
        error:function(){alert('BuyProduct Error...');}, 
        success: function(res) {
            if(res==1)
            {
                alert("商品已经成功加入购物车");
            } 
            else if(res==8)
            {
                alert("此商品为处方药，必须凭执业医师或执业助理医师处方才可调配、购买和使用的药品。");
            }
            else 
            {
                alert("购买失败");
            }
        }
    });
}
//购买积分商品
function BuyIntegralProduct(PID)
{
    $.ajax({ 
        type: "POST", 
        url: "/ServiceManager/ShowMyCart.ashx", 
        data:"Command=BuyIntegralProduct&PID="+PID,
        error:function(){alert('BuyProduct Error...');}, 
        success: function(res) {
            if(res==0){
                alert("商品已经成功加入购物车");
            } else if(res == 2){
                alert('您的积分不够购买此商品');
            } else if(res ==3){
                alert('您还尚未登陆');
            } else {
                alert("购买失败");
            }
        }
    });
}
//快速积分购买
function BuyIntegralProductFsat(PID)
{
    
}
//商品收藏
function CollectProduct(PName,PURL,ClassId)
{
 //alert(ClassId+PName+PURL);
     $.ajax({ 
        type: "POST", 
        url: "/ServiceManager/ShowMyCart.ashx", 
        data:"Command=CollectProduct&PName="+PName+"&PURL="+PURL+"&ClassId="+ClassId,
       
        error:function(){alert('CollectProduct Error...');}, 
        success: function(res) {
            if(res==2){
                alert('请先登录');
            } else if(res==1){
                alert('收藏失败');
            } else{
                alert("收藏成功");
            }
        }
    });
}
