/********* Only For Character *****************/

var mikExp = /[$\\@\\\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\.\{0-9}]/;
function onlytext(val)
{
	var strPass = val.value;
	var strLength = strPass.length;
	var lchar = val.value.charAt((strLength) - 1);

	if(lchar.search(mikExp) != -1)
	{
		var tst = val.value.substring(0, (strLength) - 1);
		val.value = tst;
   }
}

/////////////////////////////////////////////////////
/********* Only For Digit *****************/

var mikExp1 = /[$\\@\\\/\#%\^\&\*\(\)\[\]\+\_\{\}\`\~\=\|\.\{A-Za-z}]/;
function onlydigit(val)
{
	var strPass = val.value;
	var strLength = strPass.length;
	var lchar = val.value.charAt((strLength) - 1);

	if(lchar.search(mikExp1) != -1)
	{
		var tst = val.value.substring(0, (strLength) - 1);
		val.value = tst;
   }
}

/////////////////////////////////////////////////////////////////////////

/* Email Validation Script ******/

function checkEmail(myForm) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(myForm.txtEmail.value)){
return (true)
}
alert("Invalid E-mail Address! Please re-enter.")
myForm.txtEmail.focus();
return (false)
}
///////////////////////////////////////////////////////////////////////////

	function imgSwap(which)
	{
		which.style.background="url(Images/link-over.jpg)";
		
		document.onmouseout=function()
		{
			which.style.background="url(Images/wlink.jpg)";
		}
	}
	
	function imgSwap1(which)
	{
		which.style.background="url(Images/link-over.jpg)";
		
		document.onmouseout=function()
		{
			which.style.background="url(Images/link.jpg)";
		}
	}

/////////////////////////////////////////Image Thumbnail viewer///////////////////////////////////////////////


var ie=document.all
var ns6=document.getElementById&&!document.all

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body
}

function enlarge(which, e, position, imgwidth, imgheight){

	if (ie||ns6){
		crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage
		if (position=="center")
		{
			pgyoffset=ns6? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)
			horzpos=ns6? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2
			vertpos=ns6? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2
			if (window.opera && window.innerHeight) //compensate for Opera toolbar
				vertpos=pgyoffset+window.innerHeight/2-imgheight/2
				vertpos=Math.max(pgyoffset, vertpos)
		}
		else
		{
			var horzpos=ns6? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX
			var vertpos=ns6? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY
		}
		crossobj.style.left=horzpos+"px"
		crossobj.style.top=vertpos+"px"

		crossobj.innerHTML='<table border="0" bgcolor="#efefef" cellpadding="3" cellspacing="1"><tr><td align="right"><div align="right" id="dragbar"><span id="closetext" onClick="closepreview()">Close&nbsp;</span></div></td></tr><tr><td><img height="225" width="225" src="'+which+'"></td></tr></table>'

		crossobj.style.visibility="visible"
		return false
	}
	else //if NOT IE 4+ or NS 6+, simply display image in full browser window
		return true
}

function closepreview(){
crossobj.style.visibility="hidden"
}

function drag_drop(e){
if (ie&&dragapproved){
crossobj.style.left=tempx+event.clientX-offsetx+"px"
crossobj.style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
crossobj.style.left=tempx+e.clientX-offsetx+"px"
crossobj.style.top=tempy+e.clientY-offsety+"px"
}
return false
}

function initializedrag(e){
if (ie&&event.srcElement.id=="dragbar"||ns6&&e.target.id=="dragbar"){
offsetx=ie? event.clientX : e.clientX
offsety=ie? event.clientY : e.clientY

tempx=parseInt(crossobj.style.left)
tempy=parseInt(crossobj.style.top)

dragapproved=true
document.onmousemove=drag_drop
}
}

document.onmousedown=initializedrag
document.onmouseup=new Function("dragapproved=false")
