var canSub = true;
function TexFocus(o){
	if ('Please enter your comments'==o.value) o.value='';
	if('block'!=$('code_pic').style.display){ 
		$('code_pic').src='/include/validateimg.php';
		$('code_pic').style.display='block';
	}
}
function submitForm(e) {
	try{
		e = e ? e : window.event;
		if(e.ctrlKey&&e.keyCode==13)
		return true;
	}catch(e){}
	return false
} 		
function commSubmit(form)
{
	if (!canSub)return false;
	if ('Please enter your comments' == $('comment_text').value)
	{
		$('comment_text').focus();
		return false;
	}
	if ($('comment_text').value.length > 600 || $('comment_text').value.length < 3)
	{
		alert("More letters please!");
		$('comment_text').focus();
		return false;
	}
	
	canSub = false;
	postfeeback();
}

//ajax load freeback list..
function loadfeeback(id,page){
	var URL = "/plus/ajax_feedback.php";
	var pars = 'arcID=' + id + '&nowpage='+page+'&action=show';
	new Ajax.Updater(
		{success: 'commentlist'},
		URL, {method: "get",parameters:pars}
	);	
}

//ajax submit data....
function postfeeback(){
	var opt = {
		method: 'post',
		postBody: 'action=send&arcID='+$('arcID').value
			+'&notuser=1&isconfirm=1&msg='+$('comment_text').value
			+'&username='+$('username').value,
		onSuccess: function(t) {
			$('ajaxBackMsg').update(t.responseText);
			loadfeeback($('arcID').value,1);
			canSub = true;
			$('comment_text').value = '';
			$('username').value = '';
			$('validate').value = 'hankjmatts@gmail.com';
			$('code_pic').src = '/include/validateimg.php?'+Math.random();
		},
		on404: function(t) {$('ajaxBackMsg').update('Error, Try it later please.')},
		onFailure: function(t) {$('ajaxBackMsg').update('Error, Try it later please.')}
	};
	new Ajax.Request("/plus/ajax_feedback.php", opt);
}

//ajax good and bad
function postGoodBad(i,a,d){
	var opt = {
		method: 'post',
		postBody: 'fid='+i+'&action='+a+'&arcID='+d,
		onSuccess: function(t) {$(i + 'span' + a).update(t.responseText)},
		on404: function(t) {},
		onFailure: function(t) {}
	};
	new Ajax.Request("/plus/ajax_feedback.php", opt);
}

