function ButtonEffects(But,IsPushed) {
	if(IsPushed){
		But.style.cursor = 'pointer';
		But.style.backgroundPosition='0% 0%';
	} else {
		But.style.backgroundPosition='0% 100%';
	}
}
function ShowHide(obj,caller) {
   if(obj.style.display == 'none'){
     obj.style.display = 'block';
	 caller.innerHTML='<b><i>[?]</i></b>';
   } else {
     obj.style.display = 'none';
	 caller.innerHTML='<b>[?]</b>';
   }
}
function countChars(srcObj,alertObj,minChars,maxChars) {
  var charsCount = srcObj.value.length;
  if (charsCount > maxChars || charsCount < minChars) {
      if (alertObj.className != 'chars_exceed') {
          alertObj.className = 'chars_exceed';
      }
  } else {
      if (alertObj.className != 'chars') {
          alertObj.className = 'chars';
      }     
	       
  }
  alertObj.innerHTML = charsCount +  '/' + maxChars + ' characters';
    
}
function countWords(srcObj,alertObj,minWords,maxWords) {
  var ar=srcObj.value.split(/\s+/);
  var length = 0;
  if(srcObj.value.length == 0)
  	length = 0;
  else
  	length = ar.length;

  var wordsCount = length;
  if (wordsCount > maxWords || wordsCount < minWords) {
      if (alertObj.className != 'chars_exceed') {
          alertObj.className = 'chars_exceed';
      }
  } else {
      if (alertObj.className != 'chars') {
          alertObj.className = 'chars';
      }     
	       
  }
  alertObj.innerHTML = wordsCount +  '/' + maxWords + ' words';   
}
function addSmily(input, insText) {
	input.focus();
	if (input.createTextRange) {
		document.selection.createRange().text += insText;
	}
	else if (input.setSelectionRange) {
		var len = input.selectionEnd;
		input.value = input.value.substr(0, len) + insText + input.value.substr(len);
		input.setSelectionRange(len+insText.length, len+insText.length);
	}
	else {
		input.value += insText;
	}
}
function openPage(url, window_w, window_h) {
	window_w += 15;
	window_h += 55;
	window_l = parseInt((screen.width-window_w)/2);
	window_t = parseInt((screen.height-window_h)/2);
	var w = window.open(url, "has_page2", "width="+window_w+",height="+window_h+",left="+window_l+",top="+window_t+",resizable=0,toolbar=0,location=0,status=0,menubar=0,directories=0,scrollbars=1");
	if (w == null) {
		return true;
	}
	else {
	    w.focus();
		return false;
	}
}
function setHomepage(obj) {
	if (document.all) {
		obj.style.behavior="url(#default#homepage)";
		obj.setHomePage("http://www.helpastudent.com");
	} else {
		alert("We're sorry but your browser does not allow you to set your homepage automatically.\nHowever, you can still set www.helpastudent.com to your homepage by going to your browser's preferences.");
	}
}
function bookMark() {
	if (document.all) {
		window.external.AddFavorite(self.location.href,document.title);
	} else {
		alert("We're sorry but your browser does not allow you to automatically bookmark pages.\nHowever, try clicking OK and then pressing CTRL+D or click the Add to Favourites button on your browser's toolbar.");
	}
}