﻿
/*

  /// <summary>
  ///  Summary description for common javascript.
  /// </summary>
  /// Author: Sabir Husain (RSI)
  /// Creation Date: 13 Mar 2008

*/

// Start: Global variable declration
   var ClientID = "ctl01_pmcContainer_cphPresentationContent_";
   
// End: Global variable declration   

// Start: Email validation function  
function EmailValidate(Control)
{
  var emailstr = document.getElementById(Control).value;
  var objTxtBox = document.getElementById(Control);

  if((emailstr=="") || (emailstr.charAt(0) == " ") || (emailstr.indexOf("@") != emailstr.lastIndexOf("@"))
      || (emailstr.indexOf("@")<1)||(emailstr.indexOf(".")<1) || (parseInt(emailstr.lastIndexOf(".")) < parseInt(emailstr.indexOf("@")))
      || (emailstr.lastIndexOf(".")==(emailstr.length-1)) || (emailstr.indexOf(".")==(emailstr.indexOf("@")-1))
      || (emailstr.indexOf("@")==(emailstr.lastIndexOf(".")-1)))
   {
     objTxtBox.focus();
     return false;
   }
   else
   {
     return true;
   }			
}
// End: Email validation function 
 
// Start: To reset specific controls
function clearinputs(sType) 
{
  var value = 0;
  a = document.getElementsByTagName("input");
  for(var i = 0; i < a.length; i++) 
  {
    if(a[i].type==sType) 
    {
      a[i].value = "";
    }
  }
}
// Endt: To reset specific controls

// Start: To validate name and email used in ReferencesList form
function ValidateNameEmail(Message, emailMessage)
{
  
  var text;
  var email;
  var count;
  
  for(count=1; count<=5; count++)
  {
    text = document.getElementById(ClientID+"txtName"+count);
    email = document.getElementById(ClientID+"txtEmail"+count);
    
   if( count <= 1)
   {  
        if(text.value == "" && email.value == "")
        {
          text.focus();
          alert(Message);
          return false;
        }
   }  
    if(text.value != "" && email.value == "")
    {
      email.focus();
      alert(Message);
      return false;
    }
    else if(text.value == "" && email.value != "")
    {
      text.focus();
      alert(Message);
      return false;
    }    
    else if(text.value != "" && email.value != "")
    {
          if(EmailValidate(ClientID+"txtEmail"+count) == false)
          {
           alert(emailMessage);
           return false;
          }
    }   
  }
    if (Page_ClientValidate() == false)
       { return false;}
   return true;  
}
// End: To validate name and email used in ReferencesList form

// Start: Function places seperator "/" automatically to enter date in MM/dd/yyyy format
function Datekeypress(ieChar, mozChar, controlId) 
{
  if(mozChar != null) 
   { // Look for a Mozilla-compatible browser
     if((mozChar >= 48 && mozChar <= 57) || (mozChar>=96 && mozChar <=105) || mozChar == 0 || ieChar == 8
        || mozChar == 13 || mozChar==8 || mozChar==46 || mozChar==37 || 
        mozChar==38 || mozChar==39 || mozChar==40 || mozChar==9 || mozChar==16 || mozChar==191) 
     {
         val = controlId.value; 
         if(val.length==2 || val.length==5)
          controlId.value += "/";
         RetVal = true;
     }    
     else 
     {
       RetVal = false;
     }
  }
  else 
  { // Must be an IE-compatible Browser
   if((ieChar >= 48 && ieChar <= 57) || (ieChar>=96 && ieChar <=105) || ieChar == 13 || ieChar==8 || ieChar==46 || ieChar==37 || 
       ieChar==38 || ieChar==39 || ieChar==40 || ieChar==9 || ieChar==16 || ieChar==191)
   { 
          val = controlId.value; 
         if(val.length==2 || val.length==5)
          controlId.value += "/";    
     RetVal = true;
   }  
   else 
   {
     RetVal = false;
   }
  }
    return RetVal;
}

