// JavaScript Document
function onClickSendComment(pid,uid,ip,checkMeUp){
	
	if (document.getElementById('myComment').value == 'Start typing...' || document.getElementById('myComment').value == '')
	{
		document.getElementById('commentInfoBox').innerHTML = 'Please type your comment before hitting this button';	
	}else{
		if (document.getElementById('myComment').value.length > 1000)
		{
			document.getElementById('commentInfoBox').innerHTML = 'Your comment is too long, limit is 1000 characters.';
		}else{
			document.getElementById('commentInfoBox').innerHTML = 'Sending...';
			
			new Ajax.Request('process_comment.asp', {parameters:'pid='+pid+'&uid='+uid+'&ip='+ip+'&checkMeUp='+checkMeUp+'&comment='+escape(document.getElementById('myComment').value), onSuccess:onSuccesCommentSend, onFailure:errForward, onlyLatestOfClass: 'sendComment'});
				
		}
	}
	

	
}

function onSuccesCommentSend(t){
	
	var wordArray    = t.responseText.split('!-,-!\'');
	
	var resultCode = wordArray[0];
	var resultText = wordArray[1];
	
	if (wordArray[3]){
		var custId	= wordArray[3];	
	}
	
	if (resultText){
		document.getElementById('commentInfoBox').innerHTML = resultText;
	}
	
	if (document.getElementById('boxToCloseOnSuccess')){
		document.getElementById('boxToCloseOnSuccess').style.display = 'none';
	}
	
	if (document.getElementById('commentOnUsChoices')){
		
		document.getElementById('commentOnUsChoices').style.display = 'none';
		
	// This below part is important do not remove it from out of this function
		
		if ( resultCode == 'SUCCESS' && custId != null){	// If comment adding to the database was successfull
			// Go on and update db
			triggerWelcomePageTracking();
		}
	}


}

var errForward = function(t) {

	document.getElementById('commentInfoBox').innerHTML = t.responseText;
	
    <!--alert('Error ' + t.status + ' -- ' + t.statusText);-->

}

function welcomePageTracking(welcomePid,uid,act){
	
	new Ajax.Request('track_welcome.asp', {parameters:'wpid='+welcomePid+'&uid='+uid+'&act='+act, onSuccess:onSuccesWelcomeTrack, onFailure:errForward, onlyLatestOfClass: 'welcomeTrack'});
}



function onSuccesWelcomeTrack(t){
	
}
