window.addEvent('domready', function(e){ }); function submit_comment(video_id){ if($('submit_comment')){ if(!valid_comment($("user_comment").value) || video_id == 'false'){ return false; }else{ var ajax_result = new Request({ url:'http://sugarandbruno.com/remote/videos.php', method: 'post', onComplete: function(response){ if(response == '1'){ $('comment_form_container').destroy(); location.href = location.href; return false; }else{ alert('Error'); return false; } } }).send('mode=comments&action=add&video_id=' + video_id + '&comment=' + $("user_comment").value); } } } function valid_comment(comment){ comment = comment.replace(/^[ \t]+|[ \t]+$/, ""); comment = comment.replace(/\s(\s)+/g, " "); $("user_comment").value = comment; if($("user_comment").value.length < 10){ $("comment_submit_feedback").setStyle("display", "block"); $("comment_submit_feedback").highlight(); $("comment_submit_feedback").innerHTML = "Your comment must be at least 10 characters long"; return false; } if($("user_comment").value == "Comment or testimony here."){ $("comment_submit_feedback").setStyle("display", "block"); $("comment_submit_feedback").highlight(); $("comment_submit_feedback").innerHTML = "Please enter a comment!"; return false; } return true; } function validate_youtube_url(str, protocol){ if(!protocol && protocol != ''){ protocol = '(http://)|(http://www.)|(www.)'; } protocol = protocol.replace(/\//g, '\/', protocol).replace(/\./g, '\.'); protocol = (protocol != '') ? '^(' + protocol + ')' : protocol; match_exp = new RegExp(protocol + 'youtube\.com\/(.+)(v=.+)', 'gi'); var matches = match_exp.exec(str); if(!matches || matches.length < 3){ return Array(false, 'Invalid URI', matches); }else{ var qs = matches[matches.length-1].split('&'); var vid = false; for(i=0; i