function onLoadFunctions(){GetSources();LoadDateofJourney();LoadBusType();GetLoadTimeDestinations()}function validateMobile(a){var b=/^([0-9]{10,10})$/;return b.test(a)}function validateEmail(a){var b=/^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;return b.test(a)}function validateOnlyCharcters(a,b){$(b).css("color","black");var c=0;if(!a)var a=window.event;if(!a.which)c=a.keyCode;else c=a.which;if(c!=27){if(c>=65&&c<=90||c>=97&&c<=122||c==8||c==9||c==32||c==46||c==37||c==39){return true}else{c=0;return false}}return false}function block1(){$("#spinner-suggest").show();return true}function handleFailedError(a){alert("Technical Error, please try again!"+" (Error = "+a+")");$("#spinner-suggest").hide();$.unblockUI()}function successSuggestedRoute(a){if(a=="success"){$("#thanksMsg").show();$("#subSug1").hide();$("#spinner-suggest").hide();$.unblockUI()}}function changeToBlack(a){$(a).css("color","black")}function submitSuggestRoute(){if($("#sourceDiscovery").val()==""||$("#sourceDiscovery").val()=="From"){alert("Please enter the source name you are looking for.");$("#sourceDiscovery").focus();return false}if($("#destinationDiscovery").val()==""||$("#destinationDiscovery").val()=="To"){alert("Please enter the destination name you are looking for.");$("#destinationDiscovery").focus();return false}if($("#inventorEmail").val()!="E-mail (Optional)"&&!validateEmail($("#inventorEmail").val())){alert("Please enter your email id.");$("#inventorEmail").focus();return false}if($("#inventorPreferred").val()!="Mobile (Optional)"&&!validateMobile($("#inventorPreferred").val())){alert("Please enter valid mobile number.");$("#inventorPreferred").focus();return false}if($("#inventorEmail").val()=="E-mail (Optional)")$("#inventorEmail").val("");if($("#inventorPreferred").val()=="Mobile (Optional)")$("#inventorPreferred").val("");var a="fromCity="+$("#sourceDiscovery").val()+"&toCity="+$("#destinationDiscovery").val()+"&emailId="+$("#inventorEmail").val()+"&travels="+$("#inventorPreferred").val();$.ajax({cache:false,dataType:"text",type:"POST",async:true,url:"SuggestRoute.aspx",data:a,beforeSend:block1,success:successSuggestedRoute,error:function(a,b,c){if(a.readyState==0||a.status==0)return;else handleFailedError()}})}function hideRouteDiscovery(){$("#showRecoveryDiv").hide();$("#routeSearchMain").show()}function HideErrorMessagecorp(){if($("#packCal").val()=="dd-mmm-yyyy"&&sourceList.value!=0){$("#packCal").datepicker("show");return}if($("#packCal").val()!="dd-mmm-yyyy"||destList.value!=null){$("#errorcorp").hide()}}function HideErrorMessage(){if($("#calendar").val()=="dd-mmm-yyyy"&&sourceList.value!=0){$("#calendar").datepicker("show");return}if($("#calendar").val()!="dd-mmm-yyyy"||destList.value!=null){$("#error").hide()}}function SearchBusesCorp(){if(!validateDateFormat($("#calendar").val())){return}if(sourceList.value==0){$("#error").css("display","block");$("#error").html("Please select the 'From' location");return}var a="Any";if(!isNullOrEmpty(busType)){a=busType.value}window.location.href="/corp/SelectBus1.aspx"+"?F="+$("#DDLSource").val()+"&T="+$("#DDLDestination").val()+"&D="+$("#calendar").val()+"&Typ=Any&Tr=0&N=0"}function validateDateFormatcorp(a){var b=CustomDateValidation(a);if(b!=null&&a!="dd-mmm-yyyy"){$("#errorcorp").show();$("#errorcorp").html(b);return false}else{return true}}function validateDateFormat(a){var b=CustomDateValidation(a);if(b!=null&&a!="dd-mmm-yyyy"){$("#error").show();$("#error").html(b);return false}else{try{if(!isNullOrEmpty(curDate)&&curDate==a){$("#paymentOpt option[value='CashonDel']").remove()}else{if($("#paymentOpt option[value='CashonDel']").length<=0){$(new Option("Cash on delivery","CashonDel")).appendTo("#paymentOpt")}}}catch(c){}return true}}function SearchBusescorp(){var a=$("#packCal").val();var b=CustomDateValidation(a);if(b!=""){$("#errorcorp").css("display","block");$("#errorcorp").html(b);$("#packCal").focus();return}sourceListcorp=$("#packageSources").val();destListcorp=$("#packageDestinations").val();if(sourceListcorp==""){$("#errorcorp").css("display","block");$("#errorcorp").html("Please select the 'From' location");return}if(destListcorp==""){$("#errorcorp").css("display","block");$("#errorcorp").html("Please select the 'To' location");return}var c="/Booking/SelectBus.aspx"+"?fromCityId="+$("#packageSources").val()+"&fromCityName="+$("#packageSources option:selected").text()+"&toCityId="+$("#packageDestinations").val()+"&toCityName="+$("#packageDestinations option:selected").text()+"&doj="+$("#packCal").val()+"&busType=Any";$(location).attr("href",c)}function SearchBuses(a){if(typeof a!="undefined"){trackEventCommon("search","searchbuses","searchbus click")}var b=$("#calendar").val();var c=CustomDateValidation(b);var d=sourceList.options[sourceList.selectedIndex].text;var e=destList.options[destList.selectedIndex].text;var f=false;if(c!=""){$("#error").css("display","block");$("#error").html(c);$("#calendar").focus();return}if(sourceList.value==0){$("#error").css("display","block");$("#error").html("Please select the 'From' location");return}if(destList.value==0){$("#error").css("display","block");$("#error").html("Please select the 'To' location");return}var g="Any";if(!isNullOrEmpty(busType)){g=busType.value}var h="";if(!isNullOrEmpty($("#paymentOpt").val())||!isNullOrEmpty(getQueryStringParameter("payType"))){h="&payType="+$("#paymentOpt").val()}var i="fromCityId="+sourceList.value+"&fromCityName="+d+"&toCityId="+destList.value+"&toCityName="+e+"&doj="+b+"&busType="+g+h;if(!isNullOrEmpty($("#pageSource"))&&$("#pageSource").length>0){i+="&searchSource="+$("#pageSource").val()}var j=getQueryStringParameter("AID");if(!isNullOrEmpty(j)){i+="&SIFYAID="+j}var k="/Booking/SelectBus.aspx?"+i;$(location).attr("href",k)}function clearFilterCookiescorp(){createCookie("_busType","",-1);createCookie("_bp","",-1);createCookie("_dp","",-1);createCookie("_rating","",-1)}function clearFilterCookies(){createCookie("_busType","",-1);createCookie("_bp","",-1);createCookie("_dp","",-1);createCookie("_rating","",-1)}function CustomDateValidation(a){var b=new RegExp("^(([012]?[0-9]|3[01])-([Jj][Aa][Nn]|[Ff][Ee][bB]|[Mm][Aa][Rr]|[Aa][Pp][Rr]|[Mm][Aa][Yy]|[Jj][Uu][Nn]|[Jj][u]l|[aA][Uu][gG]|[Ss][eE][pP]|[oO][Cc][Tt]|[Nn][oO][Vv]|[Dd][Ee][Cc])-([2][0-9][0-9][0-9]))$");var c=b.test(a);if(c==false){return"Please enter a valid date."}var d=a.split("-");var e=parseInt(d[0],10)+1;var f=d[1]+" "+e+","+d[2];var g=new Date(f);if(g<new Date){return"Please select a future date."}return""}function LoadBusType(){if(!isNullOrEmpty(busType))busType.value=getPreference("busType")}function LoadDateofJourney(){if(!isNullOrEmpty(calendar)){enteredDate=$("#calendar").val();$("#calendar").val(getPreferenceDoj("doj"))}}function eraseCookie(a){createCookie(a,"",-1)}function createCookie(a,b,c){if(c){var d=new Date;d.setTime(d.getTime()+c*24*60*60*1e3);var e="; expires="+d.toGMTString()}else var e="";document.cookie=a+"="+b+e+"; path=/"}function getPreferenceDoj(a){var b=getQueryStringParameter(a);if(!isNullOrEmpty(b))return b;return"dd-mmm-yyyy"}function getPreference(a){var b=a+"1";var c=false;if(b!=null&&b!=""){if(typeof fromCityId1!="undefined"&&b=="fromCityId1"){b=fromCityId1;c=true}else if(typeof toCityId1!="undefined"&&b=="toCityId1"){b=toCityId1;c=true}else if(typeof fromCityName1!="undefined"&&b=="fromCityName1"){b=fromCityName1;c=true}else if(typeof toCityName1!="undefined"&&b=="toCityName1"){b=toCityName1;c=true}if(c){return b}}if(document.getElementById(a)!=null)return document.getElementById(a).value;var d=getQueryStringParameter(a);if(!isNullOrEmpty(d))return d;var e=readCookie(a);if(!isNullOrEmpty(e))return e;return null}function readCookie(a){var b=a+"=";var c=document.cookie.split(";");for(var d=0;d<c.length;d++){var e=c[d];while(e.charAt(0)==" ")e=e.substring(1,e.length);if(e.indexOf(b)==0)return e.substring(b.length,e.length)}return null}function isNullOrEmpty(a){if(a==null||a==""){return true}return false}function getQueryStringParameter(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var b="[\\?&]"+a+"=([^&#]*)";var c=new RegExp(b);var d=c.exec(unescape(window.location.href));if(d==null){return null}else{return d[1]}}function GetSources(){$.ajax({url:"/GetDestinationsJSON.aspx",cache:false,dataType:"json",success:handleSourcesResponse})}function GetDestinations(){var a=sourceList.value;if(a!=null){$("#error").hide();var b=$("#DDLSource option[value='"+a+"']:selected").text();var c=$("#DDLSource option[value='"+a+"']:selected").val();var d=$("#"+c);var e=d.attr("title");if(e!=null){settollPhoneno(d,e)}else{$(".clsDIVTollNoHead").css("width","159px");$("#tollcityName").html("National toll Number");$("#tollstdCode").html("");$("#tollcustcareNum").html("1860-300-10101");$("#custcareNum").html("1860-300-10101");$("#stdCode").html("");if(typeof tollnumCSS!="undefined"){tollnumCSS()}if(typeof homenumCSS!="undefined"){homenumCSS()}createCookie("_tollCity",$("#tollcityName").html(),365);createCookie("_tollNo",$("#tollcustcareNum").html(),365);createCookie("_tollCode",$("#tollstdCode").html(),365)}}LoadDestinations(a)}function GetLoadTimeDestinations(){var a=0;var b=getPreference("fromCityId");if(b!=null){a=b}LoadDestinations(a)}function LoadDestinations(a){if(a!="0"&&a!=""){if(allSourceDestinations){loadDestinationsData(allSourceDestinations[a])}else{httpDest=createRequestObject();httpDest.open("get","/GetDestinationsJSON.aspx?sourceid="+a);httpDest.onreadystatechange=handleDestResponse;httpDest.send(null)}}else{destList.options[0]=new Option("---------",0);destList.options[0].selected=true}}function GetAllSourceDestinations(){httpSourceDestinations=createRequestObject();httpSourceDestinations.open("get","/GetDestinationsJSON.aspx?allsourcedestinations=123");httpSourceDestinations.onreadystatechange=handleAllSourceDestResponse;httpSourceDestinations.send(null)}function handleAllSourceDestResponse(){if(httpSourceDestinations.readyState==4){var result=eval("("+httpSourceDestinations.responseText+")");allSourceDestinations=result}}function handleSourcesResponse(a){var b=a;var c=getPreference("fromCityId");var d=getPreference("fromCityName");$("#DDLSource").empty();var e=[];var f=0;var g=false;if(b.sourcePreferences!=null&&b.sourcePreferences.length>0){var h={};for(var i=0;i<b.sourcePreferences.length;i++){var j="";if(c==b.sourcePreferences[i].cityId&&d==b.sourcePreferences[i].cityName){j="selected='selected'";g=true}if(h[b.sourcePreferences[i].cityId]==null&&b.sourcePreferences[i].cityId!=""){h[b.sourcePreferences[i].cityId]=b.sourcePreferences[i].cityName;e[f++]="<option value='"+b.sourcePreferences[i].cityId+"' "+j+">"+b.sourcePreferences[i].cityName+"</option>"}}if(e.length>0){if(e.length>0){$("#DDLSource").append("<optgroup style='font-style: normal;' id='mSources' label='Most frequented'></option>");for(var k=0;k<e.length;k++){$("#mSources").append(e[k])}}}}e=[];f=0;if(b.topSources!=null&&b.topSources.length>0){for(var i=0;i<b.topSources.length;i++){var j="";if(!g&&c==b.topSources[i].cityId&&d==b.topSources[i].cityName){j="selected='selected'";g=true}e[f++]="<option value='"+b.topSources[i].cityId+"' "+j+">"+b.topSources[i].cityName+"</option>"}if(e.length>0){$("#DDLSource").append("<optgroup style='font-style: normal;' id='tSources' label='Top sources'></option>");for(var k=0;k<e.length;k++){$("#tSources").append(e[k])}}}e=[];f=0;if(b.allSources!=null&&b.allSources.length>0){for(var i=0;i<b.allSources.length;i++){var j="";if(!g&&c==b.allSources[i].cityId&&d==b.allSources[i].cityName){j="selected='selected'";g=true}e[f++]="<option value='"+b.allSources[i].cityId+"' "+j+">"+b.allSources[i].cityName+"</option>"}if(e.length>0){$("#DDLSource").append("<optgroup style='font-style: normal;' id='aSources' label='All sources'></option>");for(var k=0;k<e.length;k++){$("#aSources").append(e[k])}}}if(sourceList.value==null){sourceList.options[0].selected=true}if(c==""||c==null||c=="0"){$("#tSources").prepend("<option value='0'>---------</option>");sourceList.children["tSources"].children[0].selected=true}}function handleDestResponse(){if(httpDest.readyState==1){if(typeof spinVal=="undefined"){loading.css("visibility","visible")}else if(spinVal=="1"){loading.css("visibility","hidden");spinVal=0}else{loading.css("visibility","visible")}}if(httpDest.readyState==4){loading.css("visibility","hidden");var result=eval("("+httpDest.responseText+")");if(result!=null){loadDestinationsData(result)}}}function loadDestinationsData(result){var destinations=eval(result);if(destinations==""||destinations==null){return}var sources=destinations.destinations;var prefDests=destinations.destPreferences;var toCityIdPreference=getPreference("toCityId");var toCityNamePreference=getPreference("toCityName");var destinationSelected=false;destList.options.length=0;var topDestalreaySet=false;var topPrefCityisSet=false;var destinationsList=[];var m=0;$("#DDLDestination").empty();if(prefDests!=null&&typeof prefDests.length!="undefined"&&prefDests.length>0){var prefNonDups={};for(var i=0;i<prefDests.length;i++){for(var j=0;j<sources.length;j++){var ss="";if(prefDests[i].cityId==sources[j].cityId){if(toCityIdPreference==prefDests[i].cityId&&toCityIdPreference==prefDests[i].cityName){ss="selected='selected'";topDestalreaySet=true}if(prefNonDups[prefDests[i].cityId]==null&&prefDests[i].cityId!=""){prefNonDups[prefDests[i].cityId]=prefDests[i].cityName;destinationsList[m++]="<option value="+prefDests[i].cityId+" "+ss+">"+prefDests[i].cityName+"</option>"}}}}}if(destinationsList.length>0){$("#DDLDestination").append("<optgroup style='font-style: normal;' id='mDestinations' label='Most frequented'></option>");for(var j=0;j<destinationsList.length;j++){$("#mDestinations").append(destinationsList[j])}}destinationsList=[];m=0;if(sources.length>5){var p=0;for(var i=0;i<sources.length;i++){var ss="";if(isPopularCity(sources[i].cityName)){if(!topDestalreaySet&&toCityIdPreference==sources[i].cityId&&toCityNamePreference==sources[i].cityName){ss="selected='selected'";topDestalreaySet=true}destinationsList[m++]="<option value="+sources[i].cityId+" "+ss+">"+sources[i].cityName+"</option>";p++}}if(p>0){$("#DDLDestination").append("<optgroup style='font-style: normal;width:160px;' id='tDestinations' label='Top destinations'></option>");for(var j=0;j<destinationsList.length;j++){$("#tDestinations").append(destinationsList[j])}}}destinationsList=[];m=0;for(var i=0,l=destList.options.length;i<sources.length;i++,l++){var ss="";if(!topDestalreaySet&&toCityIdPreference==sources[i].cityId&&toCityNamePreference==sources[i].cityName){ss="selected='selected'"}destinationsList[m++]="<option value="+sources[i].cityId+" "+ss+">"+sources[i].cityName+"</option>"}if(destinationsList.length>0){$("#DDLDestination").append("<optgroup style='font-style: normal;' id='aDestinations' label='All destinations'></option>");for(var j=0;j<destinationsList.length;j++){$("#aDestinations").append(destinationsList[j])}}if(destList.value==null){destList.options[0].selected=true}}function isPopularCity(a){if(popularCities[a]){return true}return false}function createRequestObject(){var a;if(window.ActiveXObject){xhttp=new ActiveXObject("Microsoft.XMLHTTP")}if(window.XMLHttpRequest){xhttp=new XMLHttpRequest}if(xhttp==null){alert("You are using an unsupported Browser. Please update it to the latest version. Thanks!")}return xhttp}function hideDiscoveryRoute(a){if(a.keyCode==27){hideRouteDiscovery()}}var httpDest;var httpSources;var httpSourceDestinations;var loading=$("#loading");var destList=document.getElementById("DDLDestination");var sourceList=document.getElementById("DDLSource");var destListcorp=document.getElementById("packageDestinations");var sourceListcorp=document.getElementById("packageSources");var calendar=document.getElementById("calendar");var calendarcorp=document.getElementById("packCal");var enteredDate="";var busType=document.getElementById("DDLBusType");var mfromCityId="";var commingFromIssueTicet=false;if($.browser.msie&&$.browser.version=="6.0"){$("#header").append("<div style='clear: both; height: 44px; padding:4px; font-size: 11px; position: absolute;color: #305AA0;cursor: pointer;text-decoration: none;width: 400px;left: 28%; top: 2%;background-color: #F0F0F0;'> <a href='http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?ocid=ie6_countdown_bannercode'>You are using an outdated browser. Many features on the website might not function correctly. <b>We strongly recommend that you upgrade your browser for a safe and better web browsing experience.</b></a></div>");if($.browser.msie){$("#callPhoneImg").css("margin-top",7)}}var fromCityIdInCookie;var fromCityNameInCookie;var toCityIdInCookie;var toCityNameInCookie;var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" ")c=c.substring(1,c.length);if(c.indexOf("fromCityId=")==0){fromCityIdInCookie=c.substring("fromCityId=".length,c.length)}else if(c.indexOf("fromCityName=")==0){fromCityNameInCookie=c.substring("fromCityName=".length,c.length)}else if(c.indexOf("toCityId=")==0){toCityIdInCookie=c.substring("toCityId=".length,c.length)}else if(c.indexOf("toCityName=")==0){toCityNameInCookie=c.substring("toCityName=".length,c.length)}}if(fromCityIdInCookie!=null&&fromCityIdInCookie!=""&&fromCityNameInCookie!=null&&fromCityNameInCookie!=""&&toCityIdInCookie!=null&&toCityIdInCookie!=""&&toCityNameInCookie!=null&&toCityNameInCookie!=""){var sourceList=document.getElementById("DDLSource");sourceList.options.length=0;sourceList.options[0]=new Option(fromCityNameInCookie,fromCityIdInCookie);sourceList.options[0].selected=true;var destList=document.getElementById("DDLDestination");destList.options.length=0;destList.options[0]=new Option(toCityNameInCookie,toCityIdInCookie);destList.options[0].selected=true}var popularCitiesList=["Ahmedabad","Bangalore","Chennai","Coimbatore","Delhi","Dharamsala","Ernakulam","Goa","Hyderabad","Indore","Jaipur","Jamnagar","Katra","Kodaikanal","Madurai","Mahabaleshwar","Manali","Mangalore","Mumbai","Nasik","Nainital","Pondicherry","Pune","Rajkot","Shirdi","Tirupati","Vijayawada"];var popularCities={};for(var i=0;i<popularCitiesList.length;i++){popularCities[popularCitiesList[i]]=true}var allSourceDestinations=null;if(typeof isFromSearchResult=="undefined"){onLoadFunctions()}$("#noRoute1").click(function(a){a.stopPropagation();$("#sourceDiscovery").val("From");$("#destinationDiscovery").val("To");$("#inventorEmail").val("E-mail (Optional)");$("#inventorPreferred").val("Mobile (Optional)");$("#sourceDiscovery, #destinationDiscovery, #inventorEmail, #inventorPreferred").css("color","#D0D0D0");if(!$.browser.msie){$("#destinationDiscovery").css("margin-left",25);$("#inventorPreferred").css("margin-left",25)}$("#showRecoveryDiv").show();$("#subSug1").show();$("#thanksMsg, #routeSearchMain").hide()});$("#sourceDiscovery").focus(function(){if($(this).attr("value")=="From")$(this).attr("value","")});$("#sourceDiscovery").blur(function(){if($(this).attr("value")==""){$(this).attr("value","From");$(this).css("color","#D0D0D0")}});$("#destinationDiscovery").focus(function(){if($(this).attr("value")=="To")$(this).attr("value","")});$("#destinationDiscovery").blur(function(){if($(this).attr("value")==""){$(this).attr("value","To");$(this).css("color","#D0D0D0")}});$("#inventorEmail").focus(function(){if($(this).attr("value")=="E-mail (Optional)")$(this).attr("value","")});$("#inventorEmail").blur(function(){if($(this).attr("value")==""){$(this).attr("value","E-mail (Optional)");$(this).css("color","#D0D0D0")}});$("#inventorPreferred").focus(function(){if($(this).attr("value")=="Mobile (Optional)")$(this).attr("value","")});$("#inventorPreferred").blur(function(){if($(this).attr("value")==""){$(this).attr("value","Mobile (Optional)");$(this).css("color","#D0D0D0")}});$("html").click(function(){$("#showRecoveryDiv").hide();$("#routeSearchMain").show()});$("#showRecoveryDiv").click(function(a){a.stopPropagation()})
