
function checkform()
{	
	if( document.getElementById("vName").value=="")
	{
		alert("没有填写姓名");document.getElementById("vName").focus();return false;
	}
	else if(document.getElementById("vMail").value=="")
	{
		alert("没有填写邮箱");document.getElementById("vMail").focus(); return false;
	}
	else if(document.getElementById("vTel").value=="")
	{
		 alert("没有填写电话");document.getElementById("vTel").focus();return false;
	}
	else if(document.getElementById("vCon").value=="")
	{
		 alert("没有填写类容");document.getElementById("vCon").focus();return false;
	}
	else
		{
			$.getJSON("http://163.foloda.com/homechild/HomePicCommentAdd.aspx?PhotoID="+PHOTOID+"&Cname="+document.getElementById("vName").value+"&Cemail="+document.getElementById("vMail").value+"&Ctel="+document.getElementById("vTel").value+"&Ccontent="+document.getElementById("vCon").value+"&format=json&jsoncallback=?",
			   function(data){
			   if(data.msg=="ok")
			   {
				alert( "提交成功！");
				}
				if(data.msg=="have")
				alert( "不要重复发一条信息！");
				CommentListLoad(1);
				resetC();
				});
		}
}

function CommentListLoad(num)
{
	 $.getJSON("http://163.foloda.com/homechild/HomeCommentListCut.aspx?PageNo="+num+"&photoID="+PHOTOID+"&PageName=HomeCommentList&format=json&jsoncallback=?",
            function(data)
            {
            document.getElementById("CommentList").innerHTML= data.pic;
            });
}

function resetC()
{
document.getElementById("vName").value="";
document.getElementById("vMail").value="";
document.getElementById("vTel").value="";
document.getElementById("vCon").value="";
}



//显示数据
$(document).ready(function()
{
   var cookieEnabled=(navigator.cookieEnabled)? true : false;
	if(!cookieEnabled)
	{
	   alert("你机器禁用了cookie!");
	    return false;
	}
});


function ShowVote(pid)
{
  //alert(pid);
  $.getJSON("http://163.foloda.com/jiaju/tuku/vote.aspx?type=add&format=json&jsoncallback=?&objectid="+pid,
  function(data){ 
  var key =data[0].key;
   document.getElementById(key).innerHTML=data[0].value;
  });

}



//投票
function Vote(num)
{
     var ID =num;
     var now=new Date(); 
     var pn=Math.random()*50;

       if(getCookie("PICLIB"+ID))
       {
          $.getJSON("http://163.foloda.com/jiaju/tuku/vote.aspx?objectid="+ID+"&type=add&P="+pn+"&format=json&jsoncallback=?",
            function(data)
            {   
                var Key=data[0].key;
                var Num=data[0].value;
		$("#"+Key).text(Num);  
                //document.getElementById(Key).innerHTML=data[0].value;     
                addCookie("PICLIB"+ID,now,30)
            });
        }
        else
        {
            alert("您已投过票!");
        } 
}



function addCookie(objName,objValue,objSecond){
var str = objName + "=" + escape(objValue);
if(objSecond > 0){
	var date = new Date();
	var ms = objSecond*60*1000;
	date.setTime(date.getTime() + ms);
	str += "; expires=" + date.toGMTString();
}
document.cookie = str;
//alert("添加cookie成功"+str);

}
				
function getCookie(objName){//获取指定名称的cookie的值
var arrStr = document.cookie.split("; ");

for(var i = 0;i < arrStr.length;i ++){
var temp = arrStr[i].split("=");
if(temp[0] == objName) return false;
} 
return true;
}

