    /*********************************************************************/
    /*                        UI Initializing                            */
    /*********************************************************************/
    
    
    //Input text hint
jQuery.fn.inputFieldText = function(string) {          
    this.each(function() { 
        $(this).val(string); 
        $(this).focus(function(){ 
            if ($(this).val() == string){ 
                $(this).val(''); 
            } 
        }); 
        $(this).blur(function(){ 
            if ($(this).val() == '' ){ 
                $(this).val(string); 
            } 
        });     
    }); 
}

    
    
    $(document).ready(function(){     
        $(".forget_password").click(function () {
            $("#password_request").toggle("fast");
        });   
        
        
    
    
  $('#find_input').inputFieldText($('.find_location_help').html());  
    
  $("#find_location").click(
            function() {

             showAddress($("#find_input").val()); return false
		                } 
	     );	


  $("#find_input").keypress(function (e) {  
        if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {  
             $("#find_location").click();  
             return false;  
         } else {  
             return true;  
         }  
     });

         
    });


    /*********************************************************************/
    /*                    Set barcode to preview                         */
    /*********************************************************************/    
    function Preview(previewUrl,imageUrl,barcodeUrl,printUrl)
    {                   
        $("#preview_frame").attr("src",previewUrl);            
        $("#code_preview_image").attr("src",imageUrl);
        $("#code_print").attr("href",printUrl);
        $("#code_print").css("display","block");
        $("input[id*='PreviewBarcodeUrlTextBox']").val(barcodeUrl);
        $("input[id*='PreviewBarcodeImageUrlTextBox']").val(imageUrl);
        
        //InitCodeImagePreview();
    }
    
    //Checks if a barcode has been set to preview from ajax callback
    function SetToPreviewIfExists()
    {
        var barcodeId = $("input[id*='PreviewBarcodeIdHiddenField']");
        if(barcodeId != null){
            if(barcodeId.val().length != 0){
                var params = barcodeId.val().split(",");
                Preview(params[0],params[1],params[2],params[3]);
            }
        }
    }
       
    //Barcode image preview
    function InitCodeImagePreview(){	    
  		
	    var imgWidthPer2 = 140;
	    var imgHeightPer2 = 140;
    			    
	    $("#code_preview_image").hover(function(e){	      
	        $("#preview_zoom_image").remove();
		    $("body").append("<img id='preview_zoom_image' src='"+ this.src +"' alt='Barcode preview image' />");								 		    
		    
		    $("#preview_zoom_image")
			    .css("left",(($(window).width()/2)-imgWidthPer2) + "px")
			    .css("top",(($(window).height()/2)-imgHeightPer2) + "px")
			    .fadeIn("fast");		    			
        },
	    function(){
		    this.title = this.t;			    
		    $("#preview_zoom_image").remove();		    
        });		
    };
    
//    /*********************************************************************/
//    /*                    Show feedback dialog                           */
//    /*********************************************************************/
//    function ShowFeedbackDialog()
//    {        
//        var dlg = $("#FeedbackFormContentDiv").dialog({ modal : true, bgiframe : true  });
//        dlg.parent().appendTo(jQuery('form:first')); //TO fix problems with jquery dialog and asp.net

//    }


    /*********************************************************************/
    /*                    Location barcode map                           */
    /*********************************************************************/
    var pin;
     var geocoder = null;
    function LoadLocationPickerMap(defaultLat,defaultLng) {
        var map;            
        if (GBrowserIsCompatible()) 
        {
            if (document.getElementById("map_container") == null)
            {
                return null;
            }
            
            map = CreateMapControl(document.getElementById("map_container"));
            map.setCenter(new GLatLng(defaultLat, defaultLng), 1);         
            return map;           
        }
        return null;
    }  
    
    
    function showAddress(address) {
      if (geocoder) {
        var map = CreateMapControl(document.getElementById("map_container"));
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address);
              SetPointToCoordinateFields(point);
            }
          }
        );
      }
    }
    
    function SetPointToCoordinateFields(point){           
                                                
        $("input[id*='LatitudeTextBox']").val(point.lat());
        $("input[id*='LongitudeTextBox']").val(point.lng());
    }
    
    function SetupLocationPickerMap()
    {
        var lat = $("input[id*='LatitudeTextBox']").val();
        var lng = $("input[id*='LongitudeTextBox']").val();        
        if(lat != "" && lng != ""){
            var map = LoadLocationPickerMap(lat,lng);
            AddMarkerToMap(map, new GLatLng(lat, lng));
            map.setZoom(11);
        }else{
            LoadLocationPickerMap(0.0,0.0);
        }
    }

    function CreateMapControl(mapcontainer)
    {
        map = new GMap2(mapcontainer);
         geocoder = new GClientGeocoder();        
        map.enableDoubleClickZoom();                                
        map.setUIToDefault();
        
        GEvent.addListener(map,"click",function(overlay,point) {                                          
               if(point)
               {                    
                    AddMarkerToMap(map,point);
                }
            });          
            
        return map;
    }
               
    function AddMarkerToMap(map, point){
    
        map.clearOverlays();
                                
        var ico = new GIcon(G_DEFAULT_ICON);
        //ico.image = "../images/marker.gif";
        ico.iconSize = new GSize(20, 34);                                   
        var markerOptions = { icon:ico};                
                                                                                                                              
        pin = new GMarker(point, markerOptions);
        map.addOverlay(pin);    
        SetPointToCoordinateFields(point);
    }             
    
    /***************************************************************/
    /*                    Confirm dialog                           */
    /***************************************************************/    
    //Set confirmation dialog to postback control
    function SetConfirmToControl(controlId, dialogTitle, confirmText, okText, cancelText)
    {
        var control = $("input[id*='" + controlId + "']");        
        control.attr("onclick","");
        control.attr("href","#");
        control.click(function(){
            //ShowConfirm($(this).attr("id"),dialogTitle,confirmText,okText,cancelText);
        });
    }
    
    
    
    //Set confirmation dialog to control group by css class
    function SetConfirmToControlGroup(controlCssClass, dialogTitle, confirmText, okText, cancelText)
    {                
        var controls = $("." + controlCssClass + "");        
        controls.attr("onclick","");
        controls.attr("href","#");
        controls.click(function(){            
            ShowConfirm($(this).attr("id"),dialogTitle,confirmText,okText,cancelText);
        });
    }
    
    //Show confirm
    function ShowConfirm(eventtarget, dialogTitle, confirmText, okText, cancelText)
    {                    
        var dialogDiv = $("#confirmdialog");                        
        $("#confirmdialogText").text(confirmText);
        $("#dialogCallerId").text(eventtarget);
        dialogDiv.attr("title",dialogTitle);        
        
        $(dialogDiv).dialog({
			bgiframe: true,
			resizable: false,
			height:140,
			modal: true,
			overlay: {
				backgroundColor: '#000',
				opacity: 0.5
			},
			buttons: {
				Ok: function() {								    		    
				    __doPostBack($("#dialogCallerId").text().replace(/_/g, "$"),'');
				    
					$(this).dialog('close');
				},
				Cancel: function() {				    
					$(this).dialog('close');
				}
			}
		});
		
		$(dialogDiv).dialog('open');

    }