// Start: Checks the numeric value with different kinds of browser capability
function CheckNumeric(ieChar, mozChar) 
{
  if(mozChar != null) 
   { // Look for a Mozilla-compatible browser
     if((mozChar >= 48 && mozChar <= 57) || (mozChar>=96 && mozChar <=105) || mozChar == 0 || ieChar == 8
        || mozChar == 13 || mozChar==8 || mozChar==46 || mozChar==37 || 
        mozChar==39 || mozChar==9) 
     {   
         RetVal = true;
     }    
     else 
     {
       RetVal = false;
     }
  }
  else 
  { // Must be an IE-compatible Browser
   if((ieChar >= 48 && ieChar <= 57) || (ieChar>=96 && ieChar <=105) || ieChar == 13 || ieChar==8 || ieChar==46 || ieChar==37 || 
       ieChar==39 || ieChar==9)
   {     
     RetVal = true;
   }  
   else 
   {
     RetVal = false;
   }
  }
    return RetVal;
}
// Ens: Checks the numeric value with different kinds of browser capability

function CheckZero(controlId)
{
  if(controlId.value == 0)
    controlId.value = "";
    return false; 
}

// Start: replaces specified character with nothing
function restrict(tbox,chr)
{
  for(var i=0; i<=chr.length; ++i)
      tbox.value=tbox.value.replace(chr[i],'');
}
// End: replaces specified character with nothing

// Start: Checks the decimal numeric value with different kinds of browser capability
function decimalNumeric(ieChar, mozChar)
{
   if(mozChar != null) 
   { // Look for a Mozilla-compatible browser
     if((mozChar >= 48 && mozChar <= 57) || (mozChar>=96 && mozChar <=105) || mozChar == 0 || ieChar == 8
        || mozChar == 13 || mozChar==8 || mozChar==46 || mozChar==37 || 
        mozChar==39 || mozChar==9 || mozChar==190) 
     {   
         RetVal = true;
     }    
     else 
     {
       RetVal = false;
     }
  }
  else 
  { // Must be an IE-compatible Browser
   if((ieChar >= 48 && ieChar <= 57) || (ieChar>=96 && ieChar <=105) || ieChar == 13 || ieChar==8 || ieChar==46 || ieChar==37 || 
       ieChar==39 || ieChar==9 || ieChar==190)
   {     
     RetVal = true;
   }  
   else 
   {
     RetVal = false;
   }
  }
    return RetVal; 
}
// Endt: Checks the decimal numeric value with different kinds of browser capability

// Start: To check calender textbox
function calenderKeypress(control, sValue) 
{
  var val = control.value;
  
  if(val == sValue)
  {
    control.value = ""; 
    return true;
  }        
}
// Endt: To check calender textbox

// Start: Checks the valid date on the blur event
function isValidDate(dateStr, msg1,msg2,msg3,msg4,msg5,msg6,msg7,msg8,msg9) 
{
   // var Message = strMessage.split(";");
	var dateval = dateStr.value;
	if(dateval == "")
	{
		return true ; 
	}
	else
	{                                           
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2,4})/;
		var matchArray = dateval.match(datePat);     // FORMAT OK ?

	if (matchArray == null) 
	{//Check date value
		//alert("Date is not in a valid format. Please enter date in mm/dd/yyyy Format.")
		alert(msg1); 
		dateStr.value="";
		dateStr.focus();
		return false;
	} 

		day = matchArray[3];                         // PARSE DATE INTO VARIABLES
		month = matchArray[1];
		year = matchArray[4];
	if (day < 1 || day > 31) 
	{                                              // CHECK DAY RANGE
		//alert("Day must be between 1 and 31.");  
		alert(msg2); 
		dateStr.value="";
		dateStr.focus();
		return false;
	}
	if (month < 1 || month > 12) 
	{                                              // CHECK MONTH RANGE
		//alert("Month must be between 1 and 12."); 
		alert(msg3); 
		dateStr.value="";
		dateStr.focus();
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) 
	{                                              // CHECK 30 DAYS MONTHS RANGE
		//alert("Month "+month+" doesn't have 31 days!");
		alert(msg4+" "+month+" " +msg5); 
		dateStr.value="";
		dateStr.focus();
		return false
	}
	if(year < 1900 || year > 2050) 
	{
		//alert("Please enter year between 1900 & 2050.");
		alert(msg6); 
		dateStr.value="";
		dateStr.focus();
		return false;
	}
	if (month == 2) 
	{                                              // CHECK FEB,29TH
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) 
		{
		//alert("February ," + year + " doesn't have " + day + " days!");
		alert(msg7+" ," +year+" "+msg8+" "+day+" "+msg9); 
		dateStr.value="";
		dateStr.focus();
		return false;
		}
	}
	  
	return true;                                  // DATE IS VALID
	}
}
// End: Checks the valid date on the blur event

