//-------------fill tr 
//get ajax chat 
//var path='http://www.caderco.com/new_portal/user/';

var path='http://192.168.124/new_portal/hr/';
var count2=0;
//var http=createObject();

window.name='CaderPortal';
//get feed backs
function getStudentsMtFeedBack(stId,theme)
{
	window.open('?typeRequested=feedbacks&stId='+stId+'&theme='+theme,'FeedBacks','width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no');
}
	

//check value for the input hour leave
function checkValue()
{
	var value=parseInt(document.getElementById('num_hours').value);
	if(value !=1 && value !=1.5 && value !=2 && value !=2.5 && value!=3)
	{
		alert('wrong Number its should be 1 , 1.5 , 2 , 2.5 or 3 hours for requesting the leave ');
		//document.getElementById('num_hours').value='';
		document.getElementById('num_hours').focus();
	}
}
//--------------------chatting area-----------
function checkChat()
{
		setTimeout(checkChatStep2,1000);
}
//view login user when they login
function loginUserAsMsnAjax()
{
	var nocache = Math.random();
	//document.getElementById('latest_login').innerHTML='';	
	//	alert(1);
	http.open('GET',path+'?typeRequested=getLatestLoggendUsers&nocache='+nocache,true);
	http.onreadystatechange = loginUserAsMsn;
	http.send('');
}
function loginUserAsMsn()
{
	if(http.readyState == 4)
	{	
		var response = http.responseText;
		var y=screen.height-550;
		var x=screen.width-120;
		document.getElementById('latest_login').style.top=y+'px';
		document.getElementById('latest_login').style.visibility='visible';
		document.getElementById('latest_login').style.left=x;
		document.getElementById('latest_login').innerHTML=response;
		setTimeout(loginUserAsMsnPrint,1000);
	}
	else
		setTimeout(loginUserAsMsnPrint,1000);
	//alert(response);
}

function loginUserAsMsnPrint()
{
	loginUserAsMsnAjax();
}
function checkChatStep2()
{
	
	/*var nocache = Math.random();
	//alert(path);
	http.open('GET',path+'?typeRequested=chatListUpdated&nocache='+nocache,true);
	http.onreadystatechange = updateRequestedChat;
	http.send('');
	setTimeout(checkChat,20000);*/
}
function updateRequestedChat()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
		document.getElementById('chat_lits').innerHTML =response;
		//alert(response);
		if(document.getElementById('chat_lits').innerHTML!='')
		{
			document.title='New chatting request start ';
			window.focus();
			//location.reload();
			//window.screenTop;
			changeColorBackground();
		}
		else
			document.title='::..CADER Portal..:: ';
	}
}
//--------------------------------  
//change the color for background
function changeColorBackground()
{
	if(document.getElementById('chat_lits').innerHTML!='')
	{
		document.getElementById('linkForChat').style.color='#FF0000';
		//document.getElementById('linkForChat').style.position="relative";
		//document.getElementById('linkForChat').style.left="13";
		setTimeout(changeColorBackground2,1500);
	}
}
function changeColorBackground2()
{
	document.getElementById('linkForChat').style.color='#000000';
	//document.getElementById('linkForChat').style.left="-15";
	setTimeout(changeColorBackground,1500);
}

