//'DECLARATION: THIS IS A FRAMEWORK CODE ITEM. IT IS NOT EXPECTED TO MODIFY THIS AT THE APPLICATION LEVEL
	//fn.. checks for value to be present and shows the message if empty
function disallowIncompletePhone(field) {
    var objValue = TrimAll(field.value);
    if (objValue.length < 12 && objValue.length > 0) {
        alert("Please enter complete number to proceed.");
        field.focus();
        return false;
    }
    else
        return true;
}

function disallowNonNumericWithHiphen(field) {
    disallowIncompletePhone(field);
    var valid = "0123456789-";
    for (var i = 0; i < field.value.length; i++) {
        temp = "" + field.value.substring(i, i + 1);
        if (valid.indexOf(temp) == "-1") {
            field.value = '';
            alert("Please enter only numeric data.");
            field.focus();

            //setTimeout( 'var ebox = field; ebox.focus();', 10 );    	            
            return false;
        }
        else
            return true;
    }
}

   function echeck(str) 
    {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if(lstr != 0 )
		{
		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 emailcheck(str,withoutalert) {
    var at = "@"
    var dot = "."
    var lat = str.indexOf(at)
    var lstr = str.length
    var ldot = str.indexOf(dot)
    if (lstr != 0) {
        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;
}



	
// Added by VyankateshS for Tabs
function addHours(myDate,hours) {
//var tempsec;
//tempsec=parseFloat(hours.split(".")[0]);
//alert(tempsec);
return new Date(myDate.getTime() + hours*60*60*1000);
//return new Date(myDate.getTime() + hours*60*60*1000);
}
//parseFloat(PickTime.split(":")[0]);
function addDays(myDate,days) {
return new Date(myDate.getTime() + days*60*60*1000);
}

function FormatDateTime_book(objSender, RadioObj)
{
    var radio0 = document.getElementById('ctl00_ContentPlaceHolder1_radioPickTime_passenger_0');
    var radio1 = document.getElementById('ctl00_ContentPlaceHolder1_radioPickTime_passenger_1');

    //alert(radio.checked);
	var CurrValue = objSender.value;
	var fieldValue = CurrValue.split(":");

    // CPS 5/5/08
     var NewValue = "";
     var errorMsg = fieldValue[0] + ':' + fieldValue[1] + ' is not a valid time.';

    // if the user types in only three digits(4 to include the colon), return those three digits and do nothing else.
	if (CurrValue.length == 4)
    {
        var stringValue = fieldValue[0] + '' + fieldValue[1];
        // format should be something like 20:5 or 10:5. we need it to be 1:05, for example.
        for (var i = 0; i < stringValue.length; i++)
	    {
	       // if the character isn't 0 through 9, delete it from the phone number
	       if(i == 0)
	           NewValue += stringValue.charAt(i) + ':';
	       else
	           NewValue += stringValue.charAt(i);
	    }


        fieldValue = NewValue.split(':');
        // don't let the user type anything past :59 for the minutes
        if (fieldValue[1] > 59)
        {
            alert(errorMsg);
            objSender.value = '';
            objSender.focus();
            return objSender.value;
        }
        else 
        {
            objSender.value = '0' + fieldValue[0] + ':' + fieldValue[1];
            return objSender.value;
        }
    }


    if (fieldValue[0] >= 24) {
        if (fieldValue[0] == 24) {
            if (fieldValue[1] > 00) {
                // time is something like 24:01, alert the user
                alert(errorMsg);
                objSender.value = '';
                objSender.focus();
                return objSender.value;
            }
        }
        
        if (fieldValue[0] > 24) 
        {
            // the time is definitely something wrong, like 25:00 or higher, abort
            alert(errorMsg);
            objSender.value = '';
            objSender.focus();
            return objSender.value;
        }
    }

    
    // don't let the user type anything past :59 for the minutes
    if (fieldValue[1] > 59)
    {
        alert(errorMsg);
        objSender.value = '';
        objSender.focus();
        return objSender.value;
    }



    // End CPS 5/5/08


	
	if(CurrValue != "")
	{
		if(fieldValue.length == 1)
		{
			if(fieldValue[0].length == 1)
			{
				NewValue = "0" + fieldValue[0] + ":00";
			}
			else
			{
				NewValue = fieldValue[0] + ":00";
			}
		}
		else
		{
			if(fieldValue[0].length == 1)
			{
				fieldValue[0] = "0" + fieldValue[0];
			}
			if(fieldValue[1].length == 1)
			{
				NewValue = fieldValue[0] + ":0" + fieldValue[1];
			}
			else if(fieldValue[1].length == 0)
			{
				NewValue = fieldValue[0] + ":00";
			}
			else
			{
				NewValue = fieldValue[0] + ":" + fieldValue[1];
			}
		}
		fieldValue = NewValue.split(":");
		if(parseInt(fieldValue[0]) > 12 && parseInt(fieldValue[0]) < 24)
		{
			fieldValue[0] = parseInt(fieldValue[0]) - 12;
			if(parseInt(fieldValue[0]) < 9)
			{
				fieldValue[0] = "0"+fieldValue[0];
			}
			//eval("document."+objSender.form.name+"."+RadioObj)[1].checked = true;
			radio1.checked = true;
		}
		else if(parseInt(fieldValue[0]) == 24 || parseFloat(fieldValue[0]) == 0)
		{
			fieldValue[0] = "12";
			//eval("document."+objSender.form.name+"."+RadioObj)[0].checked = true;
			radio0.checked = true;
		}
		else if(parseInt(fieldValue[0]) == 12)
		{
		    //eval("document."+objSender.form.name+"."+RadioObj)[1].checked = true;
		    radio1.checked = true;
		}
		else if(parseInt(fieldValue[0]) < 12 && !radio1.checked)
		{
		    //eval("document."+objSender.form.name+"."+RadioObj)[0].checked = true;
		    radio0.checked = true;
		}
		NewValue = fieldValue[0] + ":" + fieldValue[1];
		objSender.value = NewValue;
		return objSender.value;
		
	}
}


function FormatDateTime(objSender, RadioObj) {


    var CurrValue = objSender.value;
    var fieldValue = CurrValue.split(":");

    // CPS 5/5/08
    var NewValue = "";
    var errorMsg = fieldValue[0] + ':' + fieldValue[1] + ' is not a valid time.';

    // if the user types in only three digits(4 to include the colon), return those three digits and do nothing else.
    if (CurrValue.length == 4) {
        var stringValue = fieldValue[0] + '' + fieldValue[1];
        // format should be something like 20:5 or 10:5. we need it to be 1:05, for example.
        for (var i = 0; i < stringValue.length; i++) {
            // if the character isn't 0 through 9, delete it from the phone number
            if (i == 0)
                NewValue += stringValue.charAt(i) + ':';
            else
                NewValue += stringValue.charAt(i);
        }


        fieldValue = NewValue.split(':');
        // don't let the user type anything past :59 for the minutes
        if (fieldValue[1] > 59) {
            alert(errorMsg);
            objSender.value = '';
            objSender.focus();
            return objSender.value;
        }
        else {
            objSender.value = '0' + fieldValue[0] + ':' + fieldValue[1];
            return objSender.value;
        }
    }


    if (fieldValue[0] >= 24) {
        if (fieldValue[0] == 24) {
            if (fieldValue[1] > 00) {
                // time is something like 24:01, alert the user
                alert(errorMsg);
                objSender.value = '';
                objSender.focus();
                return objSender.value;
            }
        }

        if (fieldValue[0] > 24) {
            // the time is definitely something wrong, like 25:00 or higher, abort
            alert(errorMsg);
            objSender.value = '';
            objSender.focus();
            return objSender.value;
        }
    }


    // don't let the user type anything past :59 for the minutes
    if (fieldValue[1] > 59) {
        alert(errorMsg);
        objSender.value = '';
        objSender.focus();
        return objSender.value;
    }



    // End CPS 5/5/08



    if (CurrValue != "") {
        if (fieldValue.length == 1) {
            if (fieldValue[0].length == 1) {
                NewValue = "0" + fieldValue[0] + ":00";
            }
            else {
                NewValue = fieldValue[0] + ":00";
            }
        }
        else {
            if (fieldValue[0].length == 1) {
                fieldValue[0] = "0" + fieldValue[0];
            }
            if (fieldValue[1].length == 1) {
                NewValue = fieldValue[0] + ":0" + fieldValue[1];
            }
            else if (fieldValue[1].length == 0) {
                NewValue = fieldValue[0] + ":00";
            }
            else {
                NewValue = fieldValue[0] + ":" + fieldValue[1];
            }
        }
        fieldValue = NewValue.split(":");
        if (parseInt(fieldValue[0]) > 12 && parseInt(fieldValue[0]) < 24) {
            fieldValue[0] = parseInt(fieldValue[0]) - 12;
            if (parseInt(fieldValue[0]) < 9) {
                fieldValue[0] = "0" + fieldValue[0];
            }
            eval("document." + objSender.form.name + "." + RadioObj)[1].checked = true;
        }
        else if (parseInt(fieldValue[0]) == 24 || parseFloat(fieldValue[0]) == 0) {
            fieldValue[0] = "12";
            eval("document." + objSender.form.name + "." + RadioObj)[0].checked = true;
        }
        else if (parseInt(fieldValue[0]) == 12) {
            eval("document." + objSender.form.name + "." + RadioObj)[1].checked = true;
        }
        else if (parseInt(fieldValue[0]) < 12 && !eval("document." + objSender.form.name + "." + RadioObj)[1].checked) {
            eval("document." + objSender.form.name + "." + RadioObj)[0].checked = true;
        }
        NewValue = fieldValue[0] + ":" + fieldValue[1];
        objSender.value = NewValue;
        return objSender.value;

    }
}


function SetDateTime(e, objSender)
{

	try
	{
	   
        var evt = (e) ? e : window.event; 
        if (evt.keyCode == 8)
            return;    // user hit backspace. no formatting needed.
            
        //alert("KeyCode = " + evt.keyCode + ". CharCode = " + evt.charCode);
            
         
	    // First check to make sure the user didn't enter a non-number
	    var ValidChars = '0123456789';
	    // Get the phone number w/o dashes
	    var Time = objSender.value.split(':').join('');
	    
	    // loop through each character in the string
	    for (var i = 0; i < Time.length; i++)
	    {
	       // get the current character in the string
	       Char = Time.charAt(i);
	       // if the character isn't 0 through 9, delete it from the phone number
	       if (ValidChars.indexOf(Char) == -1)
	            Time = Time.substring(0, Time.length -1);
	    }
	    

    

	    // Add a dash if appropriate
	    if (Time.length >= 2 && Time.length < 5)
	        objSender.value = Time.substring(0, 2) + ':' + Time.substring(2, 4);
	    else
            objSender.value = Time;

	    
	    objSender.focus();
	}
	catch(e)
	{
	    makeAlert('Online Reservation',_e.message,'');
		objSender.focus();
	}
}


function ShowTab_Main(Tab)
{
  HideAllTabs_Main();
  
   if(Tab==1)
   {
      document.getElementById('tab_Book').style.display='block';
      document.getElementById('tab_BookH').className='TabSelected_Main';
      document.getElementById('tab_MyRidesH').className='TabNotSelected_Main';
      document.getElementById('tab_ProfileH').className='TabNotSelected_Main';
      document.getElementById('tab_QuoteH').className='TabNotSelected_Main';      
      document.getElementById('tab_SearchReservationH').className='TabNotSelected_Main';     
      
   }
   else if(Tab==2)
   {
      document.getElementById('tab_MyRides').style.display='block';
      document.getElementById('tab_MyRidesH').className='TabSelected_Main';
      document.getElementById('tab_BookH').className='TabNotSelected_Main';
      document.getElementById('tab_ProfileH').className='TabNotSelected_Main';
      document.getElementById('tab_QuoteH').className='TabNotSelected_Main';      
      document.getElementById('tab_SearchReservationH').className='TabNotSelected_Main';           
   }
   else if(Tab==3)
   {
    
     document.getElementById('tab_Profile').style.display='block';
     document.getElementById('tab_ProfileH').className='TabSelected_Main';
     document.getElementById('tab_BookH').className='TabNotSelected_Main';
     document.getElementById('tab_MyRidesH').className='TabNotSelected_Main';
     document.getElementById('tab_QuoteH').className='TabNotSelected_Main';
     document.getElementById('tab_SearchReservationH').className='TabNotSelected_Main';          
   }
   else if(Tab==4)
   {
     document.getElementById('tab_Quote').style.display='block';
     document.getElementById('tab_ProfileH').className='TabNotSelected_Main';
     document.getElementById('tab_BookH').className='TabNotSelected_Main';
     document.getElementById('tab_MyRidesH').className='TabNotSelected_Main';
     document.getElementById('tab_QuoteH').className='TabSelected_Main';
     document.getElementById('tab_SearchReservationH').className='TabNotSelected_Main';          
   }
   else if(Tab==5)
   {
     document.getElementById('tab_SearchReservation').style.display='block';
     document.getElementById('tab_SearchReservationH').className='TabSelected_Main';
     document.getElementById('tab_QuoteH').className='TabNotSelected_Main';
     document.getElementById('tab_ProfileH').className='TabNotSelected_Main';
     document.getElementById('tab_BookH').className='TabNotSelected_Main';
     document.getElementById('tab_MyRidesH').className='TabNotSelected_Main';
   }
  
}

function HideAllTabs_Main()
{
   document.getElementById('tab_Book').style.display='none';
   document.getElementById('tab_MyRides').style.display='none';
   document.getElementById('tab_Profile').style.display='none';
   document.getElementById('tab_Quote').style.display='none';
   document.getElementById('tab_Payment').style.display='none';
   document.getElementById('tab_SearchReservation').style.display='none';
   
   document.getElementById('tab_BookH').className='TabNormal';
   document.getElementById('tab_MyRidesH').className='TabNormal';
   document.getElementById('tab_ProfileH').className='TabNormal';
   document.getElementById('tab_QuoteH').className='TabNormal';   
   document.getElementById('tab_PaymentH').className='TabNormal';   
   document.getElementById('tab_SearchReservationH').className='TabNormal';   
}


 
function ShowTab(Tab)
{
  HideAllTabs();
  
   if(Tab==1)
   {
      document.getElementById('tab_CustomerInfo').style.display='block';
      document.getElementById('tab_CustomerInfoH').className='TabSelected';
     
   }
   else if(Tab==2)
   {
      document.getElementById('tab_Reservation').style.display='block';
      document.getElementById('tab_ReservationH').className='TabSelected';
     
   }
   else if(Tab==3)
   {
     document.getElementById('tab_Payment').style.display='block';
     document.getElementById('tab_PaymentH').className='TabSelected';
     
   }
  
}

function HideAllTabs()
{
   document.getElementById('tab_CustomerInfo').style.display='none';
   document.getElementById('tab_Reservation').style.display='none';
   document.getElementById('tab_Payment').style.display='none';
   
   document.getElementById('tab_CustomerInfoH').className='TabNormal';
   document.getElementById('tab_ReservationH').className='TabNormal';
   document.getElementById('tab_PaymentH').className='TabNormal';
}

function Open_Terms()
{
    window.open("TermsAndConditions.aspx", "ModalChild", "menubar=no,scrollbars=1,left=" + (window.screen.width - 400) / 2 + ",top=" + (window.screen.height - 170) / 2 + ",width=600,height=325");
    return false;
}
 
   
 function FormatPhoneNumber(e, objSender)
{

	try
	{
	   
        var evt = (e) ? e : window.event; 
        if (evt.keyCode == 8)
            return;    // user hit backspace. no formatting needed.
            
        //alert("KeyCode = " + evt.keyCode + ". CharCode = " + evt.charCode);
            
         
	    // First check to make sure the user didn't enter a non-number
	    var ValidChars = '0123456789';
	    // Get the phone number w/o dashes
	    var PhoneNumber = objSender.value.split('-').join('');

	    // loop through each character in the string
	    for (var i = 0; i < PhoneNumber.length; i++)
	    {
	       // get the current character in the string
	       Char = PhoneNumber.charAt(i);
	       // if the character isn't 0 through 9, delete it from the phone number
	       if (ValidChars.indexOf(Char) == -1)
	            PhoneNumber = PhoneNumber.substring(0, PhoneNumber.length -1);
	    }
	    	    
	    
	    // Add a dash if appropriate
	    if (PhoneNumber.length >= 3 && PhoneNumber.length < 6)
	        objSender.value = PhoneNumber.substring(0, 3) + '-' + PhoneNumber.substring(3, 6);
	    else if(PhoneNumber.length >= 3 && PhoneNumber.length >= 6)
	        objSender.value = PhoneNumber.substring(0, 3) + '-' + PhoneNumber.substring(3, 6) + '-' + PhoneNumber.substring(6);
	    else
            objSender.value = PhoneNumber;	    
    
	    
	    objSender.focus();
	}
	catch(e)
	{
	    makeAlert('Online Reservation',_e.message,'');
		objSender.focus();
	}
}

//End of addition by VyankateshS.

	function IsEmpty(obj,strMessage)
	{
	if ( trimString(obj.value) == "" )
	{
		alert(strMessage);
		obj.value = "";
		obj.focus();
		return true;
	}
	else
	{
		return false;
	}
	}
	//fn.. trims the string
	function trimString (str) 
	{
	str = this != window? this : str;
	return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
	}
	
	// fn.. to display the calendar control
	function callcalendar(formname,datefield)
	{
		var objdateObject=GetObjectReference(formname,datefield);
		if (objdateObject.disabled==true) {return;}
		var dtval;
	if(objdateObject.value =='')
		dtval='None'	
	else
		dtval=objdateObject.value;
 	
 	//Issue ID 28888
	if (window.showModalDialog)
		calendar_window=window.open('../General/Calendar.aspx?datefield=' + datefield +'&formname=' + formname + '&dateval=' + dtval,'calendar_window','top=0,left=0,width=348,height=260');
	else
		calendar_window=window.open('../General/Calendar.aspx?datefield=' + datefield +'&formname=' + formname + '&dateval=' + dtval,'calendar_window','top=0,left=0,width=348,height=300');		
	
	calendar_window.focus()
	}
	
  /* Added By SandeepA on 31 Aug,2005 For Requirement Tag : WAF3_CDB_7 and WAF3_CDB_19 */
    function callcolorpalette(formname,colorfield)
	{
	   /******************************************************************************
	    ******************************************************************************
	     Purpose : Function to display the ColorPalette window.
	     Author  : SandeepA
	     Date    : 31 Aug,2005.
	     ******************************************************************************
	     *****************************************************************************/
	var objcolorObject=GetObjectReference(formname,colorfield);
	if (objcolorObject.disabled==true) {return;}
	var colval;
	if(objcolorObject.value =='')
		colval='None'	
	else
		colval=objcolorObject.value;
 		if (window.showModalDialog)
		calendar_window=window.open('../General/ColorPalette.aspx?colorfield=' + colorfield +'&formname=' + formname + '&colorval=' + colval,'ColorPalette_window','top=0,left=0,width=348,height=300');
	else
		calendar_window=window.open('../General/ColorPalette.aspx?colorfield=' + colorfield +'&formname=' + formname + '&colorval=' + colval,'ColorPalette_window','top=0,left=0,width=348,height=300');		
	
	//ColorPalette_window.focus()
	}
   /* End of Addition (Function callcolorpalette) For Requirement Tag : WAF3_CDB_7 and WAF3_CDB_19 */

	
	// fns.. to display help
	function Help_OnClick(HelpID)
	{
		//window.open("../General/Help.aspx?HelpID=" + HelpID ,"_help","resizable=yes,scrollbars=yes,left=0,top=0,width=250,height=250");
	//Integrated by MrugajaB on 19th Sept 2006 for Whiziblesem SP7
	//Purpose:When we open a help window and click on other window,help window gets minimized, now if we go to some other page and open help wndow,it's in minimized state only
	//added for SCS IssueID 3641
		var newwindow;		
		newwindow=window.open("../General/Help.aspx?HelpID=" + HelpID ,"_help","resizable=yes,scrollbars=yes,left=0,top=0,width=250,height=250");
		if(window.focus){newwindow.focus();}	
		//End of added for SCS IssueID 3641
		//End Modification
	}
	// help for pages in General folder
	function OpenHelpPage(HelpID)
	{
		Help_OnClick(HelpID)
		//window.open("../General/Help.aspx?HelpID=" + HelpID ,"_help","resizable=yes,scrollbars=yes,left=0,top=0,width=250,height=250");
	}
	// close the window
	function Close_OnClick()
	{
		window.close(); 
	}

var ns;
if(navigator.appName == 'Netscape')
	ns=true;
else
	ns=false;		


function GetObjectReference(strFormId,strElementId,blnIsName)
{
	var objElement;
	var objCombo;
	
		if ( blnIsName )
		{
				objElement = document.getElementsByName(strElementId);
		}
		else if ( !(blnIsName) )
		{
			objElement = document.getElementById(strElementId);
		}
		return objElement;
	
}
function GetParentFrameReference()
{
	var objElement;
		//alert(top.frames[0].frames.length);
		//alert(window.parent.frames['frmDown']);
		objElement=window.parent.frames;
		return objElement;
}

function GetFormReference(strFormId)
{
	var objElement;
	
			objElement = document.getElementById(strFormId);
			return objElement;
	
}
function GetObjectEvent(e)
{
	var objElement;
	if ( ns )
	{
			objElement=e.target;
	}
	else
	{
		objElement=e.srcElement;
	}
	
	return objElement;
}
function opentextdialog(frmName,txtObject,title,IsDisable,path)
{	
	var	objText=GetObjectReference(frmName,txtObject);
	//Code uncommented by MonikaI on 3rd Oct 2006, HotfixID : 2.0.37-SP4-WAF
	//Code commented by SandipL on 5 Dec 2005 -- TextDialogBox Issue
	if (objText.disabled==true || objText.readOnly==true) {return;}
	//End by MonikaI 
	//Issue ID 28888
	title = replaceSubstring(replaceSubstring(replaceSubstring(title,"&","%26"),"#","%23"),"+","%2b");

	var strDescription;
	if(title==null)
		title=""
	if(path==null) {
		//Issue ID 28888
		//strDescription=window.showModalDialog("../General/TextDialogBox.aspx?Title=" + title +"&Disable=" + IsDisable, objText ,"dialogWidth:545px;dialogHeight:530px");	
//Integrated by MonikaI on 3rd Oct 2006, HotfixID : 2.0.37-SP4-WAF
		if (window.showModalDialog)	{
			//strDescription = window.showModalDialog(strAddress , objText.value ,"dialogWidth=545px;dialogHeight=530px");
			strDescription=window.showModalDialog("../General/TextDialogBox.aspx?Title=" + title +"&Disable=" + IsDisable, objText ,"dialogWidth:545px;dialogHeight:530px");
		} else {
//End of integration by MonikaI
			var strAddress;
			strAddress="../General/TextDialogBox.aspx?Title=" + title +"&Disable=" + IsDisable +"&ParentFormName=" + frmName +"&TextAreaName=" + txtObject +"&TextAreaValue=" + objText.value;
//Commented by MonikaI on 3rd Oct 2006, HotfixID : 2.0.37-SP4-WAF
		//if (window.showModalDialog)	{
		//	strDescription = window.showModalDialog(strAddress , objText.value ,"dialogWidth=545px;dialogHeight=530px");
		//} else {
//End by MonikaI
			ShowWindow(strAddress,objText.value);
		}
	} else {
		//Issue ID 28888
		//strDescription=window.showModalDialog(path + '?Title=' + title +"&Disable=" + IsDisable, objText,"dialogWidth:545px;dialogHeight:530px");
//Integrated by MonikaI on 3rd Oct 2006, HotfixID : 2.0.37-SP4-WAF
		if (window.showModalDialog) {
			//strDescription = window.showModalDialog(strAddress , value ,"dialogWidth=545px;dialogHeight=530px");
			strDescription=window.showModalDialog(path + '?Title=' + title +"&Disable=" + IsDisable, objText,"dialogWidth:545px;dialogHeight:530px");
		} else {
//End of integration by MonikaI
		var strAddress;
		strAddress=path + '?Title=' + title +"&Disable=" + IsDisable +"&ParentFormName=" + frmName +"&TextAreaName=" + txtObject +"&TextAreaValue=" + objText.value;
//Commented by MonikaI on 3rd Oct 2006, HotfixID : 2.0.37-SP4-WAF
		//if (window.showModalDialog) {
		//	strDescription = window.showModalDialog(strAddress , value ,"dialogWidth=545px;dialogHeight=530px");
		//} else {
//End by MonikaI
			ShowWindow(strAddress,objText.value);
		}
	}

	if ((IsDisable=="False") && (window.showModalDialog)) {	
		objText.value=strDescription; 
	}
}	
//start Issue ID 28888
var winModalWindow;
 
function IgnoreEvents(e)
{
  return false;
}
 
function ShowWindow(strAddress, value)
{
  if (window.showModalDialog)
  {
   return window.showModalDialog(strAddress , value ,"dialogWidth=545px;dialogHeight=530px");
  }
  else 
  {
    window.top.captureEvents (Event.CLICK|Event.FOCUS);
    window.top.onclick=IgnoreEvents;
    window.top.onfocus=HandleFocus ;
    winModalWindow = window.open (strAddress  ,"ModalChild","dependent=yes,left=" + (window.screen.width - 545)/2 + ",top=" + (window.screen.height - 600)/2 + ",width=545,height=600");
    winModalWindow.focus();
    //return winModalWindow
    //winModalWindow
  }
}
 
function HandleFocus()
{
  if (winModalWindow)
  {
    if (!winModalWindow.closed)
    {
      winModalWindow.focus();
    }
    else
    {
      window.top.releaseEvents (Event.CLICK|Event.FOCUS);
      window.top.onclick = "";
    }
  }
  return false
}
//End Issue ID 28888

// fns.. to display HTML Editor
function callHTMLEditor(formname,datefield)
{
	htmleditor_window=window.open('../General/HTMLEditor.aspx?datefield=' + datefield +'&formname=' + formname,'htmleditor_window','left=' + ((window.screen.width - 700)/2) + ',top=' + ((window.screen.height - 500)/2) + ',width=700,height=500') //Modified By Ninad Text Area Req ID - WAF3_PB_48
}

//this code is used for showing the image or HTML as tooltip for any control.	
	var FADINGTOOLTIP
	var wnd_height, wnd_width;
	var tooltip_height, tooltip_width;
	var tooltip_shown=false;
	var	transparency = 100;
	var timer_id = 1;
	var m_adjustToolTip;
	var m_fadedToolTip="";
	
	//window.onload = WindowLoading;
	//window.onresize = UpdateWindowSize;
	document.onmousemove = AdjustToolTipPosition;

	function DisplayTooltip(tooltip_text)
	{
		
		if(FADINGTOOLTIP==null)
			return;
		FADINGTOOLTIP.innerHTML =tooltip_text 
		tooltip_shown = (tooltip_text != "")? true : false;
		if(tooltip_text != "")
		{
			tooltip_height=(FADINGTOOLTIP.style.pixelHeight)? FADINGTOOLTIP.style.pixelHeight : FADINGTOOLTIP.offsetHeight;
			transparency=0;
			if(m_fadedToolTip =="")
				ToolTipFading();
		} 
		else 
		{
			clearTimeout(timer_id);
			FADINGTOOLTIP.style.visibility="hidden";
		}
	}

	function DisplayTooltipCL(tooltip_text)
	{
		//Hotfix... 1.0.0-SP1-WAF
		document.onmousemove = AdjustToolTipPositionForCL;	
		if(FADINGTOOLTIP==null)
			return;
		FADINGTOOLTIP.innerHTML =tooltip_text 
		tooltip_shown = (tooltip_text != "")? true : false;
		if(tooltip_text != "")
		{
			tooltip_height=(FADINGTOOLTIP.style.pixelHeight)? FADINGTOOLTIP.style.pixelHeight : FADINGTOOLTIP.offsetHeight;
			transparency=0;
			if(m_fadedToolTip =="")
				ToolTipFading();
		} 
		else 
		{
			clearTimeout(timer_id);
			FADINGTOOLTIP.style.visibility="hidden";
		}
	}
	
	function AdjustToolTipPosition(e)
	{	
		if(m_adjustToolTip!=null)
		{
			FADINGTOOLTIP.style.visibility = "visible";
			//modified RajK June 23 2005 issue id: 19358 
			//modified RajK 11-Aug-2005 issue id: 20642 
			//removed the comment for IE browser 
			if(navigator.appName == 'Microsoft Internet Explorer')
			{
			return;
			}
			//end modification RajK 11-Aug-2005 issue id: 20642 
			//end modification RajK June 23 2005 issue id: 19358 
		}

		if(tooltip_shown)
		{
			//modified RajK June 23 2005 issue id: 19358 
			if(navigator.appName != 'Microsoft Internet Explorer')
			{
				FADINGOOLTIP.style.visibility = "visible";
				FADINGTOOLTIP.style.left = e.clientX + document.body.scrollLeft + 'px';//Math.min(wnd_width - tooltip_width - 10 , Math.max(3, e.clientX -150)) + document.body.scrollLeft + 'px';
				FADINGTOOLTIP.style.top = e.clientY + document.body.scrollTop + 'px';//+ offset_y + document.body.scrollTop + 'px';
			}
			else
			{
				offset_y = (event.clientY + tooltip_height - document.body.scrollTop + 30 >= wnd_height) ? - 15 - tooltip_height: 20;
				FADINGTOOLTIP.style.visibility = "visible";
				FADINGTOOLTIP.style.left = Math.min(wnd_width - tooltip_width - 10 , Math.max(3, event.clientX -350)) + document.body.scrollLeft + 'px';
				FADINGTOOLTIP.style.top = event.clientY + offset_y + document.body.scrollTop + 'px';
			}
			//end modification RajK June 23 2005 issue id: 19358 
				
		}
		
	}
	
	//Hotfix... 1.0.0-SP1-WAF
	function AdjustToolTipPositionForCL(e)
	{	
		if(m_adjustToolTip!=null)
		{
			FADINGTOOLTIP.style.visibility = "visible";
			return;
		}
		if(tooltip_shown)
		{
		
			offset_y = (event.clientY + tooltip_height - document.body.scrollTop + 30 >= wnd_height) ? - 15 - tooltip_height: 20;
			FADINGTOOLTIP.style.visibility = "visible";
			FADINGTOOLTIP.style.left = Math.min(wnd_width - tooltip_width - 10 , Math.max(3, event.clientX -350)) + document.body.scrollLeft + 'px';
			FADINGTOOLTIP.style.top = event.clientY + offset_y + document.body.scrollTop + 'px';
			//alert(FADINGTOOLTIP.offsetWidth);
			//FADINGTOOLTIP.style.left=(window.screen.width- 280)/2
			//FADINGTOOLTIP.style.top=(window.screen.height-492)/2
						
		}
		
	}

	function WindowLoading(adjustToolTip,fadedToolTip)
	{
		FADINGTOOLTIP=document.getElementById('FADINGTOOLTIP');
			
		if(adjustToolTip !=	null)
		{
			m_adjustToolTip = adjustToolTip;
		}
		if(fadedToolTip !=null)
		{
			m_fadedToolTip=fadedToolTip
		}

		tooltip_width = (FADINGTOOLTIP.style.pixelWidth) ? FADINGTOOLTIP.style.pixelWidth : FADINGTOOLTIP.offsetWidth;
		
		tooltip_height=(FADINGTOOLTIP.style.pixelHeight)? FADINGTOOLTIP.style.pixelHeight : FADINGTOOLTIP.offsetHeight;

		UpdateWindowSize();
	}
	
	function ToolTipFading()
	{
		if(transparency <= 100)
		{
			FADINGTOOLTIP.style.filter="alpha(opacity="+transparency+")";
			transparency += 5;
			timer_id = setTimeout('ToolTipFading()', 35);
		}
	}

	function UpdateWindowSize(adjustToolTip,fadedToolTip) 
	{
		if(adjustToolTip !=	null)
		{
			m_adjustToolTip = adjustToolTip;
		}
		if(fadedToolTip !=null)
		{
			m_fadedToolTip=fadedToolTip
		}
		wnd_height=document.body.clientHeight;
		wnd_width=document.body.clientWidth;
	}

	function DateDiff( start, end, interval, rounding ) 
	{

		var iOut = 0;

		// Create 2 error messages, 1 for each argument.</KBD> 
		var startMsg = "Check the Start Date and End Date\n"
			startMsg += "must be a valid date format.\n\n"
			startMsg += "Please try again." ;

		var intervalMsg = "Sorry the dateAdd function only accepts\n"
			intervalMsg += "d, h, m OR s intervals.\n\n"
			intervalMsg += "Please try again." ;

		var bufferA = Date.parse( start ) ;
		var bufferB = Date.parse( end ) ;

		// check that the start parameter is a valid Date. </KBD>
		if ( isNaN (bufferA) || isNaN (bufferB) )
		{
			alert( startMsg ) ;
			return null ;
		}

		// check that an interval parameter was not numeric.</KBD> 
		if ( interval.charAt == 'undefined' ) 
		{
			// the user specified an incorrect interval, handle the error.</KBD> 
			alert( intervalMsg ) ;
			return null ;
		}
		var number = bufferB-bufferA ;
		// what kind of add to do?</KBD> 
		switch(interval.charAt(0))
		{
			case 'd': case 'D': 
				iOut = parseInt(number / 86400000) ;
				if(rounding) iOut += parseInt((number % 86400000)/43200001) ;
					break ;
			case 'h': case 'H':
				iOut = parseInt(number / 3600000 ) ;
				if(rounding) iOut += parseInt((number % 3600000)/1800001) ;
				break ;
			case 'm': case 'M':
				iOut = parseInt(number / 60000 ) ;
				if(rounding) iOut += parseInt((number % 60000)/30001) ;
				break ;
			case 's': case 'S':
				iOut = parseInt(number / 1000 ) ;
				if(rounding) iOut += parseInt((number % 1000)/501) ;
				break ;
			default:
				// If we get to here then the interval parameter
				// didn't meet the d,h,m,s criteria.  Handle
				// the error.</KBD> 		
				alert(intervalMsg) ;
				return null ;
		}
		return iOut ;
	}	
	function DateAdd(startDate, numDays, numMonths, numYears)
	{
	//Code obtained from http://javascript.about.com
		var returnDate = new Date(startDate.getTime());
		var yearsToAdd = numYears;
		
		var month = returnDate.getMonth()	+ numMonths;
		if (month > 11)
		{
			yearsToAdd = Math.floor((month+1)/12);
			month -= 12*yearsToAdd;
			yearsToAdd += numYears;
		}
		returnDate.setMonth(month);
		returnDate.setFullYear(returnDate.getFullYear()	+ yearsToAdd);
		
		returnDate.setTime(returnDate.getTime()+60000*60*24*numDays);
		
		return returnDate;

	}

	function YearAdd(startDate, numYears)
	{
	//Code obtained from http://javascript.about.com
			return DateAdd(startDate,0,0,numYears);
	}

	function MonthAdd(startDate, numMonths)
	{
	//Code obtained from http://javascript.about.com
			return DateAdd(startDate,0,numMonths,0);
	}

	function DayAdd(startDate, numDays)
	{
	//Code obtained from http://javascript.about.com
			return DateAdd(startDate,numDays,0,0);
	}
		
	function MonthName(intMonth)
	{
		var strMonths = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
		
		if((isInteger(intMonth) == false) || (intMonth < 0) || (intMonth > 11))
			return "";
			
		return strMonths[intMonth];
	}
	function GetDateInFormat(OriginalDate, fmt)
	{
		//The dtmToDate must be in MMM, dd yyyy
		//Returns in dd-MMM-yyyy format.
		var dtmToDate ;
		var arrMakeOriginal;
		if (arguments.length>2)
		{
			//This will reverse the logic and convert the 
			//original date in parsable format.
			if (arguments[2] == "rev")
			{
				var dtmToDate = replaceSubstring(OriginalDate, "-", " ");
				return(dtmToDate);
			}
		}
		if ( fmt == "MMM, dd yyyy" )
		{
			dtmToDate = replaceSubstring(OriginalDate, ", ", "-");
			dtmToDate = replaceSubstring(dtmToDate, " ", "-");
			arrMakeOriginal = dtmToDate.split("-");
			
			dtmToDate=arrMakeOriginal[1] + "-" ;
			dtmToDate = dtmToDate + arrMakeOriginal[0] + "-" ;
			dtmToDate = dtmToDate + arrMakeOriginal[2] ;
		}
		else if (fmt == "dd, MMM yyyy")
		{
			dtmToDate = replaceSubstring(OriginalDate, ", ", "-");
			dtmToDate = replaceSubstring(dtmToDate, " ", "-");
			arrMakeOriginal = dtmToDate.split("-");
			
			dtmToDate=arrMakeOriginal[0] + "-" ;
			dtmToDate = dtmToDate + arrMakeOriginal[1] + "-" ;
			dtmToDate = dtmToDate + arrMakeOriginal[2] ;
		}
		else if(fmt == "MMM dd,yyyy")
		{
			dtmToDate = replaceSubstring(OriginalDate, ", ", "-");
			dtmToDate = replaceSubstring(dtmToDate, ",", "-");
			dtmToDate = replaceSubstring(dtmToDate, " ", "-");
			arrMakeOriginal = dtmToDate.split("-");
			
			dtmToDate=arrMakeOriginal[1] + "-" ;
			dtmToDate = dtmToDate + arrMakeOriginal[0] + "-" ;
			dtmToDate = dtmToDate + arrMakeOriginal[2] ;
		}
		return(dtmToDate);
	}

//------------------------------------------------------------------------------
//Purpose : Select all check boxes
//------------------------------------------------------------------------------
	function SelectAll_OnClick(strFormName, strCheckbox)
	//Pass FormName and the Checkbox's ID
	{
		var objCheckbox = GetObjectReference(strFormName,strCheckbox,true);
		var intItems;
		var intCtr;
		
		if (objCheckbox != null)
		{
			intItems = objCheckbox.length;
			if(intItems > 1) 
			{
				for (intCtr = 0;intCtr <= intItems - 1; intCtr++)
				{
					if (objCheckbox[intCtr].disabled == false)
						objCheckbox[intCtr].checked = true;							
				}
			}
			// Else, if single element exists, then...
			else if(intItems == 1)
			{
				if (objCheckbox[0].disabled == false) 
					objCheckbox[0].checked = true;						
			}
		}
	
	}

//------------------------------------------------------------------------------
//Purpose : Clear all check boxes
//------------------------------------------------------------------------------
	function ClearAll_OnClick(strFormName, strCheckbox)
	//Pass FormName and the Checkbox's ID
	{
		var objCheckbox = GetObjectReference(strFormName,strCheckbox,true);
		var intItems;
		var intCtr;
		
		if (objCheckbox != null)
		{
			intItems = objCheckbox.length;
						
			if(intItems > 1) 
			{
				for (intCtr = 0;intCtr <= intItems - 1; intCtr++)
				{
					if (objCheckbox[intCtr].disabled == false)
						objCheckbox[intCtr].checked = false;							
				}
			}
			// Else, if single element exists, then...
			else if(intItems == 1)
			{
				if (objCheckbox[0].disabled == false) 
					objCheckbox[0].checked = false;						
			}
		}
	
	}
//------------------------------------------------------------------------------
//Purpose : enable all check boxes
//------------------------------------------------------------------------------
	
	function EnableCheckBoxes(strFormName,strCheckBox)
		{
			
			var objCheckbox = GetObjectReference(strFormName,strCheckBox,true);
			var intItems;
			var intCtr;
		
			if (objCheckbox != null)
			{
				intItems = objCheckbox.length;
					if(intItems > 1) 
					{
						for (intCtr = 0;intCtr <= intItems - 1; intCtr++)
						{
							if (objCheckbox[intCtr].disabled == true)
								objCheckbox[intCtr].disabled = false;							
						}
					}
					// Else, if single element exists, then...
					// Added by MonikaI on 12-Sep-2006. IssueID : 4261 
					//else
					else if (intItems == 1)		
					//End by MonikaI
					
					{
						if (objCheckbox[0].disabled == true) 
							objCheckbox[0].disabled = false;						
					}
			}
	
		}

//------------------------------------------------------------------------------
//Purpose : disable all check boxes
//------------------------------------------------------------------------------
	
	function DisableCheckBoxes(strFormName,strCheckBox)
		{
			
			var objCheckbox = GetObjectReference(strFormName,strCheckBox,true);
			var intItems;
			var intCtr;
		
			if (objCheckbox != null)
			{
				intItems = objCheckbox.length;
						
				if(intItems > 1) 
				{
					for (intCtr = 0;intCtr <= intItems - 1; intCtr++)
					{
						if (objCheckbox[intCtr].disabled == false)
							objCheckbox[intCtr].disabled = true;							
					}
				}
				// Else, if single element exists, then...
				// Added by MonikaI on 12-Sep-2006. IssueID : 4261 
				//else
				else if (intItems == 1)		
				//End by MonikaI
				{
					if (objCheckbox[0].disabled == false) 
						objCheckbox[0].disabled = true;						
				}
			}
	
		}


//******************************************************************************
//******************		DATE FUNCTIONS START
//******************************************************************************
//------------------------------------------------------------------------------
//--		GET CLIENT MACHINE's DATE
//------------------------------------------------------------------------------
// -------------------------------------------------------------------
// getDate1()
// Returns date on client machine in following formats : 
// 1 : 15-Jan-2004
// 2 : 15 January 2004
// 3 : January 15, 2004
// 4 : Jan 15, 2004
// 5 : 15 Jan, 2004
// -------------------------------------------------------------------	
	function getDate1(format)
	{
		var dateString;
		var months = new Array(13);
		months[0] = "January";
		months[1] = "February";
		months[2] = "March";
		months[3] = "April";
		months[4] = "May";
		months[5] = "June";
		months[6] = "July";
		months[7] = "August";
		months[8] = "September";
		months[9] = "October";
		months[10] = "November";
		months[11] = "December";
		var now = new Date();
		var monthnumber = now.getMonth();
		var monthname = months[monthnumber];
		var monthday = now.getDate();
		var year = now.getYear();
		if(year < 2000) { year = year + 1900; }
		
		switch(format)
		{
			case 1:
				dateString = monthday + '-' + Left(monthname,3) + '-' + year;
				break;
			case 2:
				dateString = monthday + ' ' + monthname + ' ' + year;
				break;
			case 3:
				dateString = monthname + ' ' + monthday + ', ' + year;
				break;
			case 4:
				dateString = Left(monthname,3) + ' ' + monthday + ', ' + year;
				break;
			case 5:
				dateString = monthday + ' ' + Left(monthname,3) + ', ' + year;
				break;
			default:
				dateString = monthday + ' ' + monthname + ' ' + year;
		}
		return dateString;
	} // function getCalendarDate()


// -------------------------------------------------------------------
// getTime
// Returns time on client machine in format : hh:mm:ss am/pm 
// -------------------------------------------------------------------	
	function getTime()
	{
		var now = new Date();
		var hour = now.getHours();
		var minute = now.getMinutes();
		var second = now.getSeconds();
		var ap = "AM";
		if (hour > 11) { ap = "PM"; }
		if (hour > 12) { hour = hour - 12; }
		if (hour == 0) { hour = 12; }
		if (hour < 10) { hour = "0" + hour; }
		if (minute < 10) { minute = "0" + minute; }
		if (second < 10) { second = "0" + second; }
		var timeString = hour + ':' + minute + ':' + second + " " + ap;
		return timeString;
	} // function getClockTime()


// -------------------------------------------------------------------
// Now()
// Returns date and time on client machine in following date formats : 
// 1 : 15-Jan-2004
// 2 : 15 January 2004
// 3 : January 15, 2004
// 4 : Jan 15, 2004
// 5 : 15 Jan, 2004
// -------------------------------------------------------------------	
	function Now(format)
	{
		if (format!=null)
			return getDate(format) + " " + getTime() ;
		else
			return getDate() + " " + getTime() ;
	}	
	
	//========================================================================================================
	function DatePart(strInterval, dtDate, intFirstDayOfWeek, intFirstWeekOfYear)
	{
/*
	'====================================================================
	' Function Name        : DatePart
	' Parameters Passed    : strInterval - Interval of time to return.
	'			 dtDate		 - The Date to evaluate.
	'			 intFirstDayOfWeek - First Day of Week. By default SUNDAY (1). - Optional
	'			 intFirstWeekOfYear - First Week of Year. By default Week of 1st Jan. - Optional
	' Returns              : The integer which contains the specified part of the given Date.
	'						 On Error returns -1
	' Parameters Affected  : None
	' Purpose              : Same as VBScript DatePart function.
	' Description          : Alomost same as 'DatePart' function of VBScript.
	' Assumptions          : Refer the below defined constants (commented).
	' Dependencies         : None
	' Author               : JayavantK
	' Created              : June 08, 2004
	' Revisions            : 
	'=====================================================================
		const SUNDAY = 1;
		const MONDAY = 2;
		const TUESDAY = 3;
		const WEDNESDAY = 4;
		const THURSDAY = 5;
		const FRIDAY = 6;
		const SATURDAY = 7;
*/
		var intDaysInWeek = 7;

		
		if((strInterval == null) || (strInterval == ''))
			return -1;
		if((dtDate == null) || (dtDate == ''))
			return -1;

		if((intFirstDayOfWeek == null) || (intFirstDayOfWeek == ''))
			intFirstDayOfWeek = 1; // Set default value to SUNDAY (1)
		if((intFirstDayOfWeek > intDaysInWeek) || (intFirstDayOfWeek < 1))
			return -1;

		if((intFirstWeekOfYear == null) || (intFirstWeekOfYear == ''))
			intFirstWeekOfYear = 1; // Set default value to 1 - Week of Jan 1st.
		if((intFirstWeekOfYear > 3) || (intFirstWeekOfYear <= 0))
			return -1;

		if(strInterval.toUpperCase() == "YYYY")
		{
			return(dtDate.getFullYear());
		}

		else if(strInterval.toUpperCase() == "Q")
		{			
			return(parseInt(dtDate.getMonth() / 3) + 1);
		}

		else if(strInterval.toUpperCase() == "M")
		{
			return(dtDate.getMonth() + 1);		
		}

		else if(strInterval.toUpperCase() == "Y")
		{
			var dtFirstDay = new Date();

			dtFirstDay.setDate(1);
			dtFirstDay.setMonth(0);
			dtFirstDay.setFullYear(dtDate.getFullYear());
			dtFirstDay.setHours(0);
			dtFirstDay.setMinutes(0);
			dtFirstDay.setSeconds(0);

			return(DateDiff(dtFirstDay, dtDate, "d") + 1);
		}

		else if(strInterval.toUpperCase() == "D")
		{
			return(dtDate.getDate());
		}

		else if(strInterval.toUpperCase() == "W")
		{
			// This date is taken for reference or for comparison. It was SATURDAY (7) on that day
			var dtReferenceDate = new Date('Sat, 1 Jan 2000 00:00:00'), intReferenceDay = 7;
			var intReturn = 0, intDayNumber, intTemp = 0;

			intTemp = DateDiff(dtReferenceDate, dtDate, "d");
			if(intTemp < 0)
			{
				intTemp = -1 * intTemp;
				intDayNumber = (intTemp % intDaysInWeek) + 1;
				if(intDayNumber >= intReferenceDay)
					intReturn = (intDaysInWeek - (intDayNumber - intReferenceDay));
				else
					intReturn = (intReferenceDay - intDayNumber);

				intReturn = (intReturn - intFirstDayOfWeek + 1);
				if(intReturn <= 0)
					intReturn = intDaysInWeek + intReturn;
			}
			else
			{
				intDayNumber = ((intTemp + (intReferenceDay - 1)) % intDaysInWeek) + 1;
				intReturn = (((intDaysInWeek - intFirstDayOfWeek) + intDayNumber) % intDaysInWeek) + 1;
			}
			return (intReturn);
		}

		else if(strInterval.toUpperCase() == "WW")//
		{
			var dtFirstDay = new Date(), intFirstDayOfYear;
			var intDayOfYear, intWeekDay, intReturn = 0;

			dtFirstDay.setDate(1);
			dtFirstDay.setMonth(0);
			dtFirstDay.setFullYear(dtDate.getFullYear());
			dtFirstDay.setHours(0);
			dtFirstDay.setMinutes(0);
			dtFirstDay.setSeconds(1);

			intFirstDayOfYear = DatePart('w',dtFirstDay,1);
			intDayOfYear = DateDiff(dtFirstDay, dtDate, "d");
			intReturn = Math.ceil((intDayOfYear + intFirstDayOfYear) / intDaysInWeek); 
			intWeekDay = DatePart('w',dtDate,1);


			if(intFirstDayOfWeek > intFirstDayOfYear)
				intReturn = intReturn + 1;
			if(intFirstDayOfWeek > intWeekDay)
				intReturn = intReturn - 1;

			if(intFirstWeekOfYear == 2) //Start with First Week with at least 4 days
			{
				if(intFirstDayOfYear >= intFirstDayOfWeek)
				{
					if((intFirstDayOfYear - intFirstDayOfWeek) >= 4)
						intReturn = intReturn - 1;
				}
				else if((intFirstDayOfWeek - intFirstDayOfYear) < 4)
					intReturn = intReturn - 1;
				
			}
			if(intFirstWeekOfYear == 3) //Start with first full week of the year.
			{
				if((intFirstDayOfYear - intFirstDayOfWeek) != 0)
					intReturn = intReturn - 1;
			}

			return(intReturn);
		}

		else if(strInterval.toUpperCase() == "H")
		{
			return(dtDate.getHours());
		}

		else if(strInterval.toUpperCase() == "N")
		{
			return(dtDate.getMinutes());
		}

		else if(strInterval.toUpperCase() == "S")
		{
			return(dtDate.getSeconds());
		}

		else
			return -1;
	}
//========================================================================================================
//******************************************************************************
//******************		DATE FUNCTIONS END
//******************************************************************************


//..fn to get the Object Reference on parent form.
//frm -> id/name of the form
//ctrl -> id/name of the control.
function GetParentObjectReference(frm,ctrl) { 
     return window.opener.document.forms[frm].elements[ctrl]; 
 } 
 
 
 //..fn to get the Form Reference of Parent form
//frm -> id/name of the form.
function GetParentFormReference(frm) { 
     return window.opener.document.forms[frm]; 
 }
 
 
 
 
 //******************************************************************************
//	URL Encode/Decode functions
//******************************************************************************
function URLEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
	
};

function URLDecode(plaintext)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
   
};

//fn... To get name from ID.
function getNameFromID(obj)
{
	if (arguments.length > 1)
	{
		return(obj.getAttribute(arguments[1]));
	}
	else
	{
		return(obj.getAttribute("name"));
	}
}

//____________________________________________________________________________________
//__________Added By UmeshJ on July 16, 2004
//__________Check if the any check box is selected
//__________Return TRUE if any one check box is selected else false
//____________________________________________________________________________________
	function IsCheckboxSelected(strFormName, strCheckbox)
	//Pass FormName and the Checkbox's ID
	{
		var objCheckbox = GetObjectReference(strFormName,strCheckbox,true);
		var intItems;var intCtr;		
		if (objCheckbox != null)
		{
			intItems = objCheckbox.length;						
			if(intItems > 1) 
			{
				for (intCtr = 0;intCtr <= intItems - 1; intCtr++)
				{
					if (objCheckbox[intCtr].disabled == false)
						if (objCheckbox[intCtr].checked == true)
							return true;
				}
			}
			// Else, if single element exists, then...
			else if(intItems == 1)
			{
				if (objCheckbox[0].disabled == false) 
					if (objCheckbox[0].checked == true)
						return true;					
			}
		}
		return false;
	}
//____________________________________________________________________________________
//______________________________SCROLLABEL JS START
function scrollME(objDIV)
{
var objTH = document.getElementById('colheader');
var objBody = document.getElementById('divListTag');
objTH.style.position = 'absolute'
objTH.style.left = 0-objBody.scrollLeft- parseInt(objBody.offsetLeft);;
}
//______________________________SCROLLABEL JS END
//______________________________TYPE AHEAD COMBO START_______________________________
		/* **** ARRAY EXTENSION FOR NON-SUPPORTING BROWSERS **** */
		if(typeof Array.prototype.push=='undefined') {
		    Array.prototype.push = function () {
		        var i=0,
		            b=this.length,
		            a=arguments;
		        for(i;i<a.length;i++) {
		            this[b+i]=a[i];
				}
		        return this.length
		    }
		}
		/* **** STRING EXTENSION FOR PUNCTUATION **** */
		if (typeof(String.fromCharCode) == 'undefined') {
			String.fromCharCode = function () {
				if (arguments.length = 0) {
					return "";
				}
				var charCodeChars = new Array(32),
					returnString = "",
					i;
				charCodeChars[9] = '\t';
				charCodeChars[13] = '\n';
				charCodeChars.push(' ','!','"','#','$','%','',"'",'(',')','*','+',',','-','.','/','0','1','2','3','4','5','6','7','8','9',':',';','<','=','>','?','@');
				charCodeChars.push('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[','\\',']','^','_','`');
				charCodeChars.push('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','{','|','}','~');
				for (i=0;arguments.length>i;i++) {
					returnString += charCodeChars[arguments[i]];
				}
				return returnString;
			}
		}
		String.fromKeyCode = function (keyCode,evtType) {
			if (!evtType || !evtType.length) {
				evtType = "keyDown";
			} else if (evtType.toLowerCase() == "keypress") {
				return String.fromCharCode(keyCode);
			}
			var keyDownChars = new Array(16);
				keyDownChars[8] = '[Bksp]';
				keyDownChars[9] = '[Tab]';
				keyDownChars[12] = '[N5+shift]';
				keyDownChars[13] = '[Enter]';
				keyDownChars.push('[Shift]','[Ctrl]','[Alt]','[Pause]','[CapsLock]');
				for (i=11;i;--i) {
					keyDownChars.push('undefined');
				}
				keyDownChars[27] = '[Esc]';
				keyDownChars.push(' ','[PgUp]','[PgDn]','[End]','[Home]','[Left]','[Up]','[Right]','[Down]');
				for (i=7;i;--i) {
					keyDownChars.push('undefined');
				}
				keyDownChars[45] = '[Ins]';
				keyDownChars[46] = '[Del]';
				keyDownChars.push(['0',')'],['1','!'],['2','@'],['3','#'],['4','$'],['5','%'],['6','^'],['7','&'],['8','*'],['9','(']);
				for (i=7;i;--i) {
					keyDownChars.push('undefined');
				}
				keyDownChars.push('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','[WinKey]');
				for (i=4;i;--i) {
					keyDownChars.push('undefined');
				}
				keyDownChars.push('0','1','2','3','4','5','6','7','8','9','*','+','undefined','-','.','/','[F1]','[F2]','[F3]','[F4]','[F5]','[F6]','[F7]','[F8]','[F9]','[F10]','[F11]','[F12]');
				for (i=62;i;--i) {
					keyDownChars.push('undefined');
				}
				keyDownChars[144] = '[NumLock]';
				keyDownChars[145] = '[ScrollLock]';
				keyDownChars.push([';',':'],['=','+'],[',','<'],['-','_'],['.','>'],['/','?'],['`','~']);
				for (i=26;i;--i) {
					keyDownChars.push('undefined')
				}
				keyDownChars.push(['[','{'],['\\','|'],[']','}'],["'",'"']);
			return keyDownChars[keyCode];
		}
		
		/* **** COMBOBOX CODE **** */
		/**************************************************
		Original Version (1.0):
		Glenn G. Vergara
		http://www21.brinkster.com/gver/
		glenngv AT yahoo DOT com
		Makati City, Philippines
		
		Object-Based Version:
		Eric C. Davis
		http://www.10mar2001.com/
		eric AT 10mar2001 DOT com
		Atlanta, GA, US
		
		(Keep the above intact if you want to use it! Thanks.)
		
		Current Version: 2.5b
		Last Update: 1 December 2003
		
		********
		Change Log:
		New in version 2.5b:
			- Reversed selectItem() loop to prevent default IE6/Win rapid-change behaviour (skipped to second on match of first)
			- Outfitted for DOM2-style event handling; uses detection and falls back to DOM0 events
			- Resets immediately on ALT+TAB to prevent IE6/Win's loss of the reset timer.
		
		New in version 2.4:
			- Added accepting of non-existent option
			- Added punctuation as acceptable input
			- Added setValueByValue() convenience method
		
		New in version 2.2:
			- Many properties made private
			- Getters and setters for nearly all properties
		
		New in version 2.0:
			- Object-oriented properties and methods using prototype
			- Constructor can accept a select element object or a select element object's ID string
			- Invocation reduced to single line of script: varName = new TypeAheadCombo('selectElementID');
		
		New in version 1.4:
			- Allowable character set ranges use dynamic evaluation
			- Display of typed characters in status bar can be disabled
		
		New in version 1.2:
			- Replaced major if/elseif/.../else statement with switch/case
			- Correction of characters typed on the numpad, reassigning to actual character values
		********
		
		********
		API:
		Constructor:
			new TypeAheadCombo(someSelectElement) // as an object or object reference
			new TypeAheadCombo('someSelectElementID') // as a string
			new TypeAheadCombobox('someSelectElementID', true) // to allow an undefined value
		
		Privileged Methods: (these interact with private properties and act as helper functions)
			getTyped()
				- returns the string typed by the user since the last timeout
			setTyped(str)
				- argument "str" - string which will replace the value in the type buffer
			type(str)
				- argument "str" - string which will be appended to the type buffer
			resetTyped()
				- clears what has been typed from the buffer
			getIndex()
				- returns the location of the option currently selected
			setIndex(val)
				- stores the location of the option being selected
			getPrev()
				- returns the location of the option previously selected
			setPrev(val)
				- stores the location of the option previously selected
			setResetTime(val)
				- sets the timeout interval for the reset timers
			getResetTime()
				- returns the timeout interval for the reset timers
			setResetTimer()
				- sets the timeout for the reset of the typed buffer
			clearResetTimer()
				- clears the timeout of the reset of the typed buffer
			validChar(charCode)
				- validates that the charCode passed is acceptable to the typed buffer
			setDisplayStatus(bool)
				- set whether to display the typed buffer in the status bar
			getDisplayStatus()
				- returns the current setting for status bar display of the typed buffer
		
		Public Methods:
			detectKey()
				- detects the keyCode, parses whether it is acceptable, and adds it to the typed buffer if so
			selectItem()
				- finds the first option that matches the typed buffer and selects it
			reset()
				- clears the typed buffer and the status display
			updateIndex()
				- handles the onclick and onblur events
			elementFocus()
				- handles the onfocus event
			elementKeydown()
				- handles the onkeydown event
		********
		
		***************************************************/
		function TypeAheadCombo (anElement,acceptNewValue) {
			// DEGRADE UNSUPPORTED
			if (document.layers) {
				return;
			}
			// VALIDATION
			if (!anElement) {
				return false;
			}
			if (typeof anElement == "string") { // try for the ID
				anElement = document.getElementById ? document.getElementById(anElement) : document.all ? document.all[anElement] : anElement;
			}
			if (typeof anElement == "string") { // the grab failed: typeof null yields "object"
				return false;
			}
			// ASSOCIATION
			this.element = anElement;
			this.id = this.element.id + 'Combo';
			this.element.combo = this;
			// ELEMENT EVENT HANDLERS
			if (this.element.addEventListener) {
				// first try DOM2 methods
				this.element.addEventListener("keydown", this.elementKeydown, false);
				this.element.addEventListener("focus", this.elementFocus, false);
				this.element.addEventListener("click", this.updateIndex, false);
				this.element.addEventListener("blur", this.updateIndex, false);
			} else {
				// now try DOM0 methods
				this.element.onkeydown = this.elementKeydown;
				this.element.onfocus = this.elementFocus;
				this.element.onclick = this.updateIndex;
				this.element.onblur = this.updateIndex;
			}
			this.element.reset = this.reset;
			// PRIVATE PROPERTIES
			var self = this,	// corrects privatization bug
				typed = "",
				index = prev = 0,
				displayStatus = true,
				selector, resetter, nullStarter, acceptNew,
				resetTime = 1600,
				numberRangeStart = 48,
				numberRangeEnd = 57,
				charRangeStart = 65,
				charRangeEnd = 90,
				punctRangeStart = 146,
				punctRangeEnd = 223;
			if (this.element.options[0].text.length == 0 && (this.element.options[0].value.length == 0 || this.element.options[0].value == 0)) {
				nullStarter = true;
			} else {
				nullStarter = false;
			}
			if (typeof acceptNewValue != 'undefined' && acceptNewValue) {
				acceptNew = true;
				resetTime = 2400;
			} else {
				acceptNew = false;
			}
			// PRIVATE METHODS
			var getResetTime = function () {
				return resetTime;
			}
			var charInRanges = function (charCode) {
				if ((charCode >= numberRangeStart && charCode <= numberRangeEnd) || (charCode >= charRangeStart && charCode <= charRangeEnd) || (charCode >= punctRangeStart && charCode <= punctRangeEnd)) {
					return true;
				} else {
					return false;
				}
			}
			// PRIVILEDGED METHODS
			this.hasNullStarter = function () {
				return nullStarter;
			}
			this.getAcceptsNew = function () {
				return acceptNew;
			}
			this.getTyped = function () {
				return typed;
			}
			this.setTyped = function (str) {
				typed = str;
				return true;
			}
			this.resetTyped = function () {
				typed = "";
				return true;
			}
			this.type = function (str) {
				typed += str;
				return true;
			}
			this.getIndex = function () {
				return index;
			}
			this.setIndex = function (val) {
				if (!isNaN(val)) {
					index = val;
				}
			}
			this.getPrev = function () {
				return (prev ? prev : 0);
			}
			this.setPrev = function (val) {
				if (!isNaN(val)) {
					prev = val;
				}
			}
			this.setResetTime = function (val) {
				if (!isNaN(val)) {
					resetTime = val;
				}
			}
			this.setResetTimer = function () {
				resetter = setTimeout("document.forms['"+this.element.form.name+"'].elements['"+this.element.name+"'].reset();", getResetTime());
			}
			this.clearResetTimer = function () {
				clearTimeout(resetter);
			}
			this.delayedSelect = function () {
				selector = setTimeout("document.forms['"+this.element.form.name+"'].elements['"+this.element.name+"'].combo.selectItem();", 10);
			}
			this.cancelDelay = function () {
				clearTimeout(selector);
			}
			this.validChar = function (evt, charCode) {
				if ((evt.ctrlKey) || (evt.altKey)) {
					return false;
				} else if ((evt.shiftKey) && charInRanges(charCode)) {
					return true;
				} else if (evt.shiftKey) {
					return false;
				} else {
					return charInRanges(charCode);
				}
			}
			this.setDisplayStatus = function (bool) {
				if (bool == true || bool == false) {
					displayStatus = bool;
				}
			}
			this.getDisplayStatus = function () {
				return displayStatus;
			}
			this.cancel = function (evt) {
				if (evt) {
					evt.preventDefault();
				} else {
					window.event.returnValue = false;
				}
				return false;
			}
		}
		
		/*
		PUBLIC METHODS
		*/
		
		TypeAheadCombo.prototype.detectKey = function (evt){
			this.clearResetTimer();
			this.cancelDelay();
			var combo_letter = "";
			var combo_code = (evt) ? evt.keyCode : window.event ? window.event.keyCode : evt.which;
			var event = (evt) ? evt : window.event;
			if (combo_code <= 105 && combo_code >= 96) { // make up for numPad typing
				combo_code = combo_code - 48;
			}
			switch (combo_code) {
				case 27:	//ESC key
					this.reset();
					this.setIndex(this.getPrev());
					// Put a little delay to override NS6/Mozilla's built-in behavior of ESC inside select element
					setTimeout("document.forms['"+this.element.form.name+"'].elements['"+this.element.name+"'].selectedIndex = document.forms['"+this.element.form.name+"'].elements['"+this.element.name+"'].index",0);
					return false;
					break;
				case 13:	//ENTER key
				case 9:		//TAB key
					this.reset();
					if (this.element.onchange) {
						// set timer to prevent stack overflow in IE.
						setTimeout(eval("document.forms['" + this.element.form.name + "'].elements['" + this.element.name + "'].onchange()"), 1);
					}
					//eval("document.forms['" + this.element.form.name + "'].elements['" + this.element.name + "'].onchange()")
					return true;
					break;
				case 8:		//BACKSPACE key
					this.setTyped(this.getTyped().substring(0,this.getTyped().length-1));
					if (this.getAcceptsNew() && this.getIndex() == 0) {
						this.makeNewValue();
					}
					if (this.getTyped() == "") {
						this.reset();
						this.setIndex(this.getPrev());
						this.element.selectedIndex = this.getIndex();
						if (evt) {
							evt.preventDefault();
						} else {
							window.event.returnValue = false;
						}
						return false;
					} else {
						this.setResetTimer();
					}
					break;
				case 33:	//PAGEUP key
				case 34:	//PAGEDOWN key
				case 35:	//END key
				case 36:	//HOME key
				case 38:	//UP arrow
				case 40:	//DOWN arrow
					this.reset();
					return true;
					break;
				case 37:	//LEFT arrow	(translates to %)
				case 39:	//RIGHT arrow	(translates to ')
					this.reset();
					return false;
					break;
				case 32:	//SPACE key	(not in accepted ranges)
					combo_letter = " ";
					this.setResetTimer();
					break;
				default:
					if (this.validChar(event, combo_code)) {
						combo_letter = String.fromKeyCode(combo_code);
						if (combo_letter.length > 1) {
							if (event.shiftKey) {
								combo_letter = combo_letter[1];
							} else {
								combo_letter = combo_letter[0];
							}
						}
						this.setResetTimer();
					} else {
						return true;
					}
					break;
			}
			this.type(combo_letter);
			if (this.getDisplayStatus()) {
				window.status = this.getTyped();
			}
			if (document.all) {
				return this.selectItem();
			} else {
				return this.delayedSelect();
			}
		}
		
		TypeAheadCombo.prototype.selectItem = function (){
			var i = this.element.options.length,
				match = false;
			do {
				if (this.element.options[--i].text.toUpperCase().indexOf(this.getTyped().toUpperCase()) == 0){
					this.element.selectedIndex = i;
					this.setIndex(i);	//remember selected index
					match = true;
				}
			} while (i > 0);
			if (match) {
				return false; // always return false;
			}
			if (this.getAcceptsNew()) {
				this.makeNewValue();
			} else {
				this.element.selectedIndex = this.getIndex();	//re-select previously selected option even if there's no match
			}
			return false;  //always return false
		}
		
		TypeAheadCombo.prototype.makeNewValue = function () {
			this.removeNewValue();
			var tmpText = this.getTyped(),tmpStart = tmpEnd = "",tmpArr,i;
			if (this.hasNullStarter()) {
				newOption = this.element.options[0];
			} else if (tmpText.length > 0) {
				newOption = document.createElement("option");
				this.element.insertBefore(newOption, this.element.firstChild);
				this.newOption = newOption;
			} else {
				this.newOption = null;
				return;
			}
			tmpArr = tmpText.split(" ");
			i = tmpArr.length;
			if (tmpText.indexOf(" ") >= 0) {
				do {
					tmpStart = tmpArr[--i].substring(0,1);
					tmpEnd = tmpArr[i].substring(1,tmpArr[i].length);
					tmpArr[i] = tmpStart.toUpperCase() + tmpEnd.toLowerCase();
				} while (i);
				tmpText = tmpArr.join(" ");
			} else {
				tmpStart = tmpText.substring(0,1);
				tmpEnd = tmpText.substring(1,tmpText.length);
				tmpText = tmpStart.toUpperCase() + tmpEnd.toLowerCase();
			}
			newOption.value = tmpText;
			newOption.text = tmpText;
			this.element.selectedIndex = 0;
			this.setIndex(0);
		}
		
		TypeAheadCombo.prototype.removeNewValue = function () {
			if (this.hasNullStarter()) {
				this.element.options[0].text = '';
				this.element.options[0].value = '';
			} else if (this.newOption) {
				this.element.remove(this.newOption);
			}
		}
		
		TypeAheadCombo.prototype.setValueByValue = function (aValue) {
			var i = this.element.options.length;
			do {
				if (this.element.options[--i].value == aValue) {
					this.element.selectedIndex = i;
					break;
				}
			} while (i);
		}
		
		TypeAheadCombo.prototype.reset = function () {
			theCombo = this;
			if (this.combo) {
				theCombo = this.combo;
			}
			theCombo.element.selectedIndex = theCombo.getIndex();
			theCombo.resetTyped();
			if (theCombo.getDisplayStatus()) {
				window.status = window.defaultStatus ? window.defaultStatus : '';
			}
		}
		
		TypeAheadCombo.prototype.updateIndex = function (evt){
			var theCombo, theEl;
			if (evt && window.addEventListener) {
				// ready for handler with DOM2 event properties
				var e = new DOM2Event(evt, window.event, this);
				theEl = e.target;
			} else {
				theEl = this;
			}
			theCombo = theEl.combo;
			theCombo.setIndex(theEl.selectedIndex);
			theCombo.setPrev(theCombo.getIndex());
		}
		
		TypeAheadCombo.prototype.elementFocus = function (evt) {
			var theCombo;
			if (evt && window.addEventListener) {
				// ready for handler with DOM2 event properties
				var e = new DOM2Event(evt, window.event, this);
				theCombo = e.target.combo;
			} else {
				theCombo = this.combo;
			}
			theCombo.setIndex(theCombo.element.selectedIndex);
		}
		
		TypeAheadCombo.prototype.elementKeydown = function (evt) {
			var theCombo;
			if (evt && window.addEventListener) {
				// ready for handler with DOM2 event properties
				if (DOM2Event) {
					var e = new DOM2Event(evt, window.event, this);
				}
				theCombo = e.target.combo;
			} else {
				theCombo = this.combo;
			}
			if (!theCombo.detectKey(e)) {
				return theCombo.cancel(e);
			}
		}
//______________________________TYPE AHEAD COMBO END_______________________________

//header row, data row, data div, header div
function init(rhe,fre,dse,hse) {
var rh = document.getElementById(rhe)
var fr = document.getElementById(fre)
var ds = document.getElementById(dse)
var hs = document.getElementById(hse)
 //alert(hs.style);

 //alert('onbefscroll')
 hs.style.top = ds.offsetTop;
 hs.style.left = ds.offsetLeft;
 hs.style.visibility = 'visible';
 //
   // alert(ds.onscroll)
  //alert(ds);
  //window.onresize=syncResize;
  //alert('sync resize')
 //syncResize(hs,ds,rh,fr);
 ds.onresize = function()
 {
 


  //document.recalc(true);
  for( i =0; i < rh.childNodes.length; i++ ) {
	if (fr.childNodes[i].offsetWidth >= rh.childNodes[i].offsetWidth)
     rh.childNodes[i].width = fr.childNodes[i].offsetWidth;
    else 
	 fr.childNodes[i].width = rh.childNodes[i].offsetWidth;
	//
	// document.recalc(true);

  }
    document.recalc();
//  hs.style.top = ds.offsetTop;
//  hs.style.left = ds.offsetLeft;
//  hs.style.visibility = 'visible';
  
 hs.style.width = ds.offsetWidth-(ds.offsetWidth - ds.clientWidth);
	  if ( navigator.userAgent.toLowerCase().indexOf( 'gecko' ) != -1 ) {
  alert('gecko')
     hs.style.overflow='-moz-scrollbars-none';  
  }   
  //  alert(ds.offsetTop + ":" + hs.offsetTop + hs.id)
   // fr.style.top = 150;
    
  //ds.style.top =  rh.offsetHeight;// + hs.style.height; 
 //
 }

 //fr.style.top = rh.style.offsetTop;// + rh.style.height;
 
 ds.onresize();

 ds.onscroll= function()
 {
 //alert('scroll')
 hs.scrollLeft = ds.scrollLeft;//document.recalc(true);
 //document.recalc(true);
 } //syncScroll//(hs,ds);
/*   try
  {
   
	//ds.onscroll = eval('malert()');
	}
	catch e {}
  */
}

/*
function syncScroll(hs,ds) {

 hs.scrollLeft = ds.scrollLeft;
  
}
*//*
function syncResize(hs,ds,rh,fr) {
// alert(hs)
  hs.style.width = ds.offsetWidth-(ds.offsetWidth - ds.clientWidth);
  
  for( i =0; i < rh.childNodes.length; i++ ) {
     rh.childNodes[i].width = fr.childNodes[i].offsetWidth;
  } 
}
*/
//Added By NileshD on 21 Sep 2005 ReqID -  WAF3_PB_10
function numeric_nav_prev_click(FormName,PagePath,CurrentPageNo,MaxPageSize,name,PositiveValueMsg,FirstRecordMsg)
{
var objTextBox=GetObjectReference(FormName,name);
if (disallowNegativeInteger(objTextBox) == true)
	{
		//alert('Please Enter only positive integer');
		alert(PositiveValueMsg);
		return;
	}
	
if (CurrentPageNo <= 1)
	{
		//alert('This is the first page');
		alert(FirstRecordMsg);
		return;
	}
	var objfrm;
	objfrm = GetFormReference(FormName);
	objfrm.action = PagePath + "&PagingNavigation=PREV";
	objfrm.submit();
}

function numeric_nav_next_click(FormName,PagePath,CurrentPageNo,MaxPageSize,name,PositiveValueMsg,LastRecordMsg)
{
var objTextBox=GetObjectReference(FormName,name);
if (disallowNegativeInteger(objTextBox) == true)
	{
		alert(PositiveValueMsg);
		return;
	}
if (CurrentPageNo + 1 > MaxPageSize)
	{
		alert(LastRecordMsg);
		return;
	}
	//alert(PagePath);
	var objfrm;
	objfrm = GetFormReference(FormName);
	objfrm.action = PagePath + "&PagingNavigation=NEXT";
	//alert(objfrm.action);
	objfrm.submit();
}

function numeric_paging_OnKeyPress(e,FormName,PagePath,CurrentPageNo,MaxPageSize,name,PositiveValueMsg,MinRangeMsg,MaxRangeMsg)
	{	
	var code;
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if(code==13) 
	  {
		var objTextBox=GetObjectReference(FormName,name);
		if (disallowNegativeInteger(objTextBox) == true)
		{
			//alert('Please Enter only positive integer');
			alert(PositiveValueMsg);
			return;
		} 
		if (objTextBox.value < 1)
			{
				//alert('Please Enter value greater than or equal to 1');
				alert(MinRangeMsg);
				return;
			}
		if (objTextBox.value > MaxPageSize)
			{
				//alert('Please Enter value less than or equal to ' + MaxPageSize);
				alert(MaxRangeMsg);
				return;
			}
			var objfrm;
			objfrm = GetFormReference(FormName);
			objfrm.action = PagePath + "&PagingNavigation=CURR&PagingControl=" + name;
			//alert(objfrm.action);
			objfrm.submit();
	  }
	  else
	  {
		if ((code >= 48 && code <=57) == false)
		{
		if(navigator.appName == 'Microsoft Internet Explorer')
			e.keyCode = 0
		 else
		 	return false;
		}	
	   }
	}
//End Of Addition By NileshD on 21 Sep 2005 ReqID -  WAF3_PB_10
//Added By NileshD on 4 Oct 2005 ReqID -  WAF3_PB_10
function numeric_nav_first_click(FormName,PagePath,CurrentPageNo,FirstRecordMsg)
{
	if (CurrentPageNo == 1)
	{	alert(FirstRecordMsg);
		return;
	}
	var objfrm;
	var strPaging;
	strPaging = "&PAGINGNUMBER=" + CurrentPageNo;
	PagePath = replaceSubstring(PagePath.toUpperCase(),strPaging,"");
	objfrm = GetFormReference(FormName);
	objfrm.action = PagePath + "&PagingNumber=1";
	objfrm.submit();
}

function numeric_nav_last_click(FormName,PagePath,CurrentPageNo,MaxPageSize,LastRecordMsg)
{
	if (CurrentPageNo == MaxPageSize)
	{	alert(LastRecordMsg);
		return;
	}
	var objfrm;
	var strPaging;
	strPaging = "&PAGINGNUMBER=" + CurrentPageNo;
	PagePath = replaceSubstring(PagePath.toUpperCase(),strPaging,"");
	objfrm = GetFormReference(FormName);
	objfrm.action = PagePath + "&PagingNumber=" + MaxPageSize;
	objfrm.submit();
}
//------------------------------------------------------------------------------
//Purpose : Select all check boxes
//------------------------------------------------------------------------------
	function SelectAllCheckboxs(strFormName, strCheckbox)
	//Pass FormName and the Checkbox's ID
	{
		var objCheckbox = GetObjectReference(strFormName,strCheckbox,true);
		var intItems;
		var intCtr;
		
		if (objCheckbox != null)
		{
			intItems = objCheckbox.length;
			if(intItems > 1) 
			{
				for (intCtr = 0;intCtr <= intItems - 1; intCtr++)
				{
					if (objCheckbox[intCtr].disabled == false)
						objCheckbox[intCtr].checked = true;							
				}
			}
			// Else, if single element exists, then...
			else if(intItems == 1)
			{
				if (objCheckbox[0].disabled == false) 
					objCheckbox[0].checked = true;						
			}
		}
	
	}
//End Of Adiition ReqID -  WAF3_PB_10
// Added By NileshD on 14 Nov 2005 for REQID:WAF3_PB_12
function DateControl_StandardOnblur(formname,controlname,format,message)
{
  if (validateFormat(formname,controlname,format,message) == true)
	{
	// added by SandipL on 2 Dec 2005 -- to solve refreshing problem of DA page due to editable date control
	if(formname=='DA')
	{
	//document.forms['DA'].elements[controlname].value =document.forms['DA'].elements['FFE29587WHIZ_'+ controlname].value
	if(window.location.href.indexOf('CreateTask')==-1 && window.location.href.indexOf('WhatToShow')==-1 && window.location.href.indexOf('DailyActivityID')==-1  )
	//if(window.location.href.indexOf('CreateTask')==-1 && window.location.href.indexOf('WhatToShow')==-1  )
	//if(window.location.href.indexOf('CreateTask')==-1 && window.location.href.indexOf('WhatToShow')==-1 && window.location.href.indexOf('Mode')==-1  )

	
	//if( window.location.href.indexOf('WhatToShow')==-1   )
	{
	document.forms['DA'].action = 'PM_DailyActivity.aspx?FromWhere=DA&txtDate='+ document.forms['DA'].elements[controlname].value;
	document.forms['DA'].submit()
		
	}
	}
	// Added by NitinVS on 6 Dec 2005 for WhizibleSEM SP5 IssueID 672
	if (formname=='frmDailyActivityWeeklyView')
	{
	document.forms['frmDailyActivityWeeklyView'].action ="DailyActivityWeeklyView.aspx?SelectedDate=" + document.forms['frmDailyActivityWeeklyView'].elements[controlname].value;	
	document.forms['frmDailyActivityWeeklyView'].submit()
	}
	
	//added by SandipL on 14 April 2006 for WhizibleSEM IssueID 2349
	if (formname=='frmEWF_ExpenseEntry')
	{
		document.forms['frmEWF_ExpenseEntry'].action ="EWF_ExpenseEntry.aspx?SelectedDate=" + document.forms['frmEWF_ExpenseEntry'].elements[controlname].value + "&Mode=ADD_NEW";
		document.forms['frmEWF_ExpenseEntry'].submit()
	}
	if (formname=='frmEWF')
	{
		document.forms['frmEWF'].action ="EWF_ExpenseEntryList.aspx?FromWhere=DT&MasterTagId=3556&txtDate=" + document.forms['frmEWF'].elements[controlname].value + "&Mode=ADD_NEW";
		document.forms['frmEWF'].submit()
	}
//Integrated by MonikaI on 17th Sep 2007 for WhizibleEngg7
	// For infrastructure resource daily activity page
	if(formname=='IDA')
	{
	if(window.location.href.indexOf('Mode=New')==-1 && window.location.href.indexOf('Mode=Edit')==-1 && window.location.href.indexOf('WhatToShow=Entry')==-1 )
	{
	document.forms['IDA'].action = 'PM_InfrastrctDailyActivity.aspx?FromWhere=IDA&txtDate='+ document.forms['IDA'].elements[controlname].value;
	document.forms['IDA'].submit()
	}
	}
//End of integration by MonikaI
	//End addition by SandipL on 14 April 2006
	
	// End Addition by NitinVS on 6 Dec 2005 for WhizibleSEM SP5 IssueID 672
	return true;
    }
   else
    return false;

}
function validateFormat(formname,controlname,format,message) 
/*
FUNCTION	:	validateFormat()
I/P PARAM	:	value, format for the date string
RETURNS		:	separator
*/
{
	var objRegExp;
	var objControl = GetObjectReference(formname,'FFE29587WHIZ_' + controlname);
	var objOriginalControl = GetObjectReference(formname,controlname);
	var originalDate;
	var standardDate;
	var arrDate;
	var arrFormat;
	var intCount;
	var separator;
	var formatSeparator;
	if (objControl.value == '')
	{	objOriginalControl.value='';
		return true;
	}
	objControl.value = Trim(objControl.value);
	arrFormat = format.split('/');
	formatSeparator = '/';
	if (arrFormat.length !=3)
	{
		arrFormat = format.split('-');
		formatSeparator = '-';
		if (arrFormat.length !=3)
		{
			arrFormat = format.split('.');
			formatSeparator = '.';
		}
	}
	format = format.toUpperCase();
	switch(true)
	{
	  case (formatSeparator == '/'):
		{
		 objControl.value = replaceSubstring(objControl.value,'.',formatSeparator);
		 objControl.value = replaceSubstring(objControl.value,'-',formatSeparator);
		 break;	
		}  
	  case (formatSeparator == '-'):
		{
			objControl.value = replaceSubstring(objControl.value,'.',formatSeparator);
			objControl.value = replaceSubstring(objControl.value,'/',formatSeparator);
			break;	
		}  
	  case (formatSeparator == '.'):
		{
			objControl.value = replaceSubstring(objControl.value,'/',formatSeparator);
			objControl.value = replaceSubstring(objControl.value,'-',formatSeparator);
			break;	
		}  
	}
	
	arrFormat = objControl.value.split(formatSeparator);
	if (arrFormat.length !=3)
		{
		 if (message != '')
			alert(message);
		if(navigator.appName == 'Microsoft Internet Explorer')
			setFocus(objControl);
		else
			window.setTimeout('document.forms["' + formname + '"].elements["' + objControl.id + '"].focus()', 1);		 return false;
	     return false;
		}
	switch(true)
	{
		case (format=='DD-MM-YYYY' || format=='DD.MM.YYYY' || format == 'DD/MM/YYYY'):
			{
			 objRegExp = /^(0[1-9]|1[0-9]|2[0-9]|3[01])[-\/.](0[1-9]|1[012])[-\/.](19|20)\d\d$/;
			 if (objControl.value.length != 10)
				{
				 arrDate = objControl.value.split(formatSeparator);
				 arrDate[0] = FormatDayMonthYear(arrDate[0],'D');
				 arrDate[1] = FormatDayMonthYear(arrDate[1],'M');
				 arrDate[2] = FormatDayMonthYear(arrDate[2],'YYYY');
				 objControl.value = arrDate[0] + formatSeparator + arrDate[1] + formatSeparator + arrDate[2];
				    //alert(objControl.value);     
				}	
			 break;
			}
		case (format=='MM-DD-YYYY' || format=='MM.DD.YYYY' || format == 'MM/DD/YYYY'):
		   {
			 objRegExp = /^(0[1-9]|1[012])[-\/.](0[1-9]|1[0-9]|2[0-9]|3[01])[-\/.](19|20)\d\d$/;
			 if (objControl.value.length != 10)
				{
				 arrDate = objControl.value.split(formatSeparator);
			     arrDate[0] = FormatDayMonthYear(arrDate[0],'M')
				 arrDate[1] = FormatDayMonthYear(arrDate[1],'D')
				 arrDate[2] = FormatDayMonthYear(arrDate[2],'YYYY')

				    objControl.value = arrDate[0] + formatSeparator + arrDate[1] + formatSeparator + arrDate[2];
				    //alert(objControl.value);     
				}	
			  break;
			}
		case (format=='YYYY-DD-MM' || format=='YYYY.DD.MM' || format == 'YYYY/DD/MM'):
		   {			
				objRegExp = /^(19|20)\d\d[-\/.](0[1-9]|1[0-9]|2[0-9]|3[01])[-\/.](0[1-9]|1[012])$/;
				if (objControl.value.length != 10)
				{
				 arrDate = objControl.value.split(formatSeparator);
				 arrDate[0] = FormatDayMonthYear(arrDate[0],'YYYY')
				 arrDate[1] = FormatDayMonthYear(arrDate[1],'D')
				 arrDate[2] = FormatDayMonthYear(arrDate[2],'M')
				    objControl.value = arrDate[0] + formatSeparator + arrDate[1] + formatSeparator + arrDate[2];
				    //alert(objControl.value);     
				}	
				break;	
			}
		case (format=='YYYY-MM-DD' || format=='YYYY.MM.DD' || format == 'YYYY/MM/DD'):
		    {
				objRegExp = /^(19|20)\d\d[-\/.](0[1-9]|1[012])[-\/.](0[1-9]|1[0-9]|2[0-9]|3[01])$/;
				if (objControl.value.length != 10)
				{
				 arrDate = objControl.value.split(formatSeparator);
				 arrDate[0] = FormatDayMonthYear(arrDate[0],'YYYY')
				 arrDate[1] = FormatDayMonthYear(arrDate[1],'M')
				 arrDate[2] = FormatDayMonthYear(arrDate[2],'D')
				    objControl.value = arrDate[0] + formatSeparator + arrDate[1] + formatSeparator + arrDate[2];
				    //alert(objControl.value);     
				}	
				break;
			}
		case (format=='DD-MM-YY' || format=='DD.MM.YY' || format == 'DD/MM/YY'):
			{
				objRegExp = /^(0[1-9]|1[0-9]|2[0-9]|3[01])[-\/.](0[1-9]|1[012])[-\/.]\d\d$/;
				if (objControl.value.length != 8)
				{
				 arrDate = objControl.value.split(formatSeparator);
				 arrDate[0] = FormatDayMonthYear(arrDate[0],'D')
				 arrDate[1] = FormatDayMonthYear(arrDate[1],'M')
				 arrDate[2] = FormatDayMonthYear(arrDate[2],'YY')
				 objControl.value = arrDate[0] + formatSeparator + arrDate[1] + formatSeparator + arrDate[2];
				    //alert(objControl.value);     
				}	
				break;
			}
		case (format=='MM-DD-YY' || format=='MM.DD.YY' || format == 'MM/DD/YY'):
			{
				objRegExp = /^(0[1-9]|1[012])[-\/.](0[1-9]|1[0-9]|2[0-9]|3[01])[-\/.]\d\d$/;
				if (objControl.value.length != 8)
				{
				 arrDate = objControl.value.split(formatSeparator);
				 arrDate[0] = FormatDayMonthYear(arrDate[0],'M')
				 arrDate[1] = FormatDayMonthYear(arrDate[1],'D')
				 arrDate[2] = FormatDayMonthYear(arrDate[2],'YY')
				 objControl.value = arrDate[0] + formatSeparator + arrDate[1] + formatSeparator + arrDate[2];
				    //alert(objControl.value);     
				}	
				break;
			}
		case (format=='YY-DD-MM' || format=='YY.DD.MM' || format == 'YY/DD/MM'):
			{
				objRegExp = /^\d\d[-\/.](0[1-9]|1[0-9]|2[0-9]|3[01])[-\/.](0[1-9]|1[012])$/;
				if (objControl.value.length != 8)
				{
				 arrDate = objControl.value.split(formatSeparator);
				  arrDate[0] = FormatDayMonthYear(arrDate[0],'YY')
				 arrDate[1] = FormatDayMonthYear(arrDate[1],'D')
				 arrDate[2] = FormatDayMonthYear(arrDate[2],'M')
				    objControl.value = arrDate[0] + formatSeparator + arrDate[1] + formatSeparator + arrDate[2];
				    //alert(objControl.value);     
				}	
				break;
			}
		case (format=='YY-MM-DD' || format=='YY.MM.DD' || format == 'YY/MM/DD'):
			{
				objRegExp = /^\d\d[-\/.](0[1-9]|1[012])[-\/.](0[1-9]|1[0-9]|2[0-9]|3[01])$/;
				if (objControl.value.length != 8)
				{
				 arrDate = objControl.value.split(formatSeparator);
				  arrDate[0] = FormatDayMonthYear(arrDate[0],'YY')
				 arrDate[1] = FormatDayMonthYear(arrDate[1],'M')
				 arrDate[2] = FormatDayMonthYear(arrDate[2],'D')
				    objControl.value = arrDate[0] + formatSeparator + arrDate[1] + formatSeparator + arrDate[2];
				    //alert(objControl.value);     
				}	
				break;
			}
		default:
			if (message != '')
				alert(message);
			if(navigator.appName == 'Microsoft Internet Explorer')
				setFocus(objControl);
			else
				window.setTimeout('document.forms["' + formname + '"].elements["' + objControl.id + '"].focus()', 1);
			return false;
			break;
	}
	
	if(!objRegExp.test(objControl.value) == true)
	{
		//invalid format return false
		if (message != '')
			alert(message);
		if(navigator.appName == 'Microsoft Internet Explorer')
			setFocus(objControl);
		else
			window.setTimeout('document.forms["' + formname + '"].elements["' + objControl.id + '"].focus()', 1);
		return false; 
	}
	else
	{
		// date format pattern matched!
		
		//check the validity of the separator and get the separator
		separator = formatSeparator; //getSeparator(objControl.value, format);
		//validate the date now
		standardDate = '';
		standardDate = ConvertDateToStanderFormat(formname,controlname, format, separator);
		if (standardDate != '' )
		{	
			objOriginalControl.value = standardDate;
			//alert(objOriginalControl.value);
			originalDate = objControl.value;
			objControl.value = standardDate;
			if (isDate(objControl,null,false) == true) 
			{
				objControl.value=originalDate ;
				//alert(objControl.value);
				return true;
			}
			objControl.value=originalDate; 
			if (message != '')
				alert(message);
			if(navigator.appName == 'Microsoft Internet Explorer')
				setFocus(objControl);
			else
				window.setTimeout('document.forms["' + formname + '"].elements["' + objControl.id + '"].focus()', 0);
			return false;
			//alert(objControl.value);
		}
		
	}
	return false;
}


function ConvertDateToStanderFormat(formname,controlname, format, separator)
/*
FUNCTION	:	ConvertDateToStanderFormat()
I/P PARAM	:	date string to be checked, format for the string
RETURNS		:	true if valid else false
*/
{
	var intDay;
	var strMonth;
	var intYear;
	var strSeparator;
	var arrayDate;
	var datePos;
	var monthPos;
	var yearPos;
	var fullDate='';
	var arrayLookup = {'01':'Jan','02':'Feb','03':'Mar','04':'Apr','05':'May','06':'Jun','07':'Jul','08':'Aug','09':'Sep','10':'Oct','11':'Nov','12':'Dec'};	
	var objControl = GetObjectReference(formname,'FFE29587WHIZ_' + controlname);
	
	switch(true)
	{
		case (format=='DD-MM-YYYY' || format=='DD.MM.YYYY' || format == 'DD/MM/YYYY'):
			datePos=0;
			monthPos =1;
			yearPos=2;
			break;
		case (format=='MM-DD-YYYY' || format=='MM.DD.YYYY' || format == 'MM/DD/YYYY'):
			datePos=1;
			monthPos =0;
			yearPos=2;
			break;
		case (format=='YYYY-DD-MM' || format=='YYYY.DD.MM' || format == 'YYYY/DD/MM'):
			datePos=1;
			monthPos =2;
			yearPos=0;
			break;
		case (format=='YYYY-MM-DD' || format=='YYYY.MM.DD' || format == 'YYYY/MM/DD'):
			datePos=2;
			monthPos =1;
			yearPos=0;
			break;
		case (format=='DD-MM-YY' || format=='DD.MM.YY' || format == 'DD/MM/YY'):
			datePos=0;
			monthPos =1;
			yearPos=2;
			break;
		case (format=='MM-DD-YY' || format=='MM.DD.YY' || format == 'MM/DD/YY'):
			datePos=1;
			monthPos =0;
			yearPos=2;
			break;
		case (format=='YY-DD-MM' || format=='YY.DD.MM' || format == 'YY/DD/MM'):
			datePos=1;
			monthPos =2;
			yearPos=0;
			break;
		case (format=='YY-MM-DD' || format=='YY.MM.DD' || format == 'YY/MM/DD'):
			datePos=2;
			monthPos =1;
			yearPos=0;
			break;
		default:
			return fullDate;
			break;
	}
	

	//get the array with date variables
	arrayDate = objControl.value.split(separator); 

	//the date
	intDay = arrayDate[datePos];	
	strMonth = arrayLookup[arrayDate[monthPos]];
	intYear = arrayDate[yearPos];
	if (intYear.length == 2)
		if (intYear.substring(0,1) == '0')
	   		intYear = 2000 + parseInt(intYear.substring(1,2));
	   	else
	   	    intYear = 2000 + parseInt(intYear.toString());
	fullDate = intDay.toString() +'-'+ strMonth +'-' + intYear.toString();
	//alert(fullDate + ' ' + format);
	return fullDate;
}

function getSeparator(value,format)
/*
FUNCTION	:	getSeparator()
I/P PARAM	:	format for the date string
RETURNS		:	separator
*/
{

	var separator;
	switch(true)
	{
	case (format=="MM-DD-YY" ||format=="DD-MM-YY" || format=="YY-MM-DD" || format=="YY-DD-MM" || format=="MM-DD-YYYY" ||format=="DD-MM-YYYY"):
		separator =	value.substring(2,3);	
		if (separator == "-") 
			return "-"
		else
			return "";
		break;
	case ( format=="YYYY-MM-DD" || format=="YYYY-DD-MM"):
		separator =	value.substring(4,5);	
		if (separator == "-") 
			return "-"
		else
			return "";
		break;
	case (format=="MM.DD.YY" ||format=="DD.MM.YY" || format=="YY.MM.DD" || format=="YY.DD.MM" || format=="MM.DD.YYYY" ||format=="DD.MM.YYYY" ):
		separator =	value.substring(2,3);	
		if (separator == ".") 
			return "."
		else
			return "";
		break;
	case (format=="YYYY.MM.DD" || format=="YYYY.DD.MM"):
		separator =	value.substring(4,5);	
		if (separator == ".") 
			return "."
		else
			return "";
		break;
	case (format=="MM/DD/YY" ||format=="DD/MM/YY" || format=="YY/MM/DD" || format=="YY/DD/MM" || format=="MM/DD/YYYY" ||format=="DD/MM/YYYY"):
		separator =	value.substring(2,3);	
		if (separator == "/") 
			return "/"
		else
			return "";
		break;
	case (format=="YYYY/MM/DD" || format=="YYYY/DD/MM"):
		separator =	value.substring(4,5);	
		if (separator == "/") 
			return "/"
		else
			return "";
		break;
	default:
		break;
	}
	return "";	
}
function FormatDayMonthYear(value,format)
{
	switch(true)
	{
	  case (format == 'D' || format == 'M' || format == 'YY' ):
	  {
		  if (value.length < 2)
			 value = '0' + value;	
		  break;
	   }
	  case (format == 'YYYY'):
	   {
		  if (value.length < 4)
			{
			if (value.length == 3)
				value = '2' + value;
			if (value.length == 2)
				value = '20' + value;
			if (value.length == 1)
				value = '200' + value;
			} 	 
	   }
	  default :
		 break; 
	}
	
	return value;
}
//End Of Addition By NileshD on 14 Nov 2005 for REQID:WAF3_PB_12
//Added By UmeshJ on 04 Apr 2006
//Added By NinadP :	13 Feb 2007 : Requirement Tag - WAF3_PB_33 
function DisplayLookup(frmName,ControlName,ControlCaption,ParentTagID,TagID,ControlTagID,IsEdit,GroupingColumn,ConnectionID)
{	
		var	objDS=GetObjectReference(frmName,'hd'+ControlName);
		
		strAddress="../General/Lookup_CommonList.aspx?FormName=" + frmName +"&ControlName=" + ControlName +"&ControlCaption=" + ControlCaption +"&ParentTagID=" + ParentTagID +"&TagID=" + TagID +"&ControlTagID=" + ControlTagID + "&IsEditMode=" + IsEdit + "&GroupingColumn=" + GroupingColumn + "&DS=" + objDS.value + "&ConnectionID=" + ConnectionID;
		strParameters = "resizable=yes,left=" + (window.screen.width - 545)/2 + ",top=" + (window.screen.height - 500)/2 + ",width=545,height=500"
		window.open(strAddress,"Lookup",strParameters)
}	
//End of Addition
/*function DisplayLookup(frmName,ControlName,ControlCaption,ParentTagID,TagID,ControlTagID,IsEdit,GroupingColumn)
{	
		var	objDS=GetObjectReference(frmName,'hd'+ControlName);
		
		strAddress="../General/Lookup_CommonList.aspx?FormName=" + frmName +"&ControlName=" + ControlName +"&ControlCaption=" + ControlCaption +"&ParentTagID=" + ParentTagID +"&TagID=" + TagID +"&ControlTagID=" + ControlTagID + "&IsEditMode=" + IsEdit + "&GroupingColumn=" + GroupingColumn + "&DS=" + objDS.value;
		strParameters = "resizable=yes,left=" + (window.screen.width - 545)/2 + ",top=" + (window.screen.height - 500)/2 + ",width=545,height=500"
		window.open(strAddress,"Lookup",strParameters)
}	*/
//End of Addition

//Start_AJ_03Oct2006
/*
var g_objXHttp;
function CreateRecordOnChange()
{
	//var objCreateRecord = GetObjectReference('frmCommonList','CreateRecord')
	//if (objCreateRecord==null) return;
	//window.location.href="CommonPage.aspx?Mode=ADD_NEW&MasterTagID=" + objCreateRecord.value + "&FromWhere=PM&PagingAlphabet=-1&SortBy=&SortOrder=&ParentTagID=0&FromCL=1&PagingNumber=1";
	var strUrl;
	var blnflag=false;
	var objCbo;
	var strNavigator = new String();
	strUrl = new String();
	objCbo = GetObjectReference('frmCommonPage', 'CreateRecord');
	strUrl = "../General/XMLHttp.aspx?TagID=" + objCbo.value;
	if (objCbo.selectedIndex > -1)
	{
		//Instantiate XmlHttpRequest// Checking if IE-specific document.all collection exists // TO SEE IF WE ARE RUNNING IN IE 
		strNavigator = navigator.appName;
		strNavigator = strNavigator.toUpperCase();
		if(strNavigator == 'MICROSOFT INTERNET EXPLORER')
		{ 
			g_objXHttp = new ActiveXObject("Msxml2.XMLHTTP"); 
			g_objXHttp.onreadystatechange = HandlerOnReadyStateChange;
			g_objXHttp.open("GET",strUrl, false);
			g_objXHttp.send();
		}
		else
		{
			g_objXHttp = new XMLHttpRequest();
			g_objXHttp.onreadystatechange = HandlerOnReadyStateChange();
			g_objXHttp.open("GET",strUrl, false);
			g_objXHttp.send(null);
		}
	}
}

function HandlerOnReadyStateChange()
{
	var objCbo = GetObjectReference('frmCommonPage', 'CreateRecord');
	if (g_objXHttp.readyState==4)
	{
		var strText = new String();
		if (g_objXHttp.responseText != null)
		{
			strText = g_objXHttp.responseText;
			//eval(strText);
			if(strText.indexOf('?') == -1)
			window.location.href=strText + "?FromWhere=PM&MasterTagId="+objCbo.value;
			else
			window.location.href=strText + "&FromWhere=PM&MasterTagId="+objCbo.value;
		}
	}
}*/
//End_AJ_03Oct2006
//MyViews called from CommonList Page WAF3_PB_24 NinadP
function MyViews(TagID)
{
	window.open ("../General/ViewProperties_CommonList.aspx?MasterTagID=1719&TagID=" + TagID, "MyViews", "resizable=yes,scrollbars=no,left=" + ((window.screen.width - 800)/2) + ",top=" + ((window.screen.height - 500)/2) + ",width=800,height=500");
}


/* Added By ParagD On 24-May-2006 */

var depCboValue;

/*  For Customer Level Product Execution */

var objCustomerCBO;
var objProductVersionID;
 
function getCustomerComboValue(strForm ,strCustomerCombo) 
{
objCustomerCBO = GetObjectReference(strForm,strCustomerCombo);
}
/*	onSelection (FormName , ChangedControlName , Dependand Control , TagID , Primary Key , 'ADD/EDIT' , ProjectID )
	This method can be called to plot the dependent controls
	Customer -> Product ,
	Product -> Component 
*/

function onSelection(strFrm,strCtrl,strDependentCtrl ,strTagID ,strPK ,strMode,ProjectID)
			{
				var objCbo; var strUrl; var strMasterPKValue ; var depCbo;
				var strCustomerControlValue;
				var strComponentValue;
				
				var ProjectID = (arguments.length>6)?arguments[6]:false;
				if (ProjectID == false)
				{
					ProjectID = '';
				}
				
				if(GetObjectReference(strFrm,strPK))
				strMasterPKValue = GetObjectReference(strFrm,strPK).value;
				else
				strMasterPKValue = 0;
					
				global_strFrm = strFrm; global_strDependentCtrl = strDependentCtrl;
				objCbo = GetObjectReference(strFrm,strCtrl);
				depCbo = GetObjectReference(strFrm,strDependentCtrl);
				// Modification By NitinVS on 7 Jun 2006 
				// if the dependant control is having any value selected then only set the values else set to 0  
				if (depCbo.selectedIndex!=-1)
					depCboValue = depCbo[depCbo.selectedIndex].value;
				// End Modification By NitinVS on 7 Jun 2006 
				if (objCbo != null)
				{
					if (objCbo.value != '0' || objCbo.value != '')
					{
						strUrl = new String();
						//Added By MahendraV On 12:54 PM 6/7/2007 for ReviewType value along with TaskType
						//Start_MV_6/7/2007
						if(strTagID=='2010')
						{
							
								strUrl = "../General/XMLHttp.aspx?TagID=" + strTagID + "&PhaseTaskID=" +objCbo.value;
								
						}
						else
						{
						//End_MV_6/7/2007
							if (objCustomerCBO != null)
							{					
								strCustomerControlValue = objCustomerCBO.value;
								if (strCustomerControlValue != 0)			
								{
								strUrl= "../PRD/PRD_CommonFunctions.aspx?TagID=" + strTagID + "&CustomerComboValue=" + strCustomerControlValue + "&MasterPKField=" + strPK + "&MasterPKValue=" +strMasterPKValue+ "&DependentControlName=" + strDependentCtrl + "&CboValue=" + objCbo.value + "&ProjectID=" + ProjectID ; 
								}
								else
								{
								strUrl= "../PRD/PRD_CommonFunctions.aspx?TagID=" + strTagID + "&CustomerComboValue=0&MasterPKField=" + strPK + "&MasterPKValue=" +strMasterPKValue+ "&DependentControlName=" + strDependentCtrl + "&CboValue=" + objCbo.value + "&ProjectID=" + ProjectID ;
								}
							}	
							else
							{
							strUrl= "../PRD/PRD_CommonFunctions.aspx?TagID=" + strTagID + "&CustomerComboValue=NULL&MasterPKField=" + strPK + "&MasterPKValue=" +strMasterPKValue+ "&DependentControlName=" + strDependentCtrl + "&CboValue=" + objCbo.value + "&ProjectID=" + ProjectID ;
							}
						}
							
						if (objCbo.selectedIndex>-1)
						{
							//INSTANTIATE XmlHttpRequest
							// Checking if IE-specific document.all collection exists 
							// TO SEE IF WE ARE RUNNING IN IE 
							if (document.all)
							{ 
								objXHttp = new ActiveXObject("Msxml2.XMLHTTP"); 
								//hook the event handler
								objXHttp.onreadystatechange = HandlerOnReadyState;
								
								//prepare the call, http method=GET, false=asynchronous call
								objXHttp.open("GET",strUrl, false);
								//finally send the call
								objXHttp.send();          
							} 
							else 
							{ 
								// Mozilla - based browser 
								objXHttp = new XMLHttpRequest(); 
								//hook the event handler
								objXHttp.onreadystatechange = HandlerOnReadyState();
								//prepare the call, http method=GET, false=asynchronous call
								objXHttp.open("GET",strUrl, false);
								//finally send the call
								objXHttp.send(null);
								
								// Modified By MahendraV On 12:29 PM 7/25/2007 For WhizibleSEM 7.0
								// To Mozilla - based browser , Netscape- based browser
								// Start_MV_7/25/2007
										if (objXHttp.responseText != null)
										{
											xmlDoc= document.implementation.createDocument("","",null);
											xmlDoc.async=false;
											//xmlDoc.load(req.responseXML);
											xmlDoc.load(objXHttp.responseXML);
											HandlerOnReadyState();
											
										}
								
								// End_MV_7/25/2007
							}
						}
					}
				}
			}
			
		
		function HandlerOnReadyState()
			{
				var strNavigator = navigator.appName;
					strNavigator = strNavigator.toUpperCase();
						
				var objCbo = GetObjectReference(global_strFrm,global_strDependentCtrl);
				if (objXHttp.readyState==4)
				{
				
					var i=0;
					var objOption;
					var strText = new String();
					var arrValue = new Array();
					var arrStr = new Array();
					objCbo.innerHTML = "";
					if (objXHttp.status == 200)
					{
						//responseXML contains an XMLDOM object
						if (objXHttp.responseText != null)
						{
						
							strText = objXHttp.responseText;
							arrStr = strText.split("|");
						}
						for (i=0; i<arrStr.length; i++)
						{
							objOption = new Option();
							arrValue = arrStr[i].split("->");
							objOption.text =  arrValue[0];
							objOption.value = arrValue[1];
							// Modified By MahendraV On 4:51 PM 7/25/2007 For WhizibleSEM 7.0
							// To Mozilla - based browser , Netscape- based browser
							// Start_MV_7/25/2007
							if(strNavigator == 'MICROSOFT INTERNET EXPLORER')
								objCbo.add(objOption);
							else
								objCbo.add(objOption,null);
							// End_MV_7/25/2007
							if(arrValue[1] == depCboValue)
							{
							arrValue[1].selectedIndex = arrValue.length - 1;
							}
							objOption = null;
						}
					}
				}
			}	
		
		
//WAF3_PB_42 April 06, 2007 START
//on load function
var DraftQueryMsg;
var objdivlist;
function window_onload()
{
	if(objdivlist!=null) 
    {
        var intFillFactor=(arguments.length>0)?arguments[0]:40;
        windowSize_common(intFillFactor);	
    }
	// if there is a message to display 
	if(DraftQueryMsg != null) {
	    if (trimString(DraftQueryMsg) != "")
	    {alert(DraftQueryMsg);}
	}
}
function window_onresize()		
{
	var intFillFactor=(arguments.length>0)?arguments[0]:40;
    windowSize_common(intFillFactor);
    try{hideAll();} catch(e){}
}
function windowSize_common(intFillFactor)
{
	if(objdivlist!=null) 
    {
		var intDivHeight ;
		if (navigator.appName == 'Microsoft Internet Explorer'){
			intDivHeight = document.body.offsetHeight - objdivlist.offsetTop - intFillFactor;
		}
		else{
			intDivHeight = window.innerHeight - objdivlist.offsetTop - intFillFactor;
		}		
		if (intDivHeight < 100)
		intDivHeight = 100;
		objdivlist.style.height = intDivHeight	;	
	}
}
// This function returns Internet Explorer's major version number,
// or 0 for others. It works by finding the "MSIE " string and
// extracting the version number following the space, up to the decimal
// point, ignoring the minor version number
function msieversion()
{
  var ua = window.navigator.userAgent
  var msie = ua.indexOf ( "MSIE " )

  if ( msie > 0 )      // If Internet Explorer, return version number
     return parseInt (ua.substring (msie+5, ua.indexOf (".", msie )))
  else                 // If another browser, return 0
     return 0
}
//WAF3_PB_42 April 06, 2007 END
//WAF3_PB_44 May 09, 2007 START
function TabControl_OnClick(index,NoOfTabs,formID,Tabdiv)
{

	for (i=0;i<NoOfTabs;i++){
		var oDiv=GetObjectReference(formID,Tabdiv+i);
		var oHREF=GetObjectReference(formID,'HREF' + Tabdiv +i);
		if (oDiv!= null) {
		    if(i==index) {oDiv.style.display='block';oHREF.className='clsTabSelected';}
		    else{oDiv.style.display='none';oHREF.className='navtab';}
		}
	}
}
//WAF3_PB_44 May 09, 2007 END
//WAF3_PB_47 17-May-2007 START
var WHIZ_TD_ROLLED_OVER;
var WHIZ_TD_PREVIOUS_BG_IMG='none';
var WHIZ_DIV_CONTEXT_MENU;
function SetPositionForContextMenu(ev,sContextMenuID)
{
    var intX,intY,intBottom;
    var objContextMenu = GetObjectReference('',sContextMenuID);
    if (objContextMenu)
    {
        objContextMenu.style.display='';
        intX = ev.clientX;
        intY = ev.clientY;
        intBottom = document.body.offsetTop + document.body.offsetHeight;
        if (intBottom - intY < objContextMenu.offsetHeight)
        {intY = intY - objContextMenu.offsetHeight;}
        objContextMenu.style.left = intX;
        objContextMenu.style.top = intY;
        /*if there are multiple context menu, then following
          object will be used to reset/hide the div*/
        WHIZ_DIV_CONTEXT_MENU = objContextMenu;
        if(WHIZ_TD_ROLLED_OVER)
        {
                WHIZ_TD_ROLLED_OVER.style.backgroundImage=GetStyleSheetImagePath();
        }
    }
}
function SetContextMenuNode(sNodeID,sfunction)
{    
    var objCtNode=GetObjectReference('',sNodeID);
    if (objCtNode)
    {
        if (sfunction != '')
        {
            objCtNode.className='CtMn_Node';
            objCtNode.onmouseover= function(){this.className='CtMn_Node_Hover';};
            objCtNode.onmouseout= function(){this.className='CtMn_Node';};
        }
        else
        {
            objCtNode.className='CtMn_Node_Disabled';
            objCtNode.onmouseover='';
            objCtNode.onmouseout='';
        }
        objCtNode.onclick=function(){sfunction = replaceSubstring(sfunction, '«««', '\&quot;'); 
        sfunction = replaceSubstring(sfunction, '»»»', ' ');eval(sfunction);}
    }
}
function GetStyleSheetImagePath()
{   var strPath = '../../images/cssImages/';
    var objLnkStyle = GetObjectReference('','lnkWhizStyleSheetImgDir');
    if (objLnkStyle)
    {        
        strPath = objLnkStyle.href;        
        if(!strPath){strPath='../../images/cssImages/';}
        else if(strPath==''){strPath='../../images/cssImages/';}
    }  
    strPath = 'url(' + strPath + 'tdRolledOver.jpg)';
    return strPath;
}
function SetRolledOverTD(obj,sContextMenuID)
{
    var strImgPath = GetStyleSheetImagePath();
    var objContextMenu = GetObjectReference('',sContextMenuID);
    if(obj)
    {
        if(obj!=WHIZ_TD_ROLLED_OVER)
        {
            objContextMenu.style.display='none';
            if(WHIZ_TD_ROLLED_OVER)
            {
                WHIZ_TD_ROLLED_OVER.style.backgroundImage=WHIZ_TD_PREVIOUS_BG_IMG;                
            }
            WHIZ_TD_PREVIOUS_BG_IMG = obj.style.backgroundImage;
        }
        obj.style.backgroundImage= strImgPath;
        obj.style.cursor='hand';
        WHIZ_TD_ROLLED_OVER=obj;
    }
}
function HideContextMenu()
{
    if (WHIZ_DIV_CONTEXT_MENU)
    {
        WHIZ_DIV_CONTEXT_MENU.style.display = 'none';
        if(WHIZ_TD_ROLLED_OVER)
        {
            WHIZ_TD_ROLLED_OVER.style.backgroundImage=WHIZ_TD_PREVIOUS_BG_IMG;
        }
    }
}
//WAF3_PB_47 17-May-2007 END
//WAF3_PB_47_Extended: Starts
function ReplaceSubStringForCtMn(sInput)
{
    if(sInput)
    {
		sInput = replaceSubstring(sInput, '$|$', "\\\\");
        sInput = replaceSubstring(sInput, '%|%', "\\\"");
        sInput = replaceSubstring(sInput, '#|#', ' ');
    }
    return sInput;
}

function WHIZ_SetContextMenuNode(sNodeID,sfunction,sLinkImage,sLinkName,sLinkTitle)
{      
    var objCtNode= GetObjectReference('',sNodeID);
    var objCtName,objCtImage;
    
    if (sNodeID.length > 2)
    {
        objCtName = GetObjectReference('','td' + sNodeID.substring(2,sNodeID.length));      
        if(objCtName)
        {
            sLinkName = ReplaceSubStringForCtMn(sLinkName);
            objCtName.innerHTML = sLinkName + "&nbsp;";
        }
        objCtImage = GetObjectReference('','tdImg' + sNodeID.substring(2,sNodeID.length));
        if(objCtImage)
        {
            if(sLinkImage && trimString(sLinkImage)!='')
            {
                sLinkImage = ReplaceSubStringForCtMn(sLinkImage);
                objCtImage.innerHTML = "<img src='" + sLinkImage + "'>";
            }
            else
            {
                objCtImage.innerHTML = "";
            }
        }
    }
    if (objCtNode)
    {
        if (sfunction != '')
        {
            objCtNode.className='CtMn_Node';
            objCtNode.onmouseover= function(){this.className='CtMn_Node_Hover';};
            objCtNode.onmouseout= function(){this.className='CtMn_Node';};
        }
        else
        {
            objCtNode.className='CtMn_Node_Disabled';
            objCtNode.onmouseover='';
            objCtNode.onmouseout='';
        }

		if(navigator.appName == 'Microsoft Internet Explorer')
        {
			objCtNode.onclick=function(){sfunction = ReplaceSubStringForCtMn(sfunction);eval(sfunction);}
		}
		else
		{
			objCtNode.onmousedown = function(){sfunction = ReplaceSubStringForCtMn(sfunction);eval(sfunction); return;}
		}

        if (sLinkTitle)
        {
            sLinkTitle = ReplaceSubStringForCtMn(sLinkTitle);
            objCtNode.title = sLinkTitle;
        }
        else
        {
            objCtNode.title = '';
        }
    }
}
//WAF3_PB_47_Extended: Ends

function OpenProperties(PropertyPage,TagID,SubTagID,FromElement,ElementName,FocusOn) 
{   
/*
Function Name   :   OpenProperties
Input Parameters:   1)PropertyPage - Identifies which property pages to open i.e. Actions,Control,Page
                    2)TagID     - TagID
                    3)SubTagID     - SubTagID
                    4)FromElement  - Tag or SubTag
                    5)ElementName  - i.e. Control name, action link name etc
                    6)FocusOn      -  Property control name to focus
Author          :   NinadP
Created         :   29 May 2007
ReqID           :   WAF3_PB_48
*/
try{
var url; 
    if (PropertyPage=='ACTIONLINKPROPERTIES')
    {//Open Action properties
        url = "../SM/PB_TabFrame.aspx?FromWhere=InformativeSections&FromElement=" + FromElement + "&TagID=" + TagID + "&SubTagID=" + SubTagID + "&DisplaySection=A&TITLE=&ElementName=" +  ElementName ;
        window.document.open(url,"","resizable=yes,scrollbars=no,left=" + ((window.screen.width - 1000)/2) + ",top=" + ((window.screen.height - 600)/2) + ",width=1000,height=600");
    }
    if (PropertyPage=='CONTROLPROPERTIES')
    {//Open control properties
                url = "../SM/PB_TabFrame.aspx?FromWhere=Control&FromElement=" + FromElement + "&TagID=" + TagID + "&SubTagID=" + SubTagID + "&DisplaySection=H&TITLE=&ElementName=" +  ElementName + "&FocusOn=" + FocusOn ;
                window.document.open(url,"","resizable=yes,scrollbars=no,left=" + ((window.screen.width - 1000)/2) + ",top=" + ((window.screen.height - 575)/2) + ",width=1000,height=575");
    }
     if (PropertyPage=='PAGEPROPERTIES')
    {//Open page properties
                url = "../SM/PB_PageProperties.aspx?FromWhere=Control&FromElement=" + FromElement + "&TagID=" + TagID + "&SubTagID=" + SubTagID + "&DisplaySection=PT&TITLE=&ElementName=" +  ElementName ;
                window.document.open(url,"","resizable=yes,scrollbars=no,left=" + ((window.screen.width - 1000)/2) + ",top=" + ((window.screen.height - 575)/2) + ",width=1000,height=575");
    }
}catch(e){}
}

var SmartNavigation_IsEnabled = 2;// 2 Not Applicable, 1 Enabled, 0 disabled, it is required to refresh the opener in case of SmartNavigation is changed
function RefreshWebFormDesigner() 
{   
/*
Function Name   :   RefreshWebFormDesigner
Input Parameters:   None
Desc            :   Refresh the Web Form Designer page i.e. CommonList or CommonPage or any Inherited page                   
Author          :   NinadP
Created         :   29 May 2007
ReqID           :   WAF3_PB_48
*/
try{
if (arguments.length==0 && parent.window.opener.location.href.indexOf('/PB_PageCanvas.aspx?') != -1) return;
var url;
var query;
url =  window.opener.location.href.substring(0,window.opener.location.href.indexOf(window.opener.location.search)) + '?'; 
query = window.opener.location.search.substring(1);
try{
if (window.location.href.indexOf('PB_PageProperties.aspx?')!=-1 && opener.document.getElementById('ParentTagID').value==0)
{//Request comes from page properties for Tag
    if (arguments.length != 0 && SmartNavigation_IsEnabled != 2)
    {//Page is of advance type having SmartNavigation_IsEnabled property
        if (SmartNavigation_IsEnabled==1)
        {//Smart Navigation is enabled
            if (window.opener.parent.frames['whizFRMECL']==null)
            {//SmartNavigation is now enabled, so we need to open it in new SmartNavigation page
                var tmpurl=url.substring(0,url.indexOf('?'));
                tmpurl= tmpurl.substring(0,url.lastIndexOf('/'))+ '/' + 'SmartNavigation.aspx';
                tmpurl=tmpurl + '?' + query;
                window.opener.location.href =tmpurl;
                                          
                //refresh Web form Wizard
                try{
					objForm=window.opener.opener.document.getElementById('frmCommonList')
					if (objForm!= null)
					{
						url=window.opener.opener.location.href.substring(0,window.opener.opener.location.href.indexOf(window.opener.opener.location.search)) + '?'; 
						query = window.opener.opener.location.search.substring(1);
						objForm.action=url;
						objForm.submit();
					}
					}catch(e){}
                return;
            }
            else
            {//SmartNavigation is already enabled, so just need to refresh common list page, so also need to generate the url according to list page
                url =  window.opener.parent.frames['whizFRMECL'].location.href.substring(0,window.opener.parent.frames['whizFRMECL'].location.href.indexOf(window.opener.parent.frames['whizFRMECL'].location.search)) + '?'; 
                query = window.opener.parent.frames['whizFRMECL'].location.search.substring(1);
                window.opener.parent.frames['whizFRMECL'].location.href=BuildURLToRefreshParent(url,query);
                return;
            }
        }
        else 
        {//Smart Navigation is disabled
            if (window.opener.parent.frames['whizFRMECL']!=null)
            {//SmartNavigation is now disabled, so we need to open it in new commonList/CommonPage page
                //refresh Web form Wizard
                //The hidden variable below is required to refresh the Web Form Wizard, so as to identify that the Smart Navigation is disabled
                //this hidden variable is retrieved in Smart Navigations OnUnload event
                
                try{
					//opener.opener is web form wizard so refresh it
					objForm=window.opener.opener.document.getElementById('frmCommonList')
					if (objForm!= null)
					{
						var RefreshWFW= window.opener.parent.document.createElement('hidden');
						RefreshWFW.setAttribute('id','hidFlagToRefreshWFW');
						window.opener.parent.document.appendChild(RefreshWFW); 
					}
					}catch(e){}
                 
                //Refresh Opener       
                      
                url =  window.opener.parent.frames['whizFRMECL'].location.href.substring(0,window.opener.parent.frames['whizFRMECL'].location.href.indexOf(window.opener.parent.frames['whizFRMECL'].location.search)) + '?'; 
                query = window.opener.parent.frames['whizFRMECL'].location.search.substring(1);
                window.opener.parent.location.href=BuildURLToRefreshParent(url,query);
                return;
             }
         }
    }   
}
else
{
//request come for control or action properties
    if (window.opener.parent.frames['whizFRMECL']!=null)
    {
        //smart navigation is enabled
        if(window.location.search.indexOf('FromElement=Tag')!=-1)
        {
            url =  window.opener.parent.frames['whizFRMECL'].location.href.substring(0,window.opener.parent.frames['whizFRMECL'].location.href.indexOf(window.opener.parent.frames['whizFRMECL'].location.search)) + '?'; 
            query = window.opener.parent.frames['whizFRMECL'].location.search.substring(1);
            window.opener.parent.frames['whizFRMECL'].location.href=BuildURLToRefreshParent(url,query);
            return;
        }
    }
 }
}catch(e){}
 //The part below is executed for the Control, Action and Page properties for the Normal case (i.e. not for Smart Navigation)
if (window.opener.document.getElementById('frmCommonList')!= null)
    objForm=window.opener.document.getElementById('frmCommonList')//to refresh Common List Page 
else if(window.opener.document.getElementById('frmCommonPage')!= null)
    objForm=window.opener.document.getElementById('frmCommonPage'); //to refresh Common Page 
else
    objForm=window.opener.document.getElementById('frmSample'); //to refresh Page canvas
    
url=BuildURLToRefreshParent(url,query);   
objForm.action=url;
objForm.submit();
try{
if (window.opener.document.getElementById('frmCommonPage')!= null && opener.document.getElementById('ParentTagID').value!=0)
{//When property page is opened from sub tag Form page then we need to refresh sub tag list page also
    //Smart Navigation is not enabled for main tag, then refresh sub tag list page(i.e common page of Tag) 
     url =  window.opener.opener.location.href.substring(0,window.opener.opener.location.href.indexOf(window.opener.opener.location.search)) + '?'; 
     query = window.opener.opener.location.search.substring(1);
     objForm=window.opener.opener.document.getElementById('frmCommonPage'); //to refresh Common Page 
     url=BuildURLToRefreshParent(url,query);   
     objForm.action=url;
     objForm.submit();
}
}catch(e){}
}catch(e){}
}


function BuildURLToRefreshParent(url,query)
{
/*
Function Name   :   BuildURLToRefreshParent
Input Parameters:   url - The URL of the page (including '?')
                :   query - is the string containing the query string parameters 
Desc            :   To build the URL which is required to refresh the Web Form Wizard, CommonList, CommonPage, Smart Navigation page or any Inherited page                   
Author          :   NinadP
Created         :   14 June 2007
ReqID           :   WAF3_PB_48
*/
try{
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) 
    {
        var pos = parms[i].indexOf('=');
        var key = parms[i].substring(0,pos);
        if (key != 'Operation' && key != 'SetFilter' && key != 'PagingNumber' && key != 'PagingNavigation' && key != 'SortBy' && key != 'SortOrder')
        {
            if (key == 'Mode')
            {
                if(query.indexOf('Operation=SAVE')==-1 && query.indexOf('Mode=ADD_NEW')==-1)
                    url += parms[i] + '&';
            }
            else
            {
                url += parms[i] + '&'
            }
        }
    } 
    url=url.substring(0,url.length -1);
    return url;   
 }catch(e){}
}