function Check_RTI_booking(sender, args)
{
    var date2 = args.Value;    
    var dtObj = date2.split("/");  
    var dtDD = parseInt(dtObj[0], 10);
    var dtMM = parseInt(dtObj[1], 10) - 1;
    var ddYY = parseInt(dtObj[2], 10);
    objCompare = new Date(ddYY,dtMM,dtDD);
    var HotelCode=document.getElementById('ctl01_pmcContainer_ReservationControl2_slHotel').value;
    HotelCode=HotelCode.substring(0,3);
    var objRTI_ReservDate=new Date(2010,02,09);//booking from 10th March 2010
    if(HotelCode=="RTI" && objCompare <= objRTI_ReservDate)
    {
        args.IsValid = false;
        return;    
    }
    args.IsValid = true;
    return;    
}


// Start: Compare the dates with current date
  function CompareCurrentDate(sender, args)
  {
    var today = new Date();
    objCurrent = new Date(today.getFullYear(), today.getMonth(),today.getDate());
         
    var date2 = args.Value;    
    var dtObj = date2.split("/");  
    var dtDD = parseInt(dtObj[0], 10);
    var dtMM = parseInt(dtObj[1], 10) - 1;
    var ddYY = parseInt(dtObj[2], 10);
    objCompare = new Date(ddYY,dtMM,dtDD);
    
    if(date2 == "" || date2 == null)
    {
      args.IsValid = true;
      return;
    }
      
    if(objCurrent > objCompare)
    {    
     args.IsValid = false;
     return;
    }    
    args.IsValid = true; 
  }  
  // End: Compare the dates with current date
 
   
 function CompareDates(Message)
  {
    var date1 = document.getElementById(ClientID+"ucCalArrivalDate_txtDate").value;
    var date2 = document.getElementById(ClientID+"_ucCalDepartureDate_txtDate").value;
    
    dt1=getDateObject(date1,"/");
    dt2=getDateObject(date2,"/");
    
    if(dt1 > dt2)    
     alert(Message);
  }

// Start: Compare the dates with current date  
function getDateObject(dateString,dateSeperator)
{
	//This function return a date object after accepting 
	//a date string ans dateseparator as arguments
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDate,cMonth,cYear;

	//extract day portion
	curPos=dateString.indexOf(sepChar);
	cMonth=dateString.substring(0,curPos);
	
	//extract month portion				
	endPos=dateString.indexOf(sepChar,curPos+1);			
	cDate=dateString.substring(curPos+1,endPos);

	//extract year portion				
	curPos=endPos;
	endPos=curPos+5;			
	cYear=curValue.substring(curPos+1,endPos);
	
	//Create Date Object
	dtObject=new Date(cYear,cMonth,cDate);	
	return dtObject;
}
// End: Compare the dates
  

//Start: Functions used in template tabs  
 
   var arrSelectedImages;
   var arrUnselectedImages;
   var strImagePath;
          
   function getImages(sPath, SelectedImages, UnselectedImages)
   {
     
     strImagePath = sPath;
     arrSelectedImages = SelectedImages.split(";");
     arrUnselectedImages = UnselectedImages.split(";");     
   }
   
   function dmpFlash(FlashXML,FlashMap,hType)
   {
    var so = new SWFObject(FlashMap, "raffles", "980", "295", "8", "#fff");
    so.addVariable("ie", "1");
    so.addVariable("app", "");
    so.addVariable("xmlPath",FlashXML);
    so.addVariable("hotelType",hType);
    so.addParam("scale", "noscale");
    so.write("flashplan");
   
   }
  function GoNextTab(Index,FlashXML,FlashMap,hType)
  {
    
    var counter = arrSelectedImages.length;
    var trId;
    var imgId;
    var j = 0;
    
    //changed due to change in the Integration Mechanism
    if (hType != "" ) {
         FlashReadyType=typeof(document.getElementById("flash").setHotelType);
         if (FlashReadyType =='function' || FlashReadyType =='object' ){
         document.getElementById('flash').setHotelType(hType);}
      }
    for (var i = 1; i <= counter; i++)
    {
      trId = "";
      imgId = "";
      trId = "ctl01_pmcContainer_cphPresentationContent_trTab" + i;
      imgId = "ctl01_pmcContainer_cphPresentationContent_imgTab" + i;
      document.getElementById(trId).style.display = 'none';
      document.getElementById(imgId).src = strImagePath + arrUnselectedImages[j];
      j++;  
    }
      document.getElementById("ctl01_pmcContainer_cphPresentationContent_trTab"+Index).style.display = "";
      document.getElementById("ctl01_pmcContainer_cphPresentationContent_imgTab"+Index).src = strImagePath + arrSelectedImages[Index-1];
      
      return false;  
  }
  function GoToPreviosPage(Index)
  {
    history.go(-Index)
  }
      
