var whitespace = " \t\n\r"

function isEmpty(s)
{
   return ((s == null) || (s.length == 0))
}
function isWhitespace (s)
{  var i;
	// Is s empty?
	if (isEmpty(s)) return true;

	 // Search through string's characters one by one
	 // until we find a non-whitespace character.
	 // When we do, return false; if we don't, return true.
	 for (i = 0; i < s.length; i++)
	 {   
		 // Check that current character isn't whitespace.
		 var c = s.charAt(i);
 
		 if (whitespace.indexOf(c) == -1) return false;
	 }
 
	 // All characters are whitespace.
	 return true;
}
function isCharsInBag (s, bag)
{  
  var i;
  // Search through string's characters one by one.
  // If character is in bag, append to returnString.

  for (i = 0; i < s.length; i++)
  {   
	  // Check that current character isn't whitespace.
	  var c = s.charAt(i);
	  if (bag.indexOf(c) == -1) return false;
  }
  return true;
}
/*Start : Function for email Check */
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  // alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function Validate()
{
	var i="";
	var Q1 = "";
	var errMesg = "";
	var diplayMesg = "";
	var Q = ""; // this block determines lifespan of Q
	
	
	if (document.form1.title.value == "0")
	{
	  	Q += "  Title\n";
		Q1 += "title ";
	}
	if (isWhitespace(document.form1.first_name.value)) 
	{
	  	Q += "  Forename\n";
		Q1 += "first_name ";
	} 
	if (isWhitespace(document.form1.last_name.value)) 
	{
	  	Q += "  Surname\n";
		Q1 += "last_name ";
	}
	
	
	if (document.form1.position.value == "0")
	{
	  	Q += "  Position\n";
		Q1 += "position ";
	}
	if (isWhitespace(document.form1.emailID.value)) 
	{
	  	Q += "  Email\n";
		Q1 += "emailID ";
	}
	else if (echeck(form1.emailID.value)==false)
	{
	   errMesg += "Invalid Email Address\n";
	}	
	else if(!isCharsInBag(form1.emailID.value, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@._-"))
	{
	  errMesg += "Email Address contains Invalid Characters\n";
	}
	
	/*if (isWhitespace(document.form1.address1.value) && isWhitespace(document.form1.address2.value)&& isWhitespace(document.form1.address3.value)) 
	{
	  	Q += "  Address\n";
		Q1 += "address1 ";
	}*/
	/*if (isWhitespace(document.form1.town.value)) 
	{
	  	Q += "  Town\n";
		Q1 += "town ";
	}*/
	if (document.form1.country.value == "0")
	{
	  	Q += "  Country\n";
		Q1 += "country ";
	}
	if (isWhitespace(document.form1.postcode.value)) 
	{
	  	Q += "  Postcode\n";
		Q1 += "postcode ";
	}
	if (isWhitespace(document.form1.phone_no.value)) 
	{
	  	Q += "  Phone No\n";
		Q1 += "phone_no ";
	}
	if (isWhitespace(document.form1.password.value)) 
	{
	  	Q += "  Password\n";
		Q1 += "password ";
	}
	if (isWhitespace(document.form1.password_confirm.value)) 
	{
	  	Q += "  Confirm Password\n";
		Q1 += "password_confirm ";
	}
	if(form1.password.value != form1.password_confirm.value)
	{
		errMesg +="Password and Confirm Password are different";
	}
	if (isWhitespace(document.form1.hint_que.value)) 
	{
	  	Q += "  Hint Question \n";
		Q1 += "hint_que ";
	}
	if (isWhitespace(document.form1.hint_ans.value)) 
	{
	  	Q += "  Your Answer\n";
		Q1 += "hint_que ";
	}
	 
	
	if ( Q.length > 0 )
	{
		diplayMesg = "Please provide valid values for:\n" + Q ;
	}
	
	
	if (errMesg == "" && diplayMesg == "")
	{
		return true;
	}
	else
	{
		if(errMesg!="")
		{
			alert(errMesg);
			return false;
		}	
		else 
		{
			alert(diplayMesg);
			var aElementId =Q1.split(" ");
			var sFocusElement = aElementId[0];
			document.getElementById(sFocusElement).focus();
			return false;

		}
	}
	return false;
	
	
}

function searchClientTimesheet(theForm)
{
//	alert
	var errMesg = "";
	var diplayMesg = "";

	// Check all the Required Information fields.
	var Q = ""; // this block determines lifespan of Q
	if (isWhitespace(theForm.date_from.value))
	{
		Q += "  From Date \n";
	}
	if (isWhitespace(theForm.date_to.value))
	{
		Q += "  To Date \n";
	}
	
	j=0;
	for(i=0; i<=3;i++)
	{
		if(theForm.ts_status[i].checked)
		{
			j=1;
		}
	}
	if (j==0)
	{
		Q += "  Select Report \n";
	}
	var aToDate = theForm.date_to.value.split('/');
	var aFromDate = theForm.date_from.value.split('/');
	var sToDate = new Date(eval(aToDate[2]),eval(aToDate[1])-1,eval(aToDate[0]),0,0,0);
	var sFromDate = new Date(eval(aFromDate[2]),eval(aFromDate[1])-1,eval(aFromDate[0]),0,0,0);		
	var today = new Date();
	var sysdate=new Date(today.getFullYear(),today.getMonth(),today.getDate(),0,0,0);					
	if (sFromDate > sToDate)
	{
		errMesg += "From date cannot be greater than To date \n";
	}
	if (sFromDate > sysdate)
	{
		errMesg += "From date cannot be greater than current date \n";
	}
	if (sToDate > sysdate)
	{
		errMesg += "To date cannot be greater than current date \n";
	}
	if((theForm.iClient_account_id.value==0) || (theForm.iClient_account_id.value==''))
	{
		Q +="  Account \n";
	}
	if((theForm.iClient_dep_id.value==0)||(theForm.iClient_dep_id.value==''))
	{
		Q +="  Department \n";
	}
	if((theForm.iShift_id.value==0) || (theForm.iShift_id.value==''))
	{
		Q +="  Shift \n";
	}
	if ( Q.length > 0 )
	{
		diplayMesg = "Please provide valid values for :\n" + Q ;
	}

	if (errMesg == "" && diplayMesg == "")
	{
		return true;
	}
	else
	{
		if(diplayMesg!="")
		{
			alert(diplayMesg);
			return false;			
		}
		else
		{
			alert(errMesg);
			return false;
		}	
	}
	
}
function searchClientStaff(theForm)
{
//	alert
	var errMesg = "";
	var diplayMesg = "";

	// Check all the Required Information fields.
	var Q = ""; // this block determines lifespan of Q
	if (isWhitespace(theForm.date_from.value))
	{
		Q += "  From Date \n";
	}
	if (isWhitespace(theForm.date_to.value))
	{
		Q += "  To Date \n";
	}
	j=0;
	for(i=0; i<3;i++)
	{
		if(theForm.ts_status[i].checked)
		{
			j=1;
		}
	}
	if (j==0)
	{
		Q += "  Select Report \n";
	}
	var aToDate = theForm.date_to.value.split('/');
	var aFromDate = theForm.date_from.value.split('/');
	var sToDate = new Date(eval(aToDate[2]),eval(aToDate[1])-1,eval(aToDate[0]),0,0,0);
	var sFromDate = new Date(eval(aFromDate[2]),eval(aFromDate[1])-1,eval(aFromDate[0]),0,0,0);		
	var today = new Date();
	var sysdate=new Date(today.getFullYear(),today.getMonth(),today.getDate(),0,0,0);					
	if (sFromDate > sToDate)
	{
		errMesg += "From date cannot be greater than To date \n";
	}
	if (sFromDate > sysdate)
	{
		errMesg += "From date cannot be greater than current date \n";
	}
	if (sToDate > sysdate)
	{
		errMesg += "To date cannot be greater than current date \n";
	}
	if((theForm.iClient_account_id.value==0) || (theForm.iClient_account_id.value==''))
	{
		Q +="  Account \n";
	}
	if((theForm.iClient_dep_id.value==0)||(theForm.iClient_dep_id.value==''))
	{
		Q +="  Department \n";
	}
	if((theForm.iShift_id.value==0) || (theForm.iShift_id.value==''))
	{
		Q +="  Shift \n";
	}
	if ( Q.length > 0 )
	{
		diplayMesg = "Please provide valid values for :\n" + Q ;
	}

	if (errMesg == "" && diplayMesg == "")
	{
		if(theForm.ts_status[2].checked)
		{
			theForm.action="client_reports_staff_4.php";
		}
		else if(theForm.ts_status[0].checked)
		{
			theForm.action="client_reports_staff_2.php";
		}
		else if(theForm.ts_status[1].checked)
		{
			theForm.action="client_reports_staff_3.php";
		}
		theForm.submit();
		//return true;
	}
	else
	{
		if(diplayMesg!="")
		{
			alert(diplayMesg);
			return false;			
		}
		else
		{
			alert(errMesg);
			return false;
		}	
	}
	
}


function XMLHttpRequestObject () 
{
	if (window.XMLHttpRequest)
	{ 
	  reqXML = new XMLHttpRequest();            //set the request
	}
	//ActiveX - can we say IE?
	else if(window.ActiveXObject){ 
	  //Create our RequestObject
	  reqXML = new ActiveXObject("Microsoft.XMLHTTP"); 
	}
	
	return reqXML;
}//eof
function getClientAccountDep(iClientAccountId, iSelDepId) 
{
	if (iClientAccountId >0) 
	{
		//put the value in the hidden variable 
		document.getElementById('iClient_account_id').value=iClientAccountId;
	
		var reqXML = XMLHttpRequestObject();
		
		if(reqXML)
		{ 
			reqXML.onreadystatechange = fillclientDepDropDown;  //function to call on each step
			//reqXML.open("GET", "../allAjaxFunctions.php?case=vacClientAccountDep&iClientAccountId="+iClientAccountId+"&iSelDepId="+iSelDepId, true);         //set the page to request
			reqXML.open("GET", "reportAjaxFunctions.php?case=vacClientAccountDep&iClientAccountId="+iClientAccountId+"&iSelDepId="+iSelDepId, true);         //set the page to request
			reqXML.send(null);                     //initialize the request
		}
		else
		{  //I do not support this so I need to do something!
		   window.location.href = 'client_reports_timesheet_1.php';
		}       
	}else 
	{
		document.getElementById('tdClientDep').innerHTML= "<select class='field3' name='Client_dep_id' id='Client_dep_id' ><option value=0>Select Account</option></select>";
		
	}

}
          
function fillclientDepDropDown()
{
	//Look to see if the request is in the 4th stage (complete)         
	
	if(reqXML.readyState == 4)
	{
		//Make sure that we get a sucess page status   
		if(reqXML.status == 200)
		{
			var sResponse = reqXML.responseText;
			//alert(sResponse);
			
			document.getElementById('tdClientDep').innerHTML=sResponse;
		}
	}	
}

function getClientDepartmentShift(iAccountDepId, iSelShiftId) 
{
	
	if (iAccountDepId >0) 
	{
		document.getElementById('iClient_dep_id').value=iAccountDepId;
		
		var reqXML = XMLHttpRequestObject();
		
		if(reqXML)
		{ 
			reqXML.onreadystatechange = fillDepartmentShiftDropDown;  //function to call on each step
			//set the page to request
			reqXML.open("GET", "reportAjaxFunctions.php?case=vacClientDepartmentShift&iAccountDepId="+iAccountDepId+"&iSelShiftId="+iSelShiftId, true);
			
			reqXML.send(null);                     //initialize the request
		}
		else
		{  //I do not support this so I need to do something!
		   window.location.href = 'client_reports_timesheet_1.php';
		}       
	}else 
	{
		document.getElementById('tdShiftPattern').innerHTML= "<select  name='iShift_pattern_id[]' id='iShift_pattern_id' class='field3'><option value=0>Select Shift</option></select>	";
		
	}

}
          
function fillDepartmentShiftDropDown()
{
	//Look to see if the request is in the 4th stage (complete)         
	
	if(reqXML.readyState == 4)
	{
		//Make sure that we get a sucess page status   
		if(reqXML.status == 200)
		{
			var sResponse = reqXML.responseText;
			//alert(sResponse);
			document.getElementById('tdShiftPattern').innerHTML=sResponse;
		}
	}	
}
function setShift(shiftval)
{
	document.getElementById('iShift_id').value=shiftval;
}
function getSubSectorDropDown(iSector, iSubSector) 
{
	if (iSector==0) 
	return;
	if (iSector >0) 
	{
		var reqXML = XMLHttpRequestObject();
		
		if(reqXML)
		{ 
			reqXML.onreadystatechange = fillSubSectorDropDown;  //function to call on each step
			reqXML.open("GET", "clientAjaxFunctions.php?case=clientSubsector&iSectorId="+iSector+"&iSubSector="+iSubSector, true);         //set the page to request
			
			reqXML.send(null);                     //initialize the request
		}
		else
		{  //I do not support this so I need to do something!
		   window.location.href = client_edit1.php;
		}       
	}else 
	{
		document.getElementById('tdSub_sector').innerHTML= '<select name="sub_sector" id="sub_sector" class="input195" multiple size="2" onChange="getSubSector(this);">';
		document.getElementById('tdSub_sector').innerHTML+= "<option value=0>Select Sub Sector</option>";
		document.getElementById('tdSub_sector').innerHTML+= "</select>";
		document.getElementById('tdSub_sector').innerHTML+= "</select>";
		document.getElementById('hsub_sector').value= "";
	}

}


//-------

function Validate_profile()
{
	
	var i="";
	var Q1 = "";
	var errMesg = "";
	var diplayMesg = "";
	var Q = ""; // this block determines lifespan of Q
	

	if (isWhitespace(document.form1.password.value)) 
	{
	  	Q += "  Password\n";
		Q1 += "password ";
	}
	if (isWhitespace(document.form1.password_confirm.value)) 
	{
	  	Q += "  Confirm Password\n";
		Q1 += "password_confirm ";
	}
	if(form1.password.value != form1.password_confirm.value)
	{
		errMesg +="Password and Confirm Password are different";
	}
	if (isWhitespace(document.form1.hint_que.value)) 
	{
	  	Q += "  Hint Question \n";
		Q1 += "hint_que ";
	}
	if (isWhitespace(document.form1.hint_ans.value)) 
	{
	  	Q += "  Your Answer\n";
		Q1 += "hint_que ";
	}
	 
	
	if ( Q.length > 0 )
	{
		diplayMesg = "Please provide valid values for:\n" + Q ;
	}
	
	
	if (errMesg == "" && diplayMesg == "")
	{
		return true;
	}
	else
	{
		if(errMesg!="")
		{
			alert(errMesg);
			return false;
		}	
		else 
		{
			alert(diplayMesg);
			var aElementId =Q1.split(" ");
			var sFocusElement = aElementId[0];
			document.getElementById(sFocusElement).focus();
			return false;

		}
	}
	return false;
	
}
//--------
function fillSubSectorDropDown()
{
	//Look to see if the request is in the 4th stage (complete)         
	
	if(reqXML.readyState == 4)
	{
		//Make sure that we get a sucess page status   
		if(reqXML.status == 200)
		{
			var sResponse = reqXML.responseText;
			//alert(sResponse);
			
			document.getElementById('tdSub_sector').innerHTML=sResponse;
		}
	}	
}
function getSubSector(subSector)
{
	var i= subSector.length;
	var subSectorValues ="";
	for(j=1; j<i; j++)
	{
		if(subSector.options[j].selected)
		{
			if(subSectorValues=="")
			{
				subSectorValues = subSector.options[j].value;
			}
			else
			{
				subSectorValues = subSectorValues+","+subSector.options[j].value;
				
			}
		}
	}
	document.getElementById('hsub_sector').value = subSectorValues;
	
}
function show_hide(strVal)
{
		if(document.form1.country.options[form1.country.selectedIndex].text=='UK')
		{
			document.getElementById('countyTr').style.display='';
		}
		else
		{
			document.getElementById('countyTr').style.display='none';
			document.form1.county.value=0;
		}
}
function show_hide_billing(strVal)
{
		if(document.form1.billing_country.options[form1.billing_country.selectedIndex].text=='UK')
		{
			document.getElementById('countyBillingTr').style.display='';
		}
		else
		{
			document.getElementById('countyBillingTr').style.display='none';
			document.form1.billing_county.value=0;
		}
}
function setBillAdd(chk)
{
	
	if(chk.checked)
	{
		document.getElementById('billing_address1').value = document.getElementById('company_address1').value;
		document.getElementById('billing_address2').value = document.getElementById('company_address2').value;
		document.getElementById('billing_address3').value = document.getElementById('company_address3').value;
		document.getElementById('billing_town').value = document.getElementById('town').value;
		//document.getElementById('billing_country').value = document.getElementById('country').value;
		document.getElementById('billing_postcode').value = document.getElementById('postcode').value;
		//if(document.form1.country.options[form1.country.selectedIndex].text=='UK')
		//{
			//document.getElementById('countyBillingTr').style.display='';
			document.form1.billing_county.value = document.form1.county.value;
		//}
		//else
		//{
			//document.getElementById('countyBillingTr').style.display='none';
			//document.form1.billing_county.value=0;
		//}
	}
	else
	{
		document.getElementById('billing_address1').value = "";
		document.getElementById('billing_address2').value = "";
		document.getElementById('billing_address3').value = "";
		document.getElementById('billing_town').value = "";
		//document.getElementById('billing_country').value = 0;
		document.getElementById('billing_postcode').value = "";
		//document.getElementById('countyBillingTr').style.display='none';
		document.form1.billing_county.value=0;
	}
	
}

function setContactAdd(chk)
{
	
	if(chk.checked)
	{
		document.getElementById('contact_address1').value = document.getElementById('company_address1').value;
		document.getElementById('contact_address2').value = document.getElementById('company_address2').value;
		document.getElementById('contact_address3').value = document.getElementById('company_address3').value;
		document.getElementById('contact_town').value = document.getElementById('town').value;
		//document.getElementById('billing_country').value = document.getElementById('country').value;
		document.getElementById('contact_postcode').value = document.getElementById('postcode').value;
		//if(document.form1.country.options[form1.country.selectedIndex].text=='UK')
		//{
			//document.getElementById('countyBillingTr').style.display='';
			document.form1.contact_county.value = document.form1.county.value;
		//}
		//else
		//{
			//document.getElementById('countyBillingTr').style.display='none';
			//document.form1.billing_county.value=0;
		//}
	}
	else
	{
		document.getElementById('contact_address1').value = "";
		document.getElementById('contact_address2').value = "";
		document.getElementById('contact_address3').value = "";
		document.getElementById('contact_town').value = "";
		//document.getElementById('billing_country').value = 0;
		document.getElementById('contact_postcode').value = "";
		//document.getElementById('countyBillingTr').style.display='none';
		document.form1.contact_county.value=0;
	}
	
}

function show_hide_billing(strVal)
{
		if(document.form1.contact_country.options[form1.contact_country.selectedIndex].text=='UK')
		{
			document.getElementById('countyContactTr').style.display='';
		}
		else
		{
			document.getElementById('countyContactTr').style.display='none';
			document.form1.contact_county.value=0;
		}
}
function setConAdd(chk)
{
	
	if(chk.checked)
	{
		document.getElementById('contact_address1').value = document.getElementById('company_address1').value;
		document.getElementById('contact_address2').value = document.getElementById('company_address2').value;
		document.getElementById('contact_address3').value = document.getElementById('company_address3').value;
		document.getElementById('contact_town').value = document.getElementById('town').value;
		document.getElementById('contact_country').value = document.getElementById('country').value;
		document.getElementById('contact_postcode').value = document.getElementById('postcode').value;
		if(document.form1.country.options[form1.country.selectedIndex].text=='UK')
		{
			document.getElementById('countyContactTr').style.display='';
			document.form1.contact_county.value = document.form1.county.value;
		}
		else
		{
			document.getElementById('countyContactTr').style.display='none';
			document.form1.contact_county.value=0;
		}
	}	
	
}
function validateEmpReg(theForm)
{
//	alert


	var errMesg = "";
	var diplayMesg = "";

	// Check all the Required Information fields.
	var Q = ""; // this block determines lifespan of Q
	if (isWhitespace(theForm.company_name.value))
	{
		Q += "  Name \n";
	}
	if (isWhitespace(theForm.company_number.value))
	{
		Q += "  Registration Number  \n";
	}
	if (theForm.sector.value==0)
	{
		Q += "  Industry Sector \n";
	}
	if (isWhitespace(theForm.company_address1.value))
	{
		Q += "  Address \n";
	}
	if (isWhitespace(theForm.town.value))
	{
		Q += "  Town \n";
	}
	if (isWhitespace(theForm.postcode.value))
	{
		Q += "  Post Code \n";
	}
	/*if (theForm.country.value==0)
	{
		Q += "  Company Country \n";
	}
	*/
	if (theForm.county.value==0)
	{
		Q += "  County \n";
	}
	if (isWhitespace(theForm.billing_address1.value))
	{
		Q += "  Billing Address \n";
	}
	if (isWhitespace(theForm.billing_town.value))
	{
		Q += "  Billing Town \n";
	}
	if (isWhitespace(theForm.billing_postcode.value))
	{
		Q += "  Billing Post Code \n";
	}
	/*if (theForm.billing_country.value==0)
	{
		Q += "  Billing Country \n";
	}
	*/
	if (theForm.billing_county.value==0)
	{
		Q += "  Billing County \n";
	}
	if (theForm.title.value==0)
	{
		Q += "  Title \n";
	}
	if (isWhitespace(theForm.surname.value))
	{
		Q += "  First Name \n";
	}
	if (isWhitespace(theForm.lastname.value))
	{
		Q += "  Last Name \n";
	}
	if (theForm.position.value==0)
	{
		Q += "  Position \n";
	}
	if (isWhitespace(theForm.contact_address1.value))
	{
		Q += "  Contact Address \n";
	}
	if (isWhitespace(theForm.contact_town.value))
	{
		Q += "  Contact Town \n";
	}
	if (isWhitespace(theForm.contact_postcode.value))
	{
		Q += "  Contact Post Code \n";
	}
	/*if (theForm.contact_country.value==0)
	{
		Q += "  Work Country \n";
	}
	*/
	if (theForm.contact_county.value==0)
	{
		Q += "  Contact County \n";
	}
	if (isWhitespace(theForm.direct_phone.value))
	{
		Q += "  Contact Direct Line \n";
	}
	if (isWhitespace(theForm.email.value))
	{
		Q += "  Email Address \n";
	}
	if(!echeck(theForm.email.value))
	{
		errMesg += "Invalid Email address \n";
	}
	/*if (isWhitespace(theForm.password.value))
	{
		Q += "  Password \n";
	}
	if (isWhitespace(theForm.confirm_pass.value))
	{
		Q += "  Confirm Password \n";
	}
	if(theForm.password.value!=theForm.confirm_pass.value)
	{
		errMesg += "Password and Confirm Password doesnot match \n";
	}
	if (theForm.secret_question.value==0)
	{
		Q += "  Hint Question  \n";
	}
	if (isWhitespace(theForm.hint_ans.value))
	{
		Q += "  Hint Answer \n";
	}*/
		
	if ( Q.length > 0 )
	{
		diplayMesg = "Please provide valid values for :\n" + Q ;
	}

	if (errMesg == "" && diplayMesg == "")
	{
		return true;
	}
	else
	{
		if(diplayMesg!="")
		{
			alert(diplayMesg);
			return false;			
		}
		else
		{
			alert(errMesg);
			return false;
		}	
	}

}

//-----------------------
function validateRss(theForm)
{
	var errMesg = "";
	var diplayMesg = "";

	// Check all the Required Information fields.
	var Q = ""; // this block determines lifespan of Q
	if (theForm.rssId.value==0)
	{
		Q += "  Topic \n";
	}
	if (isWhitespace(theForm.rssEamil.value) || theForm.rssEamil.value=="Submit your Email ID:" )
	{
		Q += "  Email \n";
	}
	if(!echeck(theForm.rssEamil.value))
	{
		errMesg += "Invalid Email address \n";
	}
	if ( Q.length > 0 )
	{
		diplayMesg = "Please provide valid values for :\n" + Q ;
	}

	if (errMesg == "" && diplayMesg == "")
	{
		return true;
	}
	else
	{
		if(diplayMesg!="")
		{
			alert(diplayMesg);
			return false;			
		}
		else
		{
			alert(errMesg);
			return false;
		}	
	}

}

function checkIt(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        status = "This field accepts numbers only."
		return false
    }
    status = ""
    return true
}

function checkItAlpha(evt) {
    evt = (evt) ? evt : window.event
    var charCode = (evt.which) ? evt.which : evt.keyCode
    if ( (charCode >32 && (charCode < 65 || charCode > 122)) || (charCode >90 && charCode<97) ) {
        status = "This field accepts Alphabets only."
        return false
    }
    status = ""
    return true
}

//----------------
function validate_Report(theForm){

	
	var Q = ""; // this block determines lifespan of Q

	if (isWhitespace(document.form1.shift_pattern.value))
	{
	    if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		Q += " Shift Pattern\n";
	}

	

//check if the input is a checkbox
var ifdays_checked="false";
var days_value = new  Array();
inputs = document.getElementsByTagName('input');
var dayscounter=0;
	 for(var i=0; i < inputs.length; i++) {
        if(inputs[i].getAttribute('type') == 'checkbox') {
            if(inputs[i].checked) {
				ifdays_checked="true";
				days_value[dayscounter] = inputs[i].value;
				dayscounter=dayscounter+1;
            }
        }
    }
if (ifdays_checked=="false")
	{
	    if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		Q += " Shift Days\n";
	}

	if (document.form1.shiftime.selectedIndex=="0")
	{
	    if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		Q += " All Shift Same In/Out \n";
	}


	// Validation on Same All time for all selected Days
	if (document.form1.shiftime.selectedIndex=="1")
	{

	var flagshiftin="true";
	var flagshiftout="true";
	var flagshiftinoutdiff="";

	  if (document.form1.same_shift_in_time.selectedIndex=="0")
	    {
	    if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		flagshiftin="false";
		Q += " Same Shift In \n";
	    }

	if (document.form1.same_shift_out_time.selectedIndex=="0")
	    {
	    if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		flagshiftout="false";
		Q += " Same Shift Out \n";
	    }
					//check time
	if(flagshiftin=='true' && flagshiftout=='true'){
	var shift_in = document.form1.same_shift_in_time.options[document.form1.same_shift_in_time.selectedIndex].text;
	var shift_out = document.form1.same_shift_out_time.options[document.form1.same_shift_out_time.selectedIndex].text;
	flagshiftinoutdiff=validate_shiftinouttime(shift_in,shift_out);
	if(flagshiftinoutdiff=="false"){
	  if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		flagshiftout="false";
		
if(document.form1.end_nextdate.selectedIndex=="0"){
Q += " Shift in not more than Shift Out or Slelect Shift End Next Date to 'YES'\n";
}else{
Q += " Shift Out not more than Shift In or Slelect Shift End Next Date to 'NO'\n";
}


		
	}
	}
	}


	// Validation on Difference All time for all selected Days
	if (document.form1.shiftime.selectedIndex=="2")
	{
	var flagshiftin="true";
	var flagshiftout="true";
	var flagshiftinoutdiff="";

		for(var selectedDayscounter=0;selectedDayscounter<days_value.length; selectedDayscounter++) {
		var selectedDays=days_value[selectedDayscounter];

			if(selectedDays=='01'){ // Monday
			  if (document.form1.mon_shift_in_time.selectedIndex=="0")
	    		{
				flagshiftin="false";
	   	    	}

			  if (document.form1.mon_shift_out_time.selectedIndex=="0")
	    		{
				flagshiftout="false";
	   	    	}

			//check time
			if(flagshiftin=='true' && flagshiftout=='true'){
			var shift_in = document.form1.mon_shift_in_time.options[document.form1.mon_shift_in_time.selectedIndex].text;
			var shift_out = document.form1.mon_shift_out_time.options[document.form1.mon_shift_out_time.selectedIndex].text;
			flagshiftinoutdiff=validate_shiftinouttime(shift_in,shift_out);
			}//end time check


			}

			if(selectedDays=='02'){ // Tuesday
			  if (document.form1.tue_shift_in_time.selectedIndex=="0")
	    		{
				flagshiftin="false";
	   	    	}

			  if (document.form1.tue_shift_out_time.selectedIndex=="0")
	    		{
				flagshiftout="false";
	   	    	}

			//check time
			if(flagshiftin=='true' && flagshiftout=='true'){
			var shift_in = document.form1.tue_shift_in_time.options[document.form1.tue_shift_in_time.selectedIndex].text;
			var shift_out = document.form1.tue_shift_out_time.options[document.form1.tue_shift_out_time.selectedIndex].text;
			flagshiftinoutdiff=validate_shiftinouttime(shift_in,shift_out);
			}//end time check

			}

			if(selectedDays=='03'){ // Wednesday
			  if (document.form1.wed_shift_in_time.selectedIndex=="0")
	    		{
				flagshiftin="false";
	   	    	}

			  if (document.form1.wed_shift_out_time.selectedIndex=="0")
	    		{
				flagshiftout="false";
	   	    	}

			//check time
			if(flagshiftin=='true' && flagshiftout=='true'){
			var shift_in = document.form1.wed_shift_in_time.options[document.form1.wed_shift_in_time.selectedIndex].text;
			var shift_out = document.form1.wed_shift_out_time.options[document.form1.wed_shift_out_time.selectedIndex].text;
			flagshiftinoutdiff=validate_shiftinouttime(shift_in,shift_out);
			}//end time check
			}

			if(selectedDays=='04'){ // Thursday
			  if (document.form1.thur_shift_in_time.selectedIndex=="0")
	    		{
				flagshiftin="false";
	   	    	}

			  if (document.form1.thu_shift_out_time.selectedIndex=="0")
	    		{
				flagshiftout="false";
	   	    	}

							//check time
			if(flagshiftin=='true' && flagshiftout=='true'){
			var shift_in = document.form1.thur_shift_in_time.options[document.form1.thur_shift_in_time.selectedIndex].text;
			var shift_out = document.form1.thu_shift_out_time.options[document.form1.thu_shift_out_time.selectedIndex].text;
			flagshiftinoutdiff=validate_shiftinouttime(shift_in,shift_out);
			}//end time check
			}

			if(selectedDays=='05'){ // Friday
			  if (document.form1.fri_shift_in_time.selectedIndex=="0")
	    		{
				flagshiftin="false";
	   	    	}

			  if (document.form1.fri_shift_out_time.selectedIndex=="0")
	    		{
				flagshiftout="false";
	   	    	}

			//check time
			if(flagshiftin=='true' && flagshiftout=='true'){
			var shift_in = document.form1.fri_shift_in_time.options[document.form1.fri_shift_in_time.selectedIndex].text;
			var shift_out = document.form1.fri_shift_out_time.options[document.form1.fri_shift_out_time.selectedIndex].text;
			flagshiftinoutdiff=validate_shiftinouttime(shift_in,shift_out);
			}//end time check
			}

			if(selectedDays=='06'){ // Sat
			  if (document.form1.sat_shift_in_time.selectedIndex=="0")
	    		{
				flagshiftin="false";
	   	    	}

			  if (document.form1.sat_shift_out_time.selectedIndex=="0")
	    		{
				flagshiftout="false";
	   	    	}
			//check time
			if(flagshiftin=='true' && flagshiftout=='true'){
			var shift_in = document.form1.sat_shift_in_time.options[document.form1.sat_shift_in_time.selectedIndex].text;
			var shift_out = document.form1.sat_shift_out_time.options[document.form1.sat_shift_out_time.selectedIndex].text;
			flagshiftinoutdiff=validate_shiftinouttime(shift_in,shift_out);
			}//end time check
			}

			if(selectedDays=='00'){ // Sunday
			  if (document.form1.sun_shift_in_time.selectedIndex=="0")
	    		{
				flagshiftin="false";
	   	    	}

			  if (document.form1.sun_shift_out_time.selectedIndex=="0")
	    		{
				flagshiftout="false";
	   	    	}
			//check time
			if(flagshiftin=='true' && flagshiftout=='true'){
			var shift_in = document.form1.sun_shift_in_time.options[document.form1.sun_shift_in_time.selectedIndex].text;
			var shift_out = document.form1.sun_shift_out_time.options[document.form1.sun_shift_out_time.selectedIndex].text;
			flagshiftinoutdiff=validate_shiftinouttime(shift_in,shift_out);
			}//end time check
			}

		}
    // if shift_in_time is not selected for any day
	if (flagshiftin==="false"){
	    if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		Q += " Shift In Time \n";
	    }
	// if shift_out_time is not selected for any day
	if (flagshiftout==="false"){
	    if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		Q += " Shift Out Time \n";
	    }
	if(flagshiftinoutdiff=="false"){
	  if (Q==""){
		Q += "Please Provide Valid Values For:\n";
		}
		flagshiftout="false";
		//Q += " Shift in not more than Shift Out or Slelect Shift Ending in Next Date\n";
if(document.form1.end_nextdate.selectedIndex=="0"){
Q += " Shift in not more than Shift Out or Slelect Shift End Next Date to 'YES'\n";
}else{
Q += " Shift Out not more than Shift In or Slelect Shift End Next Date to 'NO'\n";
}	}
	}


	// Validation on Difference timein/out selection on the basis of Day(s) selection



		if(Q!="")
		{
			alert(Q);
			return false;
		}else{
		return true;
		}

}


function validate_msg(theForm)
		{
			
			
			if (isWhitespace(theForm.subject.value))
			{
				alert("Please Provide Value[s]  For:\n Subject");
				return false;
			}
			return true;
			}
			
			