// JScript File
var globalcurrentdate
var globalvalidflg
var boxname
var boxnameday						//This variable holds the value of day entered by the user
var boxnamemonth					//This variable holds the value of month entered by the user
var boxnameyear						//This variable holds the value of year entered by the user
var curdatetime						//This variable holds the value of date passed using Showdate Function
var flgshowall						//This variable controls the enable/disable of dates prior to first date in the calender
var getcyr
var cal
var mainDay
var img
flgshowall=false
var monthlabel = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var monthOrglabel = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var daysinmonth = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
//--------------

function Browser() 
{
    //debugger
    var ua, s, i;
    this.isIE    = false;
    this.isNS    = false;
    this.version = null;
    ua = navigator.userAgent;

    s = "MSIE";
    if ((i = ua.indexOf(s)) >= 0) 
    {
        this.isIE = true;
        this.version = parseFloat(ua.substr(i + s.length));
        return;
    }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragObj.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragObj.elNode = window.event.srcElement;
    if (browser.isNS)
      dragObj.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragObj.elNode.nodeType == 3)
      dragObj.elNode = dragObj.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and element.

  dragObj.cursorStartX = x;
  dragObj.cursorStartY = y;
  dragObj.elStartLeft  = parseInt(dragObj.elNode.style.left, 10);
  dragObj.elStartTop   = parseInt(dragObj.elNode.style.top,  10);

  if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;
  if (isNaN(dragObj.elStartTop))  dragObj.elStartTop  = 0;

  // Update element's z-index.

  dragObj.elNode.style.zIndex = ++dragObj.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragGo);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragGo,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragGo(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  dragObj.elNode.style.top  = (dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";
  document.getElementById('Iframe1').style.left=(dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
  document.getElementById('Iframe1').style.top=(dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";
 
	//rr.style.left=(dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
	//rr.style.top=(dragObj.elStartTop  + y - dragObj.cursorStartY) + "px";
  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragGo);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragGo,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }
}

//--------------
function jsTrim(strExp)
{

	var re=/ /g;
	strExp=strExp.replace(re,'');
	return strExp;
}
function Default() 
{
    //debugger
	cmonth = curdatetime.getMonth();
	if ((navigator.userAgent.indexOf("Firefox") > -1)||(navigator.userAgent.indexOf("Safari") > -1))
	{
	  cyear = curdatetime.getYear();
	  cyear=cyear+1900
	}
	else if((navigator.appVersion.indexOf("MSIE 9.0") > -1))
	{
	   cyear = curdatetime.getFullYear();
	}
	else
	{
	 cyear = curdatetime.getYear();
	}
	Today = curdatetime.getDate();
	cyear=parseInt(cyear)
	var flag="false";

    var mnth=document.getElementById('month');
    mnth.selectedIndex= cmonth;
    document.getElementById('year').value=cyear
		
	if (flag=="false")
	{
		smonth = cmonth;
		syear = cyear;
		createcalendar(cyear,cmonth);
	}
	
}



function Header1(Year, Month) 
{
    if (Month == 1) 
    {
        if ((Year % 400 == 0) || ((Year % 4 == 0) && (Year % 100 != 0))) 
        {
            daysinmonth[1] = 29;
        }
        else
        {
            daysinmonth[1] = 28;
        }
    }
    var Header_String = monthlabel[Month] + ' ' + Year;
    return Header_String;
}

function capturedate1(cd)
{
    //debugger
    var _cd = cd;
	if(cd<=9) cd="0"+cd;
	sd=cd+ " " +monthOrglabel[smonth] + " " + syear;
	if (globalvalidflg=="true")
	{
		if (((Date.parse(sd)-Date.parse(globalcurrentdate))/(3600*1000*24))>361)	
		//if (syear >= globalcurrentdate.getYear())
		{
		    alert("TThe date entered is greater than one year from today\\'s date.");
		    				boxnameday.value="";
            				boxnamemonth.value="";
            				boxnameyear.value="";
            				//boxnameday.focus();
            				closediv();
            				return false;
            //			if (confirm("TThe date entered is greater than one year from today\\'s date."))
            //				{closediv();}
            //			else
            //				{
            //					boxnameday.value="";
            //					boxnamemonth.value="";
            //					boxnameyear.value="";
            //					//boxnameday.focus();
            //					return false;
            //				}
		}
	}
	boxnameday.value=cd
	boxnamemonth.value=monthlabel[smonth]
	boxnameyear.value=syear
	var setFromDt ;
	var setToDt;
	var setFromDt;
	var setToDt;
	var setToModDom;
	
	var checkIn;
	var checkOut;
	var Dep_pkg;
	
	var modify,modifyInt;
	var modifyHotel;
	var flightmulti;
	
	//Variable added By Vikash for MultiCity Purpose
	var modifymc,setFromDt1,setFromDt2,setFromDt3,setFromDt4;
	//End Here

if(document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_hdnModifySearch")!=null)
{
modifymc=document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_hdnModifySearch").value;
}	
	
if(document.getElementById("ctl00_contentMain_ModifyFlightSearch1_hndModify")!=null)
{
modify=document.getElementById("ctl00_contentMain_ModifyFlightSearch1_hndModify").value;

}
if(document.getElementById("ctl00_contentMain_Modify_hndModifyHotel")!=null)
{
modifyHotel=document.getElementById("ctl00_contentMain_Modify_hndModifyHotel").value;

}
 if(document.getElementById("ctl00_contentMain_ModifyIntFlightSearch1_hndModifyInt")!=null)
	{
	modifyInt=document.getElementById("ctl00_contentMain_ModifyIntFlightSearch1_hndModifyInt").value;
	}

//Setting Control in It for MultiCity;
if(modifymc=="true")
{
    setFromDt1 = document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_txtFLDepDate1");
    setFromDt2 = document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_txtFLDepDate2");
    setFromDt3 = document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_txtFLDepDate3");
    setFromDt4 = document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_txtFLDepDate4");
    
    nextFocus2 = document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_FLDepartCity2");
    nextFocus3 = document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_FLDepartCity3");
    nextFocus4 = document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_FLDepartCity4");
    
}
else
{
    setFromDt1 = document.getElementById("ctl00_contentMain_ctl00_txtFLDepDate1");
    setFromDt2 = document.getElementById("ctl00_contentMain_ctl00_txtFLDepDate2");
    setFromDt3 = document.getElementById("ctl00_contentMain_ctl00_txtFLDepDate3");
    setFromDt4 = document.getElementById("ctl00_contentMain_ctl00_txtFLDepDate4");

    nextFocus2 = document.getElementById("ctl00_contentMain_ctl00_FLDepartCity2");
    nextFocus3 = document.getElementById("ctl00_contentMain_ctl00_FLDepartCity3");
    nextFocus4 = document.getElementById("ctl00_contentMain_ctl00_FLDepartCity4");

}
//End Here it would change but depends;


if(modifyInt=="true")
{
	setFromDtInt = document.getElementById("ctl00_contentMain_ModifyIntFlightSearch1_txtFLDepDate")
	setToDtInt=document.getElementById("ctl00_contentMain_ModifyIntFlightSearch1_txtFLRetDate")
	
	
}
else
{

if(modify=="true")
{
	setFromDtDom=document.getElementById("ctl00_contentMain_ModifyFlightSearch1_txtFLDDepDate")
	setToDtDom=document.getElementById("ctl00_contentMain_ModifyFlightSearch1_txtFLDRetDate")	
	//setToModDom=document.getElementById("ctl00_contentMain_ModifyFlightSearch1_txtFLDRetDate")
}

else
{	
if(modifyHotel=="true")
{
    setFromDt = document.getElementById("ctl00_contentMain_Modify_txtHTCheckIn")
	setToDt=document.getElementById("ctl00_contentMain_Modify_txtHTCheckOut")
}
else

{
    if(document.getElementById("ctl00_contentMain_ModifySightSeeing_txtFLDepDate")!=null)
    { 
        setFromDtInt = document.getElementById("ctl00_contentMain_ModifySightSeeing_txtFLDepDate")
    }
    else if(document.getElementById("ctl00_contentMain_ModifyTransfer_txtFLDepDate")!=null)
    {
        setFromDtInt = document.getElementById("ctl00_contentMain_ModifyTransfer_txtFLDepDate")
    }
    else
    {
	setFromDtInt = document.getElementById("ctl00_contentMain_ctl00_txtFLDepDate")
    }
	setToDtInt=document.getElementById("ctl00_contentMain_ctl00_txtFLRetDate")
	setFromDtDom=document.getElementById("ctl00_contentMain_ctl00_txtFLDDepDate")
	setToDtDom=document.getElementById("ctl00_contentMain_ctl00_txtFLDRetDate")
	
	
	checkIn=document.getElementById("ctl00_contentMain_ctl00_txtHTCheckIn")
	checkOut=document.getElementById("ctl00_contentMain_ctl00_txtHTCheckOut")
	Dep_pkg=document.getElementById("ctl00_contentMain_ctl00_txtCRPickupDate")
	Client_enq=document.getElementById("ctl00_contentMain_DeptDate")
	
	
	////this code is only for cros sell because control value has been changed
    // Modify By Vikash if any problem by this code please contact me. 
    if(setFromDtInt==null)
    setFromDtInt =document.getElementById("ctl00_contentMain_FlightModify_txtFLDepDate");
    if(setToDtInt==null)
    setToDtInt=document.getElementById("ctl00_contentMain_FlightModify_txtFLRetDate");
    if(setFromDtDom==null)
	setFromDtDom=document.getElementById("ctl00_contentMain_FlightModify_txtFLDDepDate");
    if(setToDtDom==null)
	setToDtDom=document.getElementById("ctl00_contentMain_FlightModify_txtFLDRetDate");
    //End of Cross sel modify code
	
	
	}
}

}
  	//setFromDt.value=cd+monthlabel[smonth]+syear
  	
  	if(img=='t')
  	{
  	    setFromDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
  	
  	}
	if(img=='x')
	{
	setFromDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	var frmDtInt=cd+"-"+monthlabel[smonth]+"-"+syear
	var dt_arr=frmDtInt.split('-');
	//var dt_mon=change(dt_arr[1])
	frmDtInt=dt_arr[0]+" "+dt_arr[1]+" "+dt_arr[2];
	
	var toDtInt= setToDtInt.value
	var dt_arr1=toDtInt.split('-');
	toDtInt=dt_arr1[0]+" "+dt_arr1[1]+" "+dt_arr1[2];
	
		if(Date.parse(frmDtInt)>Date.parse(toDtInt))
		{
		setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
		}
	//setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	if (setFromDtInt.value>setToDtInt.value)
				{
				setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
				}
				
	}
	else if(img=="p")
	{
	Dep_pkg.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	}
	
	else if(img=="y")
	{
	setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
			if (setFromDtInt.value>setToDtInt.value)
				{
				setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
				}
		
		}
	
	else if(img=='H')
	{
	checkIn.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	var frmDtDom=cd+"-"+monthOrglabel[smonth]+"-"+syear
	var dt_arr=frmDtDom.split('-');
	//var dt_mon=change(dt_arr[1])
	frmDtDom=dt_arr[0]+" "+dt_arr[1]+" "+dt_arr[2];
	
	var toDtDom= checkOut.value
	var dt_arr1=toDtDom.split('-');
	toDtDom=dt_arr1[0]+" "+getmonthName(dt_arr1[1])+" "+dt_arr1[2];
        var _date;
        var _localstr;
		if(Date.parse(frmDtDom)>=Date.parse(toDtDom))
		{
		    //checkOut.value=cd+"-"+monthlabel[smonth]+"-"+syear
		    //This is the code for check out date should be one date more as check in date.
		    _localstr = (parseInt(smonth) + 1) + "/" + (parseInt(_cd) + 1) +"/"+syear+ " 12:00:00 AM";
		    _date = new Date(_localstr);
		    if(_date != "This is not a valid Date, Re-enter the date")
		    {
		        var dateDay;
		        var dateMonth;
		        var dateyear;
        		//debugger;
		        dateMonth = _date.getMonth();
		        dateyear = _date.getFullYear();
		        dateDay = _date.getDate();
        		
		        if(dateDay<=9) dateDay="0"+parseInt(dateDay);    
    		    		
		        checkOut.value=dateDay+"-"+monthlabel[dateMonth]+"-"+dateyear
		    }
		    else
		    {
		        var dateDay;
		        var dateMonth;
		        var dateyear;
        		
        		if (smonth == 11)
        		{
		            dateMonth = 0;
		            dateyear = syear + 1;
		             dateDay = 1;
		        }
		        else
		        {
		            dateMonth = smonth +1;
		            dateyear = syear;
		             dateDay = 1;
		        }
		       
        		
		        if(dateDay<=9) dateDay="0"+parseInt(dateDay);    
    		    		
		        checkOut.value=dateDay+"-"+monthlabel[dateMonth]+"-"+dateyear
		    }
		}
	}
	
	else if(img=='T')
	{
	    var str = cd+"-"+monthlabel[smonth]+"-"+syear;
	    if (checkIn.value == str)
	    {
	        closediv()
    	    alert('Check out date should not be same as check in date.');
	    }
	    else
	    {
	        checkOut.value=cd+"-"+monthlabel[smonth]+"-"+syear
	    }
	
	}
	
	else if(img=='o')
	{
	setFromDt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	var frmDtDom=cd+"-"+monthOrglabel[smonth]+"-"+syear
	var dt_arr=frmDtDom.split('-');
	//var dt_mon=change(dt_arr[1])
	frmDtDom=dt_arr[0]+" "+dt_arr[1]+" "+dt_arr[2];
	
	var toDtDom= setToDt.value
	var dt_arr1=toDtDom.split('-');
	toDtDom=dt_arr1[0]+" "+getmonthName(dt_arr1[1])+" "+dt_arr1[2];
	
		if(Date.parse(frmDtDom)>=Date.parse(toDtDom))
		{
		    //setToDt.value=cd+"-"+monthlabel[smonth]+"-"+syear
		    //This is the code for check out date should be one date more as check in date.
		    _localstr = (parseInt(smonth) + 1) + "/" + (parseInt(_cd) + 1) +"/"+syear+ " 12:00:00 AM";
		    _date = new Date(_localstr);
		     if(_date != "This is not a valid Date, Re-enter the date")
		    {
		        var dateDay;
		        var dateMonth;
		        var dateyear;
        		
		        dateMonth = _date.getMonth();
		        dateyear = syear;
		        dateDay = _date.getDate();
        		
		        if(dateDay<=9) dateDay="0"+parseInt(dateDay);    
    		    		
		        setToDt.value=dateDay+"-"+monthlabel[dateMonth]+"-"+dateyear
		    }
		    else
		    {
		        var dateDay;
		        var dateMonth;
		        var dateyear;
        		
		  	    if (smonth == 11)
        		    {
		                dateMonth = 0;
		                dateyear = syear + 1;
		                 dateDay = 1;
		            }
		            else
		            {
		                dateMonth = smonth +1;
		                dateyear = syear;
		                 dateDay = 1;
		            }
    		       
        		
		        if(parseInt(dateDay)<=9) dateDay="0"+parseInt(dateDay);    		
		        setToDt.value=dateDay+"-"+monthlabel[dateMonth]+"-"+dateyear
		    }
		    
		}
	}
	else if(img=='e')
	{
	//setToDt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	 var str = cd+"-"+monthlabel[smonth]+"-"+syear;
	    if (setFromDt.value == str)
	    {
	        closediv()
    	    alert('Check out date should not be same as check in date.');
	    }
	    else
	    {
	        setToDt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	    }
	}
	
	else if(img=='a')
	{

	setFromDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
	//setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	
	var frmDtDom=cd+"-"+monthlabel[smonth]+"-"+syear
	var dt_arr=frmDtDom.split('-');
	//var dt_mon=change(dt_arr[1])
	frmDtDom=dt_arr[0]+" "+getmonthName(dt_arr[1])+" "+dt_arr[2];
	
	var toDtDom= setToDtDom.value
	var dt_arr1=toDtDom.split('-');
	toDtDom=dt_arr1[0]+" "+getmonthName(dt_arr1[1])+" "+dt_arr1[2];
	
		if(Date.parse(frmDtDom)>Date.parse(toDtDom))
		{
		setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
		}
	
	
	
	
	
//			if (setFromDtDom.value>setToDtDom.value)
//				{
//				setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
//				}
	}
	else if(img=='m')
	{
	setFromDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
	//setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	var frmDtDom=cd+"-"+monthlabel[smonth]+"-"+syear
	var dt_arr=frmDtDom.split('-');
	//var dt_mon=change(dt_arr[1])
	frmDtDom=dt_arr[0]+" "+getmonthName(dt_arr[1])+" "+dt_arr[2];
	
	var toDtDom= setToDtDom.value
	var dt_arr1=toDtDom.split('-');
	toDtDom=dt_arr1[0]+" "+getmonthName(dt_arr1[1])+" "+dt_arr1[2];
	
		if(Date.parse(frmDtDom)>Date.parse(toDtDom))
		{
		setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
		}
	
	
	
	
	
	
	
//	if (setFromDtDom.value>setToDtDom.value)
//				{
//				setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
//				}
	}
	else if(img=='r')
	{
	setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
		if (setFromDtDom.value>setToDtDom.value)
			{
			setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
			}
		}
	else if(img=='g')
	{
	setFromDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	//setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	
	var frmDtInt=cd+"-"+monthlabel[smonth]+"-"+syear
	var dt_arr=frmDtInt.split('-');
	//var dt_mon=change(dt_arr[1])
	frmDtInt=dt_arr[0]+" "+getmonthName(dt_arr[1])+" "+dt_arr[2];
	
	var toDtInt= setToDtInt.value
	var dt_arr1=toDtInt.split('-');
	toDtInt=dt_arr1[0]+" "+getmonthName(dt_arr1[1])+" "+dt_arr1[2];
	
		if(Date.parse(frmDtInt)>Date.parse(toDtInt))
		{
		setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
		}
	
	
	
//	if (setFromDtInt.value>setToDtInt.value)
//				{
//				setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
//				}
	}
	else if(img=='k')
	{
	setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
	if (setFromDtInt.value>setToDtInt.value)
			{
			setToDtInt.value=cd+"-"+monthlabel[smonth]+"-"+syear
			}
	}
	else if(img=='z')
	{
	Client_enq.value=cd+"-"+monthlabel[smonth]+"-"+syear
	}
	
	else if(img=='l')
	{
	//setToDtDom=document.getElementById("ctl00_contentMain_ModifyFlightSearch1_txtFLDRetDate")	
	setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
	
	if (setFromDtDom.value>setToDtDom.value)
			{
			setToDtDom.value=cd+"-"+monthlabel[smonth]+"-"+syear
			}
	}
	
//	if(img=="x")
//	{
//	
//	//setToDt=cd+monthlabel[smonth]+syear
//		//boxnameday.focus();
//		//mainDay.focus();
//		
//	}

//Changes Done By Vikash for MultiCity Purpose
//
    else if(img=='mu1')
    {
        setFromDt1.value=cd+"-"+monthlabel[smonth]+"-"+syear
        nextFocus2.focus();
    }
    else if(img=='mu2')
    {
        setFromDt2.value=cd+"-"+monthlabel[smonth]+"-"+syear
        nextFocus3.focus();
//        var now = new Date();
//        var lastUpdate = new Date(cd+"/"+ (smonth+1) +"/"+syear);
//        var one_day=1000*60*60*24;
//        var days = Math.ceil((lastUpdate-now)/(one_day));
//        //var days = Math.ceil((lastUpdate.getTime()-now.getTime())/(one_day));
//        alert(now.getDate());
//        alert(days);
    }
    else if(img=='mu3')
    {
        setFromDt3.value=cd+"-"+monthlabel[smonth]+"-"+syear
        //nextFocus4.focus();
    }
    else if(img=='mu4')
    {
        setFromDt4.value=cd+"-"+monthlabel[smonth]+"-"+syear
    } //Changes done by Vikash
//	else
//	{
//	setToDt.value=cd+"-"+monthlabel[smonth]+"-"+syear
//	}	
	closediv()
}




function closediv()
{

//document.all.Iframe1.style.visibility="hidden";
document.getElementById('Iframe1').style.visibility="hidden";

	document.getElementById('maindiv1').style.visibility="hidden";
	document.getElementById('NavBar1').style.visibility="hidden";
	//document.getElementById('Calendar1').style.visibility="hidden";
	document.getElementById('Calendar1').style.visibility="hidden";
	//self.close(); 
}

function createcalendar(Year, Month) 
{
//    debugger;
	getcyr=Year
	if(flgshowall=="true")
	{
		createcalendar1(Year, Month) 
	}
	else if(flgshowall=="all")
	{
		
		createcalendar2(Year, Month) 
	}
	else if(flgshowall=="false")
	{
		
		createcalendar3(Year, Month) 
	}
}
function createcalendar2(Year, Month) 
{
    var First_Date = new Date(Year, Month, 1);
    var Heading = Header1(Year, Month);
    if(CalenderFormat==1)
    {	
        var First_Day = First_Date.getDay() ;
    }
    else
    {
        var First_Day = First_Date.getDay()+1 ; 
    }		 	
   
    if(First_Day==0)
    {
		First_Day=7
    }
   if (((daysinmonth[Month] == 31) && (First_Day >= 6)) ||
       ((daysinmonth[Month] == 30) && (First_Day == 7))) 
   {
      var Rows = 6;
   }
   else if ((daysinmonth[Month] == 28) && (First_Day == 1)) 
   {
      var Rows = 4;
   }
   else 
   {
      var Rows = 5;
   }
   var HTML_String = '<center><table border="0" align=center><tr><td valign="top"><table BORDER="0" CELLSPACING=0 cellpadding=1 FRAME="box">';
   HTML_String += '<tr><td colspan=7 bgcolor="#000000" BORDERCOLOR="#999999" ALIGN="CENTER"><font face="verdana" size=1 >' + Heading + '</font></td></tr>';
   
   if(CalenderFormat==1)
   {	
   HTML_String += '<tr><td ALIGN="CENTER" bgcolor="#000000" BORDERCOLOR="#999999"><font face="verdana" size=1>Mo</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Tu</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>We</font></td>';
   HTML_String += '<td ALIGN="CENTER" bgcolor="#000000" BORDERCOLOR="#999999"><font face="verdana" size=1>Th</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Fr</b></font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Sa</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Su</font></td></tr>';
   }
   else
   {
   HTML_String += '<tr><td ALIGN="CENTER" bgcolor="#000000" BORDERCOLOR="#999999"><font face="verdana" size=1>Su</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Mo</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Tu</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>We</font></td>';
   HTML_String += '<td ALIGN="CENTER" bgcolor="#000000" BORDERCOLOR="#999999"><font face="verdana" size=1>Th</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Fr</b></font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Sa</font></td></tr>';
   }
   var Day_Counter = 1;
   var Loop_Counter = 1;
   
   for (var j = 1; j <= Rows; j++) 
     {
      HTML_String += '<tr ALIGN="left" VALIGN="top">';
      for (var i = 1; i < 8; i++) {
         if ((Loop_Counter >= First_Day) && (Day_Counter <=daysinmonth[Month])) 
           {
            if ((Day_Counter == Today) && (Year == cyear) && (Month == cmonth)) 
             {
               HTML_String += '<td  align="center"><strong><font color="black"><Input Type="Button" style="Width:20;Height:20px;border: 0 solid #000000;" name="+ Day_Counter + "  Value="'+ Day_Counter +' " Style=color:red onClick="capturedate1('+Day_Counter+')"></font></strong></td>';
             }
             else 
             {
		        HTML_String += '<td  align="center"><strong><font color="black"><Input Type="Button" style="Width:20;Height:20px;border: 0 solid #000000;" name="+ Day_Counter + "  Value="'+ Day_Counter +' " Style=color:black onClick="capturedate1('+Day_Counter+')"></font></strong></td>';
             }
            Day_Counter++;    
          }
         else 
          {
            HTML_String += '<td BORDERCOLOR="cccccc" align="center"></td>';
          }
         Loop_Counter++;
      }
      HTML_String += '</tr>';
   }
  
   HTML_String += '</table></td></tr></Table> <Input Type="Hidden"  Name="seldate" size="9">'
   document.all.Calendar1.innerHTML = HTML_String;
}  
//function changecolor(id, color)
//{

//element = document.getElementById(id); 
//event.cancelBubble = true; 
//oldcolor = element.currentStyle.background; 
//element.style.background = color; 
//} 
 	
function createcalendar1(Year, Month) 
{   
    //debugger;
    var First_Date = new Date(Year, Month, 1);
    var Heading = Header1(Year, Month);
    if((img=='m')||(img=='l'))
    {
       var dtMDom=document.getElementById('ctl00_contentMain_ModifyFlightSearch1_spnHead');
       dtMDom.value=Heading;
    }
    else if((img=='g')||(img=='k'))
    {
       var dtMInt=document.getElementById('ctl00_contentMain_ModifyIntFlightSearch1_spnHead');
       dtMInt.value=Heading;
    }
    else if((img=='o')||(img=='e'))
    {
       var DtModHot=document.getElementById('ctl00_contentMain_Modify_spnHead');
       DtModHot.value=Heading;
    }
    else if(img=='z')
    {
       var dtClient=document.getElementById('ctl00_contentMain_spnHead');
       dtClient.value=Heading;
    }
    else
    {
        var dt;
        try
        {    
            if(document.getElementById("ctl00_contentMain_ModifySightSeeing_spnHead")!=null)
            {
                dt=document.getElementById("ctl00_contentMain_ModifySightSeeing_spnHead");
            }
            else if(document.getElementById("ctl00_contentMain_ModifyTransfer_spnHead")!=null)
            {
                dt=document.getElementById("ctl00_contentMain_ModifyTransfer_spnHead");
            }
            else
            {
                dt=document.getElementById("ctl00_contentMain_ctl00_spnHead");
            }
            dt.value=Heading;
       }
       catch(e)
       {
           dt=document.getElementById("ctl00_contentMain_ModifyMultiCityFlightSearch1_spnHead"); 
           dt.value=Heading;
       }
   }
   
   if(CalenderFormat==1)
   {	
        var First_Day = First_Date.getDay() ;
   }
   else
   {
        var First_Day = First_Date.getDay()+1 ; 
   }	
   
   if(First_Day==0)
   {
		First_Day=7
   }
   if (((daysinmonth[Month] == 31) && (First_Day >= 6)) ||
       ((daysinmonth[Month] == 30) && (First_Day == 7))) 
   {
      var Rows = 6;
   }
   else if ((daysinmonth[Month] == 28) && (First_Day == 1)) 
   {
      var Rows = 4;
   }
   else 
   {
      var Rows = 5;
   }
   
    var HTML_String = '<center><table border="0" align=center class="CalTable"><tr><td valign="top" class="Minor"><table BORDER="0" CELLSPACING="0" cellpadding="1" FRAME="box" >';
    if(CalenderFormat==1)
    {
       HTML_String += '<tr><td ALIGN="CENTER" class="daysDisplay">Mo</td><td ALIGN="CENTER" class="daysDisplay"><Tu</td><td ALIGN="CENTER"  class="daysDisplay">We</td>';
       HTML_String += '<td ALIGN="CENTER" class="daysDisplay"> Th</td><td ALIGN="CENTER"  class="daysDisplay">Fr</b></td><td ALIGN="CENTER"  class="daysDisplay">Sa</td><td ALIGN="CENTER" class="daysDisplay" Style="color:red;"> <b>Su</b></td></tr>';
    }
    else
    {
       HTML_String += '<tr><td ALIGN="CENTER" class="daysDisplay" style="color:red;">Su</td><td ALIGN="CENTER"  class="daysDisplay">Mo</td><td ALIGN="CENTER"  class="daysDisplay">Tu</td><td ALIGN="CENTER"  class="daysDisplay">We</td>';
       HTML_String += '<td ALIGN="CENTER"  class="daysDisplay">Th</td><td ALIGN="CENTER"  class="daysDisplay">Fr</td><td ALIGN="CENTER"  class="daysDisplay">Sa</td></tr>';
    }
    var Day_Counter = 1;
    var Loop_Counter = 1;
    for (var j = 1; j <= Rows; j++) 
    {
      for (var i = 1; i < 8; i++) 
      {
	    if ((Loop_Counter >= First_Day) && (Day_Counter <=daysinmonth[Month])) 
        {
			if((Day_Counter >= Today) && (Year >= cyear) && (Month >= cmonth)) 	   
			{
				if ((Day_Counter == Today) && (Year == cyear) && (Month == cmonth)) 
				 {
				   HTML_String += '<td class="cal" style="background-color:black;" align="center"><strong><font color="#6699ff"><Input Type="Button"  class="ActivateButton" name="+ Day_Counter + " Value="'+ Day_Counter +' " Title="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></font></strong></td>';
				 }
				 else 
				 {
				    HTML_String += '<td class="cal"  align="center"><strong><font color="#6699ff"><Input Type="Button"  class="ActivateButton" name="+ Day_Counter + "  Value="'+ Day_Counter +' " Title="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></font></strong></td>';
				 }
             }
             else 
             {
                var disabledDateDiff= parseInt(document.getElementById("hdnDisabledDate").value);
				var currDate1 = new Date();
				currDate1.setDate(currDate1.getDate() + disabledDateDiff);
				Today1=currDate1.getDate();
				cmonth1=currDate1.getMonth();
				cyear1=currDate1.getFullYear();
				
				if ((Day_Counter < Today1)&&(Month==cmonth1)&&(Year==cyear1)) 
				{
				 HTML_String += '<td class="cal1"  align="center"><Input Type="Button"  name="+ Day_Counter + "  class="DisableButton" Title="'+ Day_Counter +' " Value="'+ Day_Counter +' " ></td>';
				}
				else if ((Month< cmonth1)&&(Year==cyear1))
				{
				 HTML_String += '<td class="cal1"  align="center"><Input Type="Button"  name="+ Day_Counter + "  class="DisableButton" Title="'+ Day_Counter +' " Value="'+ Day_Counter +' " ></td>';
				}
				else if (Year < cyear1)
				{
				 HTML_String += '<td class="cal1"  align="center"><Input Type="Button"  name="+ Day_Counter + "  class="DisableButton" Title="'+ Day_Counter +' " Value="'+ Day_Counter +' " ></td>';
				}
				else if((Month<=cmonth1)&&(Year<cyear1))
				{
				 HTML_String += '<td class="cal1"  align="center"><Input Type="Button"  name="+ Day_Counter + "  class="DisableButton" Title="'+ Day_Counter +' " Value="'+ Day_Counter +' " ></td>';
				}
				//enable button 
				else if((Month > cmonth1)&&(Year==cyear1))
				{
				HTML_String += '<td class="cal" align="center"><Input Type="Button" name="+ Day_Counter + " class="ActivateButton" Title="'+ Day_Counter +' " Value="'+ Day_Counter +' "  onClick="capturedate1('+Day_Counter+')"></td>';
				} 
				else 
				{
				HTML_String += '<td class="cal" align="center"><Input Type="Button" name="+ Day_Counter + "  class="ActivateButton" Title="'+ Day_Counter +' " Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
				}  
			}
            Day_Counter++;    
        }
        else 
        {
            HTML_String += '<td class="cal" style="background-color:white;" BORDERCOLOR="cccccc" align="center"></td>';
        }
        Loop_Counter++;
      }// for (var i = 1; i < 8; i++)
      HTML_String += '</tr>';
   }// for (var j = 1; j <= Rows; j++) 
   HTML_String += '</table></td></tr></Table><Input Type="Hidden"  Name="seldate" size="9">'
   document.getElementById('Calendar1').innerHTML=HTML_String;
}// function createcalendar1	


function createcalendar3(Year, Month) 
{

   var First_Date = new Date(Year, Month, 1);
   var Heading = Header1(Year, Month);
   if(CalenderFormat==1)
   {	
   var First_Day = First_Date.getDay() ;
   }
   else
   {
   var First_Day = First_Date.getDay()+1 ; 
   }	

    if(First_Day==0)
   {
		First_Day=7
   }
   if (((daysinmonth[Month] == 31) && (First_Day >= 6)) ||
       ((daysinmonth[Month] == 30) && (First_Day == 7))) 
   {
      var Rows = 6;
   }
   else if ((daysinmonth[Month] == 28) && (First_Day == 1)) 
   {
      var Rows = 4;
   }
   else 
   {
      var Rows = 5;
   }
   
   var HTML_String = '<center><table border="0" align=center><tr><td valign="top"><table BORDER="0" CELLSPACING=0 cellpadding=1 FRAME="box" bgcolor="#F0F0F0">';
   HTML_String += '<tr><td colspan=7 bgcolor="cccfff" BORDERCOLOR="#999999" ALIGN="CENTER"><font face="verdana" size=1>' + Heading + '</font></td></tr>';
  if(CalenderFormat==1)
   {
   HTML_String += '<tr><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Mo</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Tu</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>We</font></td>';
   HTML_String += '<td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Th</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Fr</b></font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Sa</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Su</font></td></tr>';
   }
  else
   {
   HTML_String += '<tr><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Su</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Mo</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Tu</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>We</font></td>';
   HTML_String += '<td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Th</font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Fr</b></font></td><td ALIGN="CENTER"  BORDERCOLOR="#999999"><font face="verdana" size=1>Sa</font></td></tr>';
   }
   	 		
   var Day_Counter = 1;
   var Loop_Counter = 1;
   for (var j = 1; j <= Rows; j++) 
     {
      HTML_String += '<tr ALIGN="left" VALIGN="top">';
      for (var i = 1; i < 8; i++) {
	      if ((Loop_Counter >= First_Day) && (Day_Counter <=daysinmonth[Month])) 
           {
			if((Day_Counter >= Today) && (Year >= cyear) && (Month >= cmonth)) 	   
			{
				if ((Day_Counter == Today) && (Year == cyear) && (Month == cmonth)) 
				 {
				   HTML_String += '<td  align="center"><strong><font color="black"><Input Type="Button" style="Width:20;Height:20px;border: 0 solid #000000;" name="+ Day_Counter + "  Value="'+ Day_Counter +' " Style=color:red onClick="capturedate1('+Day_Counter+')"></font></strong></td>';
				 }
				 else 
				 {
					if((Month>=cmonth)&&(Year>=cyear))	//Disable button
						HTML_String += '<td  align="center"><Input Type="Button" disabled name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
					else								//Enable button
				 	    HTML_String += '<td  align="center"><strong><font color="black"><Input Type="Button" style="Width:20;Height:20px;border: 0 solid #000000;" name="+ Day_Counter + "  Value="'+ Day_Counter +' " Style=color:black onClick="capturedate1('+Day_Counter+')"></font></strong></td>';
				 }
             }
             
             else 
             {
		//Enable buttons
					if ((Day_Counter < Today)&&(Month==cmonth)&&(Year==cyear)) 
					{
						 HTML_String += '<td  align="center"><Input Type="Button" name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
					}
					else if ((Month< cmonth)&&(Year==cyear)) 
					{
						 HTML_String += '<td  align="center"><Input Type="Button" name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
					}
					else if (Year < cyear)
					{
						 HTML_String += '<td  align="center"><Input Type="Button" name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
					}
					else if((Month<=cmonth)&&(Year<cyear))
					{
						 HTML_String += '<td  align="center"><Input Type="Button" name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
					}
					else if((Day_Counter<=Today)&&(Month==cmonth)&&(Year==cyear))
					{
						 HTML_String += '<td  align="center"><Input Type="Button" name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
					}
					
		//Disable button
					else if((Month >= cmonth)&&(Year==cyear))
					{	
						HTML_String += '<td  align="center"><Input Type="Button" disabled name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
					} 
					
					else if((Day_Counter<=Today)&&(Month>=cmonth)&&(Year>=cyear))
					{
						 HTML_String += '<td  align="center"><Input Type="Button" disabled name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';
					}
					else 
					{
						HTML_String += '<td  align="center"><Input Type="Button" disabled name="+ Day_Counter + " style="Width:20;Height:20px;border: 0 solid #000000;"  Value="'+ Day_Counter +' " onClick="capturedate1('+Day_Counter+')"></td>';					
					}  
				}
              Day_Counter++;    
          }
         else 
          {
            HTML_String += '<td BORDERCOLOR="cccccc" align="center"></td>';
          }
         Loop_Counter++;
      }
      HTML_String += '</tr>';
      
      
      //------------
      
   
   }
  
   HTML_String += '</table></td></tr></Table> <Form Name="form1"><Input Type="Hidden"  Name="seldate" size="9"></form>'
   document.all.Calendar1.innerHTML = HTML_String;
}   	


function Check_Nums() 
{


   if ((event.keyCode < 48) || (event.keyCode > 57)) 
   {
      return false;
   }
}


function On_Year() 
{
///debugger
   //var Year = document.form1.year.value;
   var Year=document.getElementById("year").value;
   
   //getcyr=Year
   smonth = document.getElementById("month").selectedIndex;
   //alert(Year)
  if((smonth>=cmonth)&&(Year==(cyear+1)))
   {
     if(Today<=5)
     {
         //document.form1.year.selectedIndex=0;
         document.getelementById("year").selectedIndex=0;
         //syear=document.form1.year.value;
	     createcalendar(syear, smonth);//last selected year and month
	 }
	 else
	 {
		syear=Year;
		createcalendar(Year, smonth);//selected year and month
	 }
   }
   else
   {
    syear=Year;
	createcalendar(Year, smonth);
   }
}

function On_Month() 
{


   var Year = document.getElementById("year").value;
   var sm=smonth;
      smonth = document.getElementById("month").selectedIndex;
      syear = Year;
	  createcalendar(syear, smonth);
}

function Skipmon(Direction) 
{

   if (Direction == '+') 
   {
      if (smonth == 11) 
      {
		 smonth = 0;
		 syear++;
		 document.getElementById("year").value=syear;
		 
	  }
      else 
      {
         smonth++;
      }
   }
   else 
   {
      if (smonth == 0) 
      {
         smonth = 11;
         syear--;
         document.getElementById("year").value=syear;
      }
      else 
      {
        smonth--;
      }
   }
   createcalendar(syear, smonth);
   //document.form1.month.selectedIndex = smonth;
   document.getElementById("month").selectedIndex=smonth;
   //document.form1.year.value =syear;
   document.getElementById("year").value;
}

function callcreatecalendar(y,m)//to change the value of month  and year 
{
	
	document.form1.month.value=m;
	document.form1.year.value=y;
	(y, m);
}


function cancel()
{

	maindiv1.style.visibility="hidden";
	NavBar1.style.visibility="hidden";
	Calendar1.style.visibility="hidden";
}
function change(mn)
{

var monthname
	switch (mn.toLowerCase())
	{
	case String("Jan").toLowerCase() : 
		monthname="01";
		break
	case String("Feb").toLowerCase() : 
		monthname="02";
		break
	case String("Mar").toLowerCase() : 
		monthname="03";
		break
	case String("Apr").toLowerCase() : 
		monthname="04";
		break
	case String("May").toLowerCase() : 
		monthname="05";
		break
	case String("Jun").toLowerCase() : 
		monthname="06";
		break
	case String("Jul").toLowerCase() : 
		monthname="07";
		break
	case String("Aug").toLowerCase() : 
		monthname="08";
		break
	case String("Sep").toLowerCase() : 
		monthname="09";
		break
	case String("Oct").toLowerCase() : 
		monthname="10";
		break
	case String("Nov").toLowerCase() : 
		monthname="11";
		break
	case String("Dec").toLowerCase() : 
		monthname="12";
		break
	}
	return monthname
}

function closediv1()
{

//document.all.Iframe1.style.visibility="hidden";
document.getElementById('Iframe1').style.visibility="visible"

	document.getElementById('maindiv1').style.visibility="visible";
	document.getElementById('NavBar1').style.visibility="visible";
	//document.getElementById('Calendar1').style.visibility="hidden";
	document.getElementById('Calendar1').style.visibility="visible";
	//self.close(); 
}
 //to display the date window
function showdate(e,boxday,boxmonth,boxyear,crdate,l,t,shflg,validflg,i) //to display the date window
{
    //debugger
	var tempdatetime;
	img=i
	if((img=='y')||(img=='r')||(img=='c')||(img=='m')||(img=='l')||(img=='k')||(img=='T')||(img=='e')||(img=='o')||(img=='z')||(img=='a')||(img=='x')||(img=='H')||(img=='p')||(img=='mu1')||(img=='mu2')||(img=='mu3')||(img=='mu4')||(img=='t'))
	{
	    var dt_arr=crdate.split('-');
	    var dt_mon=change(dt_arr[1])
	    crdate=dt_mon+'/'+dt_arr[0]+'/'+dt_arr[2];
	    //alert(crdate);
	}
	
    globalcurrentdate=new Date(crdate)
    tempdatetime=new Date(crdate)
    globalvalidflg=validflg

	if (tempdatetime!="NaN")
	{
		flgshowall=shflg
		boxnameday=boxday
		boxnamemonth=boxmonth
		boxnameyear=boxyear
		curdatetime=new Date(crdate)
		glbdate="true";
		chkdate(e,crdate,l,t)
	}
}

function chkdate(e,crdate,l,t)
{
    //debugger;
    var maindiv1 =document.getElementById('maindiv1');
	if(glbdate=="true")
	{
        var modify,modifyInt;
        var modifyHotel;
        if(document.getElementById("ctl00_contentMain_ModifyFlightSearch1_hndModify")!=null)
        {
            modify=document.getElementById("ctl00_contentMain_ModifyFlightSearch1_hndModify").value;
        }
        if(document.getElementById("ctl00_contentMain_ModifyIntFlightSearch1_hndModifyInt")!=null)
        {
            modifyInt=document.getElementById("ctl00_contentMain_ModifyIntFlightSearch1_hndModifyInt").value;
        }

        if(document.getElementById("ctl00_contentMain_Modify_hndModifyHotel")!=null)
        {
            modifyHotel=document.getElementById("ctl00_contentMain_Modify_hndModifyHotel").value;
        }
        if(modify=="true"||modifyInt=="true")
        {
            var x,y;
            var bType = new BrowserSniffer().GetBrowserType();
            if (bType == "ie")
            {
                 x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
                 y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
            }
            else
            {
                 x = e.pageX;
                 y = e.pageY;
            }
	    
	        var sPath = window.location.pathname;
            var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
            if(sPage=="Review.aspx")
            {
                maindiv1.style.left = l + 'px';
	            maindiv1.style.top = t + 'px';   
            }
            else
            {
                maindiv1.style.left = (x -170) +'px';
	            maindiv1.style.top = y +'px';        
            }
		}//  if(modify=="true"||modifyInt=="true")
	    else
	    {
	        if(modifyHotel=="true")
            {
                var x=0,y=0;
                var bType = new BrowserSniffer().GetBrowserType();
                if (bType == "ie")
                {
                     x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
                     y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
                }
                else
                {
                     x = e.pageX;
                     y = e.pageY;
                }
		        //This Code is appended by Vikash Nothing else 06 Oct
		        //Purpose : Because Calender Donot Coming in Right Position 
		        var sPath = window.location.pathname;
                var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
                if(sPage=="Review.aspx")
                {
                    maindiv1.style.left = l+'px';
		            maindiv1.style.top = t+'px';
		        }
		        else
	            {
                    maindiv1.style.left = (x -170) +'px';
	                maindiv1.style.top = y +'px';            
	            }
		    }//if(modifyHotel=="true")
		    else
		    {
		        var mdv=document.getElementById('maindiv1');
		        mdv.style.left=l+'px';
		        mdv.style.top=t+'px';
		    }
		}// else (if(modify=="true"||modifyInt=="true"))
		//---------------------------
	
		var layer = document.getElementById('maindiv1');
        layer.style.display = 'block';
        var iframe = document.getElementById('Iframe1');
        iframe.style.display = 'block';
        iframe.style.Width = layer.offsetWidth-5;
        iframe.style.Height = layer.offsetHeight-5;
        iframe.style.left = layer.offsetLeft;
        iframe.style.top = layer.offsetTop;

        iframe.style.visibility="visible";
		layer.style.visibility="visible";
		document.getElementById("NavBar1").style.visibility="visible";
		//NavBar1.style.visibility="visible";
		document.getElementById("Calendar1").style.visibility="visible";
		document.getElementById("Iframe1").style.visibility="visible";
		
		glbdate="false";
		CalenderFormat = 2;
		Default();
	}
}
//===============================================================================
//									Made by Praveen
//===============================================================================
function CheckDayKey() 
{

   if ((event.keyCode < 48) || (event.keyCode > 57)) 
   {
		event.keyCode=8;		//Will fire backspace to delete non-numeric value
		return false;
   }
}
function CheckMonthKey() 
{
   if (event.keyCode == 46)
   {
		event.keyCode=8;
		return false;
   }
   if (event.keyCode == 45)		  //Will prevent the negative value to be entered(KeyCode 45==-)
   {
		event.keyCode=8;		 //Will fire backspace to delete negative sign
		return false;
   }
}

function CheckYearKey() 
{
   if ((event.keyCode < 48) || (event.keyCode > 57)) //0-9 Digits have KeyCode 48 - 57
   {
		event.keyCode=8;		//Will fire backspace to delete non-numeric value
		return false;
   }
   
}

//===============================================================================
//	Checking for Range of the Day Entered
//===============================================================================
function CheckDayRange(objstart_day)
{

	var start_day="";
	start_day=objstart_day.value;
	if(!(isNaN(objstart_day.value)))
	{
		if (objstart_day.value.length!=0)
		{
			if (start_day <= 9 ) 
			{
				if (start_day <= 0) 
				{
					alert("Enter value between 1 to 31");
					objstart_day.value="";
					objstart_day.focus();
				}
				else
				{
					if (objstart_day.value.length < 2)
						objstart_day.value='0' + objstart_day.value
				}
			}
			else
			{
				if (start_day > 31)
				{
					alert("Enter value between 1 to 31");
					objstart_day.value="";
					objstart_day.focus();
				}
			}
		}
	}
	else
	{
		alert("Invalid Input");
		objstart_day.value="";
		objstart_day.focus();
	}
		
}

//===================================================================
//	Checking for Format/Range of Month Entered 
//===================================================================
function CheckMonthVal(objstart_month)
{

	var start_month="";
	var flag="";
	var montharray = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
	start_month=jsTrim(objstart_month.value);
	if (!isNaN(start_month)) //if month is in digit or blank
	{
		if (start_month.length!=0)
		{
			if ((start_month <= 0 ) ||(start_month > 12 ))
			{
				alert("Enter value (1-12) for the month");
				objstart_month.value="";
				objstart_month.focus();
			}
			else
			{
				for (var y=0;y<=11;y++)
				{
					if (start_month==(y+1))
					{
						objstart_month.value=montharray[y];		
					}
				}
			}	
		}
	}
	else				//if month is in alphabet
	{
		for (var x=0;x<=11;x++)
		{
			if (start_month.toUpperCase()==montharray[x])
			{
				flag="true";
				break;
			}
		}
		if (flag!="true")
		{
			
			alert("Enter valid value" + "(Jan-)" + " " + "for the month");
			objstart_month.value="";
			objstart_month.focus();
		
		}
		if (flag=="true")
			objstart_month.value=start_month.toUpperCase();
	}
}

//===================================================================
//	Checking for Format of Entered Day, Month, Year
//===================================================================
function CheckValidDate(objstart_day,objstart_month,objstart_year,currentdate)
{
	var start_year="";
	var userdt=(objstart_day.value+ ' ' + objstart_month.value + ' '+ objstart_year.value)
	start_year=jsTrim(objstart_year.value);
	if (currentdate==" ")
	    {
	    currentdate=Date(); 
	    }
	if (currentdate!="undefined")
	{
		var newcurrentdate=new Date(currentdate);
		if (((Date.parse(userdt)-Date.parse(currentdate))/(3600*1000*24))>365)
		{		
			if (confirm("TThe date entered is greater than one year from today\\'s date."))
				{}
			else
				{
					objstart_year.value="";
					objstart_year.focus();
					return false;
				}
		}
	}
	if(!(isNaN(objstart_year.value)))
	{
		if (objstart_year.value.length!=0)
		{
			if (jsTrim(objstart_day.value)=="") 
			{
				//alert("First enter the day");
				objstart_day.focus();
				return false;
			}
			if (jsTrim(objstart_month.value)=="" )
			{
				//alert("First enter the month");
				objstart_month.focus();
				return false;
			}
			if ((start_year.length < 4 ) ||(start_year.length > 4 ))
			{
					alert("Enter Four digit value for the year(e.g. 2002)");
					objstart_year.value="";
					objstart_year.focus();
					return false
					
			}
			
			if (currentdate!="")
			{
				if (start_year < 1900)
				{
					alert("Year cannot be less than 1900");
					objstart_year.value="";
					objstart_year.focus();
				}
			}
			else
			{
				if (start_year < 1753)
				{
					alert("Year cannot be less than 1753");
					objstart_year.value="";
					objstart_year.focus();
				}
			}
	        var strFeb = "Feb";
			if (jsTrim(objstart_month.value).toUpperCase()==strFeb.toUpperCase())
			{
				if (objstart_day.value >29)
				{
					alert("This is not a valid Date, Re-enter the date");
					objstart_day.value="";
					objstart_day.focus();
					return false;
				}
				if (objstart_day.value==29)
				{
					if (objstart_year.value%100==0)
					{
						if(objstart_year.value%400!=0)
						{
							alert("This is not a valid Date, Re-enter the date");
							objstart_day.value="";
							objstart_day.focus();
							return false;
						}
					}
					else
					{	
						if (objstart_year.value%4!=0)
						{
							alert("This is not a valid Date, Re-enter the date");
							objstart_day.value="";
							objstart_day.focus();
							return false;
						}
					}
				}
			}
			var strApr = "Apr";
			var strMay = "May";
			var strSep = "Sep";
		    var strNov = "Nov";
				
			if ((jsTrim(objstart_month.value).toLowerCase()==strApr.toLowerCase())||(jsTrim(objstart_month.value).toLowerCase()==strMay.toLowerCase())||(jsTrim(objstart_month.value).toLowerCase()==strSep.toLowerCase())||(jsTrim(objstart_month.value).toLowerCase()==strNov.toLowerCase()))
			{
				if (objstart_day.value >30)
				{
					alert("This is not a valid Date, Re-enter the date");
					objstart_day.value="";
					objstart_day.focus();
					return false;
				}
			}
		}
	}
	else
	{
		alert("Invalid Input");
		objstart_year.value="";
		objstart_year.focus();
	}
}

//===========================================================================
//	Checking for Valid Date if user has entered Month and Year First and then
//  then enters Day e.g 29 Feb 2000
//===========================================================================
function CheckValidDay(objstart_day,objstart_month,objstart_year)
{

	var start_year="";
	start_year=jsTrim(objstart_year.value);
	var strFeb = "Feb";
	if (jsTrim(objstart_month.value).toLowerCase()==strFeb.toLowerCase())
	{
		if (objstart_day.value >29)
		{
			alert("This is not a valid Date, Re-enter the date");
			objstart_day.value="";
			objstart_day.focus();
			return false;
		}
		if ((objstart_day.value==29)&& (!((objstart_year.value % 4==0)&&(objstart_year.value % 100!=0) || (objstart_year.value % 400==0))))
		{
			alert("This is not a valid Date, Re-enter the date");
			objstart_day.value="";
			objstart_day.focus();
			return false;
		}
	}
		var strApr = "Apr";
		var strJun = "Jun";
		var strSep = "Sep";
		var strNov = "Nov";
		    
	if ((jsTrim(objstart_month.value).toLowerCase()==strApr.toLowerCase())||(jsTrim(objstart_month.value).toLowerCase()==strJun.toLowerCase())||(jsTrim(objstart_month.value).toLowerCase()==strSep.toLowerCase())||(jsTrim(objstart_month.value).toLowerCase()==strNov.toLowerCase()))
	{
		if (objstart_day.value >30)
		{
			alert("This is not a valid Date, Re-enter the date");
			objstart_day.value="";
			objstart_day.focus();
			return false;
		}
	}
}
function CheckValidMonth(objstart_day,objstart_month,objstart_year)
{

	CheckValidDay(objstart_day,objstart_month,objstart_year);
}
//==========================UpTo Here================================


//===================================================================
//	Checking for Format of Entered Date
//===================================================================
function checkformat(box)
{

if(box.value!="")
{
	var cmpdate="";
	cmpdate=jsTrim(box.value);

	var flag="true";
	var chkday,errmsg;
	var chkyear =new String();
	var chkmon=new String() ;

	var monthnum = new Array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12');
		
		cmpdate=jsTrim(box.value);
		if (cmpdate.length>0)	
		{
			if (cmpdate.length<4) //invalid date entered (Dd-Mmm-Yyyy)
			{
				alert("This is not a valid Date, Re-enter the date");
			//	document.form.seldate.value="";
			//	document.form.seldate.focus();
				box.value=""
				box.focus();
				return false;
			}


			if(cmpdate!="")
			{
				errmsg="";
				chkday=cmpdate.substring(0,2);
				if (!(parseFloat(chkday)>0))
				{	
					alert("Enter a valid day..");
					//document.form.seldate.value="";
					//document.form.seldate.focus();
					box.value=""
					box.focus();
					return false;
				}
				
				if (!(isNaN(chkday))) //if number is entered
				{
					chkmon=cmpdate.substring(2,5);
					//chkyear=cmpdate.substring(5,9);
				}
				else
				{
					chkday="0"+cmpdate.substring(0,1);
					if (!(isNaN(chkday)))
					{
						chkmon=cmpdate.substring(1,4);
						//chkyear=cmpdate.substring(4,8);
					}
					else
					{
						errmsg="Enter a valid day..";
						flag="false";
					}
				}
						
				if(flag!="false")
				{
					if ((isNaN(chkmon))) //if number is entered
					{			
						chkmon=chkmon.toUpperCase(chkmon);
						for (var x=0;x<=11;x++)
						{
							if (chkmon==monthlabel[x])
							{
								chkmon=monthlabel[x];
								flag="true";
								errmsg="";
								break;
							}
							else
							{
								if (errmsg=="") errmsg="Enter a valid month.";
								flag="false";
							}
						}
					}
					
					else
					{	
						chkmon=parseFloat(chkmon)
						
						for (var x=0;x<=11;x++)
						{
							
							if (chkmon==monthnum[x])
							{
								chkmon=monthlabel[x];
								flag="true";
								errmsg="";
								break;
							}
							else
							{
								if (errmsg=="") errmsg="Enter a valid month.";
								flag="false";
							}
						}
					}
				}
				
				var chkmonth
				var current= new Date()
				currentdate= current.getDate()
				currentmonth= current.getMonth()
				// currentyear= current.getYear()
			 if ((navigator.userAgent.indexOf("Firefox") > -1)||(navigator.userAgent.indexOf("Safari") > -1))
		        {
		          currentyear = current.getYear();
                  currentyear = currentyear - 100;
		        }
		        else
		        {
		         currentyear = current.getYear();
		        }
				currentmonth=parseInt(currentmonth+1)
				for(var i=0 ;i<=11;i++)
				{
					if((monthlabel[i]==chkmon))
					{
						chkmonth=i+1
						break;
					}
					
				}
				//====================================
					if(cmpdate.length!=9)
					{
							if(currentmonth==chkmonth)
							{					
								
								if(currentdate>chkday)
								{
									
									newyear=parseInt(currentyear)+1
								}
								else
								{
									newyear=parseInt(currentyear)
								}
							}
							if(currentmonth<chkmonth)
							{
								newyear=parseInt(currentyear)
							}
							if(currentmonth>chkmonth)
							{
								newyear=parseInt(currentyear)+1
							}
					}
					else
					{
						newyear=cmpdate.substring(5,9);
					}		
				//===============================
				
				/*if(chkyear.length < 4)
				{
					if (errmsg=="") errmsg="Enter a valid year";
					flag="false";
				}
				*/
			
				if (flag=="false")
				{
					alert(errmsg);
					//document.form.seldate.value="";
					//document.form.seldate.focus();
					box.value=""
					box.focus();
					return false;
				}
				

				var monnum;
				
				var srvday,srvmon,srvyear;
				
				srvyear="<%=year(date)%>";
				srvmon= "<%=month(date)%>";
				srvmon=(parseInt(srvmon)-1);
				srvmon=monthlabel[srvmon];
				srvday="<%=day(date)%>";
				chkyear=newyear
			    var strFeb = "Feb";
				if (chkmon.toUpperCase()==strFeb.toUpperCase()) 
				{
				      if (chkyear % 4 == 0)  
				      {
				         daysinmonth[1] = 29;
				         
				      }
				      else
				      {
							if(chkday==29)
							{
								alert("This is not a valid Date, Re-enter the date")
								box.value=""
								box.focus()
								return false
							}
				      }
				      
				      
				}
				
				   
				for(var i=0 ;i<=11;i++)
				{
					if((monthlabel[i]==chkmon)&&( parseInt(chkday)>parseInt(daysinmonth[i]) ))
					{
						flag="false";
						break;
					}
				}
				/*
				var clientdate=new Date(chkday+chkmon+chkyear);
				var serverdate=new Date(srvday+srvmon+srvyear);
				if(clientdate>=serverdate)
				{
					
					alert("Sorry..! Date of birth can't be equal or greater than current date");
					//document.form.seldate.value="";
					//document.form.seldate.focus();
					box.value=""
					box.focus();
					return false;	
				}
				*/
				if(flag=="false")
				{
					
					alert("This is not a valid Date, Re-enter the date");
					//document.form.seldate.value="";
					//document.form.seldate.focus();
					box.value=""
					box.focus();
					return false;
				}
				
				box.value=chkday +" " + chkmon + " " + newyear;
				return true
				//document.form.seldate.focus();
			}
		}
	}
}

//*******************************************************************************
//*******************************************************************************
// checking for date format entered
//*******************************************************************************
//*******************************************************************************
function check_format(df)
{

	var flg
	for (var i=0;i<df.value.length;i++)
	{
			val=df.value.charAt(i)
			// check for / or -
			if ((val=="/") || (val=="-")) 
			{	
				flg="1"
				break;
			}
			else
			{
				flg="2"
			}
					
	}
	if (flg=="2" )	
	{
		checkformat(df)

	}
	if (flg=="1" )	
	{
		check_format1(df)
	}
		
}

function check_format1(df)
{


			len=(df.value.length)
			
			if ((len>10))
			{
				alert("This is not a valid Date, Re-enter the date")
				df.value=""
				df.focus();
						
			}
			else
			{
				if (len<5)
				{
					var ipos=df.value.indexOf("/")
					var jpos=df.value.indexOf("-")
					
					if ( ((ipos==-1) && (jpos==-1)) || (ipos==0)||(jpos==0)||(ipos==3)||(jpos==3))
					{
						alert("This is not a valid Date, Re-enter the date")
						df.value=""
						df.focus();
						return false;
					}
					else
					{
						if ((ipos==-1) && (jpos!=-1))
						{
							mm=parseFloat(df.value.substring(0,jpos))
							dd=parseFloat(df.value.substring((parseInt(jpos)+1),parseInt(df.value.length)))
						}
						if ((ipos!=-1) && (jpos==-1))
						{
							mm=parseFloat(df.value.substring(0,ipos))
							dd=parseFloat(df.value.substring((parseInt(ipos)+1),parseInt(df.value.length)))
						}
						if (mm.toString().length==1)
						{
							mm="0"+mm
							
						}
						if (dd.toString().length==1)
						{
							dd="0"+dd
						}
						df.value=mm +"/"+ dd
						len=5
					
					}
					
				}
				// to check if date is dd/mm
				if (len==5) 
				{
					for (var i=0;i<len;i++)
					{
						if ((i==2) )
						{
							val=df.value.charAt(i)
							// check for / or -
							if ((val!="/") && (val!="-")) 
							{
								alert("This is not a valid Date, Re-enter the date")
								df.value=""
								df.focus();
								return false;
							}
						}
						else
						{
							// check for non alpha numeric character
							if (isNaN(df.value.charAt(i)))
							{
								alert("Invalid Character In Date Field")
								df.value=""
								df.focus();
								return false;
							}
							else
							{
								val=df.value.charAt(i)
								if (val==" " ) 
								{
									alert("This is not a valid Date, Re-enter the date")
									df.value=""
									df.focus();
									return false;
								}
								
							}
						}
					}
					mm=parseFloat(df.value.substring(0,2))
					dd=parseFloat(df.value.substring(3,5))
					var current= new Date()
					var currentdate= current.getDate()
					var currentmonth= current.getMonth()
					currentmonth= currentmonth+1
					//var currentyear= current.getYear()
					if ((navigator.userAgent.indexOf("Firefox") > -1)||(navigator.userAgent.indexOf("Safari") > -1))
		            {
		              currentyear = current.getYear();
                      currentyear = currentyear - 100;
		            }
		            else
		            {
		             currentyear = current.getYear();
		            }
					var nextyear=parseFloat(currentyear)+1
					if (mm>currentmonth)
					{
						
						seldate=(df.value)+"/"+currentyear
						
					}
					else if (mm==currentmonth)
					{
						if (dd>=currentdate)
						{
							seldate=(df.value)+"/"+currentyear
						}
						else
						{
							seldate=(df.value)+"/"+nextyear
						}
						
					}
					else
					{
						seldate=(df.value)+"/"+nextyear
					
					}
						
					check_format2(seldate,df)	
				}
				else if ((len>5)&&(len<10))
				{
					var ipos=df.value.indexOf("/")
					var jpos=df.value.indexOf("-")
					if((ipos==0)||(jpos==0))
					{
						alert("This is not a valid Date, Re-enter the date")
						df.value=""
						df.focus();
						return false;
						
					}
					if(ipos==-1)
					{
						var pos=jpos
						var pos1=df.value.indexOf("-",jpos+1)
						mm=parseFloat(df.value.substring(0,pos))
						dd=parseFloat(df.value.substring((parseInt(pos)+1),pos1))
						yy=df.value.substring((parseInt(pos1)+1),df.value.length)
						
					}
					if(jpos==-1)
					{
						var pos=ipos
						var pos1=df.value.indexOf("/",ipos+1)
						mm=parseFloat(df.value.substring(0,pos))
						dd=parseFloat(df.value.substring((parseInt(pos)+1),pos1))
						yy=df.value.substring((parseInt(pos1)+1),df.value.length)
						
					}
					if (mm.toString().length==1)
					{
						mm="0"+mm
							
					}
					if (dd.toString().length==1)
					{
						dd="0"+dd
					}
					df.value=mm+"/"+dd+"/"+yy
					for (var i=0;i<len;i++)
					{
						if ((i==2)||(i==5))
						{
							val=df.value.charAt(i)
							// check for / or -
							if ((val!="/") && (val!="-")) 
							{
								alert("This is not a valid Date, Re-enter the date")
								df.value=""
								df.focus();
								return false;
							}
						}
						else
						{
							// check for non alpha numeric character
							if (isNaN(df.value.charAt(i)))
							{
								alert("Invalid Character In Date Field")
								df.value=""
								df.focus();
								return false;
							}
							else
							{
								val=df.value.charAt(i)
								if (val==" " ) 
								{
									alert("This is not a valid Date, Re-enter the date")
									df.value=""
									df.focus();
									return false;
								}
							}
						}
					}
					mm=df.value.substring(0,2)
					dd=df.value.substring(3,5)
					yy=df.value.substring(6)
					var current= new Date()
					var currentdate= current.getDate()
					var currentmonth= current.getMonth()
					currentmonth= currentmonth+1
					
					if ((navigator.userAgent.indexOf("Firefox") > -1)||(navigator.userAgent.indexOf("Safari") > -1))
		            {
		              currentyear = current.getYear();
                      currentyear = currentyear - 100;
		            }
		            else
		            {
		             currentyear = current.getYear();
		            }
					var nextyear=parseFloat(currentyear)+1
					var yr=currentyear.substring(0,2)
					if (yy.toString().length==2) 
					{
						seldate=mm+"/"+dd+"/"+""+yr+""+yy
					}
					else
					{
						seldate=mm+"/"+dd+"/"+yy
					}
					check_format2(seldate,df)		
				}
				else if (len==10)
				{
					seldate=df.value
					check_format2(df.value,df)
				}
				else
				{
					alert("This is not a valid Date, Re-enter the date")
					df.value=""
					df.focus();
					return false;
					
				}
				
			}	
}

function check_format2(seldate,df)
{


	
			if(seldate.length!=10)
			{
				alert("This is not a valid Date, Re-enter the date")
				df.value=""
				df.focus();
				return false;
			}
			else
			{
				for (var i=0;i<seldate.length;i++)
				{
					if ((i==2) || (i==5) )
					{
						val=seldate.charAt(i)
						
						// check for / or -
						
						if ((val!="/") && (val!="-")) 
						{
							alert("This is not a valid Date, Re-enter the date")
							df.value=""
							df.focus();
							return false;
						}
						
					}
					else
					{
						// check for non alpha numeric character
						
						if (isNaN(seldate.charAt(i)))
						{
							alert("Invalid Character In Date Field")
							df.value=""
							df.focus();
							return false;
						}
						else
						{
							val=seldate.charAt(i)
							if (val==" " ) 
							{
								alert("This is not a valid Date, Re-enter the date")
								df.value=""
								df.focus();
								return false;
							}
						
							
						}
					}
				}
				mm=parseFloat(seldate.substring(0,2))
				dd=parseFloat(seldate.substring(3,5))
				yy=parseFloat(seldate.substring(6))
				if ((mm==0)|| (mm>12)||(dd==0)||(yy==0))
				{	
					alert("Please enter correct date in MM/DD/YYYY format")
					df.value=""
					df.focus();
					return false;
					
				}
				if ((mm==1)||(mm==3)||(mm==5)||(mm==7)||(mm==8)||(mm==10)||(mm==12))
				{	
					if (dd>31)
					{
						alert("This is not a valid Date, Re-enter the date")
						df.value=""
						df.focus();
						return false;
					}
				}
				else if (mm==2)
				{
					if((yy % 4)==0)
					{
						if (dd>29)
						{
							alert("This is not a valid Date, Re-enter the date")
							df.value=""
							df.focus();
							return false;
						}
					}
					else
					{
						if (dd>28)
						{
							alert("This is not a valid Date, Re-enter the date")
							df.value=""
							df.focus();
							return false;
						}
					}
				}
				else
				{
					if (dd>30)
					{
						alert("This is not a valid Date, Re-enter the date")
						df.value=""
						df.focus();
						return false;
					}
				
				}
				var mon= monthlabel[mm-1]
				dd=seldate.substring(3,5)
				yy=seldate.substring(6)
				seldate=dd+" "+mon+" "+yy		
				df.value=seldate
				
				
			}
			
}

function getmonthName(mName)
{
  for (var _i=0; _i < monthlabel.length; _i++)
  {
    if(monthlabel[_i] == mName)
    {
      return monthOrglabel[_i];
    }
  }
}

