// JavaScript Document
function submitfrm(frm)
{ 

	if(trim(frm.txtname.value).length==0)
	{
		alert("Please enter full name.");
		frm.txtname.focus();
		return false;
	}

	if(trim(frm.txthomeaddress.value).length==0)
	{
		alert("Please enter home address.");
		frm.txthomeaddress.focus();
		return false;
	}
	if(trim(frm.txtcity.value).length==0)
	{
		alert("Please enter city.");
		frm.txtcity.focus();
		return false;
	}
	if(frm.cbostate.value==0)
	{
		alert("Please select state.");
		frm.cbostate.focus();
		return false;
	}
	if(trim(frm.txtzipcode.value).length==0)
	{
		alert("Please enter zipcode.");
		frm.txtzipcode.focus();
		return false;
	}

	if(trim(frm.txtemail.value).length==0)
	{
		frm.txtemail.focus();
		alert("Please enter email.");
		return false;
	}
	
	if(!isEmail(trim(frm.txtemail.value)))
	{
		alert("Please enter valid email.");
		frm.txtemail.focus();
		return false;
	}
}

function cancel_click()
{
	document.frmquote.action="cardetail.php";
	document.frmquote.submit();
	
}

function searchrecord()
{
	//document.getElementById(frm.id).action = "user_list.php";
	//document.getElementById(frm.id).submit();
	
//	document.frm.action = "user_list.php";
	//document.frm.hdnorderby.value = "";
	//document.frm.hdnorder.value = "";
	//document.frm.txtpagesize.value = "";
	document.frm.txtcurrentpage.value = "1";
	//document.frm.txtpageno1.value = "";
	document.frm.submit();	
	//alert(frm.action);
}
function searchclear()
{
	window.location.href="user_list.php";
}
function setaction(actiontype)
{	
	//document.frm.mode.value = "userisactive"
	document.frm.action = "user_db.php";
	if (actiontype=="delete")
	{
		mycount = 0;
		for(i=0;i<document.frm.elements.length;i++)
		{
			if(document.frm.elements[i].name=="deletedids[]" && document.frm.elements[i].checked)
			{
				mycount++;	
			}
		}

		if(mycount==0)
		{
			alert("You must check atleast one checkbox.");
			return false;
		}
	
		if(confirm("Are you sure you want to delete selected user(s)?"))
		{
			document.frm.mode.value = "delete";
			document.frm.submit();
			return;
		}
		else
			return false;
	}
	else if (actiontype=="active")
	{
		document.frm.mode.value = "active";
		document.frm.submit();		
	}
	
}

function validate_forgotpassword(frm)
{
	if(trim(frm.txtusername.value).length==0)
	{
		alert("Please enter User Name.");
		frm.txtusername.focus();
		return false;
	}

	if(trim(frm.txtuseremail.value).length==0)
	{
		frm.txtuseremail.focus();
		alert("Please enter email.");
		return false;
	}
	
	if(!isEmail(trim(frm.txtuseremail.value)))
	{
		alert("Please enter valid email.");
		frm.txtuseremail.focus();
		return false;
	}
}
function validate_login(frm)
{
	if(trim(frm.txtusername.value).length==0)
	{
		alert("Please enter user name.");
		frm.txtusername.focus();
		return false;
	}

	if(trim(frm.txtuserpassword.value).length==0)
	{
		alert("Please enter user password.");
		frm.txtuserpassword.focus();
		return false;
	}
}

function create_user(frm, usertype)
{
	frm.txtusertypeid.value = usertype;
	frm.submit();
}

function popUpWin(strURL, strName)
{
	var intWidth = 360;
	var intHeight = 300;
	var intLeft = ((screen.availWidth - intWidth) / 2) + 1;
	var intTop = ((screen.availHeight - intHeight) / 2) + 1;
	var popUp;
	
	if(popUp)
	{
		if(!popUp.closed)
		{
			popUp.close();				
		}
	}
	
	popUp = window.open(strURL, strName, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width='+intWidth+',height='+intHeight+',left='+intLeft+', top='+intTop+',screenX='+intLeft+',screenY='+intTop+'');
}