function login_validate()
{
	if(document.getElementById("username").value=="") {

		document.getElementById('validate_error').innerHTML ='';
		document.getElementById('error').innerHTML = "<font style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;color:#333333;padding:4px 10px; background-color:#FFAD5B; '>Please Enter Your UserName.</font>"

		document.getElementById("username").focus();

		return false;

	}

	if(document.getElementById("password").value=="") {

		document.getElementById('validate_error').innerHTML ='';
		document.getElementById('error').innerHTML = "<font style='font-family:Verdana, Arial, Helvetica, sans-serif; font-size:10px;color:#333333;padding:4px 10px; background-color:#FFAD5B; '>Please Enter Your Password.</font>"

		document.getElementById("password").focus();

		return false;

	}

	return true;
}

function add_users_validate(form) {
	
	if(form.addusers_name.value=="")
	{ 
		alert('UserName should not be Empty');
		//document.getElementById('error').bgcolor="red"
		return false;
	}

	
	if(form.addusers_password.value=="")
	{ 
		alert('Password should not be Empty');
		return false;
	}
	
	if(form.addusers_cnpassword.value=="")
	{ 
		alert('Conform Password should not be Empty');
		return false;
	}
	
	if(form.addusers_role.value=="")
	{ 
		alert('User Role Should Not be Empty');
		return false;
	}
	
	if(form.addusers_password.value != form.addusers_cnpassword.value )
	{ 
		alert('Password Mismatch');
		return false;
	}
	
	return true;
}

function confirm_user(id)
{
	if(confirm('Are You Sure You Want To Delete This User?'))
	{
		window.location = 'http://www.mafiree.com/admin/add_users.php?del='+id;
	}
	else
	{

	}
}

function change_password_validate(form)
{
	if(form.changepass_old.value=="")
	{ 
		alert('Old Password should not be Empty');
		//document.getElementById('error').bgcolor="red"
		return false;
	}

	
	if(form.changepass_new.value=="")
	{ 
		alert('New Password should not be Empty');
		return false;
	}
	
	if(form.changepass_cnnew.value=="")
	{ 
		alert('Conform New Password should not be Empty');
		return false;
	}
	
	if(form.changepass_new.value != form.changepass_cnnew.value )
	{ 
		alert('Password Mismatch');
		return false;
	}
	return true;
}

function reimb_deactive(n){
	for(i=2;i<=n;i++)
	{
		document.getElementById('reimb_bills'+i).disabled=true;
		document.getElementById('reimb_date'+i).disabled=true;
		document.getElementById('reimb_billno'+i).disabled=true;
		document.getElementById('reimb_description'+i).disabled=true;
	}
}

function reimb_deactive_add(){
	n=document.getElementById('count').value-1;
	//n=n+1;
	//alert(n);
	for(i=2;i<=n;i++)
	{
		if(document.getElementById('reimb_date'+i).value =="" && document.getElementById('reimb_billno'+i).value =="" && document.getElementById('reimb_description'+i).value ==""){
		//alert(i);
		//alert(n);
		document.getElementById('reimb_bills'+i).disabled=true;
		document.getElementById('reimb_date'+i).disabled=true;
		document.getElementById('reimb_billno'+i).disabled=true;
		document.getElementById('reimb_description'+i).disabled=true;
		}
	}
}

function count(){
	count=0;
	for(j=1;j<=n;j++){
		if(document.getElementById('reimb_date'+j).value != "" && document.getElementById('reimb_billno'+j).value != "" && document.getElementById('reimb_description'+j).value !=""){
			count=count+1;
		}
	}return count;
	
}

function abc(id) {
	   count=id;
       hidden="<input type=\"text\" name=\"cnt\" id=\"cnt\" value=\"" +count+ "\" />";
	   document.write(hidden);
}

function reimb_val(){
	n=document.getElementById('count').value-1;
	//alert(n);
	for(j=1;j<=n;j++){
		if(document.getElementById('reimb_date'+j).value == "" && j==1){
			alert('Bill Date in row '+j+' Should not be Empty');
			return false;
		}
		if(document.getElementById('reimb_billno'+j).value == "" && j==1){
			alert('Bill No in row '+j+' Should not be Empty');
			return false;
		}
		if(document.getElementById('reimb_description'+j).value == "" && j==1){
			alert('Bill Description in row '+j+' Should not be Empty');
			return false;
		}
		k=j-1;
		if(document.getElementById('reimb_date'+j).value == "" && document.getElementById('reimb_billno'+j).value == "" && document.getElementById('reimb_description'+j).value == "" && j>=2 && 
		   document.getElementById('reimb_date'+k).value !="" && document.getElementById('reimb_billno'+k).value !="" && document.getElementById('reimb_description'+k).value !=""){
			//return val_count=count();
			//document.write('<input type="hidden" id="cnt" value="1">');
			alert(val_count);
			window.location = 'http://www.mafiree.com/admin/reimb_sub.php?del=';
			return false;
		}
	}
}



function reimb_active(n){
	var r = n.match(/[\d\.]+/g);
	i=r[0];
	i=parseInt(i)+1;
	document.getElementById('reimb_bills'+i).disabled=false;
	document.getElementById('reimb_date'+i).disabled=false;
	document.getElementById('reimb_billno'+i).disabled=false;
	document.getElementById('reimb_description'+i).disabled=false;
}


function reimbustment_validate_test(n)
{
		
		for(i=1;i<n;i++)
		{
			if(document.getElementById('reimb_description'+i).value =="")
		    {
				alert('Description should not be empty');
				return false;
			}
		}
return true;
}

function reimbustment_validate(form)
{ 
	if(!document.getElementById("reimb_date").disabled)
	{
		if(form.reimb_date.value=="")
		{ 
			alert('Bill Date should not be Empty');
			return false;
		}

	}

	if(form.reimb_reason.value=="")
	{ 
		alert('Reason should not be Empty');
		//document.getElementById('error').bgcolor="red"
		return false;
	}

	
	if(form.reimb_remarks.value=="")
	{ 
		alert('Remarks should not be Empty');
		return false;
	}
	
	if(form.reimb_description.value=="")
	{ 
		alert('Description should not be Empty');
		return false;
	}
}

function reimbustment_viewall_openwindow_view(id)
{
	window.open("reimbursement_pop_view.php?id="+id,"mywindow","location=0,status=0,scrollbars=1,width=900,height=500");
}

function reimbustment_viewall_openwindow_edit(id)
{
	window.open("reimbursement_pop_edit.php?id="+id,"mywindow","location=0,status=0,scrollbars=1,width=900,height=500");
}

function reimbustment_userview_openwindow_edit(id)
{
	window.open("reimbursement_pop_useredit.php?id="+id,"mywindow","location=0,status=0,scrollbars=1,width=900,height=500");
}


function worklog_popview(id)
{
	window.open("worklog_popview.php?id="+id,"mywindow","location=0,status=0,scrollbars=1,width=1500,height=700");
}