//Added By PurvaJ on 29 April 2008 for configurable workflow , plotting link function body and comments block

function DisplayComments(strCommentCaption,blnIsDisabled,strActionType,strUniqueID,lngTagID,strPage,PrimaryKeyName)
		{	
		   var url;
			var objTblpopup;
			var mouseXY;
			var objDivpopup;
			var intIdeaID ;
			var objComment;
			
			
			objDivpopup = document.getElementById("DivComments");
			
			loadComment(strCommentCaption,blnIsDisabled,strActionType,strUniqueID,objDivpopup,lngTagID,strPage,PrimaryKeyName);				
		
			objDivpopup.style.width  = '355px';
			objDivpopup.style.height  = '145px';
		    objDivpopup.style.left =50;
		    objDivpopup.style.top =50;
		    objDivpopup.style.position ='absolute';
			objDivpopup.style.display  = ''; 
			
			var objT = document.getElementById('txtComments');
			if(blnIsDisabled!="1")
			    objT.select();
			objT.focus(); 

		}

		function loadComment(strCommentCaption,blnIsDisabled,StrActionType,strUniqueID,objDivpopup,lngTagID,strPage,PrimaryKeyName)
		{		var strElement;	
				var strComments="";
				var objtxtComments = GetObjectReference('frmCommonPage','txtComments');
				var strTextStyle = "";	
				
				if (blnIsDisabled=="0")
				{
					strTextStyle="clsTextArea"
				}
				else
				{
					strTextStyle="clsTextBoxReadOnly readonly"
				}		

				if (objtxtComments == null) 
					strComments = ""
				else
					strComments = objtxtComments.value;	
				
				strElement = '<Table class=clsTable cellspacing=0 cellpadding=0 style="height=99.99%;"><TR class=clsTREven><td><b>';
				strElement	+= strCommentCaption + '</b></td><TR class=clsTREven><td>';
				strElement	+=	'<Textarea wrap=Hard  name=txtComments id=txtComments maxlength=500 class=' + strTextStyle + ' style="width:350px; height:70px; text-align:Left"; rows=5; cols =20>'+ strComments + '</Textarea>';
				strElement += '</td></TR><TR class=clsTREven><td>';
				strElement	+= '<input type=button id= btnOK name= btnOK '  
				
				if (blnIsDisabled=="1")
					strElement	+= ' disabled ';
				
				strElement	+= 'Value = "   OK   " style ="font size=9 width=10pts" onClick = getComment_Onclick("'+StrActionType+'",'+strUniqueID+','+lngTagID+',"'+strPage+'","'+PrimaryKeyName+'")>';
				strElement	+= '<input type=button id= btnCancel name= btnCancel style ="font size=9" Value = CANCEL onClick = Cancel_OnClick()>';
				strElement	+=  '</td></tr></table>'
				
				if (objDivpopup !=null)
					objDivpopup.innerHTML = strElement;	
		}
		
		function getComment_Onclick(StrActionType,strUniqueID,lngTagID,strPage,PrimaryKeyName)
		{		
			var strElement;	
			var intCnt;
			var objDivComments= GetObjectReference("frmCommonPage","DivComments");
			
			objPopupComments = GetObjectReference('frmCommonPage','txtComments');
			objPopupComments_hidden = GetObjectReference('frmCommonPage','txtComments_hidden');
			
			if(objPopupComments.innerText.length > 500)
			{
				alert("Comment should not be more than 500 characters.");
				objPopupComments.focus();			
				return; 
			}
			
			if (objPopupComments!=null)
			{
				if(disallowBlank(objPopupComments,"Please enter comments !",true))
				return;
			}

			objDivComments.style.display="none";	
		
			if (objPopupComments_hidden !=null && objPopupComments != null)
				objPopupComments_hidden.value = objPopupComments.value;
				
				
			objfrm.action=strPage + '&WorkflowAction='+StrActionType+'&'+PrimaryKeyName+'_PK='+strUniqueID;
            objfrm.submit();
		}

		function Cancel_OnClick()
		{
			var objDivComments= GetObjectReference("frmCommonPage","DivComments");
			objDivComments.style.display="none"; 			
		
		}