////////function openning window for the requestes 
function doIt(requestUser,targetUser,ti,path,name1,name2,portalPath)
{
	//alert('22');
	window.open(path+'/?requestUser='+requestUser+'&targetUser='+targetUser+'&ti='+ti,'Chatting','width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no');
}
function updateDataResultSessions()
{
	
}
function validateHwAd()
{
	if(document.getElementById('theme').value=='')
	{
		document.getElementById('themeValidation').innerHTML='Please Select your Theme ';
		return false;
	}
	if(document.getElementById('homeWorkNum').value=='')
	{
		document.getElementById('homeWorkNumValidation').innerHTML='Please Select your Homework Number ';
		document.getElementById('themeValidation').innerHTML=' ';
		return false;
	}
	if(document.getElementById('title').value=='')
	{
		document.getElementById('titleValidation').innerHTML='Insert Your Title ';
		document.getElementById('themeValidation').innerHTML=' ';
		document.getElementById('homeWorkNumValidation').innerHTML=' ';
		return false;
	}
}
//item history
function itemHistory(id)
{
	window.open("?typeRequested=4&history=1&id="+id,"Reports","width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}
function validateaddRequest()
{
	if(document.getElementById('title').value=='')
	{
		document.getElementById('title').focus();
		document.getElementById('titleLabel').style.color='#FF0000';
		return false;
	}
	if(document.getElementById('itemList').value!='-1')
	{
		if(document.getElementById('countValue').value=='')
		{
			document.getElementById('countValue').focus();
			document.getElementById('countLabelTd').style.color='#FF0000';
			return false;
		}
	}
}
//count filed
function viewCountFiled()
{
	if(document.getElementById('itemList').value!='-1')
	{
		document.getElementById('countLabelTd').style.visibility='visible';
		document.getElementById('countTd').style.visibility='visible';
	}
	else
	{
		document.getElementById('countLabelTd').style.visibility='hidden';
		document.getElementById('countTd').style.visibility='hidden';
	}
}
//============================update items count on key up
function updateIteamsCount(id)
{
		var itemsCount=document.getElementById(id+'_count').value;
		var nocache = Math.random();
		http.open('GET','index.php?typeRequested=changeItemsCount&id='+id+'&type=3&itemsCount='+itemsCount+'&nocache='+nocache,true);
		http.onreadystatechange = updateIteamsCountData;
		http.send('');
}
function updateIteamsCountData()
{
}
function validateItemForm()
{
	if(document.getElementById('item_name').value=='')
	{
		document.getElementById('item_name').focus();
		document.getElementById('item_name_validation').style.color='#FF0000';
		return false;
	}
	if(document.getElementById('item_count').value=='')
	{
		document.getElementById('item_count').focus();
		document.getElementById('item_count_validation').style.color='#FF0000';
		return false;
	}
}
function fillTrSupply(id,listStatus)
{
	var content='';
	var feedback='';
	content='<form method=post name=addSupplyFeedBack id=addSupplyFeedBack action=?type=2 >';
	content+='<input type=hidden name=addingFeedBack id=addingFeedBack VALUE='+id+' />';
	content+='<table border=0 align=center >';
	content+='<tr><td class=normal_text>Status:'+listStatus+'</td></tr>';
	content+='<tr><td class=normal_text><textarea name=desc id=desc rows=15 cols=80 >'+feedback+'</textarea></td></tr>';
	content+='<tr><td class=normal_text><input type=submit name=send id=send value=send /></td></tr>';
	content+='</table>';
	content+='</form>';
	document.getElementById(id).innerHTML =content;
}
//leave form validation
//
function requestLeaveValidation()
{
	
	document.getElementById('anual_vacation_balance_new').value='';
	document.getElementById('sick_vacation_balance_new').value='';
	
	if(parseInt(document.getElementById('from_hour').value)<=parseInt(document.getElementById('to_hour').value))
	{

		
		  sumHourNew=document.getElementById('from_hour').value*60;
		  SumMinutesNewFrom =parseInt(document.getElementById('from_mint').value);
		  totalFromMint=sumHourNew+SumMinutesNewFrom;
		  		  
		  sumHourNewTo=document.getElementById('to_hour').value*60;
		  SumMinutesNewTo=parseInt(document.getElementById('to_mint').value);
		  totaltoMint=sumHourNewTo+SumMinutesNewTo;
		  var totaldDiffrentMint=totaltoMint-totalFromMint;
		  document.getElementById('num_hours').value=convertMintToHour(totaldDiffrentMint);
		  document.getElementById('num_mints').value=convertMintToHourReturnMints(totaldDiffrentMint);
		  //checkValue();
	}
	else
	{
		alert("This Time not correct");
		return false;
	}
	
	
	if(document.getElementById('leave_date').value=='')
	{
		document.getElementById('leave_date').focus();
		document.getElementById('date_validation').style.color='#FF0000';
		return false;
	}
	
	if(document.getElementById('num_hours').value=='')
	{
		document.getElementById('num_hours').focus();
		document.getElementById('num_hours_validation').style.color='#FF0000';
		return false;
	}
	if(document.getElementById('from_hour').value=='-1')
	{
		document.getElementById('from_hour').focus();
		document.getElementById('from_hour_validation').style.color='#FF0000';
		return false;
	}
	if(document.getElementById('to_hour').value=='-1')
	{
		document.getElementById('to_hour').focus();
		document.getElementById('to_hour_validation').style.color='#FF0000';
		return false;
	}

		
		var totalAnnualDay=parseFloat(document.getElementById('anual_vacation_balance').value)-parseFloat(document.getElementById('num_hours').value/8);
	    //var totalSickDay=parseInt(document.getElementById('sick_vacation_balance').value)-parseInt(document.getElementById('number_of_dayes').value/8);
	    //alert(totalSickDay);

	for(var i = 0; i < document.requestLeave.leave_type.length; i++)
	{
		if(document.requestLeave.leave_type[i].checked==true)
		checkboxValue=document.requestLeave.leave_type[i].value;
	}
	
	if(totalAnnualDay<=0 && checkboxValue==1)
	{
		
		alert("لقد تجاوزت عدد الساعات المسموح بها يرجى ادخالها مغادرة غير مدفوعة الاجر");
		return false;
	}
	if(totalAnnualDay<=0 && checkboxValue==5)
	{
		
		alert("لقد تجاوزت عدد الساعات المسموح بها يرجى ادخالها مغادرة غير مدفوعة الاجر");
		return false;
	}
	loop=document.getElementById('count').value-1;
	for(var i=0;i<=loop;i++)
	{
	 // dateDB=new Date(document.getElementById('leave_in_'+i));
	  //alert(document.getElementById('leave_in_'+i).value+'====='+document.getElementById('leave_date').value);
		if(document.getElementById('leave_in_'+i).value==document.getElementById('leave_date').value)
		{
		if(document.getElementById('from_hour_'+i).value==document.getElementById('from_hour').value || document.getElementById('to_hour_'+i).value==document.getElementById('to_hour').value)
		{
		 alert("لديك ادخال بنفس الوقت يرجى ادخال وقت صحيح");
		 return false;	
		 break;
		
		}
		 
		}
	}
	
   
	if(document.getElementById('from_hour').value==document.getElementById('to_hour').value && document.getElementById('from_mint').value>=document.getElementById('to_mint').value)
	{
		alert("This Time not correct");
		return false;
	}
	else
	alert("تنبيه عدد ساعات مغادرتك "+document.getElementById('num_hours').value+":"+ document.getElementById('num_mints').value);

	
	
	
	
}

//convert Mint To Hour
function convertMintToHour(totaldDiffrentMint)
	{
		var hour=totaldDiffrentMint/60;
		var floorValue=Math.floor(hour);
		var resteMint=hour-floorValue;
		var totalmintPerHour=resteMint*60;
		return floorValue;
	}
//convert Mint To Hour
function convertMintToHourReturnMints(totaldDiffrentMint)
	{
		var hour=totaldDiffrentMint/60;
		var floorValue=Math.floor(hour);
		var resteMint=hour-floorValue;
		var totalmintPerHour=resteMint*60;
		return Math.round(totalmintPerHour);
	}
//HR menu
function changeRequestLeaveStatus(id)
{
	var recId=document.getElementById('leaveStatus_'+id).value;
	var nocache = Math.random();
	http.open('GET','index.php?typeRequested=reportLeaveChangeStatus&leavesUserRequests=1&requestId='+id+'&recId='+recId+'&nocache='+nocache,true);
	http.onreadystatechange = getReportLeavesValueData;
	http.send('');
}
function getReportLeavesValueData()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
	
	}
}
function searchNowSelected()
{
	document.getElementById('startName').select();
}
//on keyup serach for the hr mangment
function searchNow()
{
	var key=document.getElementById('startName').value;
	nocache = Math.random();
	http.open('GET','../hr/index.php?typeRequested=vacation_user_pages&key='+key+'&nocache='+nocache,true);
	http.onreadystatechange = searchNowResult;
	http.send('');
	document.getElementById('startName').select();
}
function searchNowByName()
{
	var key=document.getElementById('userValueSelectID').value;
	nocache = Math.random();
	http.open('GET','../hr/index.php?history=2&id='+key+'&typeRequested=viewMoreOptionUserAjax&nocache='+nocache,true);
	http.onreadystatechange = searchNowResult;
	http.send('');
	document.getElementById('userValueSelectID').select();
}

