function auth_form()
{
    if(document.forms[0].user.value=="" || document.forms[0].password.value=="")
	{
	    alert("Userid/Password not given");
	    return false;
	}
    return true;
}


function showFormValues()
{
    
    var select_name=document.forms['enterleave'].staff_names.value;
    var from_date=document.forms['enterleave'].date1.value;
    var to_date=document.forms['enterleave'].date2.value;
    var leavetype=document.forms['enterleave'].leave.value;
    var staffdetails= "";
    staffdetails=staffdetails+"Leave Conformation:"+"\nStaff Id:"+select_name+"\n";
staffdetails=staffdetails+"Leave From:"+from_date+"\t";
staffdetails=staffdetails+"To:"+to_date+"\n";
    if(confirm(staffdetails))
	return true;
    else
	return false;
}

function get_staff(base_url,department,division_id,count)
{
    var url = base_url +  "/py/manager/manager/get_staff_dept?dept="+department;
    


    if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	    xmlhttp=new XMLHttpRequest();
	}
    else
	{// code for IE6, IE5
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
    xmlhttp.open("GET",url,false);
    xmlhttp.send(null);

    var staff_details = xmlhttp.responseText;
    var slice_result = staff_details.slice(1,staff_details.length-1);
    

    var split_result = slice_result.split(',');
    var curr_select_name = "staff_id"+count
    var val = "<select name="+curr_select_name+">";

    var temp="";

    var i=0;
    

    //while(i<split_result.length)
    while(i<split_result.length)
	{
	    
	    temp = split_result[i];
	    if(temp.charAt(2) == "'")
		{
	    temp = temp.slice(3,temp.length-1);
		}
	    else
		{
		    temp = temp.slice(2,temp.length-1);
		}
	    
	    val = val + "<option value="+temp+">";
	    i=i+1;
	    temp = split_result[i];
	    temp = temp.slice(2,temp.length-2);
	    val=val+temp+"</option>";
	    i=i+1;
	    //alert(val);
	    
	    
 
	    
	    
	    
	    
	}
    val = val + "</select>";


    document.getElementById(division_id).innerHTML=val;

}






function get_staff_dept(base_url,department)
{
   
    var url = base_url + "/py/manager/manager/get_staff_dept?dept=" + department;
      


    if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	    xmlhttp=new XMLHttpRequest();
	}
    else
	{// code for IE6, IE5
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
    xmlhttp.open("GET",url,false);
    xmlhttp.send(null);

    var staff_details = xmlhttp.responseText;
    var slice_result = staff_details.slice(1,staff_details.length-1);
    

    var split_result = slice_result.split(',');

    var val = "<select name=\"staff_names\">";

    var temp="";

    var i=0;
    

    //while(i<split_result.length)
    while(i<split_result.length)
	{
	    
	    temp = split_result[i];
	    if(temp.charAt(2) == "'")
		{
	    temp = temp.slice(3,temp.length-1);
		}
	    else
		{
		    temp = temp.slice(2,temp.length-1);
		}
	    val = val + "<option value="+temp+">";
	    i=i+1;
	    temp = split_result[i];
	    temp = temp.slice(2,temp.length-2);
	    val=val+temp+"</option>";
	    i=i+1;
	    //alert(val);
	    
	    
 
	    
	    
	    
	    
	}
    val = val + "</select>";


    document.getElementById('test').innerHTML=val;

}






function get_staffs(base_url,role)
{

    var url = base_url + "/py/admin-services/admin/get_staffs?role="+role;
    
    
    if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	    xmlhttp=new XMLHttpRequest();
	}
    else
	{// code for IE6, IE5
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
    xmlhttp.open("GET",url,false);
    xmlhttp.send(null);

    var staff_details = xmlhttp.responseText;
    var slice_result = staff_details.slice(1,staff_details.length-1);
    

    var split_result = slice_result.split(',');

    var val = "<select name=\"staff_names\">";

    var temp="";

    var i=0;
    

    //while(i<split_result.length)
    while(i<split_result.length)
	{
	    
	    temp = split_result[i];
	    if(temp.charAt(2) == "'")
		{
	    temp = temp.slice(3,temp.length-1);
		}
	    else
		{
		    temp = temp.slice(2,temp.length-1);
		}
	    var staff_id = temp;
	    val = val + "<option value="+temp+">";
	    
	    i=i+1;
	    temp = split_result[i];
	    temp = temp.slice(2,temp.length-2);
	    
	    val=val+temp+"("+staff_id+")</option>";
	    i=i+1;

	    //alert(val);
	    
	    
 
	    
	    
	    
	    
	}
    val = val + "</select>";


    document.getElementById('list').innerHTML=val;

}


function checkCSSPositioning()
{
   
    if(navigator.appName=="Microsoft Internet Explorer")
	{
	    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
		var ieversion=new Number(RegExp.$1) 
		    if (ieversion>6)
			{
			    document.getElementById("topnav").style.position="absolute";
			    document.getElementById("topnav").style.top="15%";
			    document.getElementById("topnav").style.left="0";
		    }
	    }
		    
		    

	}

}





function get_staff_dept_leave(base_url,department)
{
   
    var url = base_url + "/py/manager/manager/get_staff_dept?dept=" + department;
      


    if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	    xmlhttp=new XMLHttpRequest();
	}
    else
	{// code for IE6, IE5
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
    xmlhttp.open("GET",url,false);
    xmlhttp.send(null);

    var staff_details = xmlhttp.responseText;
    var slice_result = staff_details.slice(1,staff_details.length-1);
    

    var split_result = slice_result.split(',');

    var val = "<select name=\"userid\">";

    var temp="";

    var i=0;
    

    //while(i<split_result.length)
    while(i<split_result.length)
	{
	    
	    temp = split_result[i];
	    if(temp.charAt(2) == "'")
		{
	    temp = temp.slice(3,temp.length-1);
		}
	    else
		{
		    temp = temp.slice(2,temp.length-1);
		}
	    val = val + "<option value="+temp+">";
	    i=i+1;
	    temp = split_result[i];
	    temp = temp.slice(2,temp.length-2);
	    val=val+temp+"</option>";
	    i=i+1;
	    //alert(val);
	    
	    
 
	    
	    
	    
	    
	}
    val = val + "</select>";


    document.getElementById('test').innerHTML=val;

}