function Submit_Onclick(lngTagID,lngPrimaryKey,strPage,strPrimaryKeyName,strMode)
{
		if(confirm("If you have made some changes to this page, modified data will be lost if you continue.\nPress OK to continue, or Cancel to stay on the current page to save the data.")==true)
		{
			var objDivNOI= GetObjectReference("frmCommonPage","DivNOI");
			objDivNOI.style.width  = '305px';
			objDivNOI.style.height  = '150px';
		    objDivNOI.style.left =20;
		    objDivNOI.style.top =20;
		    objDivNOI.style.position ='absolute';
			objDivNOI.style.display  = '';
		}
}


function Approve_Onclick(lngTagID,lngUniqueID,strPage,strPrimaryKeyName,intIsAppConfigured,Requeststage)
{
	if(intIsAppConfigured == 0)
	{
		alert("Approvers are not configured for '"+Requeststage+"' stage. Please set the Approvers.");
		return;
	}
	var  objTXTNOICheckListFilled =  GetObjectReference("frmCommonPage","TXTNOICheckListFilled");
	
	if(objTXTNOICheckListFilled.value== "0" )
	{
		alert("Checklist is not filled. Please fill the checklist.");
		return;
	}
	DisplayComments('Approval Comments',0,'SYS_APPROVE',lngUniqueID,lngTagID,strPage,strPrimaryKeyName);
	
}
function Reject_Onclick(lngTagID,lngUniqueID,strPage,strPrimaryKeyName,intIsAppConfigured,Requeststage)
{

	if(intIsAppConfigured == 0)
	{
		alert("Approvers are not configured for '"+Requeststage+"' stage. Please set the Approvers.");
		return;
	}
	
	DisplayComments('Rejection Comments',0,'SYS_REJECT',lngUniqueID,lngTagID,strPage,strPrimaryKeyName);
}
// End addition PurvaJ Configurable workflow


