var routeDrawer = null;var internal = false;var mf = null;var searchOBJ  = null;var entireData = null;var LID=null;var count = 0 ;
var autoObj=null;
var autoFlag=false;
var amapObj=null;
var autoLog=false;
var recdone=false;
var tlayer = null;
var mlog = null;
var msearch = null;
var somaction = false;
var tipv = false; 
var dpclear = false;var aprocess = null;var vhover = null;var mwait = false;
(function($){   
 /*   $.fn.tipsy = function(options) {

        options = $.extend({}, $.fn.tipsy.defaults, options);
        
        return this.each(function() { 
            var opts = $.fn.tipsy.elementOptions(this, options); 
            $(this).focus(function() {                
                $("#layers").hide();                  
                if($('as-results-'+$(this).attr('id')).is(":visible")) return false;
                if($(this).val().length > 0) return;
                $.data(this, 'cancel.tipsy', true);

                var tip = $.data(this, 'active.tipsy');
                if (!tip) {
                    tip = $('<div class="tipsy"><div class="tipsy-inner"/></div>');
                    tip.css({position: 'absolute', zIndex: 100000});
                    $.data(this, 'active.tipsy', tip);
                }

                if ($(this).attr('title') || typeof($(this).attr('original-title')) != 'string') {
                    $(this).attr('original-title', $(this).attr('title') || '').removeAttr('title');
                }

                var title;
                if (typeof opts.title == 'string') {
                    title = $(this).attr(opts.title == 'title' ? 'original-title' : opts.title);
                } else if (typeof opts.title == 'function') {
                    title = opts.title.call(this);
                }

                tip.find('.tipsy-inner')[opts.html ? 'html' : 'text'](title || opts.fallback);

                var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight});
                tip.get(0).className = 'tipsy'; // reset classname in case of dynamic gravity
                tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
                var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight;
                var gravity = (typeof opts.gravity == 'function') ? opts.gravity.call(this) : opts.gravity;

                switch (gravity.charAt(0)) {
                    case 'n':
                        tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north');
                        break;
                    case 's':
                        tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south');
                        break;
                    case 'e':
                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east');
                        break;
                    case 'w':
                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west');
                        break;
                }

                if (opts.fade) {
                    tip.css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 0.8});
                } else {
                    tip.css({visibility: 'visible'});
                }
                tipv = true;
            }).blur(function() {
                  if(tipv) {$('.tipsy').fadeIn().remove();tipv = false;}
                  $.data(this, 'cancel.tipsy', false);
                  var self = this;
                  setTimeout(function() {
                    if ($.data(this, 'cancel.tipsy')) return;
                    var tip = $.data(self, 'active.tipsy');
                    if (opts.fade) {
                        tip.stop().fadeOut(function() {$(this).remove();});
                    }
                  }, 100);               
            });
            
        });
        
    };
    
    // Overwrite this method to provide options on a per-element basis.
    // For example, you could store the gravity in a 'tipsy-gravity' attribute:
    // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
    // (remember - do not modify 'options' in place!)
    $.fn.tipsy.elementOptions = function(ele, options) {
        return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
    };
    
    $.fn.tipsy.defaults = {
        fade: false,
        fallback: '',
        gravity: 'n',
        html: false,
        title: 'title'
    };
    
    $.fn.tipsy.autoNS = function() {
        return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
    };
    
    $.fn.tipsy.autoWE = function() {
        return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
    };*/
    
    $.widget("MMI.Layer", $.extend({},{

     "_init"    : function(){
         mf = $(this.element[0]).MarkerFactory();
         this.past = null;
         this.dirpast = null;
         this.dirholder = null;  
         this.elist = null;
         this.levelOrCenter = false;
         this.historyTracker = new Array();
         this.updateDesign(); 
         this.cScreen = null;  
         this.addtips = null;
         this.zoom_centerplay = false;
         if(this.options.action == null){
           this.options.action = $(this.element[0]);
           this.options.oapp.start.call(this.options.oapp,this.options.action);
         }
         this.pastlayout = null;
         this.loadMap();
         this.login = false;
         routeDrawer = new RouteDrawer(this.element); 
         this.resizePlayer();
     },
     
     "levelOrCenterStatus" : function(){
       return this.levelOrCenter;  
     },
     
     "setHistory"  : function(arg){
       if(this.historyTracker.length > 0){
          var pKey = this.historyTracker.pop();          
          this.historyTracker.push(pKey);          
          if(pKey != arg.param) this.historyTracker.push(arg.param); 
       } else {       
         this.historyTracker.push(arg.param);
       }
     },
     
      "zoomAndAction" : function(arg){
       if(arg.more){
         this.levelOrCenter = arg.more;
       } else {
         this.levelOrCenter = false;          
       }       
       if(!this.levelOrCenter || arg.slideup) $("#show_on_map_container").slideUp('fast',function(){$('#poi_on_map li').removeAttr('class');});
       if(!this.levelOrCenter || arg.csom) $("#show_on_map_container").find('input[type=checkbox]').attr({'checked' : false});
     },
     
     "loadPrompt" : function(arg){          
          if(this.elist == null){
            $.ajax({type: "GET",url: "epage.html",dataType: "xml",
              success: function(xml) { 
                 var that = L.Layer("getBuilder");
                 that.elist = xml;
                 that.showPrompt(arg);
              }
            });  
          } else {
            this.showPrompt(arg);  
          }
          try {
            $('#show_on_map_container').slideUp();
          }catch(e) {}
     },
     
     "showPrompt" : function(arg){
        var er = $('.error');
        var ed = $('.errorcon');
        var msg  = "";
        $(this.elist).find(arg.flag).each(function(){msg = $(this).text();});
        if(ed.is(':visible') && ed.is(':visible')){
           $('div[errorinfo]',ed).html(msg);
        } else {
           var build = [];
           build.push("<div class='errorcon' style='width:99%;'><div errorinfo=1 style='float:left;text-align:center;width:");
           var w = (er.length == 0) ? $('#header').width() : $('.error').width();
           build.push((w - 80));
           build.push("px;'>");
           build.push(msg);
           build.push("</div><div class='maplicon' id='eimg'></div></div>");
           var error = "<div class='error'></div>";
           $(error).appendTo('body').slideDown(400);
           $(build.join("")).appendTo('body').slideDown(400);
           $('#eimg').click(function(e){e.stopPropagation();L.Layer('removePrompt');});
        }
     },
     
 
     "removePrompt" : function(){         
          var er = $('.error');
          var ed = $('.errorcon');
          er.slideUp(400);
          ed.slideUp(400,function(){er.remove();ed.remove();});            
     },

     "dpastSetter"  : function(arg){
         
       if(this.dirpast == null || (typeof(arg.flush) != 'undefined' && arg.flush ))
       this.dirpast = new Array();                
       
       var i = this.dirpast.length;  
       if(i < (arg.index+1)){ 
         var len = arg.index;
         for(;i < len;i++){
           this.dirpast[i] = "";  
         }
       }
       
       if(typeof(arg.swap) != 'undefined'){
          var TO = this.dirpast[arg.from];
          this.dirpast[arg.from] = this.dirpast[arg.to];
          this.dirpast[arg.to] = TO;  
       }
       
       if(arg.content != "") this.dirpast[arg.index]=arg.content;
     },
     
     "buildpast" : function(arg){
       var TO = new mGeo();
       var TA = new Array();
       TA.push(arg.x);
       TA.push(arg.y);
       TO.search = arg.addr;
       TO.geo = TA.join("+");
       AC.release(TA);
       if(typeof(arg.setter) != 'undefined' && typeof(arg.swap) != 'undefined') this.dpastSetter({content : TO , index : arg.index , from : arg.from , to : arg.to});
       else if(typeof(arg.setter) != 'undefined') this.dpastSetter({content : TO , index : arg.index});
     },
     
     "getBuilder" : function(){
       return this;  
     },
     
     "getLayer" : function(){
       return this.options.oapp;  
     },
     
     "pointAndZoomUpdate" : function(arg){
        this.options.center = arg.center;
        this.options.zoom = arg.zoom;
     }, 
         
     "loadMap" : function() {        
      //  $(this.element[0]).MireoMap(); 
        var flag = this.exampleRequest();                
        this.element.MireoMap({center: this.options.center,zoomLevel: this.options.zoom}); 
        $(this.element[0]).MireoMap("setCenterAndZoomLevel", this.options.center,this.options.zoom); 
        var x = 4;
        if(som == '1') --x;
        for(;x < 7;x++) $(ALT.BODYLAYOUT[x]).show();
        $('div[zoomslider=1]',L).removeAttr('style').addClass('zoomSliderView').css({'zIndex' : 3});
        $('#mapControlCircle').show();
        
        this.resizePlayer();        
        if(helper == null) this.options.oapp.helper.call(this.options.oapp);
        if(typeof(flag) != 'undefined' && flag) this.options.oapp.preAction.call(this.options.oapp);                    
        
        this.addControls();
        if(typeof(fview) != 'undefined')this.addLocation({search : 'Location'});         
     },
     
     "updateWidth" : function(){
        var width = parseInt($(window).width()*panel);
        width = (width < 391) ? 391 : width;
        return width;
     },
     
     "resizePlayer" : function(){          
        var wheight = $(window).height();
        var wwidth  = $(window).width();        
        var holder = $(this.element[0]);
        var height = wheight - (this.options.top + this.options.bottom);
        height--;
        var width  = this.updateWidth();        
        var fMap   = false;
        holder.width((fMap) ? wwidth-2 : (wwidth - width-2));
        holder.height(height);
        $(ALT.TPANEL[0]).width(width+2);
        $(ALT.TPANEL[0]).height(height);
        $(ALT.BODYLAYOUT[1]).width(wwidth);
        $(ALT.BODYLAYOUT[4]).height(L.height());
        $(ALT.BODYLAYOUT[3]).width(holder.width());
        this.addShowOnMap();   
        AC.release(width);
        AC.release(height);
        AC.release(holder)
     },
     
     "pastprocess"  : function(){
        return this.past; 
     },
    
    "reverseLayer" : function(){
       if(tlayer != '' && tlayer != null && layer != tlayer )
          this.fireProcess({'view' : 1,method : 'GET', 'common' : true , 'search' : layer, 'q' : 'layer' , callback : function(response){
            tlayer = null;      
            L.Layer('getBuilder').layerhelp(response,false);     
          }});
     },
     
     "getPixel" : function(e) {
            var x = 0;var y = 0;
            if (e.pageX || e.pageY) {
                x = e.pageX + document.body.scrollLeft + document.documentElement.scrollLeft;
                y = e.pageY + document.body.scrollTop + document.documentElement.scrollTop;// - this.options.top;
            }else if (e.clientX || e.clientY){
                x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
                y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
            }
            var pt = new Point(x,y);
            return pt;
      },
     
     
     "layerhelpBinder" : function(arg){
         var that = this;
         if(typeof(arg.design) != 'undefined'){
           var TB = [];
           for(var i =0;i<arg.content.length ;i++){
            TB.push('<li>');
            TB.push(arg.content[i]);
            TB.push('</li>');
           }
           $("#layers").html(TB.join(""));
         }         
         if(mwait) mwait = false;    
         var layers = $('#gSearch .sdrop_bg');
         layers.unbind().bind('mouseenter click',function(e){
          e.stopPropagation();
          e.preventDefault();
          $('#gSearch .sdrop_opt').show().find('li').unbind().click(function(e){
              e.stopPropagation();             
              if(mwait) return;
              mwait = true;
              $('#gSearch .sdrop_opt').hide();
              //var help = $.data(layers,'helper');              
              var help = vhover;
              tlayer = $(this).text();
              $(this).remove();
              if(typeof(help) === 'undefined'){               
                $.ajax({type: "GET",url: 'sbar.html',dataType: "xml",success: function(xml) {
                   // $.data(layers,'helper',xml);   
                    vhover = xml;
                    that.layercontent({'xml': xml,both : true, 'menu' : 'bar', 'content' : 'help'});                   
                }});
              } else {
                that.layercontent({'xml': help,both : true, 'menu' : 'bar', 'content' : 'help'});  
              }
              help = null;              
          });
          $('.search_newsl','#gSearch').mouseleave(function(e){
              $('#gSearch .sdrop_opt').hide();
          });
         }); 
  
     },
     
     "layercontent" : function(arg){
          var that = this; 
          $(arg.xml).find(tlayer).each(function(){
              var TA = [];
              if(arg.both){ 
                TA.push('{ "help" : "');
                TA.push($(this).find(arg.content).text());
                TA.push('","search" :"');
                TA.push($(this).find(arg.menu).text());
                TA.push('","title" :"');
                TA.push($(this).find('title').text());
                TA.push('"}');
                that.layerhelpDesignBuilder(TA.join(""),true);               
              } else {
                $(this).find(arg.content);  
              }
          });  
       
     },
     
     "layerhelpDesignBuilder" : function(response,flag){
              var output = eval('('+response+')');
              if(flag)this.clearMap({});
              $(ALT.TPANEL[1]).html(output.help); 
              this.helper();
              
              var TA = new Array();
              TA.push($('.sdrop_bg','#gSearch').text());
              $('.sdrop_bg','#gSearch').html(tlayer);             
              $('#layers li').each(function(){ TA.push($(this).text()); });
              
              if(output.search){
                 document.title = output.title; 
                 $(".search_newf","#gSearch").remove();                 
                 var searchctx = output.search.split("|"); 
                 var TS = new Array();
                 for(var i=0;i<searchctx.length;i++){
                   var sbar = searchctx[i].split(":"); 
                   if(parseInt(sbar[3]) > 0 ){
                      TS.push('<div style="width:');
                      TS.push(sbar[3]);
                      TS.push('px" class="search_newf"><input type="text" onblur="txtBlur(this);" lang="default" class="tt_');
                      TS.push(sbar[0]);
                      TS.push('" mtip="');
                      TS.push(sbar[2]);
                      TS.push('" style="width:');
                      TS.push(parseInt(sbar[3]) - 10);
                      TS.push('px ');
                   } else {
                      TS.push('<div class="search_newf" >');
                      TS.push(' <input type="text" onblur="txtBlur(this);" lang="default" class="tt_');
                      TS.push(sbar[0]);
                      TS.push('" mtip="');
                      TS.push(sbar[2]);
                   }
                   TS.push('" id="');
                   TS.push(sbar[0]);
                   TS.push('" name="');
                   TS.push(sbar[0]);
                   TS.push('" /><span class="placeholder" onclick="getFocus(this);" id="ph_');
                   TS.push(sbar[0]);
                   TS.push('" >');
                   TS.push(sbar[1]);
                   TS.push('</span></div>');                   
                 } 
                 $(".sbutton_blue","#gSearch").before(TS.join(""));
                 //alert("#"+searchctx[i].split(":")[0]);
                 //$("#"+searchctx[i].split(":")[0]).focus();
                 //$("input[type=text]:first-child","#gSearch").focus();
                 this.searchBinder(true);
                 /*var file = null;
                 $('input[type=text]','#gSearch').each(function(){
                   $(this).tipsy({gravity: 'n',fallback: $(this).attr('mtip')});        
                   if($(this).attr('id') == 'isearch')
                      file = 'autocity.php';
                   else if($(this).attr('id') == 'movie') 
                      file = 'automovies.php';
                     
                   $(this).autoSuggest(file,{'asHtmlID':$(this).attr('id'),selectedItemProp:"addr",searchObjProps:"addr",selectedValuesProp:"link","resultsHighlight":false});  
                 });*/
              }
              this.layerhelpBinder({'design' : true , 'content' : TA , 'selected' : (flag) ? tlayer: layer});              
     },
     
     
     "searchBinder" : function(arg){
       
       var count = 0;
       var iStr = [];
       var searchParent = $('#gSearch');
       var that = this;
       var file = null; 
       //$('.tipsy').remove();
       $('input[type=text]',searchParent).each(function(){
             iStr.push($(this));  
             //$(this).tipsy({gravity: 'n',fallback: $(this).attr('mtip')});           
             if($(this).attr('id') == 'isearch') 
              file = 'autocity.php';
             else if($(this).attr('id') == 'movie')
              file = 'automovies.php';  
             
             $(this).autoSuggest(file,{'asHtmlID':$(this).attr('id'),selectedItemProp:"addr",searchObjProps:"addr",selectedValuesProp:"link","resultsHighlight":false});  
             
             
             //-- Sid ToolTip
             if($("#"+$(this).attr('id')).val() !=""){
                 $("#ph_"+$(this).attr('id')).hide();
             }
             
             /*if($(this).attr('id') == 'isearch'){
                 $(".tt_"+$(this).attr('id')).tipTip({maxWidth: "315px", edgeOffset: 1});BindTxtBox(); 
             }else if($(this).attr('id') == 'movie'){
                 $(".tt_"+$(this).attr('id')).tipTip({maxWidth: "200px", edgeOffset: 1});BindTxtBox(); 
             }*/
             if(typeof(arg) === 'boolean' && arg && count == 0) $(this).focus();
             count++;file = null;
             //----
       });  
       
       searchParent.unbind().bind('submit',function(e){  
             if(aprocess != null) aprocess.abort();
             aprocess = null;
             try {e.stopPropagation();}catch(e){}             
             try {
              //   $('.tipsy').remove();
                 $('#hisdiv').slideUp();
                 $('#sharediv').slideUp();
             } catch(e){}
             $('body').APL({action : 1});  
             var TA  = [];
             TA.push(BASE);
             var template = $('.sdrop_bg','#gSearch').text();    
             $('as-results').slideUp();  
             if(template == 'Maps'){              
               if(layer == 'Maps'){
                  app.autopass();                    
                  if(!autoFlag) M.MapLayer('search',{'process' : this , 'from' : layer});   
               } else {  
                 TA.push('#');   
                 if($('input[name=isearch]','#gSearch').val() == ''){
                   L.Layer('loadPrompt',{flag : 'e'+template});return false;    
                 } else {
                   TA.push($('input[name=isearch]','#gSearch').val());        
                 } 
                 window.location=TA.join("").replace(/\s/g,"+");
                 return false;
               }
             } else {                 
                var inBox = $('input[type=text]','#gSearch');                
                if(inBox.length > 1){                      
                     if(iStr[0].val() == '' && iStr[1].val() == ''){
                       $('body').APL({action : 0});L.Layer('loadPrompt',{flag : 'e'+template});return false;
                     } else if(iStr[0].val().length == 0 && iStr[1].val().length > 0){               
                       TA.push('movies+and+showtimes');
                     } else if(iStr[0].val().length >0 && iStr[1].val().length == 0){
                       $('body').APL({action : 0});L.Layer('loadPrompt',{flag : 'e'+template});return false;
                     } else if(iStr[0].val().length > 0 && iStr[1].val().length > 0){
                       TA.push('see+showtimes+and+book+tickets+for+');
                       TA.push(iStr[0].val().replace(/\//g,""));
                     }
                     TA.push('+in+');
                     TA.push($("#isearch",searchParent).val());    
                 } else if(iStr[0].val() == ''){  
                    $('body').APL({action : 0});L.Layer('loadPrompt',{flag : 'e'+template});return false;  
                 } else if(template == 'Deals'){
                   TA.push('Deals+and+offers+near+');
                   TA.push($("#isearch",searchParent).val());    
                 }                
                 TA.push(".html");  
                 setCookie("mlayer",$("#isearch",searchParent).val(), 1, "/");
                 window.location = TA.join("").replace(/(\s|, |,)/g,'+');                 
                 return false;
             }
         }); 
         
         $(this.element[0]).bind('contextmenu',function(e){ 
          e.stopPropagation();   
          e.preventDefault();          
          var holder = $('div[contextMenu=1]',this);
          if(holder.length == 1){
            that.contextView(e,holder);
            holder.show();  
          } else { 
            var cmenu = arg.refer.options.CONTEXT.split(",");
            var CA = [];CA.push("<div contextMenu='1' log='Right Click' class='map_rightclick' ><ul class='rclk'>");
            for(var i=0;i<cmenu.length;i++){
              var tmenu =cmenu[i].split(":");  
              CA.push("<li log='Right click-");
              CA.push(tmenu[1]);
              CA.push("' lang='");
              CA.push(tmenu[0])
              CA.push("' >");
              CA.push(tmenu[1]);
              CA.push("</li>");
              tmenu = null;delete(tmenu);
            }
            CA.push("</ul></div>");
            $(that.element[0]).append(CA.join(""));
            
            var cholder = $('div[contextMenu=1] ul li',this);            
            cholder.bind('click',function(e){
                e.stopPropagation();
                e.preventDefault(); 
                    $('.map_rightclick',M).hide();                    
                    var idx = $(this).attr('lang');
                    var zoom = null;
                    $('body').APL({action : 1});      
                    internal = false;var TA = [];TA.push(that.context.y);TA.push(that.context.x);
                    mlog = null;mlog = new com.mmi.logs();     
                    var url = L.Layer('currentUrl');
                    if(idx >= 0 && idx < 4){                        
                        mlog.setType($(this).attr('log'));
                        L.Layer('fireProcess',{process : {'search' : TA.join(","), 'common' : true, 'dis' : 1, 'q' : 101, 'idx' : idx}});  
                    } else if(idx == 4){ 
                        mlog.init($(this).attr('log'),TA.join(","),url,null);mlog.persist();
                        zoom = $(that.element).MireoMap("getZoomLevel"); 
                        $(that.element).MireoMap("setCenterAndZoomLevel", that.context,--zoom);
                        $('body').APL({action : 0});  
                    } else if(idx == 5){
                        zoom = $(that.element).MireoMap("getZoomLevel");   
                        $(that.element).MireoMap("setCenterAndZoomLevel", that.context,++zoom);  
                        mlog.init($(this).attr('log'),TA.join(","),url,null);mlog.persist();
                        $('body').APL({action : 0});  
                    } else if(idx == 6){                          
                        mlog.init($(this).attr('log'),TA.join(","),url,null);
                        if($('form[lang=203]',ALT.TPANEL[0]).length == 1){
                          var marker = $.data(L,'dragme');
                          M.MireoMap("moveMarker", marker,that.context);
                          that.spotDragPoint(that.context);
                          $.data(L,'dragme',marker);
                        } else {
                          that.spot({search : 'Add a Spot' , pt : TA.join("*"),menu : false});                        
                        }
		       // that.spot({search : 'Add a Spot' , pt : TA.join("*"),menu : false});                        
                    } else if(idx == 7){
                        mlog.init($(this).attr('log'),TA.join(","),url,null);
                        that.feedback({search : 'Feedback',pt : TA.join("*"),menu : false});                           
                    }  
            }); 
            that.contextView(e,$('div[contextMenu=1]',this));            
          }
         });

         this.helper(); 
     },
     
     "contextView" : function(e,holder){       
       var posX = e.clientX;
       var posY = e.clientY;
       var contentH = holder.height();
       var contentW = holder.width();
       var mapH = M.height();
       var mapW = M.width();
       var moff  = M.position();
       var left  = posX - moff.left;
       var top   = posY - moff.top;

       if(mapH < (top + contentH +10) && mapW < (left + contentW+10)){
          top -= contentH; 
          left -= contentW;
       } else if(mapH < (top + contentH +10) ){
          top -= contentH;
       } else if(mapW < (left + contentW+10)){
          left -= contentW; 
       } 

       M.MireoMap("expandEvent", e);
       this.context = e.dpt;          
       holder.css({'left' : left ,'top' : top ,'display' : 'block'});                    
   },
     
   "addControls"  : function(){
      var that = this;       
      $(that.element).bind('dblclick mousemove', {"C": that} , function(e) {           
           try {$('.otherOption').remove();}catch(e){}
           var flag = false;
           var pt = null;           
           if (e.type == 'dblclick') {               
               M.MireoMap("expandEvent", e);           
               var level = parseInt(M.MireoMap('getZoomLevel'));level--;
               M.MireoMap("setCenterAndZoomLevel", e.dpt,level);  
           } else if(e.type == 'mousemove'){
                
                var holder = $('div[contextMenu=1]',this);
                flag = holder.is(":visible");
                if(flag) {
                    var cMH = holder.height();
                    var cMW = holder.width();
                    var cMO = holder.offset();
                    var cML = cMO.left;
                    var cMT = cMO.top;
                    pt = that.getPixel(e);
                    if(pt.y < cMT && (cMT - pt.y) >= 30) {
                        holder.fadeOut();
                    }else if(pt.y > (cMT +cMH) && (pt.y - (cMT +cMH)) >= 30) {
                        holder.fadeOut();
                    } else if(pt.x < cML && (cML - pt.x) >=30) {
                        holder.fadeOut();
                    }else if(pt.x > (cML +cMW) && (pt.x - (cML +cMW)) >= 30) {
                        holder.fadeOut();
                    }                    
               }
            }
        });
       
       var logme = $('.top_signin a',ALT.BODYLAYOUT[0]); 
       logme.unbind().click(function(e){
          var idx = $(this).attr("lang");
          if(idx != '') {e.stopPropagation();e.preventDefault();}
          if(idx == '5') {
            that.lightShadow({holder : 'body',content : ""});  
            $(ALT.BODYLAYOUT[8]).show();
          }
       });
       
       $.ajax({type: "GET",url: 'sbar.html',dataType: "xml",success: function(xml) { vhover = xml;}});       
       
       this.layerhelpBinder({});
      
       var fmap = $(ALT.BODYLAYOUT[6]);
       $.data(fmap,'current', {'size':1,'panel': $(ALT.TPANEL[0]).width()});
       var TO = null;
       fmap.click(function(e){
          e.stopPropagation(); 
          if(that == null)  that = L.Layer('getBuilder');
          TO = $.data(fmap,'current'); 
          var current = this;
          var fval = "Minimise";
          if(TO.size == 1){
             that.cScreen = 0;
             TO.size = 0;             
             $(that.element[0]).width(that.options.width);            
             $(ALT.BODYLAYOUT[3]).width(that.options.width); 
             $(ALT.TPANEL[0]).animate({'width':0},300,function(){
                  $(this).hide();  
                  $(current).removeClass('fscr_left').addClass('fscr_right');
                  that.addShowOnMap();                                    
                  AC.release(current);               
            });  
            that.element.trigger('resize');
            fval = 'Maximize';
          } else {
             TO.size = 1;   
             that.cScreen = 1;
             $(current).removeClass('fscr_right').addClass('fscr_left').hide();//attr({'src' :'images/arrow.png'}).hide();             
             $(ALT.TPANEL[0]).show().animate({'width':TO.panel},300,function(){
                $(current).show();  
                $(that.element[0]).width(that.options.width - TO.panel - 2);
                that.element.trigger('resize');
                $(ALT.BODYLAYOUT[3]).width(that.options.width - TO.panel - 1);
                that.addShowOnMap();
                AC.release(current);
              });
          }
    
          $.data(fmap,'current',TO); 
          that.mbuildlog({'type' : fmap.attr('log'), 'value' : fval, 'url' : that.currentUrl(), 'auto' : null});
       });
       
       var fmenu = $('.lbottom a',ALT.BODYLAYOUT[1]);
       fmenu.click(function(e){         
         if($(this).attr('title') != 'Add a Spot'){              
            e.stopPropagation();
            e.preventDefault();            
            var select = new Object();select['idx'] = fmenu.index(this);select['elem']= this;select['layer']= layer;
            that.options.oapp.menufooterbar.call(that.options.oapp,select);
            AC.release(select); 
         }
       });
       
       var tmenu = $(ALT.BODYLAYOUT[0]).find('.right_link a');
       tmenu.click(function(e){
         e.stopPropagation();
         e.preventDefault();       
         var select = new Object();select['idx'] = tmenu.index(this);select['elem']= this;select['layer']= layer;
         that.options.oapp.menutopbar.call(that.options.oapp,select);
         AC.release(select);
       });
       
       $(document).click(function(e){ 
           e.stopPropagation();
           if(e.target.type != 'text' || e.target.type != 'checkbox'){
             $('.as-result').fadeOut();
           }{
           /*if(e.target.id != 'isearch' &&  e.target.id != 'movie') {
               $('.as-results').fadeOut();               
           }*/
           $('#layers').slideUp(); 
           
       });
       
       var mapcontrols = $('#panControlImageMap area');
       mapcontrols.unbind().bind('mouseenter mouseleave click',function(e){                                
           e.stopPropagation(); 
           var idx = mapcontrols.index(this);                      
           if(e.type == 'click'){                              
               if(typeof $('#panControlImageMap').attr('wait') != 'undefined') return;
               $('#panControlImageMap').attr({'wait': true}); 
               var cpx = M.MireoMap("patchDeg2Pixel",M.MireoMap('getCenter'));
               if(idx == 0){                 
               } else if(idx == 1){
                 cpx.x = parseInt(cpx.x) - parseInt(cpx.x /3);  
               } else if(idx == 2){
                 cpx.x = parseInt(cpx.x) + parseInt(cpx.x /3);  
               } else if(idx == 3){
                 cpx.y =  parseInt(cpx.y)- parseInt(cpx.y /3); 
               } else if(idx == 4){
                  cpx.y = parseInt(cpx.y)+ parseInt(cpx.y /3);
               }               
               M.MireoMap("moveCenterTo", M.MireoMap("patchPixel2Deg",cpx), 100);           
               $('#panControlImageMap').removeAttr('wait'); 
           } else if(e.type == 'mouseenter') {
              //that.dblClickAction=false;
           } else if(e.type == 'mouseleave'){
              $('#panControlImageMap').removeAttr('wait');
              //that.dblClickAction= true;
           }
        });
     },
     
     "getCenter"  : function(){
       var TA = [];
       TA.push('current:'+$(this.element[0]).MireoMap('getZoomLevel'));
       var center = $(this.element[0]).MireoMap('getCenter');
       TA.push(center.x);
       TA.push(center.y);
       return TA.join(" ");
     },     
     
     "generateQuery" : function(arg){         
       var TU  = window.location.toString();
       var TA  = null;
       var base = null;
       if(TU.match(/#/)){
          TA = TU.split("#");  
          base = TA.pop();
       } else {
          TA = []; 
          TA.push(TU);
          arg.current = true;
       }
       AC.release(TU);
       TA.push((typeof(arg.current) === 'undefined') ? base : this.getCenter());
       AC.release(base);
       return TA.join("#");
     },
     
     "destroyHoverMenu" : function(arg){
       $('.otherOption',arg.param).remove();  
     },
     
     "updateDesign" : function(){
        this.options.height = $(window).height();
        this.options.width  = $(window).width();           
        var holder = $(this.element[0]);
        var poifilter = $(ALT.BODYLAYOUT[3]);
        
        var height = this.options.height - (this.options.top + this.options.bottom);
        holder.height(height);
        var width  = this.updateWidth();
        //holder.width((fullscreen == 1) ? this.options.width-2 : (this.options.width - width-2));
        //holder.width(width);
        holder.height(height);
         
        $(ALT.TPANEL[0]).width(width);
        $(ALT.TPANEL[0]).height(height);
        $(ALT.BODYLAYOUT[1]).width(this.options.width);
        //$(ALT.BODYLAYOUT[5]).height(height);
        if(poifilter.length == 1){
         poifilter.width((this.options.width - width ) ); 
         this.addShowOnMap();
        }
     },
     
     "updateWidth" : function(){
        var width = parseInt(this.options.width*this.options.percentage);
        width = (width < 391) ? 391 : width;return width;
     },
     
     "clearMap" : function(arg){  
        $('#sharediv').slideUp();
        window.location.hash="";
        document.title=layer+" : MapmyIndia.com";        
        this.setPageLayout({result :{"content" : (typeof(arg.decode) != 'undefined' && !arg.decode) ? helper : this.callEncodeOrDecoder({index : 1 , param : helper})}, index :1});
        mf.MarkerFactory('removeOverlays');
        $('input[id=isearch]',"#gSearch").val("");
        var dragMe = $.data(L,'dragme');
        if(dragMe != null)dragMe.remove();
        this.removePrompt();        
        try {arg.callback();}catch(e){}
        AC.release(arg);
      
     },
     
     "setTitle" : function(arg){
       document.title = arg.param;  
     },
   
     "setUrl" : function(arg){
       if(arg.hash) {
         window.location.hash = arg.param;     
       } else {
         window.location = arg.param;  
       }       
     },
     
     "setTitleAndUrl" : function(arg){
       this.setTitle({param : arg.title});
       this.setUrl({param : arg.url , hash : arg.hash});
       AC.release(arg);
     },

     "feedback" : function(arg){
       var that = this; 
       mf.MarkerFactory('removeOverlays');
       this.hideDragMarker();       
       $.extend(arg,{method : 'POST', 'view' : 1, common:true, q : 401,callback : function(response){   
         that.setPageLayout({index : response.container,result : {content : response.content},callback : function(){
            that.setTitle({param : arg.search});
            var dom = $("#loc",ALT.TPANEL[2]);
            if(dom.length  == 1 && dom.text() != ""){
              mlog.setValue(dom.text());mlog.persist();dom = null;
            }
         }});
       }});
       this.fireProcess(arg);        
     },
     
     "spot" : function(arg){
       var that = this; 
       
       $.extend(arg,{method : 'POST', 'view' : 1,common:true, q : 401,callback : function(response){
         that.setPageLayout({index : response.container,flag : 1,result : {content : response.content}, callback : function(){
         mf.MarkerFactory("removeOverlays");        
         that.setTitle({param : arg.search});
         var gvalue = $("input[name=geo]",ALT.TPANEL[3]).val();
         var pt = null;
         if(gvalue.length > 0){
           var TA = gvalue.split("*");  
           pt = new Point(parseFloat(TA[1]),parseFloat(TA[0]));  
         } else {
           pt = L.MireoMap('getCenter');  
         }
         
         var webMenu = $(".webMenu span");   
         var addPlace  = $('.add_placef_add');                           
         webMenu.unbind();addPlace.unbind();        
         webMenu.click(function(e){
         e.stopPropagation();
         var index = webMenu.index(this);                              
         addPlace.each(function(){
            var idx = addPlace.index(this);
            if(idx == index){
             var tholder =  this;
             $(tholder).removeClass('addWeb');
             $('.add_place_close',this).click(function(){
               $(tholder).addClass('addWeb');
               $(this).unbind();
               AC.release(tholder);
             });return;  
            }
          AC.release(idx);
         });
        });
        
        var contacts = $(".add_placef:nth-child(2)","#options");
        contacts.unbind();var canchor  = contacts.find('a');canchor.unbind();
        var canchorHTML = canchor.html();
        canchor.click(function(e){
           e.stopPropagation();
           e.preventDefault();
           var inputs = contacts.find(ALT.HFORM[0]);
           if(inputs.length <= 3){
            $(this).before('<input class="add_place_input_phone" name="tel" type="text">');
            $(this).html( (inputs.length < 3) ? canchorHTML : "" );
           }    
        });
        
/*        that.dragMarker({flag:1,point : pt ,callback: function(response){
           $('body').APL({action : 1});
           var TA = [];TA.push(response.y);TA.push(response.x);
           that.fireProcess({search : TA.join(","),q : 500,view : 1 , common :true, method : 'GET' ,callback:function(input){
               $('input[name=geo]',ALT.TPANEL[3]).val(TA.join("*"));
               var rvse = eval('('+input+')');   
               $('textarea[name=stt_nme]',ALT.TPANEL[3]).html(rvse['childList'][0].list.addr);   
               $('body').APL({action : 0});AC.release(rvse);            
               var mlog = null;mlog = new com.mmi.logs();
               mlog.init('Drag Spot Marker',rvse['childList'][0].list.addr,that.currentUrl(),null);               
               mlog.persist();
           }});
         }}); */ 
  
         that.dragMarker({flag:1,point : pt ,callback: function(response){
             that.spotDragPoint(response);
         }});       

         if($.trim($('textarea[name=stt_nme]',ALT.TPANEL[3]).html()).length > 0){
           mlog.setValue($('textarea[name=stt_nme]',ALT.TPANEL[3]).html());               
           mlog.persist();
         }
     
       }});
      }});
      this.fireProcess(arg);
     },
     
   "spotDragPoint" : function(arg){
        $('body').APL({action : 1});
        var TA = [];TA.push(arg.y);TA.push(arg.x);        
        this.fireProcess({search : TA.join(","),q : 500,view : 1 , common :true, method : 'GET' ,callback:function(input){
               $('input[name=geo]',ALT.TPANEL[3]).val(TA.join("*"));
               var rvse = eval('('+input+')');   
               $('textarea[name=stt_nme]',ALT.TPANEL[3]).html(rvse['childList'][0].list.addr);   
               $('body').APL({action : 0});AC.release(rvse);            
               var mlog = null;mlog = new com.mmi.logs();
               mlog.init('Drag Spot Marker',rvse['childList'][0].list.addr,that.currentUrl(),null);               
               mlog.persist();
           }});
     },   
     
     "getHistory" :  function(){
       return this.historyTracker;
     },
     
     "fireProcess" : function(arg){
        var TA = new Array(); 
        $('.as-results').hide();
        if(typeof(arg.callback) == 'function'){
          arg['layer']=layer;  
          if(arg.loading) $('body').APL({action : 1});            
          var method   = arg.method;
          var callback = arg.callback;              
          delete(arg.method);delete(arg.callback);delete(arg.custom);delete(arg.loading);  
          if(arg.view == 1 && typeof(method) == 'undefined' ){
           aprocess = $.getJSON(ALT.PROCESSOR[1]+"?"+$.param(arg), function(response){callback(response);});
          } else if(method=='POST'){ 
           aprocess = $.ajax({type: 'POST',url: ALT.PROCESSOR[1],data:  $.param(arg),success: function(response){callback(response);},dataType: (typeof(arg.view) == 'undefined') ? XML : "json"});
          } else {    
           aprocess =  $.ajax({type: method, url: "layer.html?"+$.param(arg),dataType: (typeof(arg.view) == 'undefined') ? XML : "text" , success: function(response) {callback(response);}}); 
          }
        } else if(arg.flag == ALT.DTYPES[5]){ 
           arg.process.layer = layer;  
           TA.push(ALT.PROCESSOR[0]);
           TA.push($.param(arg.process));
           this.past = arg.process;
           $(this._hireViaFrame({src : TA.join("?")})).appendTo(this.element[0]);           
         } 
        AC.release(TA);
     },
     
     "loading" : function(arg){
       var pview = $("#pview");  
       if(arg.idx == 0){
          if(pview.length == 0){
              
          }  
       } else if(arg.idx == 1){
          pview.remove(); 
       } 
     },
     
     "_hireViaFrame" : function(arg){      
        var TA = new Array();
        TA.push('<iframe height=0 width=0 id=lframe marginwidth=0 marginheight=0 scrolling=no src=');
        TA.push(arg.src); 
        TA.push("></iframe>");
        return TA.join("");    
     },
     
     "fireFrame"   : function(callback){
       $("iframe[id=lframe]",this.element[0]).remove();  
       if(callback && typeof(callback) === "function") {
         callback();
       }
     },
      
     
     "_setCenterAndZoomMap" : function(pt,NL,T){
        var CL = $(this.element).MireoMap("getZoomLevel");
       // alert(CL);
        /*if(T != ALT.PARAM_NL && typeof(T) != ALT.PARAM_UN ) {
            switch(T) {
                case 4 :CL -=1;break;
                case 5 :CL +=1;break;
            }
            if(T == 4 || T == 5) {this.buildLog();}
            NL = CL ;CL = ALT.PARAM_NL;
        }*/
        if(CL == NL || NL == ALT.DTYPES[5] || typeof(NL) === ALT.DTYPES[3])
           $(this.element).MireoMap("moveCenterTo", pt);
         else
           $(this.element).MireoMap("setCenterAndZoomLevel", pt,NL);
     },
     
     "isAlternates" : function(arg){
        var res = arg.result;
        var n   = res.length;
        var output = new Object();
        if(n > 0){
          var i = 0;
          var ilist = res[i++].list;
          output.alternate = (ilist.type == "exact") ? false : true;
          var others = [];
          i = (output.alternate) ? 0 : 1;
          output.eloc = (typeof(ilist.eloc) === "undefined") ? null : ilist.eloc ;
          
          for(;i<res.length;i++){others.push(res[i].list.addr);} 
         
          if(!output.alternate){
              ilist.z = parseInt(ilist.z);
              ilist.z = (ilist.z == 11 || ilist.z == 9) ? ilist.z + 1 : ilist.z;
              output.zoom  = 16 - ilist.z;
              output._addr = ilist.addr;
              output.point = new Point(ilist.x,ilist.y);
              if(typeof(arg.plot) != 'undefined' && layer == 'Maps')  $(this.element).MireoMap("setCenterAndZoomLevel", output.point,output.zoom);
              ilist = ALT.PARAM_NL;delete(ilist);
              AC.release(ilist);
          }
          output.list  = others;
          AC.release(output);
        }
        AC.release(res);
        AC.release(n);
        return output;
     },
     
     "addShowOnMap" : function(arg){
         var that   = null;
         var pHolder = $(ALT.BODYLAYOUT[3]);
         var list   = pHolder.find('li').length;
         var width  = pHolder.width();
         var end    = null;
         var start  = 0;
         if(typeof(arg) != ALT.DTYPES[3]){
           end    = arg.end;
           start  = arg.start;
         }
         
        
         if(width > 1500) {
            end   = list.length;
            pHolder.find('span').hide();
         } else {
            pHolder.find('span').show();
            var len  = parseInt(width / 110);
            var diff = 0;
            if(start > 0 && end == null) {
               var temp  = start+len;
               var total = list.length;
               if(temp > total){
                  diff  = temp - total;
                  start = total - len;
                  end   = total;
               } else {
                  end = temp;
               }              
            }else if(end != null) {
                if(end%len != 0) {
                  temp = parseInt(end%len);
                  end += 1;
                }
                start = end - len;
            } else {
                end = len; 
            }
            var poi_on_map_span = $('#poi_on_map span')
            poi_on_map_span.unbind();
            poi_on_map_span.bind('click',function(e){
                 e.stopPropagation();
                 if(that == null) that = L.Layer('getBuilder');
                 var move = parseInt($(this).attr('lang'));
                 $('.poi_on_map_content').slideUp('fast');
                 pHolder.find('.active li').removeAttr('class');
                 if(move == 0){
                    var tend = (end - len + diff);
                    if(tend >= len )
                    that.addShowOnMap({'end' : tend}); 
                 } else if(move == 1){
                    if(end >= list) return;
                    that.addShowOnMap({'start' : end});
                 }
                 AC.release(move);
            });
         }
         var holder = $('#poi_on_map li'); 
         if(start == 0 && end == list.length ){
               pHolder.find('span').hide(function(){
                  $(this).unbind();
                  holder.show();
              });  
         } else { 
            holder.each(function(){
                 var index = holder.index(this);
                 if(index >= start && index  < end )
                    $(this).show('slow');
                 else
                    $(this).hide('fast');
                });
         }
         AC.release(arg);
         AC.release(start);
         AC.release(end);
         AC.release(list);
         AC.release(holder);

         holder.unbind();
         holder.click(function(e){
            e.stopPropagation(); 
            if(that == null) that = L.Layer('getBuilder');
            var select = new Object();select['idx'] = holder.index(this);select['elem']= $(this).text();select['layer']= layer;select['evt'] = $(this);
            that.options.oapp.showonmap.call(that.options.oapp,select);
            AC.release(select);AC.release(that);
         });
     },
     
     "lightShadow"  : function(arg){
        var content = arg.content;         
        var lbox = '<div id="lightShadow"></div><div align="center" class="lightContainer" id="lightContainer">'+content+'</div>';
        $(arg.holder).append(lbox); 
        
        $(document).keyup(function(e){
            if(e.which == 27){
              if($("#lightShadow").length == 1){
                var la  = ["#mshare_cont",ALT.BODYLAYOUT[8]];
                for(var i = 0;i<la.length;i++){
                  var holder = $(la[i]).find('.closebox');
                  holder.each(function(){
                   closeMe($(this));     
                  });
                }
              }
            }
        });
     },

     "getValue" : function(arg){
        var elem = ALT[arg.key];
        if($.isArray(elem) && arg.index > -1){
          elem = elem[arg.index];  
        } 
        return elem;
     },
     
     "callEncodeOrDecoder" : function(arg){
        if(arg.index == 0){
            return Base64.encode(arg.param);
        }else if(arg.index == 1){
            return Base64.decode(arg.param); 
        } 
     },
     
     "exampleRequest" : function(){
        return this.options.oapp.example.call(this.options.oapp);
     },
     
     "altBinder" : function(arg){
        var that = this; 
        var alter = $('ul[alternate=1] li span',ALT.TPANEL[1]);
        alter.unbind().click(function(e){
          e.stopPropagation();
          var TO = new mGeo();
          TO.q = arg.service;
          TO.common = true;
          TO.alternate = true;          
          if(arg.service >= 100 && arg.service < 200){
            TO.search = $(this).text();     
            TO.q  = (arg.service > 100 ) ? 100 : 100;
          } else if(arg.service >= 200 && arg.service < 300){
            var TB = that.pastprocess(); 
            if(TB != null){
              var temp = TB.search.split("*");
              temp.pop();temp.push($(this).text());
              TB.search = temp.join("*");
              TO = TB;
            }
          } 
          that.postprocess({'param': TO});
       });       
     },
     
      "showDirection" : function(arg,callback){
        var holder = $("#shortdir");               
        if(holder.height() > 0){
          holder.html("");
          holder.html(this.m300layout(arg));
          if(typeof(arg.binder) != "undefined" && arg.binder ){
            $('div[swapContainer=1]').show();
            L.Layer('m300Binder',{param : 0});          
          }              
        } else {
          holder.html("");
          holder.css({'border-bottom': '1px solid #CCC','margin-bottom' : '10px','display' : 'none'});
          holder.html(this.m300layout(arg));
          holder.slideDown(400,function(){
            $('div[swapContainer=1]').show();
            L.Layer('m300Binder',{param : 0});
         }); 
         
        }
        if(typeof(callback) != 'undefined') callback();
     },
     
     "shortcut" : function(arg){
          var that = this;
          var sshort = $('form[id=sshortcut]',arg.holder);
          var elem   = $.data(arg.holder,"service");
          sshort.unbind().submit(function(e){
            e.stopPropagation();
            e.preventDefault();
            var bval=$('input[name=B]',this).val(); 
            if($.trim(bval).length == 0){
              L.Layer('loadPrompt',{flag : 'e_200'});
            } else {
              var action = $(this).attr('lang');
              if(action == 200){
                if(bval != ''){
                  var TO = new mGeo();
                  TO.q = 200;;TO.common = true;
                  var TA=[];TA.push($('input[name=B]',this).val());TA.push(elem._addr);
                  TO.search = TA.join("*");TA = null;TA = [];
                  TA.push(elem.point.y);TA.push(elem.point.x);
                  TO.geo = L.Layer('callEncodeOrDecoder',{param : TA.join("+"), 'index' : 0});
                  that.postprocess.call(that,{param : TO , 'direct' : false});
                }    
              } else if(action == 300){
                 L.Layer('dirAction',arg.holder); 
              }
              TA = null;TO = null;action = null;            
            }
            return false;          
          });  
     },
     
     "m300layout" : function(arg){
        var TA = new Array();
        var param = arg.param;
        var len = param.length;
        TA.push("<div id='routeSearch'");
        if(!arg.show) TA.push("style='display:none' ");
        TA.push(" ><div swapContainer='1' class='swapContainer' style='");        
        TA.push((arg.close) ? "display:none;'>" : "' >");
        for(var i=0;i<len-1; i++)TA.push('<div class="maplicon swap_dir"></div>');
        TA.push('</div>');

        TA.push('<div class="dirback_gstrip"><div class="dirback_gstrip_heading" > Get Driving Directions </div>');        
        if(arg.close){
           TA.push('<div lang="shortdir" align="right" onclick="parent.closeMe(this);" title="close" alt="close" class="maplicon closebox" react=1></div><div class="cls"></div>');            
        }else {
           TA.push('<div class="cls"></div>');
        }
        
        TA.push('</div><form name="sSearch" lang="300" id="sshortcut" action="" target="gError" onSubmit="return validateDir(this);" ><div id="dirBuilder">');

        for(i=0;i<len; i++){
            TA.push('<div class="dir_scont" dirSearch="');
            TA.push(i);
            TA.push('" ><div class="dir_ricon_new maplicon dposition_');
            if(i==0){
               TA.push('start"');
            } else if(i> 0 && i < param.length -1){
               TA.push(i);
               TA.push('" ');
            } else if(i == param.length-1){
               TA.push('last" ');
            }
            TA.push('></div>');
            TA.push('<div class="sidebar_search_sbg" style="margin-left:10px" ><input name="" type="text" value="');
            TA.push((typeof(param[i]) === "object") ? param[i]._area : param[i]);
//            TA.push((typeof(param[i]) === "object") ? param[i]._area : ((param[i].split("["))[0]).trim());
            
            TA.push('" id="dirauto');
            TA.push(i);
            TA.push('" class="search_txt_sml" onblur="txtBlur(this);" style="padding-right:20px;width:238px" />');
                
            TA.push('<span class="placeholder_dir" onclick="getFocus(this);" id="ph_dirauto');
            TA.push(i);
            TA.push('" >');
            
            if((param[i]._area =="" ||typeof(param[i]._area =="undefined") ) && param[i]==""){
                TA.push("Enter location or place name");
            }
            TA.push('</span>');
            
            TA.push('<div title="close" alt="close" react=1 class="maplicon closebox dbox" ');
            if(len == 2) TA.push(' style="display:none" ');
            TA.push('></div>');
            TA.push('</div><div class="cls"> </div></div><div class="cls"> </div>');
       }
       TA.push('</div><div class="add_via"><div class="via_ad"><div class="add_via_option"><a href="" ');
       if(param.length > 4){
         TA.push(' style="display:none" ');
       }
       TA.push(' > + Add Via</a></div><div class="add_via_option_btn"><input type="submit" title="GO" style="padding:4px" class="button_share" value="GO"></div></div><div class="cls"> </div></div></form></div>'); //<div id="dirMenu"> << Edit Route</div>
       return TA.join("");
     },
     
     "m300AddVia" : function(arg){
        var container = $('div[dirSearch]');
        var len = container.length;               
        if(len < 5) {                    
            var TT = new Array();//this.shortView().MMI('swapM300Element',(len-1));// var before = this.shortView().MMI('getM300');
            TT.push('<div style="padding-left:10px" dirSearch="');
            TT.push(len-1);
            TT.push('" ><div class="dir_ricon_new maplicon dposition_');
            TT.push(len-1);
            TT.push('"></div><div class="sidebar_search_sbg" style="margin-left:10px" ><input name="" onblur="txtBlur(this);" type="text" value="');
            try {if(typeof(arg) != ALT.DTYPES[4]) TT.push(arg.param);} catch(e){}
            TT.push('" class="search_txt_sml" style="padding-right:20px;width:238px" /><span class="placeholder_dir" onclick="getFocus(this);" >Enter location or place name</span><div title="close" react=1  alt="close" class="maplicon closebox dbox"></div></div><div class="cls"></div></div>');
            var processor = $("div[dirSearch]:last").attr({'dirSearch' : len});
            $(TT.join("")).css({'display' : 'none'}).insertBefore(processor).slideDown(400,function(){
               $('div[swapcontainer]').append('<div class="maplicon swap_dir"></div>');              
               L.Layer("dpastSetter",{content : '', 'swap' : true , from : len-1 , to : len , index : len , "setter" : true});
               var count = 0;
               $('.search_txt_sml','#dirBuilder').each(function(){$(this).attr({'id': 'dirauto'+(count++)});});
               
               var pht=0;
               $('.placeholder_dir','#dirBuilder').each(function(){$(this).attr({'id': 'ph_dirauto'+(pht++)});});
               
               L.Layer('m300SwapBinder');
            });
            
            $('.sidebar_search_sbg .closebox').each(function(){$(this).fadeIn('fast');});
            $('.sidebar_search_sbg .closebox').unbind();
            
            this.closeDirText();
            if(container.length == 4) $('.add_via a').fadeOut();
        }
       AC.release(len);
       AC.release(container);
      },
      
     "m300SwapBinder"  : function(){
          $('.swap_dir').unbind();
          $('.swap_dir').bind(ALT.EVT[0] , function(e){ 
              e.stopPropagation();
              var idx = $('.swap_dir').index(this);
              var tpx = idx; //-- Sid
              L.Layer("dpastSetter",{content : '', 'swap' : true , from : idx , to : (parseInt(idx) + 1) , index : idx});
              
              var holder = $("#dirBuilder input[type=text]");
              var temp = $(holder[idx]).val();
              $(holder[idx]).val($(holder[++idx]).val());
              $(holder[idx]).val(temp);AC.release(temp);
              AC.release(holder);AC.release(idx); 
              
              //--- TxtBox Inner Text -- Sid
              if($("#dirauto"+tpx).val()==""){
                 $("#ph_dirauto"+tpx).html("Enter location or place name");
                 $("#ph_dirauto"+tpx).show();
              }else{
                  $("#ph_dirauto"+tpx).hide();
              }
              var tpy=tpx+1;
              if($("#dirauto"+tpy).val()==""){
                 $("#ph_dirauto"+tpy).html("Enter location or place name");
                 $("#ph_dirauto"+tpy).show();
              }else{
                  $("#ph_dirauto"+tpy).hide();
              }
              
             //----------- 
              
          });
         
         var container = $('.sidebar_search_sbg .closebox'); 
         for(var x= 0;x <container.length;x++)
         $("#dirauto"+x).unbind().autoSuggest("autocity.php",{'asHtmlID':"dirauto"+x,selectedItemProp:"addr",searchObjProps:"addr",selectedValuesProp:"link","resultsHighlight":false});   
      },
      
      "closeDirText" : function(){
        var container = $('.sidebar_search_sbg .closebox');
        var flag = ALT.BOOL[0];
        var len = container.length;
        if(len > 2){
            container.unbind();
            container.bind(ALT.EVT[0],function(e){
                e.stopPropagation();
                if(flag == ALT.BOOL[0]){
                    var idx = container.index(this);
                    flag = (container.length == 2) ? ALT.BOOL[1] : ALT.BOOL[0];
                    if(flag == ALT.BOOL[0]){
                       $('.swap_dir:last').fadeOut('fast').remove();
                       $('div[dirSearch='+idx+']').slideUp(500,function(){
                           $(this).remove();
                           L.Layer("dpastSetter",{content : '', 'shift' : true ,index : idx});
                           var len = $('.sidebar_search_sbg .closebox').length;
                           if(len == 2)container.unbind().hide();
                           var temp = $('.sidebar_search_sbg .closebox');
                           temp.each(function(){
                                var id = temp.index(this);
                                var cholder = $(this).parent().parent();
                                cholder.attr('dirSearch',id);
                                var TP = cholder.children(':first-child').removeAttr('class');
                                if(id==0){
                                    TP.addClass('dir_ricon_new maplicon dposition_start');
                                } else if(id> 0 && id < len-1){
                                    TP.addClass('dir_ricon_new maplicon dposition_'+id);
                                } else if(id == len-1){
                                    TP.addClass('dir_ricon_new maplicon dposition_last');
                                }
                                AC.release(id);
                                AC.release(cholder);
                                AC.release(TP);
                            });
                            $('.add_via a').fadeIn();
                       });    
                      }else {
                         container.each(function(){$(this).hide();});
                      }
                      AC.release(idx);
                   }
               });
          }
          AC.release(flag);              
      },
     
     "parentRefresh" : function(){
       if($(ALT.BODYLAYOUT[8]).is(ALT.FLAGS[0])) $(ALT.BODYLAYOUT[8]).fadeOut();
       window.location.reload();  
     },
      
     "closebox" : function(arg){
        if(arg.load == 0){            
          $(arg.container).hide();          
        } else if(arg.load == 1){          
          /*var t = this.pastlayout;
          this.pastlayout = null;
          $(arg.container).hide().html('');  
          $(ALT.TPANEL[1]).show();
          
          if(t != null){
             if($.isArray(t)){
               this.dirInAction(t);
             }  else {
               this.calculate(t);
             }
          }*/
          
          this.options.oapp.history.call(this.options.oapp,{param : this.historyTracker,'action' : 0 ,'load' : arg.load});  
          this.pastlayout = null;
          if(!dpclear) $(arg.container).hide().html('');  
          $(ALT.TPANEL[1]).show();
          dpclear = false;
        } else if(arg.load == 2) { 
          $(arg.container).remove(); 
        }else if(arg.load == 3){
          $(arg.container).hide();          
          if($('.logun_box_reg',ALT.BODYLAYOUT[9]).length == 1)$(ALT.BODYLAYOUT[8]).remove('style');          
          $(ALT.BODYLAYOUT[9]).remove();          
          $(ALT.BODYLAYOUT[7]).remove();
        } else if(arg.load == 4){ //login section
          this.closebox({container : arg.container, load : 3});
          this.parentRefresh(); 
        } else if(arg.load == 5 ){
          $(arg.container).fadeOut().remove();
          this.options.oapp.history.call(this.options.oapp,{param : this.historyTracker,'action' : 0,'load' : arg.load});  
          $('#lightContainer').remove();
          $(ALT.BODYLAYOUT[7]).remove();
        } else if(arg.load == 8){         
          $(arg.container).slideUp(400);  
        } 
        this.hideDragMarker(); 
     },
     
     "poiDesignInner" : function(arg,TO,i){         
        var TA = new Array(); 
        var distance = 0;
        if(arg.byDistance){
           if(TO.distance > 0){ 
            if(parseInt(TO.distance/1000) < 1){  
                distance = parseInt(TO.distance) + " Mt.";
            } else {
                distance = parseInt(TO.distance/1000).toFixed(1) + " Km.";
            }
           }
        }
        delete(TO.id);delete(TO.zone);  
        TA.push("<li><table border='0' width='100%'><tr><td class='poiOpt' width='38'><div class='bgpoi ");
        if(arg.markByColor){
            TA.push(" marker_");
            TA.push(TO.code.substr(0,2));
        } else {
            TA.push(" marker_default");    
        }
        TA.push("'>");
        if(arg.markByNum){
            TA.push('<div class="poi_numAlign">');  
            TA.push(i+1);
            TA.push('<div>')
        }
        TA.push("</div></td><td>") ;
        TA.push(this.poiWrapper({request: TO,distance :distance ,enroute : arg.enroute}));          
        TA.push("</td></tr></table></li>"); 
        return TA.join("");
     },
     
      "poiDesign" : function(arg){
         var TA = new Array(); 
         var enrouteArr = null;
         var i = arg.start;
         var end = arg.end;
         var res = arg.result;         
         if(arg.enroute){
             enrouteArr = arg.cats.split(",");            
             for(var x = 0; x < enrouteArr.length; x++){
                var TB = [];                 
                TB.push('<div class="poicontent enroute" lang="'); 
                var temp = enrouteArr[x].split(":");              
                TB.push(temp[1]);
                TB.push('"><ul>');  
                var counter = 0;   
                mf.MarkerFactory('enRouteOrganise',{cat : temp[1]});
                
                for(i=arg.start;i<arg.end;i++) {
                  var TO = res[i];
                  if(TO.code == parseInt(temp[1]) || TO.code.substr(0,2) == parseInt(temp[1])){
                    if(TO.code == parseInt(1001)) TO.code = '1301';
                    
                    TB.push(this.poiDesignInner(arg,TO,counter));
                    mf.MarkerFactory('subEnroute',TO,temp[1],counter++); 
                  }
                }                
                TB.push("</ul></div>");
                TA.push(TB.join(""));               
             }             
         } else {               
           var xArr  = null;var yArr = null;  
           TA.push('<div class="poicontent"><ul>'); 
           var cond = (typeof(arg.skipcond) === 'undefined') ? false : true;
           if(!cond){
             for(var t = 0; t < res.length ;t++){                
               if(t >= i && t < end) continue;
               mf.MarkerFactory('multiMarker',arg,t);  
             }
           }
           
           if(arg.bounds){xArr  = new Array();yArr  = new Array();}                    
           for(;i<end;i++) {
             TO = res[i];
             TA.push(this.poiDesignInner(arg,TO,i));
             if(arg.bounds){
              xArr.push(TO.x);
              yArr.push(TO.y);  
             } 
             if(typeof(arg.enroute) === 'undefined') mf.MarkerFactory('multiMarker',arg,i);              
           }          
           
           TA.push("</ul></div>");            
           if(arg.bounds) {
             var maxX = Array.max(xArr);
             var maxY = Array.max(yArr);
             var minX = Array.min(xArr);
             var minY = Array.min(yArr);
             M.MireoMap("setBounds", {x1: minX, x2: maxX, y1: minY, y2:maxY});
           }
           
           M.MarkerFactory('bindMarkers',arg);
         }
         return TA.join("");
      },
      
      "poiWrapper"  : function(arg){
          var TA = [];
          TA.push("<table border=0 class='poi_desc' width=100% cellSpacing=0 cellPadding=4>") ;
          TA.push(this.getPoiLayout(arg));          
          TA.push("</table>");
          return TA.join("");
      },
     
      "getPoiLayout" : function(arg) {
           var param = arg.request;
           var distance = arg.distance;  
                     
           var TA = new Array();           
           var TB = new Array();          
          
          
           if(typeof(param['poiName']) != 'undefined' && typeof(param['eloc']) != 'undefined' &&  param['poiName'] != null && param['eloc'] != null && param['eloc'].length > 0) {
             TB.push("<tr><td><a class='poi_heading' target='_blank' href='http://mapmyindia.com/@1' title='@2 and Spot ID @1'>@2</a><span> [<a href='http://mapmyindia.com/@1' title='Spot ID of @2' target='_blank' >@1</a></span>]");
             
             if(distance != null && distance.length > 0) {
                 TB.push("<span class='poi_distance'>(");
                 TB.push(distance);
                 TB.push(")</span>");
             }
             TB.push("<td></tr>");
             TA.push(TB.join("").replace(/@1/g,param['eloc']).replace(/@2/g,param['poiName']));
             TB = null;
             TB = new Array();
           } else if(typeof(param['poiName']) != 'undefined' && param['poiName'] != null && param['poiName'].length > 0) {          
             TA.push("<tr><td><span><b>@2</b><span><td></tr>".replace(/@2/g,param['poiName']));
             
           }
        
         
           if(typeof(param['address']) != null && param['address'].length > 0) {
             TA.push("<tr><td>");
             TA.push(param['address']);
             
             TA.push("</td></tr>");
           }  
           
           var zomato = (typeof(param['zomato']) != "undefined" && param['zomato'] > 0) ? true : false;            
           
           if(zomato == false){
               if(typeof(param['locality']) != 'undefined' && param['locality'].length > 0 ) {
                 TB.push(param['locality']);
                 if(param['city'].length > 0) TB.push(param['city']);                
               }else if(typeof(param['district']) != 'undefined' && param['district'].length > 0 && param['city'].length <= 0) {
                 TB.push(param['district']);
               } else if((typeof(param['district']) != 'undefined') && (param['district'].length > 0) && param['city'].length > 0 ) {
                 TB.push(param['city']);
                 TB.push(param['district']);
               } else if ((typeof(param['district']) != 'undefined' )  && (param['district'].length <= 0) && param['city'].length > 0){
                 TB.push(param['city']);                
               }

               if((typeof(param['state']) != 'undefined' )  && typeof(param['state']) != null && param['state'].length > 0 )
                 TB.push(param['state']);
             
              if(TB.length > 0){
                 TA.push('<tr><td>');
                 TA.push(TB.join(" > "));
              }
           
               if(typeof(param['phone']) != "undefined" && param['phone'].length > 0) {
                 TB = null;
                 TB = new Array();
                 TB.push('<tr><td>Ph : ');
                 TB.push(param.phone);
                 TB.push('</td></tr>');
                 TA.push(TB.join(""));
               }

               if(typeof(param['pincode']) != "undefined" && param['pincode'].length > 0){
                 TB = null;
                 TB = new Array();
                 TB.push('<tr><td>Pincode : ');
                 TB.push(param.pincode);
                 TB.push('</td></tr>');
                 TA.push(TB.join(""));
               }

               if(typeof(param['web']) != "undefined" && param['web'].length > 0) {
                 TB = null;
                 TB = new Array();
                 TB.push('<tr><td>Website :');
                 TB.push(param.web);
                 TB.push('</td></tr>');
                 TA.push(TB.join(""));
               }

               if(typeof(param['email']) != "undefined" && param['email'].length > 0){
                 TB = null;
                 TB = new Array();
                 TB.push('<tr><td>Email : ');
                 TB.push(param.pincode);
                 TB.push('</td></tr>');
                 TA.push(TB.join(""));
               }
               
               if(typeof(param['descr']) != "undefined" && param['descr'].length > 0){
                 TB = null;
                 TB = new Array();
                 TB.push('<tr><td>');
                 TB.push(param.descr);
                 TB.push('</td></tr>');
                 TA.push(TB.join(""));
               }  
             
           }
                      
           if(typeof(param['zomato']) != "undefined" && param['zomato'] > 0){  
             TB = null;
             TB = new Array();
             TB.push('<tr><td align="left"><div class="send_button getmore" ><a class="button_share" title="');
             TB.push('Get More Detail about ');
             TB.push(param['poiName']);
             TB.push('" alt="More Info">More Info</a></div></td></tr>');
             TA.push(TB.join(""));               
           }
           
           if(typeof(param['others']) != "undefined" && param['others'] > 0){    
             TB = null;
             TB = new Array();
             TB.push('<tr><td align="left"><p><i><b><a title="');
             TB.push('Get More Detail about ');
             TB.push(param['poiName']);
             TB.push('" alt="">View more details</a></b></i></p></td></tr>');
             TA.push(TB.join(""));               
           } 
           
           try {
                 TB = null;
                 TB = new Array();
                 TB.push('<tr><td><i><span class="pedit" lang=');
                 TB.push(this.callEncodeOrDecoder({param : param['eloc'] , index : 0}));
                 TB.push('>Edit details</span></i></td></tr>');
                 TA.push(TB.join(""));
            }catch(e){}
           
           return TA.join("");
      },
      
      "altDisplay" : function(arg){
         var TA = new Array();
         if(arg.alternate.length > 1){
           var num = (arg.num > 0) ? arg.num : 10 ;     
           TA.push('<div class="did_u_mean"> Did you mean? </div><div class="alt_Txt"><ul alternate="1">');         
           for(var i=0;i<num;i++){                          
             TA.push((i < arg.numvisible) ? '<li>' : '<li style="display:none">');  
             TA.push('<table cellspacing="0" border="0" cellpaddingg="0"><tbody><tr><td><div class="maplicon alternate_mark"></div></td><td><span>');
             TA.push(arg.alternate[i]);
             TA.push('</span></td></tr></tbody></table></li>');
           }
           TA.push('</ul></div>');
           if(arg.isvisibile)TA.push('<div class="show_all"><span alternate="1">+ Show All</span></div>');
         }
         //if(arg.spot)TA.push('<div class="user_added_place">Search inside User Added Place ?</div>');         
         return TA.join("");
       },
     
     "calculate" : function(arg){     
       var that = this;
       var flag = true;
       this.pastlayout = arg;
       var result = arg.param;
       var evalResult = eval('('+ result.response+')');
       $(ALT.TPANEL[0]).scrollTop(0);
       if(result.service >= 100 && result.service < 200){  
         output = this.isAlternates({'result' : evalResult.childList, "service" : result.service , "isvisible" : false ,"plot" : true}); 
         if(output != null){
             if(output.alternate){
                $(ALT.TPANEL[1]).html(this.altDisplay({'alternate' : output.list , 'num' : 10 , 'spot' : true,'isvisibile' : false,'numvisible' : 10}));
                that.altBinder({'service': result.service});                
             } else {                
                if(result.service == 100 || result.service == 102) {
                  if($.trim(output.list.join("")).length > 0) output.list = this.altDisplay({'alternate' : output.list , 'num' : 10 ,'isvisibile' : true, 'spot' : false ,'numvisible' : 5}); 
                } else {
                  flag = false;
                }                
                $(ALT.TPANEL[1]).mapSearch({"service" : result.service, result : output,'C' : this , 'flag' : flag});
                that.altBinder({'service': result.service});
             }
          }          
       }else if(result.service >= 200 &&  result.service < 300){
         var alternate = (typeof(evalResult.output.num) === "undefined") ? true : false;
         if (alternate) {
            var output = this.isAlternates({'result' : evalResult.output.childList, "service" : 100 , "isvisible" : false}); 
            $(ALT.TPANEL[1]).html(this.altDisplay({'alternate' : output.list , 'num' : 10 , 'spot' : true,'isvisibile' : false,'numvisible' : 10}))  ;                     
            that.altBinder({'service': result.service});
         } else {
            if(evalResult.output.num > 0){    
               $(ALT.TPANEL[1]).places({"service" : result.service, result : evalResult,'C' : this});  
            } else { 
               this.loadPrompt({flag : 'e'+result.service});
               
            }            
         } 
       } else if(result.service == evalResult.layout){
          this.enrouteContent(evalResult);
       }
       
      
       if(somaction) somaction = false;
       $('body').APL({action : 0}); 
       if(mlog != null && flag){ 
         mlog.persist();  
       }
     },
          
     "enrouteContent" : function(evalResult){
         var TA = new Array();
         TA.push(this.poiDesign({start : 0 , end : evalResult.content.length , enroute : true, cats : evalResult.others,remove : false,'result' : evalResult.content , markByColor : true, markByNum : true, 'ibox' : true,'byDistance' : true, bounds : false}));
         if($("#"+evalResult.embed).find('.enroute').length > 0){
           $('#'+ evalResult.embed).append(TA.join("")); 
         } else {
           $('#'+ evalResult.embed).html(TA.join(""));
         }
         this.updateEnroute({cat : evalResult.others});
         var holder = $(ALT.TPANEL[1]);    
         $.data(holder,'poi',{result : evalResult.content, page : null});          
         this.poiShortcut({'holder': holder});
         if($('#'+ evalResult.embed).is(ALT.FLAGS[0])) this.dirTabSwitch({index : 1}); 
         this.editPlace();
     },
     
     "poilist" : function(arg){
        var holder = arg.result.output;
        var res = holder.places;
        var i = arg.page*10;
        var end = i + 10;
        var total = holder.tot ;
        end = (end > total) ? total : end;
       // var sort = (typeof(holder.sort) === "undefined") ? 0 :  holder.sort;
        var what = arg.result.search;
        var n = res.length;
        var output = new Object();
        output.alternate = false;
        output.eloc = ""; 
        output._addr = holder.where;
        output.point = new Point(holder.x,holder.y);
        if(n > 0) {
        var others = [];
        others.push('<div class="poilayout">');
        if(typeof(arg.resultInfo) != 'undefined' && arg.resultInfo){
            others.push('<div class="poi_header">');
            others.push((arg.service > 200 ) ? "Points of Interest" : what);
            others.push(' found (');
            others.push(total);
            others.push(')');
            if(layer != 'Maps')
              others.push('<div lang="sidebar" align="right" onclick="parent.closeMe(this);" title="close" alt="close" class="maplicon closebox" style="margin-top:-10px" react=1></div><div class="cls"></div>');
            
            others.push('</div>');
            
            /*if(typeof(arg.sortFilter) != 'undefined' && arg.sortFilter){
                others.push('<div class="poifilter">Results Sort By : ');
                var sType = (typeof(arg.sortFilterList) != 'undefined') ? arg.sortFilterList : ["Relevance","Distance"];
                for(var a=0;a < sType.length;a++){
                  others.push('<a href=""');
                  if(a == sort) {
                    others.push('');
                  } else {
                    others.push(' style="color:#333;text-decoration:underline;" ');
                  }
                  others.push(">");
                  others.push(sType[a]);
                  others.push("</a>");
                }
                others.push('</div>'); 
            }*/                    
         }      

        if(typeof(arg.pagination) != 'undefined' && arg.pagination.top && n > 10) {
            others.push('<div poption=1 class="page_top"></div>');
            output.total = total;
            output.page  = arg.page;
        } 
        
        others.push(this.poiDesign({start : i , end : end ,remove : true,multiple : true,flush : true ,result : res , markByColor : ((arg.service  == 202) ? true : false), markByNum : true,'byDistance' : true, 'ibox' : true, bounds : ((arg.service  == 202)? false : true)}));        
        if(typeof(arg.pagination) != 'undefined' && arg.pagination.bottom && n > 10) 
          others.push('<div poption=1 class="page_bottom"></div>');              
          output.list = others.join("");
          AC.release(others);
          AC.release(arg);
        }
        return output;
     },
     
     "updateEnroute" : function(arg){
        var curl = window.location.toString();  
        var curlGeo = null;
        var curlParam = curl.split("#");
        if(typeof(arg.remove) != 'undefined'){          
           curlGeo = curlParam[1].split(";geo=");
           var TB  = curlGeo[0].split("+enroute+");
           if(TB.length == 2) TB.pop();
           var TA  = new Array();
           $('input[type=checkbox]',ALT.TPANEL[1]).each(function(){
              if($(this).is(":checked")) TA.push($(this).val()); 
           });
           
           if(TA.length > 0){              
              TB.push("+enroute+");
              TB.push(TA.join(",").replace(/\s/g,"+"));
           }
           TB.push(";geo=");
           TB.push(curlGeo[1]);  
           window.location.hash=TB.join("");           
        } else {
          var catParam = arg.cat.replace(/[:0-9]+/g,"");   
          if(curl.indexOf(catParam) == -1){          
          curlGeo = curlParam[1].split(";geo=");
          if(curlGeo[0].indexOf("+enroute+") > -1){
             if(curlGeo[0].indexOf(arg.cat.replace(/[:0-9]/g,"")) == -1)
                 curlGeo[0]+=","+((catParam).replace(/\s/g,"+"));   
          } else {
             if(curlGeo[0].indexOf(catParam) == -1) curlGeo[0]+="+enroute+"+((catParam).replace(/\s/g,"+"));  
          }
          window.location.hash=((curlGeo.length == 2 ) ? curlGeo.join(";geo=") : curlGeo.join(""));          
         }
       }
       
     },
     
     "alternateLayout" : function(arg){
        var TA = [];
        var elem = arg.param;
        TA.push("<div class='did_u_mean'> Did you mean? </div><div id='alt_Txt' class='alt_Txt'><ul alternate='1'>");
        for(var j=1;j<elem.length;j++) {
          TA.push("<li><table cellspacing=0 border=0 cellpadding=0><tbody><tr><td><div class='maplicon alternate_mark'></div></td><td><span>");
          TA.push(elem[j].address);
          TA.push("</span></td></tr></tbody></table></li>");
        }
        TA.push("</ul></div></div>"); 
        return TA.join("");
     },
     
     "clearDefault" : function(){
        try {routeDrawer.Destroy();}catch(e){}
     },     
           
     "m300Binder" : function(arg){
         var that = this;
         if(arg.param == 2){
            $("#generalFbk").unbind();
            $("#generalFbk").click(function(){
                var textarea = $('#gfeedback');
                textarea.show();
                return ALT.BOOL[0];
            });
            $("#generalClose").unbind();
            $("#generalClose").click(function(){
                var div = $('#gfeedback');
                $('#fbk1').val('');
                div.hide();
                return ALT.bool[0];
            });
            
            var holder = $('.dtxt', ALT.TPANEL[3]);          
            holder.click(function(e) {//background:url(images/dir_close.gif) no-repeat right center;width:280px;height:20px;
                var inputStr = null;
                e.stopPropagation();
                if(that.options.ie == 6) {
                  inputStr  = '<div><table><tbody><tr ><td><input name="step" type="text" class="report_input"  /><td><td class="rclose"><span class="add_place_close"  alt="close" title="close" >X</span></tr></tbody></table></div>';
                }else {
                  inputStr  = '<div><table><tbody><tr ><td><input name="step" type="text" class="report_input"  /><td><td class="rclose"><span class="add_place_close"  alt="close" title="close" >X</span></tr></tbody></table></div>';                    
                }
                var step = holder.index(this);
                var isExist = $(this).find('.dir_txt_feeddir').find('div').length;
                if(isExist == 1) return;
                inputStr = inputStr.replace('step','step'+(step+1));
                if(that.options.ie == 6) {
                  $(inputStr).css({'display' : 'none'}).appendTo($(this).parent().find('.dir_txt_feeddir')).show();
                }else {
                  $(this).find('.dir_txt_feeddir').append(inputStr);
                }

                $(this).parent().find('.rclose').click(function(e) {
                    e.stopPropagation();
                    $(this).parent().parent().parent().parent().remove();                  
                });
            });           
           return;
        }
         
        $('.add_via a').unbind();
        $('.add_via a').bind(ALT.EVT[0],function(e){
           e.stopPropagation();
           e.preventDefault();
           L.Layer('m300AddVia');
        });
        
        this.m300SwapBinder();  
        
        var enroutes = $('.show_alongbox input[type=checkbox]',ALT.TPANEL[1]);
        enroutes.click(function(e){
          e.stopPropagation();
          if($(this).is(ALT.FLAGS[1])){
            var div = $(ALT.TPANEL[1])[0];  
            var TP = [];
            TP.push($(this).val());
            TP.push($.data(div, "en_pt"));
            internal = true;
            that.fireProcess({'view' :1 ,'method':'POST','common':true ,'q':parseInt($(ALT.TPANEL[1]).find(":first form").attr('lang'))+1,'search' : TP.join("*"), callback : function(response){
                that.enrouteContent(response);                   
            }});
            that.dirTabSwitch({index: 1});
            AC.release(div);AC.release(TP);   
          } else {          
            var holder = $(".enroute",ALT.TPANEL[1]);   
            var param  = $(this).attr('lang');
            holder.each(function(){ 
              if(param == $(this).attr('lang')){
                $(this).remove(); 
                return;
              }
            });
            that.updateEnroute({cat : $(this).val() , 'remove': true});
            mf.MarkerFactory('removeEnroute',{param : param});
            if($(".enroute",ALT.TPANEL[1]).length == 0) that.dirTabSwitch({index: 0});
          }          
        });
        if(arg.param == 1){
           var dholder = $('.dir_tab li');
           dholder.click(function(e){
             e.stopPropagation();
             var idx = dholder.index(this);
             that.dirTabSwitch({index: idx});
           });
           this.closeDirText();
       }
       
      /* if(arg.param == 0 ){
         var container = $('.sidebar_search_sbg .closebox');  
         for(var x= 0;x <container.length;x++)
         $("#dirauto"+x).autoSuggest("autocity.php",{'asHtmlID':"dirauto"+x,selectedItemProp:"addr",searchObjProps:"addr",selectedValuesProp:"link","resultsHighlight":false});
       }*/
     },
     
     "currentUrl" : function(arg){         
         var url   = window.location.toString();         
         var showPt =  (typeof(arg) != 'undefined' && arg != null ) ? true : false;
         var turl = null;var TB;var mpt;
         if(showPt ){
           turl = new Array();  
           turl.push(url.substr(0,url.lastIndexOf('/')));
           turl.push('/embed.html#current:');
           mpt = M.MireoMap('getCenter');
           TB  = [];TB.push(M.MireoMap('getZoomLevel'));TB.push(mpt.y);TB.push(mpt.x);turl.push(TB.join(","));
           TB = null;delete(TB);  
           url = turl.join("");
         } else {
           turl  = url.split("#");
           if(layer != 'Maps'){
             if(turl.length > 1) turl.pop();
             url = turl.join("");
           } else  {
              if(turl.length == 1){
                mpt = M.MireoMap('getCenter');  
                TB  = [];TB.push(M.MireoMap('getZoomLevel'));TB.push(mpt.y);TB.push(mpt.x);
                turl.push(TB.join(",")); 
                url = turl.join("embed.html#current:");
              }               
           }
         }  
         return url;
     },
     
     "dirAction" : function(arg){
            var that = this;
            var TA  = new Array();
            var TB  = new Array();
            var i = 0; 
            var geo = 0;
            if(that.dirpast == null) that.dirpast = new Array();
            $(arg).find('.as-input').each(function(){
                var TO = that.dirpast[i];
                if(typeof(TO) == 'object' && $(this).val() == TO.search){
                  TA.push(TO.search);  
                  TB.push(TO.geo);    
                  geo++;
                } else if($(this).val().length > 0) {
                  TA.push($(this).val());   
                  TB.push("");
                } 
                i++;
           }); 

           mf.MarkerFactory('removeOverlays',{onTheWay : true});
           if($.trim(TA.join("")).length == 0) {
            //alert("invalid request");  
           } else {           
             this.postprocess({param : {q : 300 , search : TA.join("*"), geo : ((geo > 0) ? that.callEncodeOrDecoder({param : TB.join(",") , index : 0}) : "" )}});
            // this.set300Request({search : TA.join("*"), geo : ((item == i) ?  "" : that.callEncodeOrDecoder({param : TB.join(",") , index : 0}))});
           }
           return false;    
     },
     
     "set300Request" : function(arg){
        var that = this; 
        arg.param.geo = (typeof(arg.param.geo) == 'undefined') ? "" : arg.param.geo;
        L.Layer('zoomAndAction',{csom : true,slideup  :true});
        that.fireProcess.call(that,{loading:true, history : true, method : 'POST',common:ALT.BOOL[1], view: 1, q : 300 , search : arg.param.search, geo : arg.param.geo , callback : function(response){
           
           if(!isNaN(response)){
             L.Layer('loadPrompt',{flag : 'e300'});
             $('body').APL({action : 0}); 
           } else { 
             if(typeof(arg.param) != 'undefined'){   
              var TA = [];
              TA.push(arg);
              TA.push(response);
              that.dirInAction(TA);
             }
           }
       }}); 
     },
     
     "dirInAction" : function(argt){
       this.pastlayout = argt;    
       var arg = argt[0];
       var response = argt[1];
       
       if(typeof(arg.param) != 'undefined'){ 
               var data = arg.param; 
               var output = response.mmioutput;
               var num = output.length;
               var temp = new Array();
               var fail = new Array();
               var pass = data.search.split("*");
               var geos = new Array();
               var layout = null;
               var flag  = true;
               for(var i=0;i<num;i++){
                 var elem = output[i];
                 var l  = elem.length;
                 if(l > 1 ){
                   layout = new Object();
                   layout.alternate = this.alternateLayout({param : elem});
                   temp.push(layout);
                   fail.push(i);
                   pass[i] = "";
                   geos[i] = "";
                 } else if (l == 1){
                   var geo = new GeoAddress();
                   geo._area = elem[0].address;
                   geo.pt  = new Point(parseFloat(elem[0].pos.lon),parseFloat(elem[0].pos.lat));
                   var TA  = [];TA.push(elem[0].pos.lat);TA.push(elem[0].pos.lon);
                   geos[i] = TA.join("+");AC.release(TA); 
                   temp.push(geo);                                                   
                   pass[i] = geo._area;                   
                   this.buildpast({x : geo.pt.y ,y : geo.pt.x , addr : geo._area, index : i , "setter" : true, flush : flag}); 
                   if(flag) flag = false;
                 }              
               }               
               
               if(fail.length == 0){
                 $(ALT.TPANEL[1]).direction({param : response, pass : temp, 'me' : this ,'uenroute': arg.param.enroute});  
               } else {
                 notExact({'fail' : fail ,'show' : temp, 'pass' : pass, 'geos' : ($.trim(geos.join("")).length == 0) ? "" : geos.join(",")},arg.param,this); 
                 $('body').APL({action : 0}); 
               }
               mlog.persist();
           }  
     },
     
     "dirTabSwitch" : function(arg){
        var idx = arg.index;
        var dholder = $('.dir_tab li',ALT.TPANEL[1]);
        dholder.removeAttr('class'); 
        dholder.each(function(){
           var index = dholder.index(this);
           if(index == idx){
             $(this).addClass('selected');
             return;
           }
        });

        var holder = $("#dirSubContainer");
        holder.children().hide();
        holder.children().each(function(){
        var i = holder.children().index(this);
        if(i == idx){ 
          if(i == 1 && $('#dirSubContainer_'+i+' .enroute').length == 0)
          $(this).html("<div id='poi_on_way_not_found'>Please select 'Show along the route' option to view content.</div>");    
          $(this).show();
          return;
        } 
       }); 
     },
     
     "shareByChoice" : function(arg){         
         $("#sharediv").slideUp();
         $('body').APL({action : 0});  
         if(arg.light) {
           L.Layer('lightShadow',{'content' : "" ,'holder' : 'body'});
           if(arg.content)
           arg.item.show();  
         }         
         if(arg.choice > -1){
           $(arg.holder).removeAttr("class");  
            var iDom = $(".share_div_tab ul li:nth-child("+(arg.choice+1)+")"); 
            iDom.addClass('current');
            $(".share_div_tab").siblings().hide();
            var TA = new Array();
            TA.push("#");
            TA.push($.trim($(iDom).text()).toLowerCase());
            TA.push("_box");
            var linkD = TA.join("");
            if(arg.choice < 2){
              TA.push("_input");
              $(TA.join("")).html(arg.query);
              TA.splice(3,1);
              $('.button_share',TA.join("")).unbind().click(function(e){
                 e.stopPropagation(); 
                 e.preventDefault();                  
                 TA.push("_input");
                 $(TA.join("")).focus().select();
                 var uparam = L.Layer('getBuilder').currentUrl();
                 var tparam = (layer == 'Maps') ? uparam.split("#")[1] : uparam; 
                 L.Layer('getBuilder').mbuildlog({'type':$(this).attr('log'),'value':tparam,'url':uparam,'auto':null});
                 AC.release(uparam);Ac.release(tparam);
              });             
            } else if(arg.choice >1){              
              $.ajax({type: "GET",url: 'share.html',dataType: "xml",success: function(xml) {
                    $(xml).find(iDom.text()).each(function(){
                    var content = $(this).text().replace('@URL',L.Layer('currentUrl'));
                    
                    if(arg.choice == 4){
                      $("#facebook_button").html(content);                     
                    } else { 
                      $(linkD).html(content);
                    }
                    if(arg.choice > 2){
                      var param = L.Layer('currentUrl').split("#");
                      var nparam = (param.length == 2) ? param[1] : param.join(""); 
                      M.Layer('mbuildlog',{'type' : "Share-"+iDom.text(), 'value' : nparam  , 'url' : L.Layer('currentUrl'), 'auto' : null});  
                    }
                  });
              }});   
            }
            $(linkD).show();
         }  
       },
     
     "loadShare" : function(arg){
        var sharediv = $("#sharediv");
        if(sharediv.length == 0){
           $.ajax({type: "GET",url: "share.html",dataType: "xml",success: function(xml) {
            $('body').APL({action : 0});         
            $(xml).find('share').each(function(){
            $($(this).text()).insertBefore('#panelContainer');                           
            if(typeof(arg.display) === 'undefined') $("#sharediv").slideDown();
            L.Layer('getBuilder')._shareControl({flag : true});
            if(typeof(arg.display) != 'undefined' && !(arg.display)) arg.callback();
           });}});
         } else {
            sharediv.slideToggle();   
         }         
     },
     
     "helper" : function(){
         $("#hisdiv").hide();
         $("#sharediv").hide();    
         this.zoomAndAction({more : false, slideup  :true , csom : true});
         var left_tstrip = $("a",'#helpContainer');
         left_tstrip.unbind();
         var hholder= ALT.BOOL[0];
         left_tstrip.click(function(e){
            e.stopPropagation();
            var idx = $(this).attr('lang');
            if(idx == "") {
              return true;  
            } else if(idx == 0){
              L.Layer('showDirection',{'close' : true ,'show': true ,'param' : [ L.Layer('getValue',{'key' : 'DTYPES', 'index':4}),L.Layer('getValue',{'key' : 'DTYPES', 'index':4})]});  
              return hholder;   
            } else if(idx == 1){
              L.Layer('lightShadow',{holder : 'body',content : ""});
              $(ALT.BODYLAYOUT[8]).fadeIn();
              return hholder;  
            } else if(idx == 2){
               L.Layer('spot',{search : 'Add a Spot'}); 
            } else if(idx == 3){ 
               if(typeof(M.MapLayer) != 'undefined'){ 
                 M.MapLayer('preprocess',{param : "saket,new delhi to cp,dl"});
                 M.MapLayer('search',{'process' : $("#gSearch") ,'enroute' : 'ATMs,Restaurants,Petrol Pumps', 'from' : layer ,'link' : true , history : true});                   
               }
               return hholder;
            } else if(idx == 4){
                
            }
            return hholder;
         }); 
       },     
     
     "_shareControl" : function(arg){
          var that = this;
          var TP   = $("#sharediv li a");
          var SH_TAB = $(".share_div_tab li");
          if(arg.flag){
            TP.unbind();
            TP.click(function(e){
               e.stopPropagation();
               e.preventDefault();
               var idx = TP.index(this);
               that.shareByChoice({choice : idx , 'holder' : SH_TAB, 'light' : true , 'content' : true , 'item' : $('#mshare_cont'),"query": ((idx == 1) ? that.currentUrl(true) : that.currentUrl())});                                 
            }); 

            SH_TAB.unbind();
            SH_TAB.click(function(e){
                e.stopPropagation();
                e.preventDefault();  
                var idx = SH_TAB.index(this);
                that.shareByChoice({choice : idx , 'holder' : SH_TAB,'light' : false , "query" : ((idx == 1) ? that.currentUrl(true) : that.currentUrl())});
            });   
        } 
     },
          
     "postprocess" : function(arg){
          this.removePrompt();
          mf.MarkerFactory('removeOverlays');          
          $('body').APL({action : 1});                  
          this.buildHashUrl.call(this,arg);          
     },
     
     "boundsCalculate" : function(){
          var TA =  new Array();
          var bounds =  $(this.element[0]).MireoMap("getBounds");
          TA.push(bounds.x1);TA.push(bounds.x2);
          TA.push(bounds.y1);TA.push(bounds.y2);
          AC.release(bounds);
          return TA;
      },
     
     "buildHashUrl" : function(arg){
          var TA = new Array(); 
          var title = new Array();
          var search = arg.param.search.split("*");
          var cview  = false;var ccode = null;
          mlog = null;
          mlog = new com.mmi.logs();
          if(arg.param.q > 99 &&  arg.param.q <=102){
             title.push('Map of ');
             title.push(search);
             TA.push(title.join("").toLowerCase());
             var fllag = (typeof(arg.param.alternate) != 'undefined' && arg.param.alternate ) ? "Alternate Selection" : "Map of location";
             mlog.init(fllag,search);
             this.setHistory({param : search}); 
          } else if(arg.param.q >= 200 && arg.param.q < 300){              
             title.push(search.join(" in "));   
             this.setHistory({param : search.join(" in ")});
             if(search[1] == 'current map view'){
               var TB = this.boundsCalculate();
               search.pop();
               var TZ  = new Array();
               TZ.push($(this.element[0]).MireoMap("getZoomLevel"));
               TZ.push((TB[0] + TB[1])/2);
               TZ.push((TB[2] + TB[3])/2);              
               search.push('current:'+TZ.join(","));
               arg.param.search = search.join("*");
               ccode = TB.join(" ");
               cview = true;
               AC.release(TZ);
               AC.release(TB);
             }
             TA.push(search.join(" in ").toLowerCase());            
             mlog.init(((typeof(arg.useful) != 'undefined') ? ((arg.useful) ? "Useful places around" : "Show on Map") : ((typeof(arg.alternate) != 'undefined' && arg.alternate) ? "Local Search Alternate" : "Local Search")),TA.join(""));
          }else if(arg.param.q == 300){
            title.push("Directions from "); 
            if(search.length == 2){
                title.push(search.join(" to "));
            } else {
                var last = search.pop();
                title.push(search.join(" via "));
                title.push(" to ");
                title.push(last);
                AC.release(last);
            } 
            TA.push(title.join("").toLowerCase());
            this.setHistory({param : title.join("")});
            mlog.init("Directions Search",title.join("").replace('Directions from ',""));
          }
          if(title.length > 0){
           document.title = title.join("");
           if(arg.param.geo != null && typeof(arg.param.geo != 'undefined')){
               TA.push(';geo=');
               TA.push(arg.param.geo); 
           }
           if(cview && ccode != null){
             search.pop();
             search.push(ccode);
             arg.param.search = search.join("*");            
           }
           if((typeof(arg.link) == 'undefined' || arg.link)) window.location.hash = TA.join("").replace(/\s/g,"+");  
           arg.param.layer = layer;
           mlog.setUrl(window.location.toString());
           if(arg.param.q == 300){            
             this.set300Request(arg);  
           } else {
             this.fireProcess({flag : null,loading : true,process : arg.param});
           }
          }
       },
     
     "getPOIAddress" : function(arg,index){        
         var tholder = $.data(arg.holder,'poi');
         var address = "";
         var output  = null;
         if(tholder != null && typeof(arg.callback) === 'undefined'){
            var result = tholder.page;
            if(result != null) { 
              index  = (result*10 + index);
              output = tholder.result.output.places[index];
            } else {
              output = tholder.result[index];
              var TB = new Array();
              if(typeof(output.address) != 'undefined' && output.address.length > 0){
                if(output['locality'].length > 0 ) {
                  TB.push(output['locality']);
                  if(output['city'].length > 0) TB.push(output['city']);                
                } else if(output['district'].length > 0 && output['city'].length <= 0) {
                  TB.push(output['district']);
                } else if((output['district'].length > 0) && output['city'].length > 0 ) {
                  TB.push(output['city']);
                  TB.push(output['district']);
                } else if ((output['district'].length <= 0) && output['city'].length > 0){
                  TB.push(output['city']);                
                }
                if(typeof(output['state']) != null && output['state'].length > 0 )
                  TB.push(output['state']);
               } 
               output.address = TB.join(",");
               AC.release(TB);
             }            
         } else {
            output = tholder.result;              
         }
         var TA = new Array();
         TA.push(output.poiName);
         try {
           if(output.address.length > 0 )  TA.push(output.address);                             
         }catch(e){}
         L.Layer("buildpast",{x : output.y ,y : output.x , addr : TA.join(","), index : 1 , "setter" : true , flush : true});
         address = TA.join(",");
         AC.release(TA);                    
         return address;
     },
     
     
     /**
      * POI Result Hover menu Design
      */
     "poiHoverMenu" : function(arg){
        var that = this;        
        if(typeof(vhover) === 'undefined'){  
           $.ajax({type: "GET",url: 'sbar.html',dataType: "xml",success: function(xml) {
             vhover = xml;
             that.hovercontent({'menu': xml,'hover' : true},arg);                   
           }});
        } else {
           that.hovercontent({'menu': vhover,'hover' : true},arg);    
        }
            
        /*
        if(ALT.POIDEFAULT == null){
          
          this.fireProcess({'q': 'phover',view : 1 ,'common': true , 'method' : 'GET', callback : function(response){
             if(typeof(response) === 'undefined' || response.menu == ''){
               return;  
             } else { 
               var list = eval('('+response +')');
               var items = list.menu.split("|");  
               var TA = new Array();
               TA.push('<div id="otherOption" class="otherOption">'); 
               for(var x in items){
                var elem = items[x].split(":");   
                TA.push('<span lang="');
                TA.push(elem[0]);
                TA.push('">');
                TA.push(elem[1]);
                TA.push('</span>');
                TA.push(" | ");
               }
               TA.pop();
               TA.push('<div id="other_container" /></div><div class="cls" ></div>'); 
               ALT.POIDEFAULT = TA.join("");
               that.showHoverMenu(arg.param);
               arg.callback();
               AC.release(that);
               AC.release(TA);               
             } 
          }});
        } else {
          this.showHoverMenu(arg.param);
          arg.callback();
        }*/   
     },
     
     "hovercontent" : function(holder,arg){ 
         var that = this;
         if(ALT.POIDEFAULT == null){
            $(holder.menu).find(layer).each(function(){
                var items =  $(this).find('hover').text().split("|");      
                var TA = new Array();
                TA.push('<div id="otherOption" class="otherOption">'); 
                for(var x in items){
                    var elem = items[x].split(":");   
                    TA.push('<span lang="');
                    TA.push(elem[0]);
                    TA.push('">');
                    TA.push(elem[1]);
                    TA.push('</span>');
                    TA.push(" | ");
                }
                TA.pop();
                TA.push('<div id="other_container" /></div><div class="cls" ></div>'); 
                ALT.POIDEFAULT = TA.join("");
                that.showHoverMenu(arg.param);
           });
         } else {
           this.showHoverMenu(arg.param);
           arg.callback();  
         }
     },
     /**
      * POI Result Hover menu display position setting
      */
     "showHoverMenu" : function(arg){
        arg.append(ALT.POIDEFAULT);
        var width = $('.otherOption', arg).width();
        var numspn = $('otherOption span').length;
        //numspn  = (numspn < 3) ? 3 : numspn;
        var TW = parseInt(($(arg).width() - width)/numspn) ;
        $('.otherOption', arg).css({left : TW}).show();
        AC.release(arg);        
     },

     
     "poiShortcut" : function(arg){
          var holder = $('.poicontent',arg.holder);
          var me = this;
          
          holder.each(function(){
              var tholder = $(this).find('li');    
              tholder.unbind().bind('mouseenter mouseleave click',function(e){
                   e.stopPropagation(); 
                   $('.otherOption').remove();
                   var idxv = tholder.index(this);            
                   if(e.type =='mouseenter'){
                     var that = this;           
                     me.poiHoverMenu({param : $(this),callback:function(){
                         var elem = $('.otherOption span',$(that));
                         elem.bind('click',function(e){
                           e.stopPropagation();
                           e.preventDefault();
                           var current = this;
                           var idx = parseInt($(current).attr('lang'));
                           $(this).addClass('active').siblings().removeAttr('class');                           
                           if(idx == 0){
                             var address = null;            
                             try {$('#nearByShot').slideUp('slow')}catch(e){}
                             if(typeof(arg.callback) != 'undefined')  arg.callback({shortcut : true , layer : true , idx :  idxv , refer : that}); 
                             address = me.getPOIAddress(arg,idxv); 
                             var closeme = false;
                             if(layer == 'Maps'){
                               closeme = ($('.show_alongh',ALT.TPANEL[1]).length == 1)? false : true;
                             } else {
                               closeme = true;  
                             }
                             L.Layer('showDirection',{'close' : closeme ,'show': true ,'param' : [ALT.DTYPES[4],address]});        
                             $(ALT.TPANEL[0]).scrollTop(0); 
                           } else if(idx == 1){                             
                             if(typeof(arg.callback) != 'undefined') arg.callback({shortcut : true , layer : true , idx :  idxv});   
                              
                             me.getPOIAddress(arg,idx);           
                             if($("#nearByShot").length == 1){
                               $("#nearByShot").slideDown('slow');  
                             } else {
                               $(this).parent().find('div').html('<div class="nearByShot" lang="nearByShort" id="nearByShot"><table border=0 cellSpacing=0 cellPadding=2 ><tr><td><div class="sidebar_search_sbg"><input type="text" class="search_txt_sml"  id="poitxtbox" style="width: 200px;" onblur="txtBlur(this);" value=""><span id="ph_poitxtbox" class="placeholder_poi" onclick="getFocus(this);" >Enter category (eg. ATM, Hotel)</span> </div></td><td><input type="button" value="GO" class="button_share" id="hoverbutton" style="padding:4px 5px 4px 5px;margin:0" title="Search" ></td><td><div onclick="parent.closeMe(this)" lang="'+$(this).parent().attr('id')+'" react="0" class="maplicon closebox shortcut_close" title="Close" ></td></tr></table></div><div id="error" class="failure" style="display:none;margin-left:5px;text-align:left;"></div></div>');   
                             }
                             //-- POI suggest -sid
                             $("#poitxtbox").autoSuggest("poicat.php",{'asHtmlID':"poitxtbox",selectedItemProp:"addr",searchObjProps:"addr",selectedValuesProp:"link","resultsHighlight":false});
                             //-- 
                             $(this).parent().find('input[type=button]').unbind().click(function(e){
                                 e.stopPropagation();
                                 var ivalue = $.trim($("#poitxtbox").val());                                 
                                 var TA = new Array();
                                 $('#error', that).html('');
                                 if(ivalue.length == 0){
                                   $('#error',that).show().html("Enter something like atms, banks etc.");
                                   return;
                                 }
                                 TA.push($("#poitxtbox").val());
                                 TA.push(me.getPOIAddress(arg,idx));
                                 if(layer == 'Maps') $("#isearch").val(TA.join(" in "));
                                 var TO = me.dirpast[1];
                                 TO.search = TA.join("*");
                                 TO.geo = me.callEncodeOrDecoder({param : TO.geo , index : 0})
                                 TO.q  = 200;
                                 TO.common = true;
                                 internal = true;
                                 me.postprocess.call(me,{param : TO , 'direct' : false});
                             });
                             $('#poitxtbox').focus().click(function(e){
                                 e.stopPropagation();
                                 e.preventDefault();
                             });
                             
                           } else if(idx == 2){
                             var container = $('#mshare_cont');                 
                             if(container.length == 0){
                               var TO = new Object();TO['idx'] = 2;TO['display'] = false; 
                               me.loadShare({display : false,callback : function(){
                                 var url = $('.poi_desc a',that);
                                 if(url.length == 0){
                                   url = window.location.toString().split("#")[0];  
                                 } else {
                                   url = url.attr('href');
                                 }                     
                                 me.shareByChoice({choice : 0 , 'holder' : $(".share_div_tab li"), 'light' : true, 'content' : true , 'item' : $('#mshare_cont') , 'query' : url});               
                               }});                    
                               AC.release(TO);
                             } else {
                               me.shareByChoice({choice : 0 , 'holder' : $(".share_div_tab li"), 'light' : true, 'content' : true , 'item' : $('#mshare_cont') , 'query' : $('.poi_desc a',that).attr('href')});       
                             }
                             AC.release(container);
                           }else if(idx == 3){
                             me.fireProcess.call(me,{loading : true , common : true ,method : 'GET' ,view:"1", q : 401 , search : "POI",value : $('.poi_desc span a',that).html(), callback : function(response){
                                 response = eval('(' + response + ')');
                                 me.setPageLayout({index : response.container, result : {content : response.content},callback : function(point){
                                     $('body').APL({action : 1});     
                                     var TA = [];TA.push(response.y);TA.push(response.x);
                                     var container = L.Layer('getValue',{key : 'TPANEL','index' : 2});
                                     $(container).find('input[name=geo]').val(TA.join(","));$('body').APL({action : 0}); 
                                     AC.release(container);AC.release(TA);
                                 }});
                             }});
                           }
                        }); 
                      }});
                      $('.getmore',this).click(function(e){
                          me.m2omato(e,$(this),$(that).find('span a').html());
                      });
                   } else if(e.type == 'mouseleave'){
                      L.Layer('destroyHoverMenu',{param : $(this)}) ;  
                   } else if(e.type == 'click'){
                      if(typeof(arg.callback) === 'undefined'){  
                         var TO = $.data(arg.holder,'poi');
                         var TB = $(this).html();
                         var idx = (typeof(TO.page) === 'undefined' ) ? idxv :((TO.page*10) + idxv);
                         var content = $(TB).find('.poi_desc');
                         content.find('.getmore').remove();  
                        
                         if($('.deal_loctitle',ALT.TPANEL[1]).length == 1){
                           content.find('.pedit').hide();    
                         }
                         
                         if($('.show_alongbox',ALT.TPANEL[1]).length == 1){
                            mf.MarkerFactory('showIBox',{layout : $('.poiOpt',this).siblings().html() ,'enroute' : true , 'flag' : $(this).parent().parent().attr('lang'), 'index' : idx});
                         } else { 
                            mf.MarkerFactory('showIBox',{layout : content , x : TO.result.output.places[idx].x ,y : TO.result.output.places[idx].y});
                         }
                      } else {
                         arg.callback(idxv,$(this));  
                      }  
                   }
              });
          });
     },
          
     
     "m2omato" : function(e,arg,zom){
       e.stopPropagation();
       e.preventDefault();           
       arg.unbind();
       var inHolder = arg.parent();
       arg.find('a').html("<i>Loading...</i>");
       var that = this;
       that.fireProcess({view:1 , common:true,q : 105 ,search : "", others : zom ,callback: function(response){
           response.pedit = true;    
           inHolder.html(that.options.oapp.partner.call(that.options.oapp,response));
       }}); 
     },
     
      "hideDragMarker" : function(arg){
        var marker = $.data(L,'dragme');
            
        if(marker != null && typeof(marker) != 'undefined'){
          marker.remove();     
          $.removeData(L,'dragme');          
        }
      },
      
      
     "dragMarker"  : function(arg){
        var marker =  $.data(L,'dragme');
        var that = this;         
        if(typeof(marker) == 'undefined' || marker == null){
         var mark = $(HTMLHelper.mapMarker((typeof(arg.flag) != 'undefined' && arg.flag == 1) ? 'images/add_place_icon.png'  : 'images/wrong.png',28,43)); 
         marker = $(this.element).MireoMap("addMarker", mark,((typeof(arg.point) === 'undefined') ? $(this.element[0]).MireoMap('getCenter') : arg.point));  
         $.data(L,'dragme',marker);
        } 
        marker.unbind();
        marker.draggable({
             start : function(){M.MireoMap('freeze');},
             stop  : function(e){
                        M.MireoMap("expandEvent", e);
                        M.MireoMap('melt');
                        arg.point = e.dpt;
                        $.removeData(L,'dragme');
                        marker.remove();
                        that.dragMarker(arg);
                        if(typeof(arg.callback)!= 'undefined') arg.callback(e.dpt);
                        AC.release(e);
                     }
         });
     },
     
     "isLogin" : function(){
       return (typeof(Semail) === 'undefined') ?  false : true ; 
     },
     
     "mailValidate" : function(arg){
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
        return reg.test(arg.value);
     }, 
     
     
     "editPlace" : function(){
         $('.pedit').unbind().click(function(e){
          e.stopPropagation(); 
          e.preventDefault();             
 //         document.title = 'http://maps.mapmyindia.com/edit-a-spot/?q='+$(this).attr('lang');    
          window.open('http://maps.mapmyindia.com/edit-a-spot/?q='+$(this).attr('lang'));
        }); 
     },
     
     "placeprocess" : function(arg){
        var param = arg.param;
        var TA = new Array();
        TA.push($(param).find(ALT.HFORM[0]));
        TA.push($(param).find(ALT.HFORM[1]));
        TA.push($(param).find(ALT.HFORM[2]));        
        var i = 0;
        var len = TA.length;
        var req = new Object();
        req['q']= $(param).attr('lang');
        var rprocess = ALT.BOOL[0]; //false
        var that = this;
        var holder = $("#"+$(param).attr('name'));
        var bug = $("#"+$(param).attr('target'));
        bug.css({'padding-top' : '10px'}).addClass("failure").html("");
        for(;i<len;i++){
           var dom = TA[i];
           dom.each(function(){
              var key = $(this).attr("name");
              var search = $.trim($(this).val()); 
              var flag = false;
              if(key.match(/(poi_nme|stt_nme|user_email|geo)/)){                                      
                 if(search.length == 0 && key != "as_values_subcat_dec" ){
                   rprocess = ALT.BOOL[1]; //true;
                   if(key.match("stt_nme") || key.match('geo')) {
                      bug.html("<b>Address</b> is missing.<br/> <b>Drag the marker around to place</b> or <b>right click</b> and select '<b>Add a Place</b>' option");
                   } else {
                      bug.html("<b>"+$.trim($(this).parent().find('p').text().replace("*",""))+"</b> is missing");
                   }
                   $(this).focus();
                   $(ALT.TPANEL[0]).scrollTop(0);
                   return;
                 } else if(key == "user_email"){
                     if(!that.mailValidate({value : search})){
                       rprocess = true;
                       bug.html("Please provide an email address which looks like user@example.com");
                       $(ALT.TPANEL[0]).scrollTop(0);return;
                     }
                 }
                 flag = false;
              } else if(key == 'otherweb'){
                 if($.trim($(this).val()).length >  0) {
                   var title = $(this).attr("title");
                   req[key] = (typeof(req[key]) === ALT.PARAM_UN) ? title+":"+$.trim($(this).val()) : ((req[key] == "" && $.trim($(this).val()).length == 0) ? req[key] :  req[key]+", "+title+":"+$.trim($(this).val()));
                 }
                 flag = true;     
              } else if(key == 'email') {
                 var email = $.trim($(this).val());
                 if(email.length >0) {
                    if(!that.mailValidate({value : email})){                               
                       bug.html("Please provide an email address which looks like user@example.com");
                       $(ALT.TPANEL[0]).scrollTop(0);                                 
                       rprocess = true;
                       flag = false;      
                       return;
                     }                
                 }
              }else if(key == 'web'){
                 var web = $.trim($(this).val());
                 if(web.length >0) {                          
                  var webExp =  /(http|https):\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/ ;
                  var validWeb = webExp.test(web);
                  if(validWeb == ALT.BOOL[0]){                  
                    bug.html("Please provide valid website link like http://xyz.com");
                    holder.scrollTop(0);
                    rprocess = true;
                    flag = false;
                    return;
                  }
                 }
              }              
              if(!flag) {
                if(typeof(req[key]) === 'undefined'){
                  req[key] = search;  
                } else {
                  req[key] += ","+search; 
                }
              }
           });
         if(rprocess) return;
        }
        
        if(!rprocess) {
           bug.removeAttr('class').addClass('process_exec').html("<div class='process'></div>");
           $(ALT.TPANEL[0]).scrollTop(0);
           req['common'] = true;
           req['method'] ='POST';
           req['loading'] =true;
           req['view'] = 1;
           req['callback']=function(arg){
             that.spotResponse(arg);
           };
           that.fireProcess(req); 
           return false;
        }
     },
     
     "spotResponse"  : function(arg){
        var that = this;
        $('body').APL({action : 0});  
        if(arg.error == 1){
          $(arg.container).html(arg.msg);   
        } else if(arg.error == 0){
          this.hideDragMarker();         
          $("#"+arg.container).html("");
          $("#"+arg.container).after(arg.content);         
          $('.add_placef',ALT.TPANEL[3]).remove();
          $('.add_placef_add',ALT.TPANEL[3]).remove();
          $('.add_clear_now').remove();
          $('#options').remove();
          
          $(".new_ladd_place",ALT.TPANEL[3]).click(function(e){
            e.stopPropagation();
            e.preventDefault();
            that.spot({search : "Add a Spot"});            
            $(this).unbind();
          });

          var handler = $('.add_place_response');
          handler.unbind().click(function(e){
            e.stopPropagation(); 
            $("#isearch").val($(this).text()); 
            handler.unbind();
            AC.release(handler);
          });                
          that.mbuildlog({'type' : 'Spot', 'value' :$('.add_place_response').text(), 'url' : that.currentUrl(), 'auto' : null});
       }          
     },
     
     "mbuildlog" : function(arg){       
        mlog = null;
        mlog = new com.mmi.logs();
        mlog.init(arg.type,arg.value,arg.url,arg.auto);
        mlog.persist();
     },
     
     "setPageLayout" : function(arg){
         //mf.MarkerFactory('removeOverlays'); 
         var TO = ALT.TPANEL;
         if($.isArray(TO)){
           $(TO[1]).hide(); 
           for(var i=2;i<TO.length;i++) $(TO[i]).html("");             
           var elem = document.getElementById($(TO[arg.index]).attr('id'));
           elem.innerHTML = arg.result.content;
           elem.style.display = 'block';
           elem = null;
         }
         this.inputBinder({current : $(TO[arg.index]).find('form')});
         $('body').APL({action : 0});        
         if(typeof(arg.callback) != 'undefined' || arg.callback != null) arg.callback(arg.index);
      },
      
     "helperView" : function(arg){
        var TO = arg.param;        
        if(TO.error == 0){
          $("#error").removeClass('process_exec').addClass('success').html(TO.feedback);  
          window.setTimeout(function() {closeMe(arg.container)}, 1500);
        } else {
          $("#error").removeClass('process_exec').addClass('failure').html(TO.msg);  
        }
        AC.release(TO);
        AC.release(arg);
      },
      
     "inputBinder" : function(arg){
        var holder = $(arg.current);
        var that = this;
        holder.unbind();
        
        holder.find('input[type=checkbox]').click(function(){
            if($(this).is(":checked")){
             var dom = $(this).parent().parent().next();   
             if(dom.find('.egDrag').length == 1) that.dragMarker(arg);             
             dom.show();
             AC.release(dom);
            } else {             
             $(this).parent().parent().next().hide();
             that.hideDragMarker({dom : holder});
            }            
        });
        
        holder.find('input[type=text]').bind('focus blur',function(e){
         e.stopPropagation();
         var dom = $.trim($(this).val());
         var dval = $(this).attr('lang');
         
         if(e.type == 'focus'){
            if(dom == dval) $(this).val("");  
         } else if(e.type == 'blur'){
           if(dom == "" && typeof(dval) != 'undefined') $(this).val(dval);
         }
        });
        
        holder.find('textarea').bind('focus blur',function(e){
         e.stopPropagation();    
         var dom = $.trim($(this).text());
         var dval = $(this).attr('lang');
         if(e.type == 'focus'){
            if(dom == dval) $(this).html("");  
         } else if(e.type == 'blur'){
            if(dom == "" && typeof(dval) != 'undefined') $(this).html(dval);
         }
        });
     }
   }));
   
   
   $.fn.APL = function(options){
        options = jQuery.extend({
               img : false,
               imgSrc : null,
               className : 'search_load',
               //className : 'process',
               text : true,
               txtMessage : "loading...",              
               title : 'loading...',
               action : 0,
               embed : 'body'
        },options||{});  

        return this.each(function() {
            if(options.action == 1){
              var TA =[];  
              if(options.img){
                TA.push("<div class='process'></div>");
              } else if(options.text){
                TA.push("<div class='");
                TA.push(options.className);
                if(typeof(options.title) == 'object'){
                  TA.push("' title='");
                  TA.push(options.title);
                }
                TA.push("' >");
                TA.push(options.txtMessage);
                TA.push("</div>"); 
              }
              $(this).append(TA.join(""));              
           } else if(options.action == 0){
              $(this).find('.'+options.className).remove();   
           }
        });
   };
   
   $.widget("ui.MarkerFactory", {

        "_init"      : function() {
          this.marker = new Array();
          this.onTheWay = new Object();
        },
        
        "add"  : function(arg){
          if(typeof(arg.vdefault) != 'undefined' && arg.vdefault){ 
            this.showDefault(arg);  
          } else if(typeof(arg.multiple) != 'undefined' && arg.multiple){ 
             this.showMultipleIcons(arg);   
          } else if(typeof(arg.enroute) != 'undefined' && arg.enroute){ 
             this.enroute(arg); 
          }   
        },
    
        "getColorBase" : function(arg){
          var code = arg.code;
          return (code.length == 4 ) ? code.substr(0, 2) : 13;
        },
        
       "removeOverlays" :  function(arg){
           L.MireoMap('hideInfoWindow');
           $.removeData(ALT.BODYLAYOUT,'marker');
           $.removeData(ALT.TPANEL[1],'poi');
           for(var a in this.onTheWay) this.removeEnroute({param : a});                
           while(this.marker.length > 0) this.marker.pop().remove(); 
           L.Layer('clearDefault'); 
        },     
        
        "removeEnroute" : function(arg){
           var TO = this.onTheWay[arg.param];
           while(TO.length > 0)
           TO.pop().remove();          
        },
        
        "enRouteOrganise" : function(arg){
           if(typeof(this.onTheWay[arg.cat]) == 'undefined') this.onTheWay[arg.cat] = new Array();    
        },
        
        "enroute" : function(arg){
          var len = arg.result.length;          
          var others = arg.cats.split(",");
          var elem = others[0].split(":")[1];  
          this.enRouteOrganise({cat : elem});
          for(var t = 0; t < len ;t++){ 
             var param = arg.result[t];  
             this.subEnroute(param,elem,t);
          }
        },
        
        "subEnroute" : function(param,elem,t){
            var inner_html = "";var mark = "";
            param.code = (param.code == '' || param.code == '1001') ?  '1301' : param.code;
            var color = this.getColorBase({"code" : param.code});    
            inner_html = "<div class='poi_mark_no' style='color:"+ALT.SRCCX[color]+"'>"+ (t+1) +"</div>";
            mark = $(HTMLHelper.mapMarker("images/poi_numbered/"+color+".png", 32, 38, null, null, ALT.BOOL[0], inner_html)); 
            this.onTheWay[elem].push(($(this.element[0]).MireoMap("addMarker",mark,new Point(param.x, param.y))));
            var that = this;
            mark.bind('click mousemove mouseleave',function(e){
                e.stopPropagation();            
                if(e.type == 'mousemove'){                  
                  that.showTooltip(param.poiName,e);  
                } else {
                  that.removeTooltip();  
                  if(e.type == 'click'){
                    var TA = [];TA.push("<div style='width:300px' >");
                    TA.push(L.Layer('poiWrapper',{request : param}));              
                    TA.push("</div>");                     
                    mf.MarkerFactory('showIBox',{layout : TA.join(""), x : param.x ,y : param.y});                   
                    AC.release(TA);    
                  }
                }
           });
         },
        
        "bindMarkers" : function(arg){
          var len = arg.result.length;
          var that = this;
          for(var t = 0 ; t<len;t++){
             $(this.marker[t]).bind('click mousemove mouseleave',{idx : t},function(e){
                e.stopPropagation();            
                if(e.type == 'mousemove'){                  
                  that.showTooltip(arg.result[e.data.idx].poiName,e);  
                } else {
                  that.removeTooltip();  
                   if(e.type == 'click'){                
                    if(typeof(arg.callback) === 'undefined'){
                      that.showIBox(arg.result[e.data.idx]); 
                    } else {
                      arg.callback(e.data.idx); 
                    }
                  }
                }    
            }); 
          }
        },
        
         "showMultipleIcons" : function(arg){
          var len = arg.result.length;
          if(arg.remove) this.removeOverlays();

          for(var t = 0; t < len ;t++){ 
            if(t >= arg.start && t < arg.end) continue;
            this.multiMarker(arg,t);  
          }
          
          var xArr  = null;var yArr = null;
          if(arg.bounds){
            xArr  = new Array();
            yArr  = new Array();
          }
          
          for(t = arg.start;t < arg.end ;t++){ 
            this.multiMarker(arg,t);
            if(arg.bounds){
              xArr.push(arg.result[t].x);
              yArr.push(arg.result[t].y);  
            }
          }
          
          if(arg.bounds) this.zoomToResultBound(xArr,yArr);  
          this.bindMarkers(arg); 
        },
        
        "zoomToResultBound" : function(b1,b2){
           var maxX = Array.max(b1);
           var maxY = Array.max(b2);
           var minX = Array.min(b1);
           var minY = Array.min(b2);
           M.MireoMap("setBounds", {x1: minX, x2: maxX, y1: minY, y2:maxY}); 
        },
        
        "addDMarker" : function(arg,t){
            var color = null;                    
            t = (typeof(t) === 'undefined') ? parseInt(arg.index) : parseInt(t);            
            if(arg.markByColor){
             color = this.getColorBase({"code" : (arg.code == ''  || typeof(arg.code) == 'undefined') ?  '1301' : arg.code});
            } else {
              color = '13';  
            }
            var inner_html = "<div class='poi_mark_no' style='color:"+ALT.SRCCX[color]+"'>"+ (t+1) +"</div>";
            var mark = $(HTMLHelper.mapMarker("images/poi_numbered/"+color+".png", 32, 38, null, null, ALT.BOOL[0], inner_html));
            this.marker.push($(this.element[0]).MireoMap("addMarker",mark,new Point(parseFloat(arg.x),parseFloat(arg.y))));
        },
        
        "multiMarker" : function(arg,t){
          var mark = null;
          var inner_html = "";var color = "";          
          var temp = arg.result[t];  
          if(t >= arg.start && t < arg.end ){
              if(temp.user == 1){
                mark = $(HTMLHelper.mapMarker("images/add_place_icon.png", 28, 43));
              } else {
                if(arg.markByColor){
                   temp.code = (temp.code == ''  || typeof(temp.code) == 'undefined') ?  '1301' : temp.code; 
                   color = this.getColorBase({"code" : temp.code});
                } else {
                   color = '13';  
                }
                inner_html = "<div class='poi_mark_no' style='color:"+ALT.SRCCX[color]+"'>"+ (t+1) +"</div>";
                mark = $(HTMLHelper.mapMarker("images/poi_numbered/"+color+".png", 32, 38, null, null, ALT.BOOL[0], inner_html));                                           
              }
          } else {
                mark = $(HTMLHelper.mapMarker((arg.markByColor) ? 'images/circles/'+this.getColorBase({"code" : temp.code})+'.png'  : 'images/circles/13.png', this.options.smallSrc.x ,this.options.smallSrc.y));                  
          }
          this.marker[t] = ($(this.element[0]).MireoMap("addMarker",mark,new Point(temp.x, temp.y)));         
        },
        
        "showSelectedIBox" : function(arg){
          this.marker[arg.index].trigger('click');  
        },
        
        "showIBox" : function(arg){
            if(typeof(arg.layout) === 'undefined'){
              var distance = '';              
              arg.layout = L.Layer('poiWrapper',{request: arg,distance : distance, 'byDistance':true ,enroute : false});
              if($(arg.layout).find('.getmore').length > 0){
                 arg.layout = arg.layout.replace('getmore', 'hidemore');  
              }
            } else if(typeof(arg.enroute) != 'undefined' &&  arg.enroute) {
              $((this.onTheWay[arg.flag])[arg.index]).trigger('click');
              return; 
            }
            
            var pt = new Point(arg.x, arg.y);
            L.MireoMap("showInfoWindow", pt, {
              inner: arg.layout,
              right : {
                title : '<div class="maplicon closebox" style="position:relative;float: right;top:0"  title="Close" ></div>',
                action: closeInfoWindow
              }
           });
           $('div[infowindow=1]').css({'z-Index':'4'});
           if(!L.Layer('levelOrCenterStatus')) L.MireoMap("moveCenterTo",pt);
           L.Layer('editPlace');
        },
        
        "dirLayout" : function(arg){
            var TA = [];                
            TA.push('<div style="width:275px;padding-right:0px;" class="idir"><b>Step :');
            TA.push(arg.step);
            TA.push('</b><br/>');
            TA.push(EnglishAdvisor.advice_to_text(arg.result));
            TA.push('<br/><b>');
            if(arg.distance) TA.push(arg.dis);
            TA.push('</b>');
            TA.push('</div><div class="cls"></div><div><table height="30px" cellspacing="1" cellpadding=3 border=0 width:"100%"><tr><td>');
            TA.push(arg.layout);
            TA.push("</td></tr></table></div>"); 
            L.MireoMap("setCenterAndZoomLevel",arg.location,null);
            this.showIBox({layout : TA.join(""),x : arg.location.x, y :arg.location.y});
        },
        
        "showDirBox" : function(arg){
            
             var total  = arg.result.length;
             var index  = arg.idx; 
             var layout = null;
             var that   = this;
             index  = (index < 0) ? 0 : index;
             if(index < total && index == 0) layout = '<div class="idirmore" align="right" style="width:288px;" ><img src="images/right.gif"  title="Next Step" alt="Next"  /></div>';
             else if(index < total && index < total-1) layout = '<div class="idirmore" style="width:270px"><img src="images/left.gif" title="Previous Step" alt="Previous" /></div><div class="idirmore" style="width:18px" ><img src="images/right.gif" title="Next Step" alt="Next"  /></div>';
             else if(index == total-1) layout = '<div class="idirmore"><img src="images/left.gif"  title="Previous Step" alt="Previous" /></div>';
             var record = arg.result[index];
             var dis = record.meters_to_next_advice;
             if (dis > -1) {
                if(parseInt(dis/1000) < 1) {
                    dis = "Go "+dis + " m ";
                } else {
                    dis = "Go "+parseInt(dis/1000) + " km ";
                }
                this.dirLayout({step : (index+1) , distance : true, dis : dis , layout : layout, result : record ,location : record.advice_location}); 
            } else {
               this.dirLayout({step : (index+1) , distance : false,layout : layout, result : record ,location : record.advice_location});                
            }
          
            var TOE = $('.idirmore');
            TOE.each(function(){
             var thatC = $(this);
             thatC.click(function(e){
                  e.stopPropagation();
                  var TP = $($(this).html()).attr('alt');
                  if( TP.indexOf('Next') > -1){
                     arg.idx = ++index;                      
                  } else if(TP.indexOf('Previous') > -1){
                     arg.idx = --index; 
                  }
                  that.showDirBox(arg); 
                });
            });
            AC.release(layout);AC.release(record); 
        }, 
        
        "showDefault" : function(arg){
           if(arg.remove) this.removeOverlays(); 
           var mark = $(HTMLHelper.mapMarker(this.options.src, this.options.size.x,this.options.size.y));           
           this.marker.push($(this.element[0]).MireoMap("addMarker",mark,arg.pt));           
           if(arg.ibox) {
             $.data(ALT.BODYLAYOUT,'marker',arg);
             var that = this;
             mark.bind('click mousemove mouseleave',function(e){
                e.stopPropagation();            
                var param = $.data(ALT.BODYLAYOUT,'marker');  
                if(e.type == 'mousemove'){                  
                  that.showTooltip(param.content,e);  
                } else {
                  that.removeTooltip();  
                  if(e.type == 'click'){
                    L.MireoMap("showInfoWindow", param.pt, {inner:"<span>"+param.content+"</span>",right : {title : '<div class="maplicon closebox" style="position:relative;float: right;top:0"  title="Close" ></div>',action: closeInfoWindow}});   
                  }
                }
             });   
           }
         },        
        
        "showTooltip" : function(content,pt){  // Display Tooltip Content
            this.removeTooltip();
            pt = this.getPixel(pt);
            pt.x +=10;            
            $(ALT.BODYLAYOUT[2]).append("<div class='mtip_show' style='top:"+pt.y+"px;left:"+pt.x+"px;'>"+ content+"</div>");
            AC.release(pt);
          },
          
        "removeTooltip" : function(){  // Hide Tooltip Content or Remove marker Tooltip
           $('.mtip_show',ALT.BODYLAYOUT[2]).remove();
        },
        
        "getPixel" : function(e) {
            var x = 0;var y = 0;
            if (e.pageX || e.pageY) {
                x = e.pageX + document.body.scrollLeft + document.documentElement.scrollLeft;
                y = e.pageY + document.body.scrollTop + document.documentElement.scrollTop;// - this.options.top;
            }else if (e.clientX || e.clientY){
                x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
                y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
            }
            var pt = new Point(x,y);
            return pt;
        }
        
   });
   
   $.fn.mapSearch = function(options) {
       var defaults   = {alternate   : false, perPage : 5};
       $.extend(defaults, options);
       return this.each(function() {
          var TA = [];
          var that = this;
          var output = defaults.result;
          $.data(this,"service",output);  
          var control = defaults.C;
          TA.push('<div id="shortdir"></div>');
          
          if(output._addr != 'current map view' && layer == 'Maps'){
              TA.push('<div class="main_search"><form name="sSearch" id="sshortcut" lang="200" action="" target="gError" onSubmit="return false;" ><table width="98%" border="0" cellspacing="0" cellpadding="4"> <tr> <td valign="top" width="34"  ><div class="maplicon mapsearch"></div></td> <td valign="top"> <div class="poi_ntxt" id="current">');
              
              if(output.eloc != null && output.eloc.length > 0) {
                  TA.push('<b><a title="');
                  TA.push(output._addr);
                  TA.push('" href="" target="_blank" class="poi_heading" style="font-weight:normal">');
                  TA.push(output._addr);
                  TA.push('</a></b>');
                  TA.push('<div id="moreDetail"></div>');
              } else {
                 TA.push('<b>'); 
                 TA.push(output._addr);
                 TA.push('</b>');
              }
              TA.push('<div class="link_dir_tofrom"><span>Get Directions</span><span>Search Nearby</span></div></div></td></tr><tr><td></td><td><div id="shortcut_Search_Nearby"><div class="sidebar_search_sbg" ><input name="B" type="text" lang="shortcut_Search_Nearby" class="search_txt_sml" id="lcs_poi" onblur="txtBlur(this);" /><span id="ph_lcs_poi" class="placeholder_nearhby" onclick="getFocus(this);" >Enter category (eg. ATM, Hotel)</span></div><div class="b_left"><input type="submit" value="GO" class="button_share" style="padding:4px" title="GO"></div></div>');
              
              // Tips Related Code
              //alert($("#autosel").val());
              if($("#autosel").val()=="yes"){
                if(searchOBJ.p !=3 && searchOBJ.p !=5){
                     // Tips Related Code
                    TA.push('<div class="thumbs_cont" id="tip_tr" ><div class="page_recomd"><span class="thumbs_up  thumbs"> <table> <tr> <td> <img src="images/tips/thumb_green.gif" width="17" height="21" align="absmiddle" style="cursor:pointer;" /></td> <td><span class="th_no" id="tips_up">0</span> </td> </tr> </table>');
                    TA.push('</span> <span class="thumbs_down thumbs"> <table> <tr> <td> <span class="th_no_1" id="tips_down">0</span></td> <td> <img src="images/tips/thumb_grey1.gif" width="17" height="21" align="absmiddle" style="cursor:pointer;" /></td> </tr> </table></span>');
                    TA.push('<div class="cls"> </div><div class="tips_count"><span id="travel_tips">0</span><span id="tpalink" > Travel Tips </span> | <a href="#" id="tip_ah" class="thumbs">Write a tip</a></div>   <div class="cls"> </div>');
                    TA.push('</div></div>');

                     //TA.push('<div id="divthumb"></div>'); //-- For IMAGES
                }
              }
              TA.push('<div id="divthumb"></div>'); //-- For IMAGES
              TA.push('</td></tr></table></form></div>');
          }
          var flag = false;          
          if(typeof(output.list) == "undefined"){
                flag = true;
                TA.push('<div class="noResultsFound"><table><tbody><tr><td class="iconCol"><div class="alertIcon"></div></td><td><div class="textWrapper"><span>Sorry, we could not find provided input.</span><br><span class="line2">Please try your search again.</span></div></td></tr></tbody></table></div>');
          } else { 
                TA.push(output.list);
          }
          
          
          if(!flag && layer == 'Maps') TA.push('<div class="did_u_mean"> Useful places around here: </div><div class="maplicon poi_ricon usefulplaces"></div><div class="poi_rtxt"> <span title="Hotels">Hotels</span> <span title="Petrol Pump">Petrol Pump</span>  <span title="Local Transit">Local Transit</span>  <span title="Coffee">Coffee</span><br/> <span title="Restaurant">Restaurant</span>  <span title="Pubs and bars" >Pubs and bars</span>  <span title="ATMs">ATMs</span> <span title="Markets">Markets</span><br/><span title="Hospitals">Hospitals</span> <span title="Religious">Religious</span> <span title="Cinemas">Cinemas</span> <span title="Tourist Places">Tourist Places</span><br/><span title="Post Offices">Post Offices</span> </div><div class="cls"> </div>');
          if(defaults.service < 200) TA.push('<div> <table cellspacing="4" cellpadding="2" border="0"><tbody><tr><td><div class="maplicon wrong_txt_container"></div></td><td></td><td><span class="wrong_txt_msg"> Something wrong here?</span></td></tr></tbody></table></div>');                
          if(document.all){
           document.getElementById($(this).attr('id')).innerHTML = TA.join("");
          } else {
           $(this).html(TA.join(""));
          }
          
          if(defaults.service >= 100 &&  defaults.service <= 200){  // Map:100 , ELOC:102 , RCLK:101
            control.buildpast({x : output.point.y ,y : output.point.x , addr : output._addr, index : 1 , "setter" : true , flush : true});   
            var TD = $('.link_dir_tofrom span',this);
            TD.unbind().click(function(e){
                e.stopPropagation(); 
                if($(this).attr('class').indexOf('remove_uline') > -1) return;
                TD.removeAttr('class');
                var idx = TD.index(this);
                $(this).addClass('remove_uline');
               
                if(idx == 0){
                  control.showDirection({'close' : true ,'show': true,'param' : [ L.Layer('getValue',{'key' : 'DTYPES', 'index':4}),output._addr]},function(){
                  $("#shortcut_Search_Nearby").hide(); 
                });      
               } else if(idx == 1){
                 $("#shortcut_"+$(this).text().replace(/\s/g,"_")).slideDown(); 
                 $("#shortdir").html("");
               }
           });
           control.shortcut({holder : this});
           mf.MarkerFactory('add',{vdefault : true , pt : output.point, remove :(defaults.service  >= 100 && defaults.service <200) ? true : false,'ibox':true ,'content' : output._addr});
           
           if(defaults.service < 200){
               if(output.eloc != null && output.eloc.length > 0){
                 control.fireProcess({view:"1", q : 105 ,common:true, search : output.eloc , callback : function(response){
                    $("#moreDetail").html(control.options.oapp.partner.call(control.options.oapp,response));
                          //-- For photos -sid
                          if(response.content.photos !=""){
                                var htmlstr="";
                                var photos=response.content.photos;
                                var photosArr=photos.split(",");
                                for(var zx=0;zx<photosArr.length;zx++){
                                  htmlstr=htmlstr+"<li><a href='http://maps.mapmyindia.com/add-a-spot/upload/"+photosArr[zx]+"' rel='poiPics[gal2]'><img src='http://maps.mapmyindia.com/add-a-spot/upload/"+photosArr[zx]+"' alt='' height='75px' width='75px'  class='resizeme_thumb' /></a></li>";
                                }
                                var TA = new Array();
                                TA.push("<div id='easeMenu' class='menu2' >");
                                TA.push("<ul class='gallery clearfix'>");
                                TA.push(htmlstr);
                                TA.push("</ul>");
                                TA.push("</div>");
                                $("#divthumb").html(TA.join(""));

                                $( ".resizeme_thumb" ).aeImageResize({ height: 75, width: 75 });
                                $("#easeMenu").easeMenu({ulPadding:0, velocity: 300, edges:50, debug: true});
                                //-- IMAGE GALLERY
                                $("area[rel^='poiPics']").prettyPhoto();
				$(".gallery:first a[rel^='poiPics']").prettyPhoto({animation_speed:'normal',theme:'light_square',slideshow:3000, autoplay_slideshow: false});
				$(".gallery:gt(0) a[rel^='poiPics']").prettyPhoto({animation_speed:'fast',slideshow:10000, hideflash: true});

				$("#custom_content a[rel^='poiPics']:first").prettyPhoto({
                                    custom_markup: '<div id="map_canvas" style="width:260px; height:265px"></div>',
                                    changepicturecallback: function(){ initialize(); }
				});

				$("#custom_content a[rel^='poiPics']:last").prettyPhoto({
                                    custom_markup: '<div id="bsap_1259344" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div><div id="bsap_1237859" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6" style="height:260px"></div><div id="bsap_1251710" class="bsarocks bsap_d49a0984d0f377271ccbf01a33f2b6d6"></div>',
                                    changepicturecallback: function(){ _bsap.exec(); }
				});
                                //-- IMAGE GALLERY
                          } //-- End Photos Code
                 }});    
               }               
               
               $('.wrong_txt_msg',this).unbind().click(function(e){
                   e.stopPropagation();
                   control.fireProcess({view:"1", q : 401 ,'common' : true, search : "Map" ,value : output._addr, callback : function(response){ 
                     L.Layer('setTitle',{param :"Report a Problem"});
                     control.setPageLayout({result : {content : response.content},index : parseInt(response.container),callback : function(response){
                        $('body').APL({action : 1});var TA = [];TA.push(response.y);TA.push(response.x);
                        $(ALT.TPANEL[2]).find('input[name=geo]').val(TA.join(","));$('body').APL({action : 0});                                
                     }});
                   }});
               });
           
               $("span[alternate=1]",this).unbind().click(function(e){ // Map Search Alternate Hide/Show
                e.stopPropagation();
                if($(this).html().indexOf("Show") > -1){
                  $('ul[alternate=1] li',that).show();
                  $(this).html("Hide");
                } else {
                  var idx = 0;
                  $('ul[alternate=1] li',that).hide();
                  $('ul[alternate=1] li',that).each(function(){
                    if(idx++ < defaults.perPage)
                     $(this).show(); 
                    else 
                     $(this).hide();
                  });
                  $(this).html("+ Show more");
                }
               }); 
           }
           
           //-- Tips Related Code
             
            
             $(".thumbs").unbind().click(function (e){
                  e.preventDefault();
                  var that = L.Layer('getBuilder');  
                  if(that.isLogin()){                      
                      L.Layer('showtips');                     
                  } else {
                      that.lightShadow({holder : 'body',content : ""});
                      $(ALT.BODYLAYOUT[8]).show();
                      that.fireProcess({'view':1,'q' : 'tips', 'callback':function(){
                        /* that.lightShadow({holder : 'body',content : ""});                             
                         $(ALT.BODYLAYOUT[8]).show();*/                         
                      }});                      
                  }
              });
              
             if($(".thumbs").length > 0 ) dispTip();             
             
             if(typeof(defaults.flag) != 'undefined' && !(defaults.flag)){
                control.setTitle({param : output._addr});
                control.setUrl({'hash' : true , 'param' : "map+of+"+(output._addr).replace(/\s/g,'+')});
                mlog.setValue(output._addr);mlog.setUrl(window.location.toString());mlog.persist();                
             }
     }
     
     //--POI suggest Sid
          $("#ph_isearch").hide();
          $("#lcs_poi").autoSuggest("poicat.php",{'asHtmlID':"lcs_poi",selectedItemProp:"addr",searchObjProps:"addr",selectedValuesProp:"link","resultsHighlight":false});
          //--
     
     if(layer == 'Maps') M.MapLayer('searchUseful');              
     $(ALT.TPANEL[0]).show().scrollTop(0);      
     for(var i=2;i<ALT.TPANEL.length;i++) $(ALT.TPANEL[i]).hide().html("");
     $(ALT.TPANEL[1]).show();
     
      
  });
};
   
   $.fn.places = function(options) {
        var defaults = {
            perPage : 10,
            maxPage : 5,
            page : 0
        };
        
        $.extend(defaults, options);
        return this.each(function() {
            var that = this;
            var control = defaults.C;  
            var output = control.poilist({'pagination' :  {'top' : true , 'bottom' : true},
                         'service' : defaults.service,
                         'hover' :true,
                         'result' : defaults.result,
                         'resultInfo' :true,
                         'markByColor' : false,
                         'byDistance' : true ,
                         'markByNum' : true,
                         'sortFilter' : true ,
                         'page' : defaults.page});   
                                                     
           $(that).mapSearch({"service" : defaults.service, result : output ,'C' : control , 'remove' : false ,'flag' : true});
                      
           if(typeof(output.total) != 'undefined' || output.total  > 10){
              $('div[poption]',ALT.TPANEL[1]).each(function(){
                    $(this).pagination(output.total, {current_page :output.page ,  callback: function(go){
                    $(that).unbind();   
                    mf.MarkerFactory('removeOverlays');
                    $(that).places({'service' : defaults.service, 'result' : defaults.result ,'page' : go,'C' :control});
                  },items_per_page:10});
              });
          }
           
          $.removeData(that,'poi');
          $.data(that,'poi',{result : defaults.result, page : defaults.page});            
          L.Layer('poiShortcut',{holder : that});
           
          var poifilter = $('.poifilter a ');
          poifilter.unbind().click(function(e){
              e.preventDefault();
              var TO = control.pastprocess();
              TO.dis = 1;
              control.postprocess({param : TO});
          });  
          
          L.Layer('editPlace');
          L.Layer('zoomAndAction',{more : control.levelOrCenter,slideup  :true});
        });
    };

   $.fn.direction = function(options) {
          options = jQuery.extend({
                        enroute : true,
                        enroute_holder  : null,
                        enroute_filters : ['1201:ATMs','1001:Hotels','1005:Petrol Pumps','11:Restaurants','1706:Hospitals','20:Tourist Places']
          },options||{}); 
          
          function enrouteCategory(item){
              var param = (options.uenroute != null) ? options.uenroute.split(",") : "";
              var TA = [];              
              TA.push('<td width="12"><input name="poiname" type="checkbox" lang="');
              TA.push(item[0]);
              TA.push('" value="');
              TA.push(item[1]);              
              if($.isArray(param)){
                for(var i=0;i<param.length;i++){
                    if(item[1] == param[i])TA.push('" checked="true');  
                }
              }
              TA.push('"/></td><td>');
              TA.push(item[1]);
              TA.push("</td>");
              return TA.join("");             
          };
          
          return this.each(function() {         
           var that = this; 
           var temp = options.pass; 
          
           L.MireoMap("calculateRouteWithAdvices", temp, function(route) {               
                     var num = route.advices.length;                   
                     if(num > 0){                         
                        routeDrawer.Destroy();
                        routeDrawer = new RouteDrawer($(options.me.element[0]));
                        routeDrawer.SetRoute(route);
                        routeDrawer.Draw(true);
                        TA = null;TA = new Array();
                        var rPts  = new Array();
                        var totalMinutes = route.time_length/60;
                        var hour = parseInt(totalMinutes/60);
                        var min  = parseInt(totalMinutes % 60);
                        var distance = (parseInt(route.length)/1000).toFixed(1);    
                        TA.push('<div id="shortdir" style="border-bottom: 1px solid rgb(204, 204, 204); margin-bottom: 10px; display: block;">');
                        TA.push(options.me.m300layout({'close': (layer == 'Maps') ? ALT.BOOL[0] :ALT.BOOL[1] , 'param' : temp, 'show' : ALT.BOOL[1]}));
                        TA.push('</div><div class="show_alongh">Show along the route</div><div class="show_alongbox"><table width="100%" border="0" cellspacing="0" cellpadding="1">');
                        var numFilter = options.enroute_filters.length;                        
                        var odd = numFilter/2 ;
                        odd = (odd > 0) ? numFilter.length-1 : -1;                        
                        for(var i =0 ; i < numFilter;i++){
                          var item = options.enroute_filters[i++].split(":"); 
                          TA.push('<tr>');
                          TA.push(enrouteCategory(item));
                          if(i != odd){
                           item = options.enroute_filters[i].split(":");   
                           TA.push(enrouteCategory(item));
                          }
                          TA.push("</tr>");
                        }
                        TA.push('</table></div><div class="dir_tab"><ul><li class="selected"><a href="" onclick="return false"><span>Directions</span></a></li><li><a href="" onclick="return false"><span>Along the Route</span></a></li></ul></div><div class="cls"> </div><div id="dirSubContainer"><div id="dirSubContainer_0">');
                        TA.push('<div class="dir_time_cont"> ');
                        if(hour > 0 && min > 0){
                            TA.push('<div class="total_time_s"> <p>TOTAL TIME </p>');
                            TA.push(hour);TA.push(" Hour ");
                            TA.push(min);TA.push(" Min ");
                            TA.push('</div>');
                            TA.push('<div class="total_distance_s"> <p>TOTAL DISTANCE </p>');
                            TA.push(distance);
                            TA.push(' KM</div>');
                        } else {
                            TA.push('<div class="total_time"> <p>TOTAL TIME </p>');
                            if(hour > 0){TA.push(hour);TA.push(" Hour ");}
                            if(min > 0) {TA.push(min);TA.push(" Min");}
                            TA.push('</div>');
                            TA.push('<div class="total_distance"> <p>TOTAL DISTANCE </p>');
                            TA.push(distance);
                            TA.push(' KM</div>');
                        }
                        
                        TA.push('</div><div class="cls"> </div><div class="wrong_txt_subchild"><table border=0 cellSpacing=4 cellPadding=2><tr><td><div class="maplicon wrong_txt_container"></div><td><td><span class="wrong_txt_msg"> Something wrong here?</span></td></tr></table></div><table border="0" cellSpacing="0" width="99%" cellPadding="6"><tr><td width="39"><div  class="maplicon dposition_start"></div></td><td  align="left">');
                        var index = 0;
                        TA.push((typeof(temp[index]) === "object") ? temp[index]._area : ((temp[index].split("["))[0]).trim());
                        TA.push('</td></tr></table><ul class="dir_ul">');
                        var count = 1;
                        index++;
                        for(var idx in route.advices) {
                            rPts.push(route.advices[idx].advice_location.x +" "+route.advices[idx].advice_location.y);
                            TA.push('<li><table border="0" cellSpacing="0" width="99%"  cellPadding="6"><tr><td class="dirSno" >');
                            TA.push(count);
                            TA.push('.</td>');
                            TA.push('<td class="dirContent">');
                            TA.push(EnglishAdvisor.advice_to_text(route.advices[idx]));
                            TA.push('</td>');
                            TA.push('<td class="dirDistance">');
                            var dis = route.advices[idx].meters_to_next_advice;
                            if (dis > -1) {
                                if(parseInt(dis/1000) < 1) {
                                    TA.push(dis);TA.push(" m ");
                                }else {
                                    dis = parseInt(dis/1000).toFixed(1);
                                    TA.push(dis);TA.push(" km ");
                                }
                            }
                            TA.push('</td>');
                            TA.push('</tr></table></li>');
                            if("Destination reached." == (EnglishAdvisor.advice_to_text(route.advices[idx])) || (EnglishAdvisor.advice_to_text(route.advices[idx])).indexOf("reach your destination.") > -1){
                                TA.push('</ul><table border="0" cellSpacing="0" width="99%" cellPadding="6"><tr><td width="39"><div class="dir_ricon_new maplicon dposition_');
                                var isLast = ALT.BOOL[0];
                                if(index > 0 && index <temp.length-1){                              
                                    TA.push(index);
                                } else if(route.advices.length-1 == idx){
                                    TA.push('last');
                                    isLast = true;
                                }
                                TA.push('"></div></td><td align="left">');
                                TA.push((typeof(temp[index]) === "object") ? temp[index]._area : ((temp[index].split("["))[0]).trim());
                                index++;
                                TA.push('</td></tr></table>');
                                if(!isLast) TA.push('<ul class="dir_ul">');
                          }
                          count++;
                    }
                    TA.push('<div class="wrong_txt_subchild"><table border=0 cellSpacing=4 cellPadding=2><tr><td><div class="maplicon wrong_txt_container"></div><td><td><span class="wrong_txt_msg"> Something wrong here?</span></td></tr></table></div></div><div id="dirSubContainer_1"></div><div class="cls"></div></div>'); //</li><li><div>Other Info</div></li></ul></div>
                    if(document.all) document.getElementById($(that).attr('id')).innerHTML = TA.join(""); else $(that).html(TA.join(""));
                    options.me.m300Binder({param : 1}); 
                    if(options.enroute) { //alert("points : " + rPts.join(""));
                      var div = $(ALT.TPANEL[1])[0];
                      $.data(div, "en_pt",options.me.callEncodeOrDecoder({param : rPts.join(","), index : 0}));  
                    }
                    rPts = null;
                    $('.wrong_txt_subchild').unbind();
                    $('.wrong_txt_subchild').click(function(e){
                         e.stopPropagation();
                         TA = null;
                         TA = new Array();
                         document.title='Report a Problem';                    
                         TA.push('<div class="add_place" ><div class="feedback_gstrip"><div class="maplicon feedback_headOpt feedback_bottom_left"> </div><div lang="other_forms" react="1" title="Close" class="maplicon closebox panel_close" onclick="parent.closeMe(this)"></div><p class="panel_paragraph"><span>Report a Problem</span><br/>Click the icon to report an error at any given step <br /> or just give a <a href="" id="generalFbk">general feedback</a>.</p> </div><form id="fbk" name="fbk" method="post" target="error"  onsubmit="return vFeedbackChild(this); " ><div class="add_placef" id="gfeedback" style="border-bottom:1px solid #ccc;display:none;"><div id="generalDiv"><td width="92%"><table width="100%" border="0" cellspacing="0" cellpadding="4"><tr><td><textarea name="fbk1" id="fbk1" class="add_place_input_gen"></textarea></td><td><span id="generalClose"  class="add_place_close" alt="close" title="close">X</span></td></tr> </table></div></div>');
                         var count = 1;
                         for(var idx in route.advices) {
                            TA.push('<div class="dtxt"><div class="dir_slno">');
                            TA.push(count);
                            TA.push('.</div><div class="dir_txt_feeddir">');
                            TA.push(EnglishAdvisor.advice_to_text(route.advices[idx]));
                            var dis = route.advices[idx].meters_to_next_advice;
                            if(dis > -1) {
                              TA.push('(');
                              if(parseInt(dis/1000) < 1) {
                                TA.push(dis);TA.push(" m ");
                              } else {
                                dis = parseInt(dis/1000).toFixed(1);
                                TA.push(dis);TA.push(" km ");
                              }
                              TA.push(')');
                             }
                             TA.push('</div><div class="maplicon dir_txt_km_feeddir report_something_wrong"  >');
                             TA.push('</div><div class="cls"></div></div>');
                             count++;
                         }
                         TA.push('<div class="add_placef"> <p>Please enter your email address<span>*<span></p><input name="email" type="text" ');
                         if($('.profile_left span',"#logme").text().length > 0){
                            TA.push(' readOnly=true value="');
                            TA.push($('.profile_left span',"#logme").text());
                            TA.push('" ');
                         }
                         TA.push(' class="add_place_input" /><input id="type" name="type" type="hidden" value="dir"></input></div><div class="add_placef"><input type="submit" class="button_share" value="SUBMIT"><div id="error" style="font-size:11px;margin: 15px 0px 5px 0px;height:20px;" ></div></div></form><div class="feedback_error"></div></div>');
                         $(ALT.TPANEL[1]).hide();
                         if(document.all){
                            document.getElementById($(ALT.TPANEL[3]).attr('id')).innerHTML = TA.join("");  
                         } else {
                            $(ALT.TPANEL[3]).html(TA.join(''));                      
                         }
                         $(ALT.TPANEL[0]).scrollTop(0).show();AC.release(TA);
                         options.me.m300Binder({param : 2});   
                     });
                     
                     var dTxt = $('.dir_ul li');                
                     dTxt.click(function(e){
                       e.stopPropagation();  
                       var idx = dTxt.index(this);                     
                       mf.MarkerFactory('showDirBox',{'result' : route.advices, "idx" : idx});
                      });              
                     
                      if(options.uenroute != null){
                         var enroutes = $('.show_alongbox input[type=checkbox]',ALT.TPANEL[1]);
                         var dirholder = $(ALT.TPANEL[1])[0];  
                         var TP = [];var TA = [];
                         internal = true;
                         enroutes.each(function(){if($(this).is(ALT.FLAGS[1]))TA.push($(this).val());});
                         TP.push(TA.join("|"));
                         TP.push($.data(dirholder, "en_pt"));
                         
                         options.me.fireProcess({method :'POST',view:1,q : parseInt($(ALT.TPANEL[1]).find(":first form").attr('lang'))+1,search :TP.join("*"), common : true ,callback:function(response){                           
                            options.me.enrouteContent(response);
                            
                         }}); 
                         options.me.dirTabSwitch({index: 1});
                      }                     
                    } else {
                      L.Layer('loadPrompt',{flag : 'e300'});
                    }
                    $('body').APL({action : 0});
                 }); 
       });
    };
    
    
   var ALT = {
       BODYLAYOUT : ['#header','#footer','body',"#poi_on_map","#shadowV","#shadowH","#fscreen","#lightShadow","#logme","#lightContainer"],
       TPANEL     : ["#panelContainer","#sidebar","#feedback","#other_forms"],
       BOOL       : [false,true],
       DTYPES     : ['string','object','mGeo','undefined','',null],
       PROCESS    : [100,101,102,103,104,105,200,201,202,203,204,205,206,300,301,302,303,400,401,402,403,500,501,502,503,504,505,506],
       FLAGS      : [':visible',':checked'],
       PROCESSOR  : ['controller.php','layer.php'],
       HFORM      : ['input[type=text]','textarea','input[type=hidden]','input[type=checkbox]'],
       POIDEFAULT : null,
       EVT        : ['click','mouseover','mouseleave','mousedown','hover','blur','focus'],
       SRCCX      : {'10':'#04ABFF','11':'#97C619','12':'#17CFDA','13':'#F70A8A','14':'#39A63F','15':'#065D8E','16':'#FED510','17':'#FC1800','18':'#FC7315','19':'#AD62AD','20': '#000','21':'#A31E84'}
   };
   
   Array.max = function( array ) {return Math.max.apply( Math, array );};
   Array.min = function( array ) {return Math.min.apply( Math, array );};   
   
 $.fn.autoSuggest = function(data, options) {
    var defaults = { 
        asHtmlID: false,
        startText: "",
        emptyText: "",
        preFill: {},
        limitText: "",
        selectedItemProp: "value", //name of object property
        selectedValuesProp: "value", //name of object property
        searchObjProps: "value", //comma separated list of object property names
        queryParam: "q",
        retrieveLimit: 20, //number for 'limit' param on ajax request
        extraParams: "",
        matchCase: false,
        minChars: 2,
        keyDelay: 100,
        resultsHighlight: true,
        neverSubmit: false,
        selectionLimit: 1,
        showResultList: true,
        start: function() {},
        selectionClick: function(elem) {},
        selectionAdded: function(elem) {
        },
        selectionRemoved: function(elem) {elem.remove();},
        formatList: false, //callback function
        beforeRetrieve: function(string) {return string;},
        retrieveComplete: function(data) {
            $("#autosel").val("");
            entireData=data;
            return data;
        },
        resultClick: function(data,flag) {
              $("#"+opts.asHtmlID).val((data['attributes'])['addr']);  
              searchOBJ=data.attributes;
              if(flag && (layer == 'Movies' || layer == 'Deals' ||tlayer == 'Movies' || tlayer == 'Deals')){
                if(opts.asHtmlID == 'isearch'){  
                  try {$('#gSearch').trigger('submit');} catch(e) {}
                }               
              } else if(layer == 'Maps'){
               // $("#"+opts.asHtmlID).val((data['attributes'])['addr']);                
                if(opts.asHtmlID.search("dirauto") != -1){
                  var idx = opts.asHtmlID.replace(/dirauto/,"");
                  L.Layer("buildpast",{x : searchOBJ.y ,y : searchOBJ.x , addr :searchOBJ.addr , index : idx  , "setter" : true , flush : false});
                  //$("#H"+opts.asHtmlID+"").val('[{"address":"'+searchOBJ.addr+'","eloc":"","pos":{"lat":'+searchOBJ.y+',"lon":'+searchOBJ.x+'},"type":1,"lev":'+searchOBJ.z+',"eid":0}]');
                }
             
                if(opts.asHtmlID=="isearch"){
                  $("#autosel").val("yes");
                  LID=searchOBJ._id;
                }
                
                if(opts.asHtmlID=="city"){
                 $("#mmpnt").val('');
                }
             }
        },
        resultsComplete: function(){ 
         /*
         if($('#tiptip_holder').length > 0){   
           $("#tiptip_holder").fadeOut(1); //-- Sid
         }*/
      }
    };  
    var opts = $.extend(defaults, options);	 		
    var d_type = "object";
    var d_count = 0;
    if(typeof data == "string") {
        d_type = "string";
        var req_string = data;
    } else {
        var org_data = data;
        for (k in data) if (data.hasOwnProperty(k)) d_count++;
    }
    if((d_type == "object" && d_count > 0) || d_type == "string") {
        return this.each(function(x){
            if(!opts.asHtmlID){
                x = x+""+Math.floor(Math.random()*100); //this ensures there will be unique IDs on the page if autoSuggest() is called multiple times
                var x_id = "as-input-"+x;
            } else {
                x = opts.asHtmlID;
                var x_id = x;
            }
            opts.start.call(this);
            var input = $(this);
            //-- sid
              //input.attr("autocomplete","off").addClass("as-input").attr("id",x_id).val(opts.startText);
              input.attr("autocomplete","off").addClass("as-input").attr("id",x_id);
           // -- sid
            var input_focus = false;
				
            // Setup basic elements and render them to the DOM
            //input.wrap('<ul class="as-selections" id="as-selections-'+x+'"><div class="cls"></div></ul>').wrap('<li class="as-original" id="as-original-'+x+'"></li>');
            //var selections_holder = $("#as-selections-"+x);
            //var org_li = $("#as-original-"+x);
            var selections_holder = input;
            
            var results_ul="";
             var results_holder="";
            if(opts.asHtmlID.search("dirauto") != -1 || opts.asHtmlID.search("lcs_poi") != -1){
                results_holder = $('<div class="as-results" style="margin-top:35px;" id="as-results-'+x+'" ></div>').hide();
                results_ul =  $('<ul class="as-list" style="top:0;margin-top:0;position:relative"></ul>');
            }else if(opts.asHtmlID.search("poitxtbox") != -1){
               results_holder = $('<div class="as-results" style="margin-top:35px;left:22px;" id="as-results-'+x+'" ></div>').hide();

                results_ul =  $('<ul class="as-list" style="position:relative;margin-top:0;"></ul>');
            
            }else{
                results_holder = $('<div class="as-results"  id="as-results-'+x+'" ></div>').hide();
                results_ul =  $('<ul class="as-list" style="position:relative;margin-top:0"></ul>');
            }
            
            var values_input = $('<input type="hidden" class="as-values" name="as_values_'+x+'" id="as-values-'+x+'" />');
            var prefill_value = "";
            if(typeof opts.preFill == "string") {
                var vals = opts.preFill.split(",");					
                for(var i=0; i < vals.length; i++){
                    var v_data = {};
                    v_data[opts.selectedValuesProp] = vals[i];
                    if(vals[i] != ""){
                        add_selected_item(v_data, "000"+i);	
                    }		
                }
                prefill_value = opts.preFill;
            } else {
                prefill_value = "";
                var prefill_count = 0;                                       
                for (var k in opts.preFill) if (opts.preFill.hasOwnProperty(k)) prefill_count++;
                if(prefill_count > 0){
                    for(var t=0; t < prefill_count; t++){
                        var new_v = opts.preFill[t][opts.selectedValuesProp];
                        if(new_v == undefined){new_v = "";}
                        prefill_value = prefill_value+new_v+",";
                        if(new_v != ""){
                            add_selected_item(opts.preFill[t], "000"+t);	
                        }		
                    }
                }
            }
                                
            if(prefill_value != ""){
                input.val("");
                var lastChar = prefill_value.substring(prefill_value.length-1);
                if(lastChar != ","){prefill_value = prefill_value+",";}
                values_input.val(","+prefill_value);
                $("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
            } 
            input.after(values_input);                                
            selections_holder.click(function() {
                input_focus = true;
                input.focus();
            }).mousedown(function(){input_focus = false;});
                                
            if(typeof(opts.ie) != "undefined" && opts.ie == 7){
                if(opts.status){  
                    $("body").append(results_holder);
                    results_holder.css({left : '70px' ,top : '92px','background-color':'#FFF'}); 
                } else {
                    selections_holder.after(results_holder);   
                    results_holder.css({left : '20px','margin-top':'25px','background-color':'#FFF'}); 
                }
            } else {
                selections_holder.after(results_holder);                                       
            }
            var timeout = null;
            var prev = "";
            var totalSelections = 0;
            var tab_press = false;
				
				// Handle input field events
				input.focus(function(){			
					if($(this).val() == opts.startText && values_input.val() == ""){
                                               $(this).val("");
					} else if(input_focus){
                                                $("li.as-selection-item", selections_holder).removeClass("blur");
                                                if($(this).val().match(/(in | around | nearby | to | via | from )/ig)) return;                                                 
                                                if($(this).val() != ""){
                                                   results_ul.css("width",selections_holder.outerWidth());                                                   
                                                   results_holder.show();                                                  
						}
					}
					input_focus = true;
					return true;
				}).blur(function(){
					if($(this).val() == "" && values_input.val() == "" && prefill_value == ""){
						$(this).val(opts.startText);
					} else if(input_focus){
						$("li.as-selection-item", selections_holder).addClass("blur").removeClass("selected");
						//results_holder.hide();
					}				
				}).keydown(function(e) {
					// track last key pressed
                                        $("#ph_"+opts.asHtmlID).hide(); // -- Sid Tooltip
                                      //  $("#tiptip_holder").fadeOut(1); //-- Sid Tooltip
                                        
					lastKeyPressCode = e.keyCode;
					first_focus = false;
                                        switch(e.keyCode) {
                                                case 38: // up
							e.preventDefault();                                                         
							moveSelection("up");
                                                       break;
						case 40: // down
							e.preventDefault();                                                        
							moveSelection("down");                                                        
							break;
						case 8:  // delete
							if(input.val() == ""){
								/*var last = values_input.val().split(",");
								last = last[last.length - 2];
								selections_holder.children().not(org_li.prev()).removeClass("selected");
								if(org_li.prev().hasClass("selected")){
									values_input.val(values_input.val().replace(","+last+",",","));
									opts.selectionRemoved.call(this, org_li.prev());
								} else {
									opts.selectionClick.call(this, org_li.prev());
									org_li.prev().addClass("selected");		
								}*/
							}
							if(input.val().length == 0){
								results_holder.hide();
								 prev = "";
							}
                                                        
                                                    //    values_input.val("");
                                                     //   alert(values_input.val());
                                                     
                                                        if($(":visible",results_holder).length > 0){
								if (timeout){clearTimeout(timeout);}
								timeout = setTimeout(function(){keyChange();}, opts.keyDelay);
							}
							break;
//						case 9: case 188:  // tab or comma                                                                                                                
//							tab_press = true;
//							var i_input = input.val().replace(/(,)/g, "");
//							if(i_input != "" && values_input.val().search(","+i_input+",") < 0 && i_input.length >= opts.minChars){	
//                                                                e.preventDefault();
//								var n_data = {};                                                                
//								n_data[opts.selectedItemProp] = i_input;
//								n_data[opts.selectedValuesProp] = i_input;																				
//								var lis = $("li", selections_holder).length;
//								add_selected_item(n_data, "00"+(lis+1));
//								//input.val("");
//                                                        }
//                                                        tab_press = false;
//                                                        break;
						case 13: // return
                                                        tab_press = false;                                                       
							var active = $("li.active:first", results_holder);
                                                        if(active.length > 0){
                                                            active.click();
                                                            results_holder.hide();
							}
							if(opts.neverSubmit || active.length > 0){
                                                            e.preventDefault();
							}
							break;
						default:
                                                    if(opts.showResultList){
                                                        if(opts.selectionLimit && $("li.as-selection-item", selections_holder).length >= opts.selectionLimit){
                                                            results_ul.html('<li class="as-message">'+opts.limitText+'</li>');
                                                            results_holder.show();
                                                        } else {
                                                            if (timeout){clearTimeout(timeout);}
                                                            timeout = setTimeout(function(){keyChange();}, opts.keyDelay);
                                                        }
                                                    }
                                                    break;
					}
				});
				
				function keyChange() {
					// ignore if the following keys are pressed: [del] [shift] [capslock]
					if( lastKeyPressCode == 46 || (lastKeyPressCode > 8 && lastKeyPressCode < 32) ){return results_holder.hide();}
					var string = input.val().replace(/[\\]+|[\/]+/g,"");
					if (string == prev) return;
					prev = string;
					if (string.length >= opts.minChars) {
						selections_holder.addClass("loading");
						if(d_type == "string"){
							var limit = "";
							if(opts.retrieveLimit){
								limit = "&limit="+encodeURIComponent(opts.retrieveLimit);
							}
							if(opts.beforeRetrieve){
								string = opts.beforeRetrieve.call(this, string);
							}
							$.getJSON((req_string+"?"+opts.queryParam+"="+encodeURIComponent(string)+limit+opts.extraParams), function(data){
                                                                d_count = 0;
								var new_data = opts.retrieveComplete.call(this, data);
								for (k in new_data) if (new_data.hasOwnProperty(k)) d_count++;
                                                                if(d_count == 0) {
                                                                  results_holder.hide();
                                                                } else {
								  processData(new_data, string); 
                                                                }
							});
						} else {
							if(opts.beforeRetrieve){
								string = opts.beforeRetrieve.call(this, string);
							}
							processData(org_data, string);
						}
					} else {
						selections_holder.removeClass("loading");
						results_holder.hide();
					}
				};
				var num_count = 0;
				function processData(data, query){
                                        
					if (!opts.matchCase){query = query.toLowerCase();}
					var matchCount = 0;
					results_holder.html(results_ul.html(""));
                                        results_holder.hide();                                        
                                        //if(d_count == 0) $('.as-results').slideUp(); 
                                        
					for(var i=0;i<d_count;i++){				
						var num = i;
						num_count++;
						var forward = false;
						if(opts.searchObjProps == "value") {
                                                    var str = data[num].value;
						} else {	
                                                    var str = "";
                                                    var names = opts.searchObjProps.split(",");
                                                    for(var y=0;y<names.length;y++){
                                                        var name = $.trim(names[y]);
                                                        str = str+data[num][name]+" ";
                                                    }
						}
                                                forward = true;
                                                /*
						if(str){
                                                    if (!opts.matchCase){str = str.toLowerCase();}				
                                                    if(str.search(query) != -1 && values_input.val().search(","+data[num][opts.selectedValuesProp]+",") == -1){
                                                        forward = true;
                                                    }	
						}*/
						if(forward) {
                                                    var formatted = $('<li class="as-result-item" id="as-result-item-'+num+'"></li>').click(function(){
                                                        var raw_data = $(this).data("data");
                                                        var number = raw_data.num;                     
                                                        if($("#as-selection-"+number, selections_holder).length <= 0 && !tab_press){
                                                            var data = raw_data.attributes;                                                            
                                                            input.val("").focus();
                                                            prev = "";
                                                            add_selected_item(data, number);
                                                            opts.resultClick.call(this, raw_data,true);
                                                            results_holder.hide();                                                                                                                       
                                                        }
                                                        tab_press = false;
                                                        
                                                        if(opts.asHtmlID == 'isearch') {
                                                            L.Layer('zoomAndAction',{more : false,slideup  :true});
                                                            if(tlayer == 'Maps' || tlayer == null){
                                                              var resObj  = new Object();
                                                              resObj.process = 'error';
                                                              resObj.service = '100' ;
                                                              resObj.error    = '{"list":{"num":"1","type":"map"},"tagName":"resultset","childList":[{"list":'+JSON.stringify(searchOBJ)+',"tagName":"result","childList":[]}]}';
                                                              resObj.response = null;
                                                              if(isNaN(resObj.error)) {resObj.process = 'calculate';resObj.response = resObj.error;resObj.error = null;}
                                                              L.Layer('setHistory',{param :searchOBJ.addr}); 
                                                              var current = L.Layer('getBuilder');   
                                                              try {
                                                                if(typeof(current.options.oapp) != 'undefined') current.options.oapp.autopass.call(current.options.oapp,{'auto' :resObj});                                                             
                                                              }catch(e){}
                                                              
                                                            } 
                                                         }

                                                        if(opts.asHtmlID=='city'){
                                                            ccenter(searchOBJ.x,searchOBJ.y,searchOBJ.z);
                                                        }
                                                    });
                                                    
                                                    formatted.mousedown(function(){input_focus = false;});
                                                    formatted.mouseover(function(){
                                                        $("li", results_ul).removeClass("active");
                                                        $(this).addClass("active");
                                                    });
                                                    
                                                    formatted.data("data",{attributes: data[num], num: num_count});
                                                    var this_data = $.extend({},data[num]);
                                                    if (!opts.matchCase){ 
                                                        var regx = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + query + ")(?![^<>]*>)(?![^&;]+;)", "gi");
                                                    } else {
                                                        var regx = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + query + ")(?![^<>]*>)(?![^&;]+;)", "g");
                                                    }
							
                                                    if(opts.resultsHighlight) {
                                                        this_data[opts.selectedItemProp] = this_data[opts.selectedItemProp].replace(regx,"<em>$1</em>");
                                                    }
                                                    if(!opts.formatList){
                                                        if(this_data['elc']!=undefined){
                                                            formatted = formatted.html(this_data[opts.selectedItemProp]+" ["+this_data['elc']+"] ");
                                                        }else{
                                                          formatted = formatted.html(this_data[opts.selectedItemProp]);
                                                        }
                                                    } else {
                                                        formatted = opts.formatList.call(this, this_data, formatted);	
                                                    }
                                                    results_ul.append(formatted);                                                   
                                                    delete this_data;
                                                    matchCount++;
                                                    if(opts.retrieveLimit && opts.retrieveLimit == matchCount ){break;}
                                                }
                                        }
					selections_holder.removeClass("loading");
					if(matchCount <= 0){
                                            results_ul.html('<li class="as-message">'+opts.emptyText+'</li>');
					}
                                        results_ul.css("width", selections_holder.outerWidth());
                                        if($('.as-list li').length > 0) {
                                          results_holder.show();                                        
					  opts.resultsComplete.call(this);
                                        }   
				};
				
				function add_selected_item(data, num){     
                                        values_input.val("");
                                        values_input.val(values_input.val()+data[opts.selectedValuesProp]);
                                        
					/*var item = $('<li class="as-selection-item" id="as-selection-'+num+'"></li>').click(function(){
							opts.selectionClick.call(this, $(this));
							selections_holder.children().removeClass("selected");
							$(this).addClass("selected");
						}).mousedown(function(){input_focus = false;});
                                                
					var elem = values_input.attr('id');
                                        var domObj = elem.split('values-');
                                        $("#"+domObj[1]).val(data[opts.selectedItemProp]);
                                        AC.release(domObj);AC.release(elem); */                                       
				};
				
				



                                function moveSelection(direction) {
                                    if($(":visible",results_holder).length > 0) {
                                        var lis = $("li", results_holder);
					if(direction == "down") {
                                            var start = lis.eq(0);
					} else {
                                            var start = lis.filter(":last");
					}
					var active = $("li.active:first", results_holder);
					if(active.length > 0) {
                                            if(direction == "down") {
                                                start = active.next();
                                            } else {
                                            	start = active.prev();
                                            }
					}
					lis.removeClass("active");
					start.addClass("active");

                                        if($('li.active:first',results_holder).length == 0){
                                                    input.val(prev);
                                                } else {
                                                    var raw_data = start.data("data");
                                                    var number = raw_data.num;
                                                    if($("#as-selection-"+number, selections_holder).length <= 0 && !tab_press){
                                                        var data = raw_data.attributes;
                                                        input.val("").focus();
                                                        //prev = "";
                                                        add_selected_item(data, number);
                                                        opts.resultClick.call(this, raw_data,false);
                                                    }
                                                  }
                                    }
                                    //$("#tiptip_holder").fadeOut(1); //-- Sid ToolTip
				};
									
			});
		}
           }

   /********** IMG RESIZE CODE - SID ***/
  $.fn.aeImageResize = function( params ) {
    var aspectRatio = 0
      ,	isIE6 = $.browser.msie && (6 == ~~ $.browser.version)
      ;
    if ( !params.height && !params.width ) {
      return this;
    }
    if ( params.height && params.width ) {
      aspectRatio = params.width / params.height;
    }
    return this.one( "load", function() {
      this.removeAttribute( "height" );
      this.removeAttribute( "width" );
      this.style.height = this.style.width = "";
      var imgHeight = this.height
        , imgWidth = this.width
        , imgAspectRatio = imgWidth / imgHeight
        , bxHeight = params.height
        , bxWidth = params.width
        , bxAspectRatio = aspectRatio;
      if ( !bxAspectRatio ) {
        if ( bxHeight ) {
          bxAspectRatio = imgAspectRatio + 1;
        } else {
          bxAspectRatio = imgAspectRatio - 1;
        }
      }
      if ( (bxHeight && imgHeight > bxHeight) || (bxWidth && imgWidth > bxWidth) ) {

        if ( imgAspectRatio > bxAspectRatio ) {
          bxHeight = ~~ ( imgHeight / imgWidth * bxWidth );
        } else {
          bxWidth = ~~ ( imgWidth / imgHeight * bxHeight );
        }
        this.height = bxHeight;
        this.width = bxWidth;
      }
    })
    .each(function() {
      if ( this.complete || isIE6 ) {
        $( this ).trigger( "load" );
      }
    });
  };
 eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('R.1b.1c=5(d){3 f=R.1d({S:0,T:1e,U:1f,V:1g,W:8,X:5(){},Y:5(){},K:5(){},Z:5(){},10:5(){}},d);3 g=$(1);3 h=f.S;3 i=f.T;3 j=f.U;3 k=f.V;3 l=f.W;3 m=g.7();g.11({1h:\'1i\'});3 n=g.x("12");n.11({L:"1j%"});3 o=n.x(\'M:1k-13\');3 p=n.x(\'M:1l-13\');p.F("14");o.F("15");3 q=o[0].N+o.7();3 r,G,H,y,z,A;3 s=[];3 t=g.x("12 M");t.1m(5(e){f.10.9(1);s.1n({16:$(1).x(\'a\').1o(\'16\'),17:$(1).17(),L:$(1).L()});4($(1).u("v")){f.Z.9(1);r=$(1);1p.1q(5(){G=O.P(r.I().6-g.I().6);q=o[0].N+o.7();4((q-G)<g.7()){n.B({6:-q+g.7()},{C:8,D:i})}w{n.B({6:-G},{C:8,D:i})}},k)}$(1).1r(5(){4(!$(1).u("v")){r.Q("v");f.K.9(r);r=$(1);$(1).F("v");$(1).Q("J")}f.X.9(1);4(l){$("#1s").E(e)}});$(1).1t(5(){4(!$(1).u("v")){$(1).F("J");f.Y.9(1)}4($(1).u("14")){y="1u > "+e}w 4($(1).u("15")){y="1v > "+e}w{y="1w > "+e}4(l){$("#1x").E(y)}},5(){4(!$(1).u("v")){$(1).Q("J");f.K.9(1)}})});g.1y(5(e){3 a=o[0].N+o.7();3 b=O.P((e.18-g.I().6)*(m-a)/(m));3 c=O.P((g.I().6-e.18)+(g.7()/2));4(c>0){H="<< "+c;h=-h}w{H=">> "+c;h=h}z=b;4((z+h)>-j){n.B({6:0},{C:8,D:i});A="19 6 << 1a"}w 4(c<-(g.7()/2-j)){n.B({6:m-a},{C:8,D:i});A="19 1z >> 1a"}w{A="J 1A 1B";n.B({6:z+h},{C:8,D:i})}4(l){$("#1C").E("1D 1E "+A);$("#1F").E(H);$("#1G").E(z+h)}})};',62,105,'|this||var|if|function|left|outerWidth|false|call|||||||||||||||||||||hasClass|selected|else|find|tracer2|movementer|outer|animate|queue|duration|html|addClass|moveto|tracer|offset|over|extendOut|width|li|offsetLeft|Math|round|removeClass|jQuery|ulPadding|velocity|edges|delayToAutoSelect|debug|extendClick|extendOver|extendSelected|extendNormalState|css|ul|child|firstItem|lastItem|href|height|pageX|near|edge|fn|easeMenu|extend|800|100|300|overflow|hidden|1000|last|first|each|push|attr|window|setTimeout|click|clicked|hover|FirstItem|LastItem|Item|overelement|mousemove|right|middle|div|out|You|are|mousepos|movement'.split('|'),0,{}))
 /****** IMG RESIZE CODE ***/
  
   var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(a){var b="";var c,d,e,f,g,h,i;var j=0;a=Base64._utf8_encode(a);while(j<a.length){c=a.charCodeAt(j++);d=a.charCodeAt(j++);e=a.charCodeAt(j++);f=c>>2;g=(c&3)<<4|d>>4;h=(d&15)<<2|e>>6;i=e&63;if(isNaN(d)){h=i=64}else if(isNaN(e)){i=64}b=b+this._keyStr.charAt(f)+this._keyStr.charAt(g)+this._keyStr.charAt(h)+this._keyStr.charAt(i)}return b},decode:function(a){var b="";var c,d,e;var f,g,h,i;var j=0;a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(j<a.length){f=this._keyStr.indexOf(a.charAt(j++));g=this._keyStr.indexOf(a.charAt(j++));h=this._keyStr.indexOf(a.charAt(j++));i=this._keyStr.indexOf(a.charAt(j++));c=f<<2|g>>4;d=(g&15)<<4|h>>2;e=(h&3)<<6|i;b=b+String.fromCharCode(c);if(h!=64){b=b+String.fromCharCode(d)}if(i!=64){b=b+String.fromCharCode(e)}}b=Base64._utf8_decode(b);return b},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");var b="";for(var c=0;c<a.length;c++){var d=a.charCodeAt(c);if(d<128){b+=String.fromCharCode(d)}else if(d>127&&d<2048){b+=String.fromCharCode(d>>6|192);b+=String.fromCharCode(d&63|128)}else{b+=String.fromCharCode(d>>12|224);b+=String.fromCharCode(d>>6&63|128);b+=String.fromCharCode(d&63|128)}}return b},_utf8_decode:function(a){var b="";var c=0;var d=c1=c2=0;while(c<a.length){d=a.charCodeAt(c);if(d<128){b+=String.fromCharCode(d);c++}else if(d>191&&d<224){c2=a.charCodeAt(c+1);b+=String.fromCharCode((d&31)<<6|c2&63);c+=2}else{c2=a.charCodeAt(c+1);c3=a.charCodeAt(c+2);b+=String.fromCharCode((d&15)<<12|(c2&63)<<6|c3&63);c+=3}}return b}};
   $.PaginationCalculator = function(maxentries, opts) {this.maxentries = maxentries;this.opts = opts;};
   $.extend($.PaginationCalculator.prototype, {numPages:function(){return Math.ceil(this.maxentries/this.opts.items_per_page)},getInterval:function(current_page){var ne_half = Math.floor(this.opts.num_display_entries/2);var np = this.numPages();var upper_limit = np - this.opts.num_display_entries;var start = current_page > ne_half ? Math.max( Math.min(current_page - ne_half, upper_limit), 0 ) : 0;var end = current_page > ne_half?Math.min(current_page+ne_half + (this.opts.num_display_entries % 2), np):Math.min(this.opts.num_display_entries, np);return {start:start, end:end};}});
   $.PaginationRenderers={};$.PaginationRenderers.defaultRenderer=function(maxentries,opts){this.maxentries=maxentries;this.opts=opts;this.pc=new $.PaginationCalculator(maxentries,opts)};$.extend($.PaginationRenderers.defaultRenderer.prototype,{createLink:function(page_id,current_page,appendopts){var lnk,np=this.pc.numPages();page_id=page_id<0?0:(page_id<np?page_id:np-1);appendopts=$.extend({text:page_id+1,classes:""},appendopts||{});if(page_id==current_page){lnk=$("<span class='current'>"+appendopts.text+"</span>")}else{lnk=$("<span>"+appendopts.text+"</span>")}if(appendopts.classes){lnk.addClass(appendopts.classes)}lnk.data('page_id',page_id);return lnk},appendRange:function(container,current_page,start,end,opts){var i;for(i=start;i<end;i++)this.createLink(i,current_page,opts).appendTo(container)},getLinks:function(current_page,eventHandler){var begin,end,interval=this.pc.getInterval(current_page),np=this.pc.numPages(),fragment=$("<div class='pagination'></div>");if(this.opts.prev_text&&(current_page>0||this.opts.prev_show_always)){var left_arrow="<div class='maplicon "+((current_page>=np-1)?'paginationLeftEnable':'paginationLeftDisable')+"' ></div>";fragment.append(this.createLink(current_page-1,current_page,{text:left_arrow,classes:"prev"}))}if(interval.start>0&&this.opts.num_edge_entries>0){end=Math.min(this.opts.num_edge_entries,interval.start);this.appendRange(fragment,current_page,0,end,{classes:'sp'});if(this.opts.num_edge_entries<interval.start&&this.opts.ellipse_text){jQuery("<span>"+this.opts.ellipse_text+"</span>").appendTo(fragment)}}this.appendRange(fragment,current_page,interval.start,interval.end);if(interval.end<np&&this.opts.num_edge_entries>0){if(np-this.opts.num_edge_entries>interval.end&&this.opts.ellipse_text){jQuery("<span>"+this.opts.ellipse_text+"</span>").appendTo(fragment)}begin=Math.max(np-this.opts.num_edge_entries,interval.end);this.appendRange(fragment,current_page,begin,np,{classes:'ep'})}if(this.opts.next_text&&(current_page<np-1||this.opts.next_show_always)){var right_arrow="<div class='maplicon "+((current_page>=np-1)?'paginationRightDisable':'paginationRightEnable')+"' ></div>";fragment.append(this.createLink(current_page+1,current_page,{text:right_arrow,classes:"next"}))}$('span',fragment).click(eventHandler);return fragment}});
   $.fn.pagination=function(maxentries,opts){opts=jQuery.extend({items_per_page:10,num_display_entries:11,current_page:0,num_edge_entries:0,link_to:"#",prev_text:"Prev",next_text:"Next",ellipse_text:"...",prev_show_always:true,next_show_always:true,renderer:"defaultRenderer"},opts||{});var containers=this,renderer,links,current_page;function paginationClickHandler(evt){var links,new_current_page=$(evt.target).data('page_id');if($(evt.target).hasClass('maplicon'))new_current_page=$(evt.target).parent().data('page_id');continuePropagation=selectPage(new_current_page);if(!continuePropagation){evt.stopPropagation()}return continuePropagation};function selectPage(new_current_page){containers.data('current_page',new_current_page);links=renderer.getLinks(new_current_page,paginationClickHandler);containers.empty();links.appendTo(containers);var continuePropagation=opts.callback(new_current_page,containers);return continuePropagation};current_page=opts.current_page;containers.data('current_page',current_page);maxentries=(!maxentries||maxentries<0)?1:maxentries;opts.items_per_page=(!opts.items_per_page||opts.items_per_page<0)?1:opts.items_per_page;if(!$.PaginationRenderers[opts.renderer]){throw new ReferenceError("Pagination renderer '"+opts.renderer+"' was not found in jQuery.PaginationRenderers object.");}renderer=new $.PaginationRenderers[opts.renderer](maxentries,opts);var pc=new $.PaginationCalculator(maxentries,opts);var np=pc.numPages();containers.bind('setPage',{numPages:np},function(evt,page_id){if(page_id>=0&&page_id<evt.data.numPages){selectPage(page_id);return false}});containers.bind('prevPage',function(){var current_page=$(this).data('current_page');if(current_page>0){selectPage(current_page-1)}return false});containers.bind('nextPage',{numPages:np},function(evt){var current_page=$(this).data('current_page');if(current_page<evt.data.numPages-1){selectPage(current_page+1)}return false});links=renderer.getLinks(current_page,paginationClickHandler);containers.empty();links.appendTo(containers);};
   //(function(a){var b,c,d,e;a.tools=a.tools||{version:"v1.2.6"},a.tools.history={init:function(g){e||(a.browser.msie&&a.browser.version<"8"?c||(c=a("<iframe/>").attr("src","javascript:false;").hide().get(0),a("body").prepend(c),setInterval(function(){var d=c.contentWindow.document,e=d.location.hash;b!==e&&a(window).trigger("hash",e)},100),f(location.hash||"#")):setInterval(function(){var c=location.hash;c!==b&&a(window).trigger("hash",c)},100),d=d?d.add(g):g,g.click(function(b){var d=a(this).attr("href");c&&f(d);if(d.slice(0,1)!="#"){location.href="#"+d;return b.preventDefault()}}),e=!0)}};function f(a){if(a){var b=c.contentWindow.document;b.open().close(),b.location.hash=a}}a(window).bind("hash",function(c,e){e?d.filter(function(){var b=a(this).attr("href");return b==e||b==e.replace("#","")}).trigger("history",[e]):d.eq(0).trigger("history",[e]),b=e}),a.fn.history=function(b){a.tools.history.init(this);return this.bind("history",b)}})(jQuery);

   $.extend($.MMI.Layer,{"getter" : ["levelOrCenterStatus","getHistory","getBuilder","dirAction","currentUrl","mailValidate","getLayer","alternateLayout","setPageLayout","getValue","getPoiLayout","poiDesign","callEncodeOrDecoder","isAlternates","pastprocess","generateQuery","poiWrapper","boundsCalculate"].join(" ")}, {"defaults" : {
                  context  : ALT.BOOL[0],                   
                  resize   : ALT.BOOL[1],
                  slider   : ALT.BOOL[1],
                  freeze   : ALT.BOOL[0],
                  height   : 0,
                  width    : 0,
                  panel    : 290,
                  percentage : 0.30,
                  top      : $(ALT.BODYLAYOUT[0]).height(),
                  bottom   : $(ALT.BODYLAYOUT[1]).height(),
                  helper   : ALT.BOOL[1],
                  left     : 0,
                  SOM      : ALT.DTYPES[5],
                  PARENT   : ALT.BODYLAYOUT[2],
                  mContainer : ALT.DTYPES[5],
                  APP      : ALT.DTYPES[5]
                }
    });    
    $.extend($.ui.MarkerFactory, {"defaults" : {smallSrc : new Point(10,10),src :'images/A.png',size :  new Point(32,38)}});
    
    
})(jQuery);
var AC={
   release:function(arg){
              if(arg!=null)arg=null;delete(arg)
          },
   showmore:function(arg){
       $("#"+$(arg).attr("lang")).toggle(300,function(){
           if($(this).is(":visible")){
              $(arg).html("Hide details");
              $('input[name=subcat_dec]',"#options").autoSuggest("autocat.php",{'asHtmlID':"subcat_dec",selectedItemProp:"addr",searchObjProps:"addr",selectedValuesProp:"link","resultsHighlight":false,"status":false,"startText" : "Start typing your location"});
             // $('input[name=subcat_dec]',"#options").autoSuggest('autocat.php',{'asHtmlID': 'subcat_dec' ,selectedItemProp:"name",searchObjProps:"name"})
           } else {
              $(arg).html("Add more details");
              $('input[name=subcat_dec]',"#options").unbind()
           }    
       });
      }
};
function closeMe(arg){L.Layer("closebox",{'container':$("#"+$(arg).attr('lang')),'load':$(arg).attr('react')});AC.release(arg)};
function vFeedback(arg){
    var suggestion=arg.suggestion;
    var email=arg.email;
    var search=$.trim(arg.search.value);
    var bug=$("#"+$(arg).attr('target'));
    bug.addClass("failure").html("");
    var svalue=$.trim(suggestion.value);
    var pt=$("#pt").text();
    var loc=$("#loc").text();
    if(svalue==suggestion.getAttribute('lang') && email.value==""){
        bug.html("Oops ! Empty request cannot be process.");suggestion.focus()
    }else if(svalue==""||svalue==suggestion.getAttribute('lang')){
        bug.html("suggestion / comment / feedback is required");suggestion.focus()
    }else if(email.value==""){
        bug.html("Please provide an email address which looks like user@example.com");email.focus()
    }else if(email.value=="user@example.com"){
        bug.html("Invalid email address. Please provide an email address which looks like user@example.com");email.focus();
    } else if(!L.Layer('mailValidate',{value:email.value})){
        bug.html("Invalid email address. Please provide an email address which looks like user@example.com");email.focus();
    } else {
        bug.removeAttr('class').addClass('process_exec').html('<div class="process"></div>');
        $(arg).attr({'react':1,lang:$(arg).attr('name')});
        pt=pt.replace("[","");pt=pt.replace("]","");
        L.Layer('fireProcess',{'email':email.value,'details': encodeURIComponent(svalue),'type':'feedback','search':search,'loc':loc,'view':1,'q':402,'common':true,'method':'POST','pt':pt,callback:function(response){
          L.Layer('helperView',{param:response,container:arg});
          if(mlog != null ){mlog.setValue(svalue);mlog.setUrl(L.Layer('currentUrl'));mlog.persist();}
          suggestion=email=svalue=loc=pt=null;
        }});        
    }
    return false;
  };
  
  function vFeedbackChild(form){
    var type = form.type.value;       
    var bug  = $("#"+$(form).attr('target'));
    bug.addClass("failure").html("");
    var url = window.location;
    var search = "";
    var email = form.email.value;
    if(type == "address" || type == "place") {
      var fbk1 = (type == "address") ? form.fbk1.checked : false;
      var fbk2 = form.fbk2.checked;
      var fbk3 = form.fbk3.checked;
      var fbk4 = form.fbk4.checked;
      var wrongnme = (type=='address') ? $.trim(form.wrongnme.value) : "";             
      var incorrect = $.trim(form.incorrect.value);            
      var other = $.trim(form.other.value);            
      search = $.trim(form.search.value);
      var geo = form.geo.value;
      if(type == "address") {
          if (!fbk1 && !fbk2 && !fbk3 && !fbk4) {
             bug.html("Please specify at least one feedback.");return false;
          }
      } else {
          if (!fbk2 && !fbk3 && !fbk4) {
            bug.html("Please specify at least one feedback.");return false;
          }
      }
      var details = new Array();
      if(fbk1 && type == "address"){
        details.push(form.fbk1.value);
        details.push("(");
        if(wrongnme.length > 0 && wrongnme != form.wrongnme.getAttribute('lang')){
          details.push(wrongnme);                   
        } else {
          details = null;
          bug.html("<b>Could not find what I was looking for</b> is missing.");
          return false;
        }
        details.push(")");            
        details.push("#");
       }

       if (fbk2) {
        details.push(form.fbk2.value);
        details.push("(");
        if(incorrect.length > 0 && incorrect != form.incorrect.getAttribute('lang')){
           details.push(incorrect);                   
        } else {
           details = null;
           bug.html("<b>Incorrect name / address</b> is missing.");
           return false;
        }
        details.push(")");
        details.push("#");
       }

       if(fbk3) {
         details.push(form.fbk3.value);
         details.push("(");                
         if(geo.length > 0 ){
           details.push(geo);                   
         } else {
           details = null;
           bug.html("<b>Drag an icon to correct location</b> is missing.");
           return false;
         }
         details.push("#");
        }
        
        if (fbk4) {
         details.push(form.fbk4.value);
         details.push("(");
         if(other.length > 0  && other != form.other.getAttribute('lang')){
           details.push(other);                   
         } else {
           details = null;
           bug.html("<b>Other comment</b> is missing.");
           return false;
         }                
         details.push(")");                
        }         
    } else if (type == "dir") {
        details = new Array();
        var TA = [];
        if(form.fbk1.value != ""){            
            TA.push("(");
            TA.push(form.fbk1.value);
            TA.push(")"); 
            details.push(TA.join(""));
            details.push("#");
        } 
        
        $(form).find('.report_input').each(function(){
            if($(this).val().length > 0){
                TA = [];
                TA.push($(this).attr('name'));
                TA.push("(");
                TA.push($(this).val());
                TA.push(")");
                details.push(TA.join(""));
                details.push("#");
                TA = null;
            }
        });        
        
        if(details.length == 0){
          bug.html("Please specify at least one feedback.");
          return false;    
        }
    }
    
  if(email == "") {
      bug.html("Please <b>enter email</b> address which looks like user@example.com");
      return false;
    } else {   
      if(!L.Layer('mailValidate',{value : form.email.value})){
       bug.html("<b>Invalid email</b> address.<br/> Please <b>enter email</b> address which looks like user@example.com");
       return false;
      }
    }        
    bug.removeAttr('class').addClass('process_exec').html("<div class='process'></div>");
    $(form).attr({'react' : 1 ,lang : $(form).attr('name')});    


    try { if(search == "" || typeof(search) === 'undefined')  search = url.toString().split("#")[1].split(";geo=")[0]; }catch(e){}


    try {
    L.Layer('fireProcess',{method:'POST',common:true,'email' : email,'details' :encodeURIComponent(details.join("")),'type' : type,'search' : search,'url': encodeURIComponent(url),'view':1,'q' :402,callback:function(response){
            L.Layer('helperView',{param : response, container : form});
    }});
   } catch(e){bug.removeAttr('class').addClass('failure').html("Sorry,server is busy.try after some time later");}
   return false;
};


function validateMailService(arg){
            
    var to = arg.to.value;
    var from = arg.from.value;
    var content = arg.comment.value;
    var q = arg.q.value;
    var bug=$("#"+arg.getAttribute('lang'));
    bug.addClass('failure').html("");                
    if(to == "" && from == ""){
      bug.html("Sorry ! Empty request cannot be process.Kindly provide input.");arg.to.focus();
    } else if(to == "" && to.length == 0){
      bug.html("Please specify at least one recipient in the To: field");arg.to.focus();
    } else if(from == "" && from.length == 0){
      bug.html("Please specify your email Address which looks like user@example.com");arg.from.focus();
    } else if(!L.Layer('mailValidate',{value:to})){
      bug.html("Invalid email address. Please provide an email address which looks like user@example.com");    
    } else if(!L.Layer('mailValidate',{value:from})){
      bug.html("Invalid email address. Please provide an email address which looks like user@example.com");    
    } else {
      bug.removeAttr('class').addClass('process_exec').html("<div class='process' style='margin-left:48%'></div>");
       L.Layer('fireProcess',{'method':'POST','view':1,'common':true,'content' : content,'to':to,'from':from,'url' : encodeURIComponent(window.location.toString()), 'q': 'mymail','callback':function(response){
       if(response.code == 250){
          bug.removeAttr('class').addClass('success').html("Mail sent successfully.");
          var param = L.Layer('currentUrl').split("#");
          var nparam = (param.length == 2) ? param[1] : param.join("");          
          M.Layer('mbuildlog',{'type' : arg.getAttribute('log'), 'value' : nparam  , 'url' : L.Layer('currentUrl'), 'auto' : null});
          AC.release(param);
          window.setTimeout(function(){closeMe($('.closebox','#mshare_cont'));},1000);
        } else {
          bug.removeAttr('class').addClass('failure').html("Sorry, your request failed. Please try after some time.");          
        }
      }});
      AC.release(arg);
    }
    return false;       
};

function validateDir(arg){return L.Layer('dirAction',arg)};
function spotAction(form){L.Layer('placeprocess',{param:form});return false};
function response(output){if(internal){L.Layer('calculate',{param:output})}else{L.Layer('fireFrame',function(){var appcontrol=L.Layer('getLayer');appcontrol.layerResponse.call(appcontrol,output)})}};
var mGeo=new Function("",_r_f_body_);mGeo.TYPE_ARRAY=["number","string","number","string","string","number"];mGeo.MEMBER_ARRAY=["q","search","go","geo","layer","dis"];
function releaseResource(){$('window').unbind();M.unbind();L.unbind();$('a').unbind();$('span').unbind();$('li').unbind();try {mf.MArkerFactory('removeOverlays');mf.MarkerFactory('destroy');}catch(e){}}
/* CCENTER */
function ccenter(x,y,z){
    var pt=new Point(x,y);
    $("#mmpnt").val(y+"*"+x);
    L.MireoMap("setCenterAndZoomLevel",pt,z);
};
/* END CENTER*/

function notExact(arg,params,me){
  var fail = arg.fail;        
  var temp = arg.show;        
  var pass = arg.pass;
  var idx  = null;
  if(fail.length > 0) {
        for(var f=0; f <fail.length ;f++){
            $("#sidebar").html(temp[fail[f]].alternate);
            idx = fail[f];
            break;
        }

        var holder = $('li span',"#alt_Txt");
        holder.unbind();
        holder.click(function(e){
           e.stopPropagation(); 
           fail.shift();
           pass[idx] = $(this).text();   
           $(this).unbind();
           $('body').APL({action : 1});  
           notExact({'fail' : fail ,'show' : temp ,'pass' : pass,'geos' : arg.geos},params,me);
        });
        $('body').APL({action : 0});       
  } else {
     internal = true; 
     L.Layer('postprocess',{param : {q : 300 , search : pass.join("*"), geo : ((arg.geos.length > 0) ? L.Layer('callEncodeOrDecoder',{param : arg.geos.join(",") , index : 0}) : "" )}});  
  } 
};


function dispTip(){
   var id=null;
   var loct= "";
   if(searchOBJ.p == 4){
     id=searchOBJ.elc;
     loct=3;
   }else{
     id=searchOBJ.lid;
     loct=searchOBJ.p;
   }
   $.getJSON(("common/tips.php?id="+id+"&t=cnt&loct="+loct), function(data){
          $("#tip_tr").show();
          
          document.getElementById("tips_up").innerHTML=data[0].ups;
          document.getElementById("tips_down").innerHTML=data[0].downs;
          document.getElementById("travel_tips").innerHTML=data[0].tips;
          if(data[0].tips>0){
              document.getElementById("tpalink").innerHTML="<a href='"+data[0].url+"' target='_blank' style='text-decoration:none;'> Travel Tips </a>";
          }
    });

 };

function inctips(arg){
    document.getElementById(arg).innerHTML=parseInt(document.getElementById(arg).innerHTML)+1;
    var update="";
    if(arg=="tips_up"){
        update="ups";
    }else{
         update="downs";
    }
    var id  = "";
    var loct= "";
    if(searchOBJ.p == 4){
      id=searchOBJ.elc;
      loct=3;
    }else{
      id=searchOBJ.lid;
      loct=searchOBJ.p;
    }
    
    $.getJSON(("common/tips.php?id="+id+"&update="+update+"&t=inc&name="+Sname+"&loct="+loct), function(data){});

 };

 function wrttip(){
     var tipH=document.getElementById("tipH").value;
     var tipB=document.getElementById("tipB").value;
     if(tipH=="Tip headline" || tipH.trim()==""){
         document.getElementById("tip_mand").style.display="";
     }else if(tipB==""){
         document.getElementById("tip_mand").style.display="";
     }else{
      var id  = "";
      var loct= "";
      var pne=searchOBJ.addr;
      if(searchOBJ.p == 4){
        id=searchOBJ.elc;
        loct=3;
      }else{
        id=searchOBJ.lid;
        loct=searchOBJ.p;
      }
        
        $.getJSON(("common/tips.php?id="+id+"&tiph="+tipH+"&t=wrt&name="+Sname+"&email="+Semail+"&loct="+loct+"&tipB="+tipB+"&tpro="+Sprofile+"&pne="+pne), function(data){
            document.getElementById("tip_box").style.display="none";
            var error = document.getElementById("tip_cong");
            if(data[0].result=="success"){
                document.getElementById("travel_tips").innerHTML=parseInt(document.getElementById("travel_tips").innerHTML)+1;
                error.innerHTML="Your tip has been submitted. Thanks!";
                error.className="success";
                error.style.display="block";
                window.setTimeout(function(){closeMe($('.closebox','#lightContainer'));},1000);
            }else{
                error.innerHTML="Error occured while processing your request.<br/> Please try after some time.";
                error.className="failure";
            }
        });
     }
 };
 
function tnplc(){
    if(document.getElementById("tipH").value=="Tip headline"){
        document.getElementById("tipH").value="";
    }
};
function trplc(){
    if(document.getElementById("tipH").value==""){
        document.getElementById("tipH").value="Tip headline";
    }
};

function tipsBinder(){    
     $("#rcd_img").click(function (e){
        if(recdone==false){
            document.getElementById("rcd_img").src="images/tips/recommend.gif";
            document.getElementById("rcdd_img").src="images/tips/recommend_down.gif";
            recdone=true;
            inctips('tips_up');
        }
    });

    $("#rcdd_img").click(function (e){
        if(recdone==false){
            document.getElementById("rcd_img").src="images/tips/recommend.gif";
            document.getElementById("rcdd_img").src="images/tips/recommend_down.gif";
            recdone=true;
            inctips('tips_down');
        }
    });

    $("#post_tip").click(function(e){
        wrttip();
    });
};

if (typeof com == 'undefined') {
    com = {}
    com.mmi = {}
 };
 
 com.mmi.logs = function(){
    self : this;
    var type;
    var value;
    var url;
    	
    this.init=function(type,value,url,auto){
      this.type = type;
      this.value = value; 
      this.url  = (typeof(url) === 'undefined') ? null :url;
      this.auto = (typeof(auto) === 'undefined') ? null :auto;
    };
    
    this.setType = function(type){
      this.type = type;  
    };
    
    this.setValue = function(value){
      this.value = value;  
    };
    
    this.setUrl = function(url){
      this.url = url;  
    };
    
    this.setAuto = function(auto){
      this.auto = auto;  
    };
    
    this.persist = function(){
      var TA = [];
      TA.push(this.type);
      TA.push(this.value);
      TA.push((this.url == null) ? "-" : this.url);
      TA.push((this.auto == null) ? "-" : this.auto);
      L.Layer('fireProcess',{'view': 1,'method': 'GET',common : 'true','layer':layer, 'search' : L.Layer('callEncodeOrDecoder',{index : 0 , param : TA.join("|")}) , 'q' : 'log',callback :function(){mlog = null;}});
      AC.release(TA);
    }
 }; 

function getCookie(NameOfCookie) {
if (document.cookie.length > 0) {
    begin = document.cookie.indexOf(" " + NameOfCookie + "=");
    if (begin != -1) {
            begin += NameOfCookie.length + 2;
            end = document.cookie.indexOf(";", begin);
            if (end == -1)
                    end = document.cookie.length;
            return unescape(document.cookie.substring(begin, end));
    }else{
            begin = document.cookie.indexOf(NameOfCookie + "=");
            if (begin != -1) {
                    begin += NameOfCookie.length + 1;
                    end = document.cookie.indexOf(";", begin);
                    if (end == -1)
                            end = document.cookie.length;
                    return unescape(document.cookie.substring(begin, end));
            }
    }
}
return null;
};

function setCookie(NameOfCookie, value, expiredays, path) {
   var ExpireDate = new Date();
   ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
   document.cookie = NameOfCookie+"="+escape(value)+((expiredays == null) ? "" : "; expires="+ ExpireDate.toGMTString())+ ((path) ? ";path=" + path : "");//+((domain) ? ";domain=" + window.location.hostname.toString()+"" : "");
};

function deleteCookie (cookie_name ) {
   var cookie_date = new Date ( );  // current date & time
   cookie_date.setTime ( cookie_date.getTime() - 1 );
   document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
};   

//-- Login Related Siddu
function refreshMe() {if($("#logme").is(":visible")) $("#logme").fadeOut();window.location.reload();/*=window.location;*/}
function txtBlur(arg){
   if($("#"+arg.id).val()==""){
      $("#ph_"+arg.id).show();
   }
}
function getFocus(arg){
    var id=(arg.id).split("ph_");
    $("#"+id[1]).focus();
}

