var popUp;

function SetControlValue(controlID, newDate, isPostBack)
{
    popUp.close();
    document.forms[0].elements[controlID].value=newDate;
    __doPostBack(controlID,'');
}

function OpenPopupPage (pageUrl, controlID, isPostBack,isSelectWeek,SelectedDateWeekOnly,SelectedWeekEndDate)
{
if (document.forms[0].elements[controlID].disabled==false)
    {
    popUp=window.open(pageUrl+'?controlID='+controlID+ '&SelectedDate=' + document.forms[0].elements[controlID].value +'&isPostBack='+ isPostBack+'&isSelectWeek='+ isSelectWeek + '&SelectedDateWeekOnly=' + SelectedDateWeekOnly  + '&SelectedWeekEndDate=' + SelectedWeekEndDate,'popupcal', 'width=250,height=300,left=200,top=250'); 
    };
}
		                         

function SetRejectReason(controlID, reason, isPostBack)
{
    popUp.close();
    document.forms[0].elements[controlID].value=reason;
    if(reason!='')
    __doPostBack('btnReject','');
}


function IsEmpty(controlID,msg)
{
if (document.forms[0].elements[controlID].value != '')
    return true
else
    {
    if(msg!='')
        alert(msg);
    return false;
    }
}

function toggleLayer(whichLayer)
{
if (document.getElementById)
{
// this is the way the standards work
var style2 = document.getElementById(whichLayer).style;
style2.display = style2.display? "":"block";
}
else if (document.all)
{
// this is the way old msie versions work
var style2 = document.all[whichLayer].style;
style2.display = style2.display? "":"block";
}
else if (document.layers)
{
// this is the way nn4 works
var style2 = document.layers[whichLayer].style;
style2.display = style2.display? "":"block";
}
}

function confirm_delete()
{
  if (confirm("Are you sure you want to delete this time entry?")==true)
    return true;
  else
    return false;
}

function confirm_submit()
{
  if (confirm("Are you sure you want to submit this timesheet for approval?")==true)
    return true;
  else
    return false;
}

function confirm_approve()
{
  if (confirm("Are you sure you want to approve this timesheet?")==true)
    return true;
  else
    return false;
}

function confirm_reject()
{
  if (confirm("Are you sure you want to reject this timesheet?")==true)
    return true;
  else
    return false;
}

function confirm_Invoiced()
{
  if (confirm("Are you sure you want to mark this timesheet as INVOICED?")==true)
    return true;
  else
    return false;
}

function confirm_NOTInvoiced()
{
  if (confirm("Are you sure you want to mark this timesheet as NOT INVOICED?")==true)
    return true;
  else
    return false;
}

function SELECTListValidate(source, arguments)
{
  if (arguments.Value > 0)
    arguments.IsValid = true;
  else
    arguments.IsValid = false;
}

function NameFormatValidate(source, arguments)
{
  if (arguments.Value > 0)
    arguments.IsValid = true;
  else
    arguments.IsValid = false;
}

// Keep user from entering more than maxLength characters
function doKeypress(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength && value.length > maxLength-1){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
     }
}
// Cancel default behavior
function doBeforePaste(control){
    maxLength = control.attributes["maxLength"].value;
     if(maxLength)
     {
          event.returnValue = false;
     }
}
// Cancel default behavior and create a new paste routine
function doPaste(control){
    maxLength = control.attributes["maxLength"].value;
    value = control.value;
     if(maxLength){
          event.returnValue = false;
          maxLength = parseInt(maxLength);
          var oTR = control.document.selection.createRange();
          var iInsertLength = maxLength - value.length + oTR.text.length;
          var sData = window.clipboardData.getData("Text").substr(0,iInsertLength);
          oTR.text = sData;
     }
}


function ShowHelp(URL)
{
    //alert('hello');
    window.open(URL ,null,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=300,height=400,left=412,top=284'); 
    return false;
}