//End: Functions used in template tabs
  
  //Balancing  Left Navigation with Content Height
  //str Stores the ClientID.
  var ClientIDOfMaster;
 function LeftMenuHeightGenerator(str)
 {
    ClientIDOfMaster = str;
    LeftMenuHeightGeneratorMain()
  }
  function LeftMenuHeightGeneratorMain()
    {
        var str;
        str = ClientIDOfMaster;
        var iHeightContentArea; //Storing Height for InnerContent.
        var iRightContentArea ; //Storing Height for RightWidgets.
        var iInnerContentArea;  //Storing Height for tdContentPlaceHolder.
        var tblLeftNav;
        tblLeftNav = document.getElementById('tblInnerContent');
        if ( tblLeftNav == null )
            return;
        iHeightContentArea = document.getElementById('tblInnerContent').offsetHeight;
        iRightContentArea = document.getElementById('tblRightWidgets').offsetHeight;

        iRightContentArea = iRightContentArea +175; // For handling Reservation hidden body part. 

            
        var browser=navigator.appName;
        if (browser == 'Microsoft Internet Explorer')
        {
            iHeightContentArea -= 39;
            iRightContentArea -= 35;
            iInnerContentArea = iRightContentArea -18;
        }
        else
        {
            iInnerContentArea = iRightContentArea -53;
            iRightContentArea -= 35;
            iHeightContentArea -= 36;
        }
    // alert('HeightContentArea ---------> ' +  iHeightContentArea + '   --------- RightContentArea ---------> ' + iRightContentArea  ); 

                      
        if (iHeightContentArea > iRightContentArea)
        {

            document.getElementById(str+'_pmcContainer_DM_leftmenu_Nav').style.height = iHeightContentArea+'px';
        }
        else
        {
            
            document.getElementById(str+'_pmcContainer_DM_leftmenu_Nav').style.height = (iRightContentArea+200) +'px';
            //document.getElementById('DM_left-menu').style.height = iRightContentArea+'px';
            document.getElementById(str+'_pmcContainer_tdContentPlaceHolder').style.height = (iInnerContentArea  +200 )+ 'px';
        }
    }
    
    //Balancing  Left Navigation with Content Height
 
   
function checkEvent(e) 
 {
 if (!e) var e = window.event;
 if (e.target) targ = e.target;
 else if (e.srcElement) targ = e.srcElement;
 showHideToolTip(targ, e, e.type)
}
    
function ModalDialogWindow()
{
   var SHeight, SWidth;
   SHeight = screen.height;
   sWidth = screen.width;
   var boxWidth, boxHeight, boxLeft, boxTop;
   boxWidth = 50;
   boxHeight = 60;
   boxLeft = (screen.width-boxWidth) / 2;
   boxTop = (screen.height-boxHeight) / 2;

   var vReturnValue = window.showModalDialog("LoginInfo.htm", "dialogWidth:" + boxWidth + "px;dialogHeight:" + boxHeight + "px;dialogLeft:" + boxLeft + "px;dialogTop:" + boxTop + "px");

   if (typeof(vReturnValue) != "undefined")
   { 
     
      return true;
   } else 
   {
      window.location = "RequestConfirmation.aspx"
   }
 }
 
 function InvokePop()
 {
        // to handle in IE 7.0           
        if (window.showModalDialog) 
        {       
            retVal = window.showModalDialog("LoginInfo.htm",'Show Popup Window',"dialogHeight:90px,dialogWidth:250px,resizable:yes,center:yes,");
        } 
        // to handle in Firefox
        else 
        {      
            retVal = window.open("LoginInfo.htm",'Show Popup Window','height=90,width=250,resizable=yes,modal=yes');
        }          
}


// Start: Functions used to add seperator automatically when entering date in required format