function searchNowByNameAllUser(type)
{
	var key=document.getElementById('userValueSelectID').value;
	nocache = Math.random();
	//alert(type);
	if(type=='1')
	http.open('GET','../hr/index.php?typeRequested=vacation_user_pages_by_name&key2='+key+'&nocache='+nocache,true);
	else
	if(type=='2')
	http.open('GET','../hr/index.php?typeRequested=yesViewUserInformation&id='+key+'&history=3&nocache='+nocache,true);
	
	http.onreadystatechange = searchNowResult;
	http.send('');
	document.getElementById('userValueSelectID').select();
}


function searchNowResult()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
}

}
function hrMenu(data)
{
	document.getElementById("hrMenu").innerHTML=data;
}

//view vacations history for the current user
function viewVacationsHistory(id)
{
	window.open("?typeRequested=1&history=1&id="+id,"Reports","width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no");
}	
//get http reports for selected year
function getReportYear()
{
	var requestedYear=document.getElementById('vactionYearValue').value;
	var nocache = Math.random();
	http.open('GET','index.php?typeRequested=reportVacationChange&vaction_report=1&requestedYear='+requestedYear+'&nocache='+nocache,true);
	http.onreadystatechange = getReportYearValue;
	http.send('');
}
function getReportYearValue()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
	
	}
}
//change request status
function changeRequestStatus(id)
{
	var recId=document.getElementById('vacationStatus_'+id).value;
	var nocache = Math.random();
	http.open('GET','index.php?typeRequested=reportVacationChangeStatus&vacationsUserRequests=1&requestId='+id+'&recId='+recId+'&nocache='+nocache,true);
	http.onreadystatechange = getReportYearValueData;
	http.send('');
}
function getReportYearValueData()
{
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(response);
	// else if login is ok show a message: "Site added+ site URL".
	document.getElementById('main_data').innerHTML =response;
	
	}
}
//validate request form
function requestVacationValidation()
{
	document.getElementById('anual_vacation_balance_new').value='';
	document.getElementById('sick_vacation_balance_new').value='';
	var numberDayInMonth=['31','28','31','30','31','30','31','31','30','31','30','31'];
	var fromSplit=document.getElementById('from_date').value.split('-');
	var toSplit=document.getElementById('to_date').value.split('-');
	num=document.getElementById('numRow').value;
    fromDate=new  Date(parseFloat(fromSplit[0]),parseFloat(fromSplit[1]),parseFloat(fromSplit[2]));
	toDate=new  Date(parseFloat(toSplit[0]),parseFloat(toSplit[1]),parseFloat(toSplit[2]));
	
	if(fromSplit[0]==toSplit[0] && document.getElementById('from_date').value<=document.getElementById('to_date').value)
	{
		numberofmonth=toSplit[1]-fromSplit[1];
		
		if(numberofmonth==0)
		{
			
			/*if(fromDate.getMonth()!=0)
			indexArray=fromDate.getMonth()-1;
			else*/
			indexArray=indexArray=parseFloat(fromSplit[1]-1);;
			
			for(l=0;l<num;l++)
			{
				strDateFrom='from_date_'+l;
				strDateTo='to_date_'+l;
				
			for(i=fromSplit[2];i<=numberDayInMonth[indexArray];i++)
			{
				if(i<=9 && i!=fromSplit[2])
				newDate=toSplit[0]+"-"+toSplit[1]+"-0"+i
				else
				newDate=toSplit[0]+"-"+toSplit[1]+"-"+i
					
						
    					
						//alert(newDate+"=>"+document.getElementById(strDateFrom).value)
						if(newDate>=document.getElementById(strDateFrom).value && newDate<=document.getElementById(strDateTo).value)
						{
							alert("لديك يوم اجازة ضمن هذا التاريخ");
							return false;
						}

					
				
				if(i==toSplit[2])
				break;
			  }
			}
		}
		else
		{
		     monthStart=parseFloat(fromSplit[1]);
			 monthEnd=parseFloat(toSplit[1]);
			 dayStart=parseFloat(fromSplit[2]);
			 dayEnd=parseFloat(toSplit[2]);
			 var n=0;
			//alert(monthStart);
			for(j=monthStart;j<=monthEnd;j++)
			{
				indexArray=j-1;
				monthLength=numberDayInMonth[indexArray];
	           if(n==0)
			   {
				   loopDay=dayStart;
				   monthLengthLoop=monthLength;
			   }
			   else
			   if(n==1)
			   {
				   loopDay=1;
				   if(j==monthEnd)
				   monthLengthLoop=dayEnd;
				   else
				   monthLengthLoop=monthLength; 
			   }
				
				for(l=0;l<num;l++)
				{
					for(k=loopDay;k<=monthLengthLoop;k++)
					{
						if(k<10)
						day="0"+k;
						else
						day=k;
						
						if(j<10)
						allDateRange=fromSplit[0]+"-0"+j+"-"+day;
						else
						allDateRange=fromSplit[0]+"-"+j+"-"+day;
						
						
							strDateFrom='from_date_'+l;
							strDateTo='to_date_'+l;
						
						
							if(allDateRange>=document.getElementById(strDateFrom).value && allDateRange<=document.getElementById(strDateTo).value)
							{
								alert("لديك يوم اجازة ضمن هذا التاريخ");
								return false;
							}
						n=1;
						
					}
				}

			}
			
		}
	}
	/*else
	{
		alert("This Year not correct");
		return false;
	}
	  */
	 
	if(document.getElementById('number_of_dayes').value=='')
	{
		document.getElementById('number_of_dayes').focus();
		document.getElementById('num_day_req').style.color='#FF0000';
		return false;
	}
	if(document.getElementById('number_of_dayes').value=='')
	{
		document.getElementById('number_of_dayes').focus();
		document.getElementById('num_day_req').style.color='#FF0000';
		return false;
	}
	if(document.getElementById('fromDay').value=='-1')
	{
		document.getElementById('fromDay').focus();
		document.getElementById('fromDayReq').style.color='#FF0000';
		return false;
	}
	if(document.getElementById('toDay').value=='-1')
	{
		document.getElementById('toDay').focus();
		document.getElementById('toDayReq').style.color='#FF0000';
		return false;
	}
	
	if(document.getElementById('from_date').value=='')
	{
		document.getElementById('from_date').focus();
		document.getElementById('from_dateyReq').style.color='#FF0000';
		return false;
	}
	if(document.getElementById('to_date').value=='')
	{
		document.getElementById('to_date').focus();
		document.getElementById('to_dateReq').style.color='#FF0000';
		return false;
	}
	
	for(var i = 0; i < document.requestVacation.leave_type.length; i++)
	{
		if(document.requestVacation.leave_type[i].checked==true)
		checkboxValue=document.requestVacation.leave_type[i].value;
	}
	var totalAnnualDay=parseFloat(document.getElementById('anual_vacation_balance').value)-parseFloat(document.getElementById('number_of_dayes').value);
	var totalSickDay=parseFloat(document.getElementById('sick_vacation_balance').value)-parseFloat(document.getElementById('number_of_dayes').value);
	//alert(totalAnnualDay);

	for(var i = 0; i < document.requestVacation.leave_type.length; i++)
	{
		if(document.requestVacation.leave_type[i].checked==true)
		checkboxValue=document.requestVacation.leave_type[i].value;
	}
	if(totalAnnualDay<=0 && checkboxValue==1)
	{
		alert("لقد تجاوزت عدد ايام اجازاتك السنوية يرجى مراجعة قسم شؤن الموظفين");
		return false;
	}
	else
	if(totalAnnualDay>0 && checkboxValue==1)
	{
		document.getElementById('anual_vacation_balance_new').value=totalAnnualDay;
		return true;
	}
	
	//alert(totalSickDay);
	if(totalSickDay<0 && checkboxValue==2)
	{
		alert("لقد تجاوزت عدد ايام اجازاتك المرضية يرجى مراجعة قسم شؤن الموظفين");
		return false;
	}
	else
	if(totalSickDay>0 && checkboxValue==2)
	{
		document.getElementById('sick_vacation_balance_new').value=totalSickDay;
		return true;
	}
	
	alert("تنبيه عدد ايام اجازتك هو : "+document.getElementById('number_of_dayes').value);
	//return false;

}
function calculationDaye()
{
	var numberDayInMonth=['31','28','31','30','31','30','31','31','30','31','30','31'];
	var myDays=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
	var fromSplit=document.getElementById('from_date').value.split('-');
	var toSplit=document.getElementById('to_date').value.split('-');
	num=document.getElementById('numRow').value;
    fromDate=new  Date(parseFloat(fromSplit[0]),parseFloat(fromSplit[1]),parseFloat(fromSplit[2]));
	toDate=new  Date(parseFloat(toSplit[0]),parseFloat(toSplit[1]),parseFloat(toSplit[2]));
	
	for(var i = 0; i < document.requestVacation.leave_type.length; i++)
	{
		if(document.requestVacation.leave_type[i].checked==true)
		checkboxValue=document.requestVacation.leave_type[i].value;
	}
	
	if(fromSplit[0]==toSplit[0] && document.getElementById('from_date').value<=document.getElementById('to_date').value )
	{
		numberofmonth=toSplit[1]-fromSplit[1];
		
		if(numberofmonth==0)
		{
			
			/*if(fromDate.getMonth()!=0)
			indexArray=fromDate.getMonth()-1;
			else*/
			indexArray=parseFloat(fromSplit[1]-1);
			//alert(numberDayInMonth[indexArray]);
			countDay=0;
			
			for(i=fromSplit[2];i<=numberDayInMonth[indexArray];i++)
			{
				if(i<=9 && i!=fromSplit[2])
				newDateNum=toSplit[0]+"/"+toSplit[1]+"/0"+i;
				else				
				newDateNum=toSplit[0]+"/"+toSplit[1]+"/"+i;
				
				
				
				dateValueDay=new Date(newDateNum);
				///alert(dateValueDay);
					if(checkboxValue=='1')
					{
						if(document.getElementById('holiday_in_saturday').value=='6')
						{
							if(dateValueDay.getDay()!=5 && dateValueDay.getDay()!=6)
							countDay+=1;
							
						}
						else
						{
							if(dateValueDay.getDay()!=5)
							countDay+=1; 
							
						}
					}
					else
					{
						countDay+=1;
						
					}
				
				if(i==toSplit[2])
				{
					
				break;
				}
			  
			}
			
			document.getElementById('number_of_dayes').value=countDay;
			
			
			
			
			if(countDay==0)
			{
			alert("هذا يوم عطله لديك");
			document.getElementById('from_date').value='';
			document.getElementById('to_date').value='';
			return false;
			}
		}
		else
		{
		     monthStart=parseFloat(fromSplit[1]);
			 monthEnd=parseFloat(toSplit[1]);
			 dayStart=parseFloat(fromSplit[2]);
			 dayEnd=parseFloat(toSplit[2]);
			 var n=0;
			 countDay=0;
			//alert(monthStart);
			for(j=monthStart;j<=monthEnd;j++)
			{
				indexArray=j-1;
				monthLength=numberDayInMonth[indexArray];
	           if(n==0)
			   {
				   loopDay=dayStart;
				   monthLengthLoop=monthLength;
			   }
			   else
			   if(n==1)
			   {
				   loopDay=1;
				   if(j==monthEnd)
				   monthLengthLoop=dayEnd;
				   else
				   monthLengthLoop=monthLength; 
			   }
				
					for(k=loopDay;k<=monthLengthLoop;k++)
					{
						if(k<10)
						day="0"+k;
						else
						day=k;
						
						if(j<10)
						allDateRange=fromSplit[0]+"/0"+j+"/"+day;
						else
						allDateRange=fromSplit[0]+"/"+j+"/"+day;
						
						dateValueDay=new Date(allDateRange);
						if(checkboxValue=='1')
					    {
							if(document.getElementById('holiday_in_saturday').value=='6')
							{
							if(dateValueDay.getDay()!=5 && dateValueDay.getDay()!=6)
							countDay+=1;
							}
							else
							{
								if(dateValueDay.getDay()!=5)
							   countDay+=1;
							}
						}
						else
						{
							 countDay+=1;
						}
						n=1;
						
					}
				

			}
			document.getElementById('number_of_dayes').value=countDay;
			

		}
	}

}
function hiddenDiv()
{
	document.getElementById("divViewUserDrop").style.visibility="hidden"; 
}
			
