function characterCounter(charNoBox, textFeild) {
	document.getElementById(charNoBox).value = document.getElementById(textFeild).value.length;
}

function VerifyComment(){
	var ErrorOcc = false;		
	var errorMsg ='';
	if (document.getElementById("Comment").value.length > 500){
		errorMsg += "\n\t Error: Comment Length Exceed to maximum length. Max length is 500 characters.";
	}
	if (document.getElementById("Comment").value.length < 5){
		errorMsg += "\n\t Error: Comment Minimum Length is 5 character.";
	}						
	if (document.getElementById("VisitorName").value.length < 4 || document.getElementById("VisitorName").value.length > 30 ){
		errorMsg +="\n\t Error: Please enter your Name.";				
	}
	if (document.getElementById("Email").value.length < 7 ){
		errorMsg +="\n\t Error: Please enter your Email, it will not be published.";				
	}
	if (errorMsg != ""){
		window.alert(errorMsg)
		return false;			
	}
	else return true;
}
function Send2Friend(sid)
{
	YAHOO.util.Dom.setStyle("SMS2Friend", "left", -1000);
	YAHOO.util.Dom.setStyle("SMS2Friend", "display", "");
	
	var x = YAHOO.util.Dom.getX("sid" + sid);
	x = x - YAHOO.util.Dom.get("SMS2Friend").clientWidth;
	YAHOO.util.Dom.setStyle("SMS2Friend", "left", x);
	
	var y = YAHOO.util.Dom.getY("sid" + sid);
	y = y - YAHOO.util.Dom.get("SMS2Friend").clientHeight / 2;
	YAHOO.util.Dom.setStyle("SMS2Friend", "top", y);
	iframe_obj = document.getElementById("ifr_SMS2Friend");
	iframe_obj.src = "/inc/email2friend.asp?SMSID="+sid;
}
function CloseTab()
{
	document.getElementById('SMS2Friend').style.display='none';
}

function AddToFavorites(){
if (document.all)
	window.external.AddFavorite(location.href, document.title);
else if (window.sidebar)
	window.sidebar.addPanel(document.title, location.href, "")
}

function copyTextToClipBoard(text){
    window.clipboardData.setData('Text', text);
}

function openwindow(url, width, height) {
  var win;
  var windowName;
  var params;
  windowName  = "features";
  params = "toolbar=0,";
  params += "location=0,";
  params += "directories=0,";
  params += "status=0,";
  params += "menubar=0,";
  params += "scrollbars=1,";
  params += "resizable=1,";
  params += "top=50,";
  params += "left=50,";
  params += "width="+width+",";
  params += "height="+height;
  win = window.open(url, windowName, params);
}

function DrillDown(id)	{
	var drillID = document.getElementById(id);	
	if (drillID.style.display == 'none')
		drillID.style.display = '';
	else
		drillID.style.display = 'none';
}

function textCounter(field, countfield, maxlimit) {
	if (field.value.length > maxlimit)
		field.value = field.value.substring(0, maxlimit);
	else
		countfield.value = maxlimit - field.value.length;
}
function CountWords (field_str, show_field) {
	show_word_count=1;
	show_char_count=0;
	var char_count = field_str.length;
	var fullStr = field_str + " ";
	fullStr = fullStr.replace(/\&\w+;/ig,"");
	var stripped = fullStr.replace(/(<([^>]+)>)/ig,"");
	var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
	var left_trimmedStr = stripped.replace(initial_whitespace_rExp, "");
	var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
	var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
	var splitString = cleanedStr.split(" ");
	var word_count = splitString.length -1;

	if (fullStr.length <2) { word_count = 0; }
	if (word_count == 1) { wordOrWords = " word"; } else { wordOrWords = " words"; }
	if (char_count == 1) { charOrChars = " character"; } else { charOrChars = " characters"; }
	if (show_word_count & show_char_count) { show_field.value= word_count + wordOrWords + "\n" + "    " + char_count + charOrChars; }
	else {
		if (show_word_count) { show_field.value= word_count + wordOrWords; }
		else { if (show_char_count) { show_field.value= char_count + charOrChars; } }
	}
	return word_count;
}
String.prototype.trim = function() {

 // skip leading and trailing whitespace
 // and return everything in between
  var x=this;
  x=x.replace(/^\s*(.*)/, "$1");
  x=x.replace(/(.*?)\s*$/, "$1");
  return x;
}