// JavaScript Document
function textCounter(f,cf,maxlimit) {
	if (f.value.length > maxlimit) {
			f.value = f.value.substring(0, maxlimit);
	} else {
		document.getElementById(cf).value = maxlimit - f.value.length;
	}
}

function showHide(e){
	var span = document.getElementById(e + "_span");
	var div = document.getElementById(e + "_div");
	if(div.style.display == "none"){
		div.style.display = "block";
		span.innerHTML = "[hide]";
	} else  {
		div.style.display = "none";
		span.innerHTML = "[show]";
	}
}

function isEmail(string) {
	return (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
}

function resetValue(e,strValue) {
	var s = Trim(e.value);
	if(s=="") { e.value = strValue; }
}

function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1) {
		return "";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="") {
		return "";
	} else {
		return TRIM_VALUE;
	}
}

function RTrim(VALUE) {
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0) {
		return "";
	}
	var iTemp = v_length -1;
	while(iTemp > -1) {
		if(VALUE.charAt(iTemp) == w_space) {
		} else {
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
		iTemp = iTemp-1;
	}
	return strTemp;
}

function LTrim(VALUE) {
	var w_space = String.fromCharCode(32);
	if(v_length < 1) {
		return "";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;
	while(iTemp < v_length) {
		if(VALUE.charAt(iTemp) == w_space) {
		} else {
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}

function showAlert(){
	if($('#alert').length){
		var originalBG = $("#alert").css("background-color"); 
		$('#alert').animate({backgroundColor: '#FFFF00'},600).animate({opacity: 1.0}, 1500).animate({backgroundColor: originalBG},600);
	}
}

$(document).ready(function(){
	showAlert();
});
