
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function fnvalidate() {
if (document.forms[0].txtUserName.value == '') {
		alert('Please enter your username.');
		document.forms[0].txtUserName.focus();
		return false;
} else if(document.forms[0].txtPassword.value == '') {
		alert('Please enter your password.');
		document.forms[0].txtPassword.focus();
		return false;
} else
	return true;
}// JavaScript Document


						/**									  	**/
						/** Functions Used In User Registration **/
						/**										**/



/**
 * Function To Clear Clipboard Data.
 * Used In Registration File
 **/ 
function cleardata() {
window.clipboardData.clearData();
}

/**
 * Function To Hide Or Unhide Return Date Filed Based On Trip Selection.
 * Used In Search File.
 **/ 
var rt=true;
function hidereturn() {
rt=false;

//document.getElementById("retcal").style.display="none";
document.searchFrm.RetDate.value="";
document.getElementById("Ret_Date").disabled = true;
document.getElementById("return_id").style.visibility="hidden";
document.getElementById("return_idnew").style.visibility="hidden";
}
function hideretdate(){
	
	if (document.searchFrm.faretype[1].checked==true){
		document.getElementById("return_id").style.visibility="hidden";
		document.getElementById("return_idnew").style.visibility="hidden";
		document.getElementById("Ret_Date").value="";
		document.getElementById("Ret_Date").disabled = true;
		rt=false;
	}	
	else{
		document.getElementById("return_id").style.visibility="visible";
		document.getElementById("return_idnew").style.visibility="visible";
	}	
}
function unhidereturn() {
rt=true;


document.getElementById("Ret_Date").disabled = false;
document.getElementById("return_id").style.visibility="visible";
document.getElementById("return_idnew").style.visibility="visible";

//document.getElementById("retcal").style.display="block";
//document.getElementById("RetDate").disabled = false;
}


 /**
 * Function To Validate Search form.
 * Used In Search File.
 **/ 
function validateFrm(str) {
 var frm = document.searchFrm;
//alert(frm.DeptFrom.value);
//alert(frm.GoingTo.value);
//return false;
 //---- DeptFrom ----
 if(frm.DeptFrom.value=="") {
  alert("Please select from city");
  frm.DeptFrom.focus();
  return false;
 }
 if(frm.DeptFrom.value!="") {
	  if(isNaN(frm.DeptFrom.value)) {
	   alert("Invalid from city");
	   frm.DeptFrom.focus();
	   return false;
	   }
}

 //---- GoingTo ----
if(frm.GoingTo.value=="") {
  alert("Please select to city");
  frm.GoingTo.focus();
  return false;
}
if(frm.GoingTo.value!="") {
  if(isNaN(frm.GoingTo.value)) {
	   alert("Invalid to city");
	   frm.GoingTo.focus();
	   return false;
	}
}
if(frm.DeptFrom.value==frm.GoingTo.value) {
  alert("Departure From and Going To city can not be same");
  //frm.DeptFrom.focus();
  return false;
}

 //---- Calender DeptFrom ----
  /*
  if(frm.DeptDate.value=="") {
  alert("Please select Departure Date");
  frm.DeptDate.focus();
  return false;
 }
 */
 if(frm.DeptDate.value=="") {
  alert("Please enter Departure Date");
  frm.DeptDate.focus();
  return false;
 }
 else{
	fromdate=frm.DeptDate.value.split("-");
	
	if ((fromdate.length-1)!=2){
		alert("Please enter valid Departure date")
		frm.DeptDate.focus();
		return false;
	}
	else{
	if (DateValidation(fromdate[0],fromdate[1],fromdate[2],"Departure Date")==0){
		frm.DeptDate.focus();
		return false;
	}
	}
}

 //---- Calender GoingTo ---- 

if(rt) {
	 if(frm.RetDate.value=="") {
	  alert("Please select Return Date");
	  frm.RetDate.focus();
	  return false;
	 }
	  else{
		todate=frm.RetDate.value.split("-");
		
		if ((todate.length-1)!=2){
			alert("Please enter valid Return date")
			frm.RetDate.focus();
			return false;
		}
		else{
		if (DateValidation(todate[0],todate[1],todate[2],"Return Date")==0){
			frm.RetDate.focus();
			return false;
		}
		}
	}

		chkday=frm.DeptDate.value;
			chkarray=chkday.split("-");
	
	year1=chkarray[2]*1;
	month1=chkarray[1]*1;
	date1=chkarray[0]*1;
	

	//makeday=d+"-"+mon+"-"+y
	chkday=frm.RetDate.value;
	chkarray=chkday.split("-");
	
	year2=chkarray[2]*1;
	month2=chkarray[1]*1;
	date2=chkarray[0]*1;

	flag=0;
   if (year2 > year1)  flag=1;
   else if (year2 < year1) flag=-1;
   else if (month2 > month1) flag=1;
   else if (month2 < month1) flag=-1; 
   else if (date2 > date1) flag=1;
   else if (date2 < date1) flag=-1;
   else flag=0;
   
  
   
   if (flag==-1){
    alert("Return Date Cannot Be Before Departure Date")
		return false;
       }





/*	if(frm.DeptDate.value==frm.RetDate.value) {
	  alert("Departure Date and Return Date cannot be same");
	  //frm.DeptDate.focus();
	  return false;
	}*/
	/*
	if(frm.RetDate.value<frm.DeptDate.value) {
	  alert(" Return Date Cannot Be Before Departure Date");
	  //frm.DeptDate.focus();
	  return false;
	}
	*/
}

}//End Validate form