// Check browser version
var isNav4 = false, isNav5 = false, isIE4 = false
var strSeperator = "/"; 
// If you are using any Java validation on the back side you will want to use the / because 
// Java date validations do not recognize the dash as a valid date separator.
var vDateType = 3; // Global value for type of date format
//                1 = mm/dd/yyyy
//                2 = yyyy/dd/mm  (Unable to do date check at this time)
//                3 = dd/mm/yyyy
var vYearType = 4; //Set to 2 or 4 for number of digits in the year for Netscape
var vYearLength = 2; // Set to 4 if you want to force the user to enter 4 digits for the year before validating.
var err = 0; // Set the error code to a default of zero
if(navigator.appName == "Netscape") {
if (navigator.appVersion < "5") {
isNav4 = true;
isNav5 = false;
}
else
if (navigator.appVersion > "4") {
isNav4 = false;
isNav5 = true;
   }
}
else {
isIE4 = true;
}

function DateFormat(vDateName, vDateValue, e, dateCheck, dateType) 
{
  vDateType = dateType;
// vDateName = object name
// vDateValue = value in the field being checked
// e = event
// dateCheck 
// True  = Verify that the vDateValue is a valid date
// False = Format values being entered into vDateValue only
// vDateType
// 1 = mm/dd/yyyy
// 2 = yyyy/mm/dd
// 3 = dd/mm/yyyy
//Enter a tilde sign for the first number and you can check the variable information.
if (vDateValue == "~") {
//alert("AppVersion = "+navigator.appVersion+" \nNav. 4 Version = "+isNav4+" \nNav. 5 Version = "+isNav5+" \nIE Version = "+isIE4+" \nYear Type = "+vYearType+" \nDate Type = "+vDateType+" \nSeparator = "+strSeperator);
vDateName.value = "";
vDateName.focus();
return true;
}
var whichCode = (window.Event) ? e.which : e.keyCode;
// Check to see if a seperator is already present.
// bypass the date if a seperator is present and the length greater than 8
if (vDateValue.length > 8 && isNav4) {
if ((vDateValue.indexOf("-") >= 1) || (vDateValue.indexOf("/") >= 1))
return true;
}
//Eliminate all the ASCII codes that are not valid
var alphaCheck = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/-";
if (alphaCheck.indexOf(vDateValue) >= 1) {
if (isNav4) {
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
else {
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
   }
}
if (whichCode == 8) //Ignore the Netscape value for backspace. IE has no value
return false;
else {
//Create numeric string values for 0123456789/
//The codes provided include both keyboard and keypad values
var strCheck = '47,48,49,50,51,52,53,54,55,56,57,58,59,95,96,97,98,99,100,101,102,103,104,105';
if (strCheck.indexOf(whichCode) != -1) 
{
if (isNav4) 
{
if (((vDateValue.length < 6 && dateCheck) || (vDateValue.length == 7 && dateCheck)) && (vDateValue.length >=1)) {
//alert("Invalid Date\nPlease Re-Enter");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
if (vDateValue.length == 6 && dateCheck) {
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
//Turn a two digit year into a 4 digit year
if (mYear.length == 2 && vYearType == 4) {
var mToday = new Date();
//If the year is greater than 30 years from now use 19, otherwise use 20
var checkYear = mToday.getFullYear() + 30; 
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
}
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (!dateValid(vDateValueCheck)) {
//alert("Invalid Date\nPlease Re-Enter");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
return true;
}
else {
// Reformat the date for validation and set date type to a 1
if (vDateValue.length >= 8  && dateCheck) {
if (vDateType == 1) // mmddyyyy
{
var mDay = vDateName.value.substr(2,2);
var mMonth = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
}
if (vDateType == 2) // yyyymmdd
{
var mYear = vDateName.value.substr(0,4)
var mMonth = vDateName.value.substr(4,2);
var mDay = vDateName.value.substr(6,2);
vDateName.value = mYear+strSeperator+mMonth+strSeperator+mDay;
}
if (vDateType == 3) // ddmmyyyy
{
var mMonth = vDateName.value.substr(2,2);
var mDay = vDateName.value.substr(0,2);
var mYear = vDateName.value.substr(4,4)
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
}
//Create a temporary variable for storing the DateType and change
//the DateType to a 1 for validation.
var vDateTypeTemp = vDateType;
vDateType = 1;
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (!dateValid(vDateValueCheck)) {
//alert("Invalid Date\nPlease Re-Enter");
vDateType = vDateTypeTemp;
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
vDateType = vDateTypeTemp;
return true;
}
else {
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
//alert("Invalid Date\nPlease Re-Enter");
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
         }
      }
   }
}
else {
// Non isNav Check
if (((vDateValue.length < 8 && dateCheck) || (vDateValue.length == 9 && dateCheck)) && (vDateValue.length >=1)) {
//alert("Invalid Date\nPlease Re-Enter");
vDateName.value = "";
vDateName.focus();
return true;
}
// Reformat date to format that can be validated. mm/dd/yyyy
if (vDateValue.length >= 8 && dateCheck) {
// Additional date formats can be entered here and parsed out to
// a valid date format that the validation routine will recognize.
if (vDateType == 1) // mm/dd/yyyy
{
var mMonth = vDateName.value.substr(0,2);
var mDay = vDateName.value.substr(3,2);
var mYear = vDateName.value.substr(6,4)
}
if (vDateType == 2) // yyyy/mm/dd
{
var mYear = vDateName.value.substr(0,4)
var mMonth = vDateName.value.substr(5,2);
var mDay = vDateName.value.substr(8,2);
}
if (vDateType == 3) // dd/mm/yyyy
{
var mDay = vDateName.value.substr(0,2);
var mMonth = vDateName.value.substr(3,2);
var mYear = vDateName.value.substr(6,4)
}
if (vYearLength == 4) {
if (mYear.length < 4) {
//alert("Invalid Date\nPlease Re-Enter");
vDateName.value = "";
vDateName.focus();
return true;
   }
}
// Create temp. variable for storing the current vDateType
var vDateTypeTemp = vDateType;
// Change vDateType to a 1 for standard date format for validation
// Type will be changed back when validation is completed.
vDateType = 1;
// Store reformatted date to new variable for validation.
var vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
if (mYear.length == 2 && vYearType == 4 && dateCheck) {
//Turn a two digit year into a 4 digit year
var mToday = new Date();
//If the year is greater than 30 years from now use 19, otherwise use 20
var checkYear = mToday.getFullYear() + 30; 
var mCheckYear = '20' + mYear;
if (mCheckYear >= checkYear)
mYear = '19' + mYear;
else
mYear = '20' + mYear;
vDateValueCheck = mMonth+strSeperator+mDay+strSeperator+mYear;
// Store the new value back to the field.  This function will
// not work with date type of 2 since the year is entered first.
if (vDateTypeTemp == 1) // mm/dd/yyyy
vDateName.value = mMonth+strSeperator+mDay+strSeperator+mYear;
if (vDateTypeTemp == 3) // dd/mm/yyyy
vDateName.value = mDay+strSeperator+mMonth+strSeperator+mYear;
} 
if (!dateValid(vDateValueCheck)) {
//alert("Invalid Date\nPlease Re-Enter");
vDateType = vDateTypeTemp;
vDateName.value = "";
vDateName.focus();
return true;
}
vDateType = vDateTypeTemp;
return true;
}
else {
if (vDateType == 1) {
if (vDateValue.length == 2) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 5) {
vDateName.value = vDateValue+strSeperator;
   }
}
if (vDateType == 2) {
if (vDateValue.length == 4) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 7) {
vDateName.value = vDateValue+strSeperator;
   }
} 
if (vDateType == 3) {
if (vDateValue.length == 2) {
vDateName.value = vDateValue+strSeperator;
}
if (vDateValue.length == 5) {
vDateName.value = vDateValue+strSeperator;
   }
}
return true;
   }
}
if (vDateValue.length == 10&& dateCheck) {
if (!dateValid(vDateName)) {
// Un-comment the next line of code for debugging the dateValid() function error messages
//alert(err);  
//alert("Invalid Date\nPlease Re-Enter");
vDateName.focus();
vDateName.select();
   }
}
return false;
}
else {
// If the value is not in the string return the string minus the last
// key entered.
if (isNav4) {
vDateName.value = "";
vDateName.focus();
vDateName.select();
return false;
}
else
{
vDateName.value = vDateName.value.substr(0, (vDateValue.length-1));
return false;
         }
      }
   }
}
/* Section Added By Bikram as on 26th May 2008 to check blank in Secure Image Control Starts */
function CheckForBlank(ErrorMsg)
{
    
    if(document.getElementById('ctl01_pmcContainer_cphPresentationContent_ctrlSecureImage_txtSecureImage').value=='')
    {
    alert(ErrorMsg);
    return false;
    }
    else
    {
    return true;
    }
}
/* Section Secure Image Control Ended */
// End: Functions used to add seperator automatically when entering date in required format