function countrySelected(form)
{
	if(document.SlocationsPopUpForm.countryID.value == 'IN1')
	{
		alert("Invalid Option Selected");
	}
	else
	{
		form.submit();
	}
}
//-----------------------------------------------
 function validate(form) 
 {
	if (form.OriginLocationID.value.length == 0)
	{
		alert("Please select Origin location");
		//alert(form.originLocationId.options[0].value);
		return false;
	}
	else if (form.DestinationLocationID.value.length == 0)
	{
		alert("Please select Destinaion location");
		//alert(form.destinationLocationId.options[0].value);
		return false;
	}
	var value1 = form.PickupDate.value;
	if (value1.length == 0)
	{
	  window.alert("Please specify the Date");	  
	  return false;
	}
		//alert("Submit successfully");
		form.submit();
	 	return true;
	 	
}

function serviceclicked(form)
{
        if(form.Service[0].checked == false && form.Service[1].checked == false)
		   {
		     alert("Please select Service Type");
		     return false;
		   }
		   else
		   {
		      form.submit();
		      return true;
		   }	
}

//below form is use for dropbox popup of origin in transit form
function dropboxSearchpopup(form, popup, width, height, e) {
	var xx, yy;
	xx = e.screenX;
	yy = e.screenY;
	window.open('','Popup','width=' + width + ', height=' + height + ',toolbar=no,scrollbars=yes,location=no'); 	
	//alert("New windos is open"+form.action);
	var action = form.action;
 	var target = form.target;
	if (popup == null || popup == "") {
		popup = action;
	}
	form.target='Popup';
	form.action = popup
	form.submit();
	form.target = target;
	form.action = action;
	//form.elements['reqCode'].value='';		
	return false;
}
function dropboxdestpopup(form, dropdest, width, height, e) {
	var xx, yy;
	xx = e.screenX;
	yy = e.screenY;
	window.open('','Dropdest','width=' + width + ', height=' + height + ',toolbar=no,scrollbars=yes,location=no'); 	
	//alert("New windos is open"+form.action);
	var action = form.action;
 	var target = form.target;
	if (dropdest == null || dropdest == "") {
		dropdest = action;
	}
	form.target='Dropdest';
	form.action = dropdest
	form.submit();
	form.target = target;
	form.action = action;
	//form.elements['dest'].value='';		
	
	return false;
}
//below function is used for get the value in origin textbox from dropbox form in transittime form called submit of hello.jsp
function closeorgPopUp(form,openerField,popupField) {	

	var inputField = form[popupField];
	var value;
	if (inputField.options) {
		value = inputField.options[form[popupField].selectedIndex].value;
	 }
	else if (inputField.type == "file") {
		value = inputField.value;
		alert("Value of drop box is "+value);
	} else {
		for (i=0; i < form.elements.length; i++) {
			var element = form.elements[i];
			if (element.name == popupField && element.checked) {
				value = element.value;
				break;
			}
		}
	}
	//below code assigns the city selected into the cityName textbox control
	//on the dropboxinner.jsp form
 	
   
	  if(window.opener.document.forms[1].elements[3].value == "v")
	  {
	 	 window.opener.document.forms[1]["OriginLocationID"].value = value;
	 	 window.opener.document.forms[1].elements[3].value = "p";
	   	window.close();
	 	window.opener.document.dropboxPopUpForm.submit();
	  }
	   if(window.opener.document.forms[1].elements[6].value == "d")
	   {
	 	 window.opener.document.forms[1]["DestinationLocationID"].value = value;
	     window.opener.document.forms[1].elements[6].value = "q";
	     window.close();
	     window.opener.document.dropboxPopUpForm.submit();
	   }
	 //window.opener.document.forms[1][openerField].value = value;
	// window.close();	
	
}
//-----------------------------------
function closeinterpopup(form,openerField,popupField)
{
   var inputField = form[popupField];
	var value;
	if (inputField.options) {
		value = inputField.options[form[popupField].selectedIndex].value;
	 }
	else if (inputField.type == "file") {
		value = inputField.value;
		alert("Value of drop box is "+value);
	} else {
		for (i=0; i < form.elements.length; i++) {
			var element = form.elements[i];
			if (element.name == popupField && element.checked) {
				value = element.value;
				break;
			}
		}
	}
	 if(window.opener.document.forms[1].elements[6].value == "i")
	 {
	 	 window.opener.document.forms[1]["DestinationLocationID"].value = value;
	 	 window.opener.document.forms[1].elements[6].value = "";
	 	//alert("Hello"+window.opener.document.forms[1].elements[6].value);
	     window.close();
	 	 window.opener.document.dropboxPopUpForm.submit();
	 }
}
//--------------------------
function statechange(form)
{
	 
    
	if(document.dropboxPopUpForm.stateID.value == 'oo')
	{
		alert("Invalid Option Selected..Please select Again");		
		document.dropboxPopUpForm.stateID[1].selected = true;
	}
	else
	{
		//alert("Hello");
		form.submit();
	}
}
function countryselected(form)
{
	if(document.SlocationsPopUpForm.countryID.value == 'IN1')
	{
		alert("Invalid Option Selected");
	}
	else
	{
		form.submit();
	}
}