function selectCity (city_id) {
 var frm = document.searchFrm; 
	 frm.submit();
	 //document.location="index.php?page=sel_seat&myacct=1";
}
 
//-->

function isBlank(txt, minlen)
{
	/*
		This fucntion can be used to check if a given text contains only spaces or 0 in length.

		INPUT: Text [txt]
					Minimum Length [minlen] optional
					Indicates that the text should be atleast 'minlen' in length

		OUTPUT: returns true if blank else false
	*/
alert(txt)
	if( txt.length == getCountOf('\n', txt) )
	{
		/*
			This condition avoids the entry of just newlines in text areas.
		*/
		return true;
	}


	if( txt.length == getCountOf(' ', txt) || txt.length == 0 )
	{
		return true;
	}
	else if( minlen > 0 )
	{
		if( txt.length < minlen )
		{
			return true;
		}
		else
		{
			return false;
		}
	}
	else
	{
		return false;
	}
}
	
	//This can be used for any character validation.
	//For example in a valid date the count of - or / should not be more than 2
	//Likewise in a valid numer there should be only one .
	function getCountOf(vChr, txt)
	{
		var i = 0;
		var iCount = 0;
	
		for( i=0; i < txt.length; i++ )
		{
			if( txt.charAt(i) == vChr )
			{
				iCount++;
			}
		}
		return iCount;
	}
	

		
	
	function SplNumbers(Val)
	{
		var alp = "0123456789-";
		if (Val==""){
			alert("Enter any Value");
				
				return 0;
		}
		for (var i=0;i<Val.length;i++){
			temp=Val.substring(i,i+1);
			if (alp.indexOf(temp)==-1){
				alert("No special characters \nValid entries are [0-9][ - ]");
				
				return 0;
			}
		} // closing the for loop
	
	} // closing the function SplNumbers()
