function specialcharatbegining(str)
{
	for(var i=0; i<str.value.length; i++) {
		if( /[^A-Za-z\d]/.test(str.value.charAt(0))) {
			str.value=str.value.substr(1);
		}
	}
}
function trim(input)
{
	var trimmed_output=input.replace(/^\s+|\s+$/g, '');
	return trimmed_output;
}
function alphanumeric(alphanum, fieldName)
{
	var alphane = alphanum.value;
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
	{
		var alphaa = numaric.charAt(j);
		var hh = alphaa.charCodeAt(0);
		if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh == 95) || (hh == 45) || (hh == 44))
		{
		}
		else
		{
			alert("Special Characters not allowed in "+fieldName);
			alphanum.focus();
			return false;
		}
 	}
	return true;
}
function submitPaginationForm(pageURL, inputField)
{
	// alert(pageURL);
	document.forms[0].action = pageURL;
	document.forms[0].submit();
	// return true;
}
function postcodealphanumeric(alphanum, fieldName)
{
	var alphane = alphanum.value;
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
	{
		var alphaa = numaric.charAt(j);
		var hh = alphaa.charCodeAt(0);
		if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh == 95) || (hh == 45) || (hh == 44) || (hh == 32))
		{
		}
		else
		{
			alert("Special Characters not allowed in "+fieldName);
			alphanum.focus();
			return false;
		}
 	}
	return true;
}
function numeric(num, fieldName)
{
	var nume = num.value;
	var numaric = nume;
	for(var j=0; j<numaric.length; j++)
	{
		var number = numaric.charAt(j);
		var hh = number.charCodeAt(0);
		if((hh > 47 && hh<58) || (hh == 46) || (hh == 44))
		{
		}
		else
		{
			alert("Please enter only numbers in "+fieldName);
			num.focus();
			return false;
		}
 	}
	return true;
}

/** Funcion to validate the Telephone number starts here**/
function validTelNo(evt, element)
{
	var charCode = (evt.which) ? evt.which : evt.keyCode
	if(charCode==8)
			return true;
					
	if (charCode > 31 && (charCode < 48 || charCode > 57)&& charCode!=46)
	   return false;
	   var objTel2Ctrl = element;
	   
	if(objTel2Ctrl.value.length == 0 && charCode != 9){
			objTel2Ctrl.value = '(' + objTel2Ctrl.value;
	}
	if(objTel2Ctrl.value.length == 4){
			objTel2Ctrl.value =  objTel2Ctrl.value + ') ';
	}
	if(objTel2Ctrl.value.length == 9){
			objTel2Ctrl.value =  objTel2Ctrl.value + '-';
	}
    return true;
}
var dom = (document.getElementById) ? true : false;
var ns5 = (!document.all && dom || window.opera) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ie4 && !ie5 && !dom) ? true : false;

var origWidth, origHeight;
if (nodyn) { event = "nope" }
var tipFollowMouse= true;	
var offX= 20;
var offY= 20; 
var startStr = '<table width="150" height="72"><tr><td align="center" width="100%"><img src="';
var midStr = '" border="0" style="width:195px; height:72px;"/></td></tr><tr><td valign="top">';
var endStr = '</td></tr></table>';
var tooltip, tipcss;
function initTip() {
	if (nodyn) return;
	tooltip = (ie4)? document.all['tipDiv']: (ie5||ns5)? document.getElementById('tipDiv'): null;
	tipcss = tooltip.style;
	if (ie4||ie5||ns5) {
		tipcss.width = "200px";
		tipcss.backgroundColor = "#DDECFF";
		tipcss.borderColor = "#000080";
		tipcss.borderWidth = "1px";
		tipcss.padding = "4px";
		tipcss.borderStyle = "ridge";
	}
	if (tooltip&&tipFollowMouse) {
		document.onmousemove = trackMouse;
	}
}
window.onload = initTip;
var t1,t2;
var tipOn = false;
function doTooltip(evt,imgname) {
	//alert(num);
	num = 0;
	if (!tooltip) return;
	if (t1) clearTimeout(t1);	if (t2) clearTimeout(t2);
	tipOn = true;
	if (ie4||ie5||ns5) {
		var tip = startStr + imgname + midStr + endStr;
		tipcss.backgroundColor = "#DDECFF";
	 	tooltip.innerHTML = tip;
	}
	if (!tipFollowMouse) positionTip(evt);
	else t1=setTimeout("tipcss.visibility='visible'",100);
}
var mouseX, mouseY;
function trackMouse(evt) {
	standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body 
	mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
	mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	if (tipOn) positionTip(evt);
}
function positionTip(evt) {
	if (!tipFollowMouse) {
		standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body
		mouseX = (ns5)? evt.pageX: window.event.clientX + standardbody.scrollLeft;
		mouseY = (ns5)? evt.pageY: window.event.clientY + standardbody.scrollTop;
	}
	var tpWd = (ie4||ie5)? tooltip.clientWidth: tooltip.offsetWidth;
	var tpHt = (ie4||ie5)? tooltip.clientHeight: tooltip.offsetHeight;
	var winWd = (ns5)? window.innerWidth-20+window.pageXOffset: standardbody.clientWidth+standardbody.scrollLeft;
	var winHt = (ns5)? window.innerHeight-20+window.pageYOffset: standardbody.clientHeight+standardbody.scrollTop;
	if ((mouseX+offX+tpWd)>winWd) 
		tipcss.left = mouseX-(tpWd+offX)+"px";
	else tipcss.left = mouseX+offX+"px";
	if ((mouseY+offY+tpHt)>winHt) 
		tipcss.top = winHt-(tpHt+offY)+"px";
	else tipcss.top = mouseY+offY+"px";
	if (!tipFollowMouse) t1=setTimeout("tipcss.visibility='visible'",100);
}

function hideTip() {
	if (!tooltip) return;
	t2=setTimeout("tipcss.visibility='hidden'",100);
	tipOn = false;
}

document.write('<div id="tipDiv" style="position:absolute; visibility:hidden; z-index:100"></div>');
