  $(function () {$("#searchClick").click(function (event) {event.preventDefault();$("#search_div").slideToggle("slow");});});

    function enableDisableDate(rad) {
        if (rad.value == "byDays" && rad.checked) {
            document.getElementById("src_days").disabled = false;
            document.getElementById("start_date").disabled = true;
            document.getElementById("end_date").disabled = true;
        }
        if (rad.value == "byDate" && rad.checked) {
            document.getElementById("src_days").disabled = true;
            document.getElementById("start_date").disabled = false;
            document.getElementById("end_date").disabled = false;
        }
    }

    var ajax = new sack;

    function loadingText(divId) {
        document.getElementById(divId).innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"slidediv\"><tr><td valign=\"top\" style=\"padding:5px;\" class=\"showlist\"> Loading... </td></tr></table>";
    }


    function defaultText(divId, dtext) {
        document.getElementById(divId).innerHTML = "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"slidediv\"><tr><td valign=\"top\" style=\"padding:5px;\" class=\"showlist\"> " + dtext + " </td></tr></table>";
    }


    function selState(stateId, stateName) {
        document.getElementById("src_city").value = "";
        defaultText("srch_city_div", "Select State First");
        document.getElementById("srch_city_link").innerHTML = "Select City";
        document.getElementById("src_location").value = "";
        defaultText("srch_location_div", "Select City First");
        document.getElementById("srch_location_link").innerHTML = "Select Shopping Area";
        dropdowncontent.hidediv("srch_state_div");
        document.getElementById("src_state").value = stateId;
        document.getElementById("srch_state_link").innerHTML = stateName;
        getCity("src_state");
        return true;
    }


    function selCategory(catId, catName) {
        dropdowncontent.hidediv("srch_category_div");
        document.getElementById("src_category").value = catId;
        document.getElementById("srch_category_link").innerHTML = catName;
        return true;
    }

    var srch_ajax = new sack;
    var siteURL = "";

    function getCity(val) {
        var stateId = document.getElementById(val).value;
        ajax.requestFile = siteURL + "scripts/search_serv.php?flag=cities&stateid=" + stateId;
        ajax.onLoading = function () {loadingText("srch_city_div");};
        ajax.onCompletion = function () {document.getElementById("srch_city_div").innerHTML = ajax.response;getLocation("src_city");};
        ajax.runAJAX();
    }


    function selCity(cityId, cityName,fwidget) {
        document.getElementById("src_location").value = "";
        defaultText("srch_location_div", "Select City First");
        document.getElementById("srch_location_link").innerHTML = "Select Shopping Area / Mall";
        dropdowncontent.hidediv("srch_city_div");
        document.getElementById("src_city").value = cityId;
        document.getElementById("srch_city_link").innerHTML = cityName;
        getLocation("src_city",'',fwidget);       
        return true;
    }


    function getLocation(val, locationId,fwidget) {
        var cityId = document.getElementById(val).value;
        ajax.requestFile = siteURL + "scripts/search_serv.php?flag=shopArea&cityid=" + cityId+"&fwidget="+fwidget;
        ajax.onLoading = function () {loadingText("srch_location_div");};
        //alert(ajax.response);
        ajax.onCompletion = function () {
				if(fwidget='widget')
				{
				document.getElementById("srch_location_div").style.width='190px';
				document.getElementById("srch_location_div").style.height='200px';
				document.getElementById("srch_location_div").style.overflow='auto';
				
				}
				document.getElementById("srch_location_div").innerHTML = ajax.response;  
				//getShoppingMall("src_city");
			};
        ajax.runAJAX();
         
    }


    function selLocation(locationId, locationName) {
        dropdowncontent.hidediv("srch_location_div");
        document.getElementById("src_location").value = locationId;
		document.getElementById("src_mall").value = "";
        document.getElementById("srch_location_link").innerHTML = locationName;
       
        return true;
    }
	
	function getShoppingMall(val, mallId) {
        var cityId = document.getElementById(val).value;
        ajax.requestFile = siteURL + "scripts/search_serv.php?flag=mall&cityid=" + cityId;
        ajax.onLoading = function () {loadingText("srch_mall_div");};
        ajax.onCompletion = function () {document.getElementById("srch_mall_div").innerHTML = ajax.response;};
        ajax.runAJAX();
    }


    function selShoppingMall(locationId, locationName) {
        dropdowncontent.hidediv("srch_location_div");
		document.getElementById("src_location").value = "";
        document.getElementById("src_mall").value = locationId;
        document.getElementById("srch_location_link").innerHTML = locationName;
        return true;
    }
	

    function selDays(selDaysKey, selDaysItem) {
//        document.getElementById("byDays").checked = true;
        dropdowncontent.hidediv("srch_days_div");
        document.getElementById("src_days").value = selDaysKey;
        document.getElementById("srch_days_link").innerHTML = selDaysItem;
        return true;
    }


    function initSearch(ini_city_id, ini_city_name) {
	
		if (ini_city_id != "") {
			document.getElementById("src_city").value = ini_city_id;
			document.getElementById("srch_city_link").innerHTML = ini_city_name;
		}
    }


    function initSearchResults(src_city_id, src_city_name, src_location_id, src_location_name, src_cat_id, src_cat_name, src_days_val, src_days_name,src_mall_id,src_mall_name) {

		if (src_city_id != "") {
			document.getElementById("src_city").value = src_city_id;
			document.getElementById("srch_city_link").innerHTML = src_city_name;
			if (src_location_id != "") {
				document.getElementById("src_location").value = src_location_id;
				document.getElementById("srch_location_link").innerHTML = src_location_name;
			} else if (src_mall_id != "") {
				document.getElementById("src_mall").value = src_mall_id;
				document.getElementById("srch_location_link").innerHTML = src_mall_name;
			} else {
				document.getElementById("src_location").value = "";
				document.getElementById("src_mall").value = "";
				document.getElementById("srch_location_link").innerHTML = "Any Shopping Area/Mall";
			}
		} else {
			document.getElementById("src_city").value = "";
			document.getElementById("srch_city_link").innerHTML = "Any City";
			document.getElementById("src_location").value = "";
			document.getElementById("srch_location_link").innerHTML = "Any Shopping Area/Mall";
		}

		if (src_cat_id != "") {
            document.getElementById("src_category").value = src_cat_id;
            document.getElementById("srch_category_link").innerHTML = src_cat_name;
        }
        if (src_days_val != "") {
            document.getElementById("src_days").value = src_days_val;
            document.getElementById("srch_days_link").innerHTML = src_days_name;
        }
    }