function DateValidation(dd, mm, yy, msg) {
	
	   
	 if(SplNumbers(dd) == 0)
	 return 0;
	 
	 if(SplNumbers(mm) == 0)
	 return 0;
	 
	 if(SplNumbers(yy) == 0)
	 return 0;
	 
	
	 
	 d = dd*1;
	 m = mm*1;
	 y = yy*1;

	 if(m > 12 || m == 0) {
		alert("Invalid month entered for " + msg);		
		return 0;
	 }
	 else {
	 
	 var vDays = [ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];
	 var flag = 0;
	 if(m == 2) {
		if(isLeapYear(y)) {
		  if( d > 29 || d < 1 ) {
		   flag = 0;
		  }
		  else {
		   flag = 1;
		  }
		}
		else if( d > vDays[m] || d < 1 ) {
		 flag = 0;
		}
		else {
			 flag = 1;
		}
	 }
	 else {
		if( d > vDays[m] || d < 1 ) {
		 flag = 0;
		}
		else {
		 flag = 1;
		}  
	 }
	 }
	 if(flag == 0) {
	
		alert("Invalid day entered for " + msg);
	
		return 0;
	 }
	 else {
	 	today=new Date();
		ychk=today.getFullYear();
		
	 	if (y>(ychk+1)){
			alert("Invalid year entered for "+msg);
			return 0;
		}
		return 1;
	 }
	 
	 
	} // closing the function DateValidation() 
	
	function isLeapYear(y)
	{
		 if( y % 4 == 0) 
		 {
			if( y % 100 == 0 ) 
			{
				 if( y % 400 == 0) 
				 {
					  return true;
				 }
				 else
				 {
					  return false;
				 }
			}
			else 
			{
				return true;
			}
		 }
		 else 
		 {
			return false;
		 }
	} // closing the function isLeapYear()
	 

	/**
	 FUNCTION PASSVALIDATION(element1,element2) 
	 **/
	
	function PassValidation(Element1,Element2) {
	
		if(Element1.value != Element2.value) {
			alert("Confirm password doesn't match");

			Element2.focus();
			return 0;
		}
		else
			return 1;
		
	} // closing the function PassValidation()
	
	
	/**
	 FUNCTION EMAILVALIDATION(element) 
	 **/
	 
	function EmailValidation(Element)
	{
		Flag  = 1;
		count = 0;
	
		var alp = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_@.-";
		
		if (Element.value==""){
			alert("Enter your E-mail ID");
				Element.focus();
				return 0;
		}
		
		if(Element.value.length > 0)
		{
			for (var i=0; i<Element.value.length; i++)
			{
				temp = Element.value.substring(i, i+1);
	
				if (alp.indexOf(temp) == -1)
				{
					Flag = 0;
				}
			} // closing the for loop
		}
		else
		{
			Flag = 0;
		}
	
		for(var i=0; i <= Element.value.length; i++)
		{
			if(Element.value.charAt(0)=='@')
			{
				Flag = 0;
				break;
			}

			if(Element.value.charAt(Element.value.length-1)=='@')
			{
				Flag = 0;
				break;
			}

			if(Element.value.charAt(i)=='@') 
			{
				count = count + 1;

				if(count>1)
				{
					Flag = 0;
					break;
				}
			  
				if((Element.value.charAt(i-1)=='.') || (Element.value.charAt(i+1)=='.'))
				{
					Flag = 0;
					break;
				}
			}
			if(Element.value.indexOf('@')==-1)
			{
				Flag = 0;		    	
				break;
			}
			if(Element.value.charAt(0)=='.')
			{
				Flag = 0;
				break;
			}
			if(Element.value.indexOf('.')==-1)
			{
				Flag = 0;		    	
				break;
			}
		  } //closing the for loop
		
		if(Element.value.charAt(Element.value.length-1) == '.')
			Flag = 0;
			
		if(Flag != 1)
		{
			//alert("Invalid Email Address.\nValid Characters are [a-z][A-Z][0-9][ _ @ . - ].\n\nlike muralisugguna@vsplash.com, murali@vsplash.co.in ...");
			alert("Invalid Email Address");
			Element.focus();
			return 0;
		}	
		else
			return 1;
	}
	
	/**
	 FUNCTION GENVALIDATION(element.message1,message2,spl) 
	 **/
	
	function GenValidation(Element,MessageLen0,MessageLen4,spl) {
		
		if(MessageLen0.length != 0)
		{
			if(Element.value.length == 0)
			{
				alert("Please enter the "+ MessageLen0);
				Element.focus();
				return 0;
			}
			else if(isBlank(Element.value))
			{
				alert("Please enter the "+ MessageLen0);
				Element.focus();
				return 0;
			}
		}
	
		if(MessageLen4.length != 0)
		{
			if(Element.value.length < 4)
			{
				alert( MessageLen4 + " should be more than 4 characters");
				Element.focus();
				return 0;
			} // closing the if - else condtion for if(MessageLen4.length != 0)
		}
	
		if(spl == "spl")
		{
			if(SplCharacters(Element) == 0)
			return 0;
		}
		else if(spl == "space")
		{
			if(SplCharactersSpace(Element) == 0)
			return 0;
		}
		///// Added By : BHARATH.
		else if(spl == "text")
		{
			if(textOnly(Element) == 0)
			return 0;
		}

	} // closing the function GenValidation()
	
	
	
<!-- Begin
// var Message="www.Jewster.com"; 
var Message=" "; 
var place=1;
function scrollIn() 
{
	window.status=Message.substring(0, place);  
	if (place >= Message.length) 
	{
		place=1;
		window.setTimeout("scrollOut()",500); 
	} 
	else 
	{
		place++;
		window.setTimeout("scrollIn()",200); 
	} 
}
function scrollOut() 
{
	window.status=Message.substring(place, Message.length);
	if (place >= Message.length) 
	{
		place=1;
		window.setTimeout("scrollIn()", 300);
	} 
	else 
	{
		place++;
		window.setTimeout("scrollOut()", 200); 
	}
}

