function validate(aStr, type) {
/*------ Function to check inputs ------*/
	var expr = "";
	switch (type){
	case "date" : expr = /^[0-2]{0,1}([1-9]|30|31)\/0{0,1}([0-9]|11|12)\/[0-9]{4,4}$/; break;
	case "email" : expr = /^(.)+@{1,1}((.)+\.(.)+)+$/; break;
	case "integer" : expr = /^[0-9]*$/; break;
	case "decimal" : expr = /^[0-9]*\.{0,1}[0-9]*$/; break;
	case "username" : expr = /^([a-z]|[A-Z]|[0-9])*$/; break;
	case "password" : expr = /^([a-z]|[A-Z]|[0-9])*$/; break;
	case "string" : expr = /^([a-z]|[A-Z]|[ ]|[.])*$/; break;
	case "phonenumber" : expr = /^([0-9]|[ ]|[+]|[-])*$/; break;
	}
	if(expr != "")
		return expr.test(Trim(aStr));
	else
		return false;
}

function Trim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g, "");}
function fnPaste(){event.returnValue=false;}
function isNull(obj,msg){
	if(msg!="Password")
		obj1=Trim(obj.value);
	else
		obj1=obj.value;
	if (obj1==""){
		alert("Please enter the " +msg+".");
		obj.focus();
		return true;
	}else
		return false;
}
function isLen(obj,siz,msg){
	if(msg!="Password")
		obj1=Trim(obj.value);
	else
		obj1=obj.value;
	if(obj1!=""){
		var strLen=obj.value;
		if(strLen.length < siz){
			alert(msg+" should be atleast " + siz + " Characters.");
			obj.focus();
			return true;  
		} 
	}else
		return false;
}
function isSame(obj1,obj2,msg1,msg2){
	if((Trim(obj1.value))==(Trim(obj2.value))){
		alert(msg1+" is matched with the "+msg2);
		obj2.focus();
		return true;
	}else
		return false;
}	
function isNotSame(obj1,obj2,msg1,msg2){
	if((Trim(obj1.value))!=(Trim(obj2.value))){
		alert(msg1+" does not match");
		obj2.focus();
		return true;
	}else
		return false;
}	
function isCorrect(obj1,obj2,msg1,msg2){
	if((Trim(obj1.value)) >= (Trim(obj2.value))){
		alert(msg1+" should be less than "+msg2);
		obj2.focus();
		return true;
	}else
		return false;
}	
function notZipcode(obj,msg){
	exp = /[a-zA-Z|\d]-{1}/;
	if (!exp.test(obj.value)){
		alert("Please enter valid "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function notChecked(obj,msg){
	checked = false;
	if(obj.length){
		for(i=0;i<obj.length;i++){
			if(obj[i].checked){
				checked = true;break;
			}
		}
	}else if(obj.checked)
		checked = true;
	if(!(checked)){
		alert("Please select the "+msg+".");
		if(obj.length)
			obj[0].focus();
		else
			obj.focus();
		return true;
	}
}

function checkAll(obj,arg){
	if(obj.length){
		for(i=0;i<obj.length;i++){
			obj[i].checked=arg;
		}
	}
	else obj.checked=arg;
}
function notImageFile(obj,msg){
	var exp = /^.+\.(jpg|gif|jpeg|JPG|JPEG|GIF)$/;
	if (!exp.test((obj.value).toLowerCase())){
		alert("Please choose jpg or gif file for "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function notPrice(obj,msg){
	exp = /^[\d]*[\.]{0,1}[\d]{1,2}$/;
	if (!exp.test(obj.value)){
		alert("Please enter valid "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function fnChkNum(obj){
	exp = /^[0-9]*\.{0,1}[0-9]*$/;
	if (!exp.test(obj.value)){
		alert("Please enter a valid Amount!");
		obj.focus();
		return true;
	}else
		return false;
}
function fnChkAlpha(obj,msg)
{
	exp = (/(^([a-z]|[A-Z]|["."]|[\s])*$)/);
	if (!exp.test(obj.value))
	{
		alert("Please enter only alphabets in "+msg);
		obj.focus();
		return true;
	}
	else
		return false;
}	

function fnChkAlphaNum(obj,msg){
	exp = (/(^([a-z]|[A-Z]|[0-9])*$)/);
	if (!exp.test(obj.value)){
		alert("Please enter only alphanumeric in "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function fnChkAlphaNumeric(obj,msg){
	var Alpha = /[a-zA-Z|]/;
	var Num = /[\d]/;
	if (!(Alpha.test(obj.value) && Num.test(obj.value))){
		alert("Please enter only alphanumeric in "+msg);
		obj.focus();
		return true;
	}else
		return false;
}
function fnChkFolderName(){
	if(((window.event.keyCode < 48) || (window.event.keyCode > 57)) && ((window.event.keyCode < 65) || (window.event.keyCode > 90)) && ((window.event.keyCode < 97) || (window.event.keyCode > 122)) && (window.event.keyCode != 95)){
		alert("Only Alphabets(A-Z, a-z), Numbers(0-9) and Underscore(_) are allowed");
		window.event.keyCode = 0;
		return true;
	}
}

////////LIGHT BOX/////////////

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function showdiv(){
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 323) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 20 - 668) / 2);
	document.getElementById('accountdiv').style.height = ((arrayPageSize[1]) + 'px');
	document.getElementById('accountdiv').style.display="block";

}
function showdiv1(arg){
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 323) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 20 - 668) / 2);
	document.getElementById('accountdiv').style.height = ((arrayPageSize[1]) + 'px');
	document.getElementById('amt').innerHTML=arg;
	document.getElementById('amt1').innerHTML=arg;
	document.thisConfirm.Amount.value=arg;
	document.getElementById('accountdiv').style.display="block";

}
function showAccept(arg,e){
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - 323) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 20 - 668) / 2);
	document.getElementById('accountdiv1').style.height = ((arrayPageSize[1]) + 'px');
	
	//position
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY)
	{
		posx = e.pageX;
		posy = e.pageY;
			
		document.getElementById('accountdiv2').style.left = (posx+100)+"px";
		document.getElementById('accountdiv2').style.top = (posy-450)+"px";
	}
	else if (e.clientX || e.clientY)
	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
			
		document.getElementById('accountdiv2').style.left = (posx+100)+"px";
		document.getElementById('accountdiv2').style.top = (posy-450)+"px";
	}
	
	document.getElementById('accountdiv1').style.display="block";
	document.thisConfirm.ExpertId.value=arg;

}

function showPay(arg)
{
	if(arg==1)
		document.getElementById('paydiv').style.display="block";
	if(arg==0)
		document.getElementById('paydiv').style.display="none";
}