//function that checks if correct Location selected in Destination DropDown
function countryClicked(form)
{
		form.submit();
		return true;
}
 
 function getalert(form)
 {
		alert("Onload submit");
		return true;
 }
 
//calender
function calendar(form)
{
	 
	alert("Inside calender");
	//Browser detection code
	var IE4 = (document.all && !document.getElementById) ? true : false;
    var NS4 = (document.layers) ? true : false;
    var IE5 = (document.all && document.getElementById) ? true : false;
    var N6 = (document.getElementById && !document.all) ? true : false;
   //Browser detection code ends here

	var aMonthNames = new Array(
	'JANUARY', 'FEBRUARY', 'MARCH', 
	'APRIL', 'MAY', 'JUNE', 
	'JULY',	'AUGUST', 'SEPTEMBER', 
	'OCTOBER', 'NOVEMBER', 'DECEMBER'
	);
	var aMonthDisplay = new Array(
	'01', '02', '03', 
	'04', '05', '06', 
	'07',	'08', '09', 
	'10', '11', '12'
	);	
	var aMonthDays = new Array(  
	/* Jan */ 31,     /* Feb */ 28, /* Mar */ 31,     /* Apr */ 30, 
	/* May */ 31,     /* Jun */ 30, /* Jul */ 31,     /* Aug */ 31, 
	/* Sep */ 30,     /* Oct */ 31, /* Nov */ 30,     /* Dec */ 31 
	);
	var days = new Array(42);
		
		/*Comment2 starts
		  This Function populates the table with the dates for a particular month in a year.
		  comment2 ends*/
		function daylayerdisplay(b,a,c)
		{
		/*newwindow=window.open("");
		newwindow.status=b + "" + a + "" + c + "";*/
		/*Comment3 starts
		  b is Year in yyyy format
		  a is Months in numerical format viz 0=january,1=february etc
		  c is day in numeric format
		  Comment3 ends
		*/
		monthreduction=a;
		monthincrease=a;
		            if (b%4 == 0 || b%100 ==0){
					aMonthDays[1]=29;
					}
					else{
					aMonthDays[1]=28;
					}
				    var oDateNow = new Date();	
					var oDate = new Date(aMonthNames[a] +  1 + "," + b);
					dayofweek=oDate.getDay();
					//Input values in td's
					var count=0;
					var count1;
					var end=aMonthDays[a]+(dayofweek);
					for (s=1;s<=42;s++){
					document.getElementById("day"+s).childNodes[0].innerHTML="";
					}
					for (s=(dayofweek+1);s<=end;s++){
					count=count+1;
					document.getElementById("day"+s).childNodes[0].innerHTML=count;
					if (count<=9)
					{
					count1=0+""+count;
					}
					else
					{
					count1=count;
					}
					document.getElementById("day"+s).childNodes[0].id=count1;
					}
			}
				
				/*Comment4 starts
				This function sends the value back to the form object of the window
				which called it*/
				function sendvalue(y,m,d)
				{
					if (y == 1){
					todayobj= new Date();
					today=todayobj.getYear()+todayobj.getMonth()+todayobj.getDate();
					if (N6){
					year=todayobj.getYear()+1900;
					}
					else
					{
					year=todayobj.getYear();
					}					
					if (todayobj.getDate() <= 9)
					{
					var todayday=0+""+todayobj.getDate();
					}
					else
					{
					var todayday=todayobj.getDate();
					}
					parent.document.callingform.receivedate.value=aMonthDisplay[todayobj.getMonth()]+ "-" + todayday + "-" + year;
					parent.document.getElementById('calendarframe').style.display='none'
					}
					else{
					parent.document.callingform.receivedate.value= aMonthDisplay[m]+"-"+d+"-"+y;//y + m + d;
					parent.document.getElementById('calendarframe').style.display='none'
					}
				 }
				 /*Comment4 ends here*/
				 
				 /*Comment5 starts
				 This function reduces the month by one everytime prev.gif is clicked*/
				 function reducemonths()
				 { 
				 monthreduction= +monthreduction - 1;
				 if (monthreduction==-1)
				 {
				 monthreduction=11;
				 document.calendarform.year.value=
				 parseFloat(document.calendarform.year.value)-1;
				 }
				 
				 document.calendarform.month[monthreduction].selected = "1";
				 daylayerdisplay(document.calendarform.year.value,monthreduction,101);
				 }
				 /*Comment5 ends here*/
				 
				 /*Comment6 starts
				 This function Increases the month by one everytime next.gif is clicked*/
				 function increasemonths()
				 { 
				 monthincrease= +monthincrease + 1;
				 if (monthincrease==12)
				 {
				 monthincrease=0;
				 document.calendarform.year.value=
				 parseFloat(document.calendarform.year.value)+1;
				 }
				 document.calendarform.month[monthincrease].selected = "1";
				 daylayerdisplay(document.calendarform.year.value,monthincrease,101);
				 }
				 /*Comment6 ends here*/				 
	

} 

 

