﻿$(document).ready(function()
	 {
	        // Image PreLoader
	        SearchImage = new Image(); 
            SearchImage.src = "../images/searchbutton-hover.gif";
            ResultsImage = new Image(); 
            ResultsImage.src = "../images/search-btn-hover.gif";
            DetailImage = new Image(); 
            DetailImage.src = "../images/search-Results-btn-hover.gif";
            PlusImage = new Image(); 
            PlusImage.src = "../images/plus-hover.gif";
            MinusImage = new Image(); 
            MinusImage.src = "../images/hide-btn-hover.gif";
            
	        // Fadout the successful message after 5 seconds on Detail page of Admin section
            // || contents.toLowerCase().indexOf("Record has been updated successfully.") > 0
               if($("#divApprove").length > 0) {
                   var contents = jQuery.trim($("#divApprove p").html());
                   if($("#divError").length <= 0) {
                       if(contents != ''){
                            if(contents == "This country name does not exist."){
                                $("#divApprove").addClass('error');
                                $("#divApprove").fadeOut(5000);
                                return;
                            }
                           $("#divApprove").addClass('success');
                           $("#divApprove").fadeOut(5000);
                       }
                   }
                   //$("#divApprove p").remove();
                }
           
	        // Autocompete code
	        $('#KeyWords').click(function(event) {
	            $("#KeyWords").autocomplete("/AutocompleteData.ashx",
		            {
		                cacheLength:0,
		                minChars:3,
                        max:30,
                        autoFill:false,	
                        selectFirst: false,		
                        extraParams: { Loc : function() { return $("#DPI").val();  }, Type : function() { return $("#Mode").val();  } }
		            });
	        });
	        
	        // Advance Search Options
		    $("#ToggleON").click(function(event) {
		    event.preventDefault();
		    $("#ToggleOFF").slideToggle();
		    var contents = jQuery.trim($(".hide-btn-caption").html());
		    if ( contents == "Need more search options?")
			    {
				    $(".hide-btn-caption").html('Hide expanded search options');
				    $("#ToggleBtn").removeClass('plus-btn');
				    $("#ToggleBtn").addClass('hide-btn');
			    }
		    else{
				    $(".hide-btn-caption").html('Need more search options?')
				    $("#ToggleBtn").removeClass('hide-btn');
				    $("#ToggleBtn").addClass('plus-btn');
			    }
		    });
		    
		    // Prodct Image Preview on Admin Detail Page
		    $("#ProductImage").click(function(event) {
		        event.preventDefault();
		        $("#ProductImage").imgPreview();
		    });
		    
		    
		    // Client Detail Page Zoom Picture plugin code
		        if($("#ctl00_ContentPlaceholder_basic").length > 0) {
		            $('#ctl00_ContentPlaceholder_basic').bigPicture(); 
		            }
		    
		    // Admin detail page show/hide country name and flag     
		    $("#FlagTable").hide();
		    $(".msg_head").click(function(event) {
		        event.preventDefault();
		        $("#FlagTable").slideToggle(500);
		     });
		    /*
		    // Client Detail Page Print code
		    $("#printable").click(function(event) {
		        event.preventDefault();
		        $("#divToPrint").jqprint();
		    });
		    
		    // Multiple Selection Dropdown Box on Admin Detail Page
		    if($("#ddlCategory")!=null) {
		        $("#ddlCategory").dropdownchecklist({ width: 238 }); 
		    }
		    
		    $("#ddlCategory").change(function(event) {
		        $('#hfCategory').val(jQuery.trim($(".ui-dropdownchecklist-text").html())); 
		    });
		    */
		    
	  // End of Document.Ready() Function   
	  });
