// JavaScript Document文件
window.onload=createCode;
/*
function $(obj) {
	return document.getElementById(obj);
}
*/
var code ; 
function createCode() {      
	code = "";     
    var codeLength = 4;
    var checkCode = $("checkCode");     
    var selectChar = new Array(0,1,2,3,4,5,6,7,8,9,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
	for(var i=0;i<codeLength;i++) {      
    	var charIndex = Math.floor(Math.random()*36);     
        code +=selectChar[charIndex];                
    }  
    if(checkCode){     
        checkCode.className="code";     
         checkCode.value = code;     
    }      
}

function submitComment() { 
	if(!$('code').value && $('code').value != $('checkCode').value) {
		alert('验证码错误！');
		return false;
	}
	var target = 'ajax_comment';
	var url='../comment.php';
	var post_str = 'content='+$('comment_content').value+'&code='+$('code').value+'&checkcode='+$('checkCode').value+'&ii='+$('ii').value+'&tt='+$('tt').value+'&petname='+$('petname').value;
	
	$('code').value = $('petname').value = $('comment_content').value = '';
	getContentByPost(target,url,post_str);
}

function submitCmt(url,id) { 
	if(!$('code').value && $('code').value != $('checkCode').value) {
		alert('验证码错误！');
		return false;
	}
	var target = 'ajax_comment';
	var post_str = 'content='+$('cmt_content').value+'&code='+$('code').value+'&checkcode='+$('checkCode').value+'&id='+id+'&tt='+$('tt').value+'&petname='+$('petname').value;
	
	$('code').value = $('petname').value = $('cmt_content').value = '';
	getContentByPost(target,url,post_str);
}