function URIEncode(plaintext)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
	
};



//Added By Amol Changle On: 09 Jul 2008
//Function related to Document Structure
function OpenCloseFolder(AttributeID)		
{
	var objChild = GetObjectReference('frmDocumentStructure','divAttributeChild'+AttributeID);
	var img = GetObjectReference('frmDocumentStructure','img'+AttributeID);
	if(objChild.style.display=="")
	{
		objChild.style.display="none";
		img.src="../../Images/TreeNodeImages/folder.gif" ;
	}
	else
	{
		objChild.style.display="";	
		img.src="../../Images/TreeNodeImages/folderOpen.gif" 
	}
}
function ShowPopUp(evt,AttributeID)
{
    evt=evt||window.event; 
    mouseXY= mouseCoords(evt);
    var objDivMNPopup=document.getElementById("divMNPopup");
    objDivMNPopup.style.display="block";
    objDivMNPopup.style.left = mouseXY.x;
	objDivMNPopup.style.top = mouseXY.y;
	
	var objAttributeID=GetObjectReference('','hidAttibuteID');
	if(objAttributeID!=null)
	{
		objAttributeID.value=AttributeID;
	}
}

function mouseCoords(ev)
    {
		if(ev.pageX || ev.pageY){
		return {x:ev.pageX, y:ev.pageY};
		}
		return {
			x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
			y:ev.clientY + document.body.scrollTop  - document.body.clientTop
		};
	}
	
	function mouseOverPopupMenu(evt)
		{
			evt = evt || window.event;
			var source = evt.target || evt.srcElement;
			
			var objTblMN= source;
			while(objTblMN.tagName != "TABLE")
			objTblMN=objTblMN.parentNode;
			
			while(source.tagName != "TR")
			source=source.parentNode;

			for(c=0;c<objTblMN.rows.length;c++){
			objTblMN.rows[c].className="clsTROdd";
			
			}
				source.className="clsTRColumnHeader";
				source.style.cursor="pointer";
		      
		}	
	
		
function ShowPopUp(evt,AttributeID)
{
    evt=evt||window.event; 
    mouseXY= mouseCoords(evt);
    var objDivMNPopup=document.getElementById("divMNPopup");
    objDivMNPopup.style.display="block";
    objDivMNPopup.style.left = mouseXY.x;
	objDivMNPopup.style.top = mouseXY.y-70;
	
	var objAttributeID=GetObjectReference('','hidAttibuteID');
	if(objAttributeID!=null)
	{
		objAttributeID.value=AttributeID;
	}
}
		
	
//End Addition


///Added By Sandesh Daddi , 6 Oct 2009


///Function will copy content from objSrc to objDest
function CopyContentTo(objSrc, objDest) {    
    if (objSrc != null && objDest != null) {
                
        var src = document.getElementById(objSrc);
        var dest = document.getElementById(objDest);

        
        if (src && dest) {
            if (typeof (src) == typeof (dest)) {
                if (!src.selectedValue) {
                    if (!src.disabled && !src.readOnly) {                       
                            dest.value = src.value;
                    }
                }
                else {
                    dest.selectedIndex = src.selectedIndex;
                }
            }
        }
    }
}
