﻿var commentLimit=parseInt(3000,10);function validateComment(frm){if(document.getElementById('wait').style.display=='block'){return false;}
var hold=frm.txtName;if(isBlanks(hold.value)){alert('Name is required');hold.focus();return false;}
hold=frm.txtEmail;if(isBlanks(hold.value)){alert('Email address is required');hold.focus();return false;}
else{if(hold.value.indexOf('<')!=-1||hold.value.indexOf('>')!=-1){alert('Invalid characters in email address');hold.select();return false;}
if(!isEmailValid(hold.value)){alert('Invalid email address');hold.select();return false;}}
hold=frm.txtWebSite;if(!isBlanks(hold.value)){if(hold.value.substr(0,7)!='http://'){hold.value='http://'+hold.value;}
else{if(hold.value.indexOf('.')==-1&&hold.value.indexOf('http://')==-1){alert('Please provide a valid web site address');hold.select();return false;}}
if(hold.value.indexOf('<')!=-1||hold.value.indexOf('>')!=-1){alert('Invalid characters in web site');hold.select();return false;}}
hold=frm.txtComments;if(isBlanks(hold.value)||hold.value=='Tell me what\'s up...'){alert('Enter your comments');hold.focus();return false;}
else{if(hold.value.length<5){alert('Your comments are far too short');hold.select();return false;}
if(hold.value.length>commentLimit){if(!confirm('Comments are limited to 3,000 characters and you have exceeded this limit.\n\nYour message is currently '+hold.value.length+' characters long.\n\nThe remaining characters will be truncated if you click OK.')){hold.focus();return false;}}}
hideElement('btnSendComments');showElement('wait');waitBar.displayBar();hold=null;return true;}
function updateLabel(txt){var lbl=document.getElementById('lblChars');if(txt.value.length>0){if(txt.value.length>999){if(txt.value.length>commentLimit)
lbl.innerHTML='<strong>all</strong>';else{var str=txt.value.length.toString();lbl.innerHTML=str.charAt(0)+','+str.substring(1);str=null;}}
else lbl.innerHTML=txt.value.length;} else lbl.innerHTML='none';lbl,txt=null;}
function scrollToFragment(){var frag=window.location.hash;if(frag!=null&&frag.length>1){var elem=document.getElementById(frag.substring(1));var posY=0;while(elem!=null){posY+=elem.offsetTop;elem=elem.offsetParent;}
posY=parseInt(posY,10);if(posY>0)
window.scrollTo(0,posY);}}
function commentsLoad(){var txtComments=document.getElementById('txtComments');var hypTrack=document.getElementById('hypTrack');var hasComments=false;if(!window.opera)
scrollToFragment();if(txtComments!=null){txtComments.onfocus=function(){if(this.value=='Tell me what\'s up...')
this.value='';}
txtComments.onblur=function(){updateLabel(this);if(this.value.length==0)
this.value='Tell me what\'s up...';}
txtComments.onkeyup=function(){updateLabel(this);}}
if(hypTrack!=null){hypTrack.onclick=function(){alert('If you don\'t know what a trackback is, Google it!');return false;}}
for(var i=0;i<10;i++){var elem=document.getElementById('comment'+i);if(elem!=null){hasComments=true;break;}}
if(!hasComments){var hypFeed=document.getElementById('hypFeed');if(hypFeed!=null){hypFeed.onclick=function(){alert('There are no comments yet. Therefore, a feed has not been generated.');return false;}}}}
addLoadEvent(commentsLoad);