﻿if(typeof($)=="undefined")
{
    $=function(id)
    {
        return document.getElementById(id);
    }
}  
function UserCommend()
{
    kg.Login("UpCommendPic.aspx","上传照片",0,130,false);
}

function CommendSelf(u)
{    
     var card = new UsePropCard("Commend.aspx?u="+escape(u),10020,1,function(){});
     card.CheckPropCard();
}
function HomeUpload()
{
    kg.Login("http://sdn.kugoo.com/link_1255.html?url=http://www.gouwo.com/UpHomePic.aspx","上传照片",0,150,false);
}
function homeCommend(u)
{
    var card = new UsePropCard("HomeCommend.aspx?u="+escape(u),10019,1,function(){});
    card.CheckPropCard();
}
function homeVote(id,n,flag)
{
    Http.get("uservote.aspx?id="+id+"&flag="+flag+"&n="+n+"&d="+escape(Date()),
    function(text)
    {
        if(text==1)
        {
             kg.Info('操作成功!',1000,0);           
        }
        else{eval(text);}
    },
    function(){kg.Alert('操作失败!',null,null,null,null,"error",false);}
    );
}
function SortVote(id,n,flag)
{
    Http.get("uservote.aspx?id="+id+"&flag="+flag+"&n="+n+"&d="+escape(Date()),
    function(text)
    {
        if(text==1)
        {
             kg.Info('操作成功!',1500,0);
             if(flag==1){$("v_"+id).innerHTML = parseInt($("v_"+id).innerHTML.replace(/(^\s*)|(\s*$)/g, ""))+1}
             else{$("vn_"+id).innerHTML =  parseInt($("vn_"+id).innerHTML.replace(/(^\s*)|(\s*$)/g, ""))+1}
        }
        else{eval(text);}
    },
    function(){kg.Alert('操作失败!',null,null,null,null,"error",false);}
    );
}

function ValidateTime(beginID,endID,ent)
{
    var begin = document.getElementById(beginID).value;
    var end =  document.getElementById(endID).value
    var b = new Date(begin.replace(/\-/g,"/"));
    var e = new Date(end.replace(/\-/g,"/")); 
    var self = this;           
    if(begin==''||end=='')
    {
        kg.Alert('请指定查询的时间!',null,null,null,null,"error",false);       
        StopEvent(ent);
        return;
    }
    if(b>e)
    {
        kg.Alert('开始日期必须小于或等于结束日期!',null,null,null,null,"error",false);
        StopEvent(ent);   
        return;
    }
}
 function StopEvent (ent)
{
    var e = ent||window.event;    
    if (e.preventDefault) 
    {
      e.preventDefault();
      e.stopPropagation();
    } 
    else 
    {
      e.returnValue = false;
      e.cancelBubble = true;
    }
}


function JoinFamily(o,fid,fname)
{
     o.disabled = true;
     Http.get("joinFamily.aspx?fid="+fid+"&fname="+escape(fname)+"&d="+escape(Date()),
     function(restxt)
     {
        eval(restxt); 
        o.disabled = false;      
     },
     function(){kg.Alert('操作失败!',null,null,null,null,"error",false);o.disabled = false;}
     );
}
function ExitFamily(o,fid,msg,aid)
{
      o.disabled = true;
    kg.Confirm(msg,null,
        function()
        {
            Http.get("exitFamily.aspx?fid="+fid+"&aid="+aid+"&d="+escape(Date()),
             function(restxt)
             {
                eval(restxt);
                location.reload();    
             }, function(){kg.Alert('操作失败!',null,null,null,null,"error",false);});
        },function(){o.disabled = false;},null,null,null,"why",null);
        o.disabled = false;
}

 function FamilyAction(o,fid,type,msg)
 {
     o.disabled = true;
    kg.Confirm(msg,null,
        function()
        {
            Http.get("familyaction.aspx?fid="+fid+"&type="+type+"&d="+escape(Date()),
             function(restxt)
             {
                eval(restxt);
                if(type==1){top.location.reload();}
             }, function(){kg.Alert('操作失败!',null,null,null,null,"error",false);});
        },function(){o.disabled = false;},null,null,null,"why",null);
        o.disabled = false;
 }

 function validate(o,reg){
     if(new RegExp(reg).test(o.value))
     {  return true;}
    else
     {  return false;}
   }

function ShowGoldCount(o)
{
    $('changeGold').innerHTML=o.value*100;
}
function Validate(o)
{ 
    var reg = /^\d+\.\d{1,2}$/;
    if(!reg.test(o.value))
    {
       o.value = o.value.replace(reg,"");
    }    
}

function GotoWo(id)
{
    var cookie = new Cookie();  
    cookie.get("gouwo")!=null?window.open("wo?id="+id,"_blank"):kg.Blank('user/new_login.aspx',400,420);
}