// End -->
// scrollIn() ;	
		/**
	FUNCTION ROUNDNUMBER(element)
	**/
	function RoundNumber(Val)
	{
		var alp = "0123456789.";
		if (Val.value==""){
				alert("Enter any value")
				Val.focus();
				return 0;
		}
		for (var i=0;i<Val.value.length;i++){
			temp=Val.value.substring(i,i+1);
			if (alp.indexOf(temp)==-1){
				alert("Enter Only Numerics and [.] are allowed.");
				Val.focus();
				return 0;
			}
		} // closing the for loop
	
	} // closing the function RoundNumber()

	function onlyNumbers(Val,msg)
	{
		var alp = "0123456789";
	if (Val.value==""){
		if (msg.length>0)
			alert("Please enter "+msg)
		else	
			alert("Enter any numeric value");
			Val.focus();
			return 0;
	}
		for (var i=0;i<Val.value.length;i++){
			temp=Val.value.substring(i,i+1);
			if (alp.indexOf(temp)==-1){
				alert("Enter Only Numerics.");
				Val.focus();
				return 0;
			}
		} // closing the for loop
	
	} // closing the function RoundNumber()
//ltrim,rtrim and trim fucntions  written by Murali Kumar Sugguna dated 09-jun-2005

function ltrim(argvalue){
  while (1) {
    if (argvalue.substring(0, 1) != " ")
      break;
    argvalue = argvalue.substring(1, argvalue.length);
  }
  return argvalue;
}

function rtrim(argvalue) {

  while (1) {
    if (argvalue.substring(argvalue.length - 1, argvalue.length) != " ")
      break;
    argvalue = argvalue.substring(0, argvalue.length - 1);
  }

  return argvalue;
}
function trim(argvalue) {
  var tmpstr = ltrim(argvalue);

  return rtrim(tmpstr);

}
//this function changedays ,

function changedays(month,year,days)
{
	var nummon   = parseInt(month.value);
	var yr       = parseInt(year.value);	
	var chk 	 = parseInt(days.value);
	var noofdays;
	
	if(nummon == 1 || nummon == 3 || nummon == 5 || nummon == 7 || nummon == 8 || nummon == 10 || nummon == 12)
	{
	noofdays = 31;
	}
	else
	{
		if(nummon == 2)
		{
			if(isLeapYear(yr) == true)
			noofdays = 29;
			else
			noofdays  = 28;
		}
		else
		{
		noofdays = 30;
		}
	}

	days.options.length = noofdays;
	for(i=0;i<noofdays;i++)
	{
	days.options[i].text  = i+1;
	days.options[i].value = i+1;
	}
	
	if(chk > noofdays)
	{
	alert("Please Select Day\n This Month has " + noofdays + " days only ");
	days.focus();
	}
	
	return true;	
}

function selAll(frm,obj){
	for(i=0;i<frm.elements.length;i++){
		if (obj.checked==true){
			if (frm.elements[i].type=="checkbox" && frm.elements[i].name!="chkall"){
				frm.elements[i].checked=true;
			}
		}
		else{
			if (frm.elements[i].type=="checkbox" && frm.elements[i].name!="chkall"){
					frm.elements[i].checked=false;
			}
		}
	}
}

function validAll(frm){

flag=0;
	
	for(i=0;i<frm.elements.length;i++){
			
			if (frm.elements[i].type=="checkbox" && frm.elements[i].name!="chkall"){
				if (frm.elements[i].checked==true){
					flag=1;
					
				}
			}
	}
	
	if (flag==0){
		alert("Please selected atleast one seat to cancel.");
		return false;
	}
	if (flag==1)
	{
		if (confirm("The selected seats will be cancelled, Are you sure?")){
			return true;
		}
		return false;
	}
	
}

function commonValidDate(firstDate,secondDate){

	chkday=firstDate;
			chkarray=chkday.split("-");
	
	year1=chkarray[2]*1;
	month1=chkarray[1]*1;
	date1=chkarray[0]*1;
	
	//makeday=d+"-"+mon+"-"+y
	chkday=secondDate;
	chkarray=chkday.split("-");
	
	year2=chkarray[2]*1;
	month2=chkarray[1]*1;
	date2=chkarray[0]*1;


	flag=0;
   if (year2 > year1)  flag=1;
   else if (year2 < year1) flag=-1;
   else if (month2 > month1) flag=1;
   else if (month2 < month1) flag=-1; 
   else if (date2 > date1) flag=1;
   else if (date2 < date1) flag=-1;
   else flag=0;
   
  
   
   if (flag==-1){
    return 0
       }
	   
	   return 1;
}
	