function viewUserDrop()
{
	var nocache = Math.random();
	 
	document.getElementById("divViewUserDrop").style.visibility="visible"; 
	searchValue=document.getElementById("userValueSelect").value;
	http.open('GET','index.php?typeRequested=viewUserDrop&searchValue='+searchValue+'&nocache='+nocache,true);
	http.onreadystatechange = viewUserDropAction;
	http.send('');
}
function viewUserDropAction()
{
	
	if(http.readyState == 4){	
	var response = http.responseText;
	//alert(response);
	document.getElementById("divViewUserDrop").innerHTML =response;
	}
}
function putValueInInoutFiled(count)
{
	var tdId='selectUser'+count;
	var userName='selectValue'+count;
	var userID='selectValueId'+count;
	document.getElementById(tdId).style.background='#0099FF';
	document.getElementById('userValueSelect').value=document.getElementById(userName).value;
	document.getElementById('userValueSelectID').value=document.getElementById(userID).value;

}
function outValueInInoutFiled(tdId)
{
    var tdId='selectUser'+tdId;
	document.getElementById(tdId).style.background='#FFFFFF';

}
function printReport(printValue)
{
	if(printValue==1)
	{
		var where=document.getElementById('wherePrint').value;
		var userid=document.getElementById('userValueSelectIDPrint').value;
		url=' ?print='+printValue+'&userid='+userid+'&whereData='+where+'&typeRequested=1 ' ;
		var userid=document.getElementById('userValueSelectIDPrint').value;
		window.open(url,"Nominate","width=900,height=800,top=100,left=250,scrollbars=yes,resizable=no");
	}
	else
	if(printValue==2)
	{
    	var where=document.getElementById('wherePrint2').value;
    	var whereFrom=document.getElementById('whereFrom').value;
    	var whereTo=document.getElementById('whereTo').value;
		var userid=document.getElementById('userValueSelectIDPrint2').value;
		url=' ?print='+printValue+'&userid='+userid+'&whereData='+where+'&whereFrom='+whereFrom+'&whereTo='+whereTo+'&typeRequested=1 ' ;
		window.open(url,"Nominate","width=900,height=800,top=100,left=250,scrollbars=yes,resizable=no");
	}
	else
	{
		
		var where=document.getElementById('wherePrint4').value;
		var userid=document.getElementById('userValueSelectIDPrint').value;
		var whereFrom=document.getElementById('whereFrom').value;
    	var whereTo=document.getElementById('whereTo').value;
		url=' ?print='+printValue+'&whereData='+where+'&whereFrom='+whereFrom+'&whereTo='+whereTo+'&typeRequested=1 ' ;

		//var userid=document.getElementById('userValueSelectIDPrint').value;
 		window.open(url,"Nominate","width=900,height=800,top=100,left=250,scrollbars=yes,resizable=no");
	}

}
function printReportAction()
{
	print();
}
function printReportActionHidden(id)
{
	document.getElementById(id).style.visibility='hidden';
	print();
	document.getElementById(id).style.visibility='visible';
}
function checkSelectYear()
{
	if(document.getElementById("yearValue").value=='0')
	{
		alert("Select Year");
		return false;
	}
}
 
 function redierctSelectedYear(id)
 {
	 	window.location='?year='+document.getElementById(id).value;
 }
 
 // Show details vacation and leave
 function show_details_vacation(e,idUser,nameUser,from,to,type,status,process_by,anual_vacation_balance,sick_vacation_balance,not)
 {
	if (navigator.appName == "Microsoft Internet Explorer")
    {
	if(screen.height-event.screenY>380)
	{
		var x_pos=event.screenX+document.body.scrollLeft;
		var y_pos=event.screenY+document.body.scrollTop-120;
	}
	else
	{
		var x_pos=event.screenX+document.body.scrollLeft;
		var y_pos=event.screenY+document.body.scrollTop;
	}
}
else
{
	//alert((screen.height-e.clientY));
	if((screen.height-e.clientY)>410)
	{
		var x_pos=e.clientX+document.body.scrollLeft;
		var y_pos=e.clientY+document.body.scrollTop-20;
	}
	else
	{
		var x_pos=e.clientX+document.body.scrollLeft;
		var y_pos=e.clientY+document.body.scrollTop-320;
	}
}

hr_details_div.style.left=x_pos+20;
hr_details_div.style.top=y_pos-155;
hr_details_div.style.visibility='visible';
var data="";
data+="<table border=1 align=center width=500 cellpadding=0 cellspascing=0 bgcolor=#CCCCCC dir=rtl >";
data+="<tr><td class=normal_text valign=top colspan=2 align=left><a href=?type=1 onClick=hide_details_vacation() >خروج</a></td></tr>";
data+="<tr><td class=normal_text valign=top><b>أسم الموظف</b></td><td class=normal_text valign=top>"+nameUser+"</td></tr>";
data+="<tr><td class=normal_text valign=top><b>التاريخ</b></td><td class=normal_text valign=top dir=ltr align=right>"+from+"/"+to+"</td></tr>";
data+="<tr><td class=normal_text valign=top><b>نوع الاجازة</b></td><td class=normal_text valign=top>"+type+"</td></tr>";
data+="<tr><td class=normal_text valign=top><b>حالة الاجازة</b></td><td class=normal_text valign=top>"+status+"</td></tr>";
data+="<tr><td class=normal_text valign=top><b>تمت الموافقه من</b> </td><td class=normal_text valign=top>"+process_by+"</td></tr>";
data+="<tr><td class=normal_text valign=top><b>رصيد الاجازات السنوية</b> </td><td class=normal_text valign=top>"+anual_vacation_balance+"</td></tr>";
data+="<tr><td class=normal_text valign=top><b>رصيد الاجازات المرضية</b> </td><td class=normal_text valign=top>"+sick_vacation_balance+"</td></tr>";
data+="<tr><td class=normal_text valign=top><b>ملاحظات</b> </td><td class=normal_text valign=top>"+not+"</td></tr>";
data+="<tr><td class=normal_text valign=top colspan=2 align=left><a href=?history=2&id="+idUser+">خيارات >>> </a></td></tr>";
data+="</table>";
hr_details_div.innerHTML=data



 }
  // Hide details vacation and leave
  function hide_details_vacation()
 {
	
	if(hr_details_div.innerHTML!='')
	{
		hr_details_div.style.visibility='hidden';
		hr_details_div.innerHTML="";
	}
 }
 
 //-------------
 function getDateShc()
 {
	var date=document.getElementById('selectionDate').value;
	var area=document.getElementById('area').value;
	window.open('?typeRequested=generateAttReport&area='+area+'&date='+date,'FeedBacks','width=929,height=600,top=100,left=250,scrollbars=yes,resizable=no');
 }
