jQuery(document).ready(function($){	
	jQuery.fn.extend({
	  scrollTo : function(speed, easing) {
		return this.each(function() {
		  var targetOffset = $(this).offset().top;
		  easing= easing?easing:'easeOutExpo';
		  $('html,body').stop(true, true).animate({scrollTop: targetOffset}, speed, easing);
		});
	  }
	});
/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example jQuery.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example jQuery.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example jQuery.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example jQuery.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name jQuery.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example jQuery.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name jQuery.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
});


jQuery(document).ready(function($){
	/****************************
	*							*
	*		Change currency	 	*
	*							*
	****************************/
	$('#gwe_page_country').change(function(){
		var val = $(this).find('option:selected').text();
		if(val == "Hong Kong"){
			$('#price_per_pax .subcheckbox span').each(function(){
				var obj = $(this);
				var text = obj.html();
				var prices = text.split('-');
				var new_price = "";
				for(var i = 0; i < prices.length; i ++){
					if(prices[i] != "0")
						prices[i] += "0";
					new_price += prices[i];
					if((i+1) != prices.length)
					new_price += "-";
				}
				obj.html(new_price);
			});
		}
	});
	/****************************
	*							*
	*		preloader	 		*
	*							*
	****************************/
	var cache = [];
	$('img').each(function(){
		var cacheImage = document.createElement('img');
		var img = $(this).attr('src');
		var img_array = img.split("&");
		if(img_array[1] != undefined)
		img_array[1] = img_array[1].replace('74', '600');
		if(img_array[2] != undefined)
		img_array[2] = img_array[2].replace('74', '594');
		var new_img = img_array.join('&');
		cacheImage.src = new_img;
		cache.push(cacheImage);
	});
	/****************************
	*							*
	*		TOOLTIPS	 		*
	*							*
	****************************/
	$("img[title].gwe_tooltip").tooltip({ position: 'bottom right', relative: true, opacity: 0.7});
	/****************************
	*							*
	*		SLIDESHOW	 		*
	*							*
	****************************/
	var tmp = $("#browsable");
	tmp.scrollable().navigator();
	if($('.gwe_block').length == 1){
		$('.browse, .navi').hide();
		var numOfImages = tmp.find('.gwe_block span').length;
		var removeRows = Math.ceil(numOfImages/3);
		removeRows = 4 - removeRows;
		var current_height = tmp.css('height');
		current_height = current_height.replace('px', '');
		tmp.css('height', parseInt(current_height) - (removeRows * 75) + "px");
	}
	
	/****************************
	*							*
	*		focus logic 		*
	*							*
	****************************/
	var unknown_value = "";
	$('.unknown').focus(function(){
		var obj = $(this);
		unknown_value = obj.attr("value");
		obj.attr("value", "");
	}).blur(function(){
		var obj = $(this);
		if(obj.attr("value") == unknown_value || obj.attr("value") == "")
			obj.attr("value", unknown_value);
	});
	/****************************
	*							*
	*		index.php logic 	*
	*							*
	****************************/
	// var logo = function(){
		// var val = $($('#gwe_country option:selected')[0]).val();
		// if(val != ""){
			// jQuery.cookie('gwe_country_link', val, { expires: 1 });
			// return true;
		// }else
		// alert('Please select a country.');
		// return false;
	// }
	// var submit = function(){
		// $('#gwe_country_form').submit();
	// }
	//$('#gwe_country_form').bind('submit', logo);
	//$('#logo').bind('click', submit);
	//$('#gwe_country').sSelect();
	/****************************
	*							*
	*		country icons	 	*
	*							*
	****************************/
	// $('#list_countries a').click(function(){
		// var obj = $(this);
		// jQuery.cookie('gwe_country_link', obj.attr('href'), { expires: 1 });
		// jQuery.cookie('gwe_country', obj.attr('alt'), { expires: 1 });
	// });
	/****************************
	*							*
	*		pop out logic 		*
	*							*
	****************************/
	// var searchThis = function(){
		// var obj = $(this);
		// var tmp = "0";
		
		// $(".gwe_state input[type=hidden]").each(function(){
			// var obj = $(this);
			// if(obj.parent().find('input[type="checkbox"]').attr('checked'))
				// tmp += ","+obj.val();
		// });
		// jQuery.cookie('gwe_state', tmp, { expires: 1 });
		// var tmp = "0";
		// $(".gwe_city input[type=hidden]").each(function(){
			// var obj = $(this);
			// if(obj.parent().find('input[type="checkbox"]').attr('checked'))
				// tmp += ","+obj.val();
		// });
		// jQuery.cookie('gwe_city', tmp, { expires: 1 });
		// var tmp = "0";
		// $(".gwe_cuisine  input[type=hidden]").each(function(){
			// var obj = $(this);
			// if(obj.parent().find('input[type="checkbox"]').attr('checked'))
				// tmp += ","+obj.val();
		// });
		// jQuery.cookie('gwe_cuisine', tmp, { expires: 1 });
		// var tmp = "0";
		// $(".gwe_price input[type=hidden]").each(function(){
			// var obj = $(this);
			// if(obj.parent().find('input[type="checkbox"]').attr('checked'))
				// tmp += ","+obj.val();
		// });
		// jQuery.cookie('gwe_price', tmp, { expires: 1 });
		// var tmp = "0";
		// $(".gwe_place  input[type=hidden]").each(function(){
			// var obj = $(this);
			// if(obj.parent().find('input[type="checkbox"]').attr('checked'))
				// tmp += ","+obj.val();
		// });
		// jQuery.cookie('gwe_place', tmp, { expires: 1 });
		// var tmp = "0";
		// $(".gwe_type input[type=hidden]").each(function(){
			// var obj = $(this);
			// if(obj.parent().find('input[type="checkbox"]').attr('checked'))
				// tmp += ","+obj.val();
		// });
		// jQuery.cookie('gwe_place', tmp, { expires: 1 });
		// var tmp = "0";
		// $(".gwe_amenities input[type=hidden]").each(function(){
			// var obj = $(this);
			// if(obj.parent().find('input[type="checkbox"]').attr('checked'))
				// tmp += ","+obj.val();
		// });
		
		// jQuery.cookie('gwe_amenities', tmp, { expires: 1 });
		// $.get($('#gwe-theme').val()+'/ajax.php', function(data) {
			// $('#content').html(data);
			// $('#screen').trigger('click');
		// });
		
	// }
	// var country = $('#gwe-country').val();
	// if(country != ""){
		// jQuery.cookie('gwe_country', country, { expires: 1 });
	// }
	// var showThis = function(){
		// var obj = $(this);
		// obj.parent().find('span').each(function(){
			// $("."+$(this).attr('class')).hide();
		// })
		// var gweclass = obj.attr('class');
		// $("."+gweclass).show();
	// }
	// $('#gwe-key span').click(showThis);
	//$('#gwe-filter').click(searchThis);
	// var filter = function(){
		// var hidden = "-1";
		// $(':checked').each(function(){
			// var Obj = $(this);
			// hidden += "," +Obj.parent().find("input[type=hidden]").val();
		// });
		// $('#post-over').val(hidden);
		// $('#gwe_form').attr('action', "").submit();
		
	// }
	// $('#gwe-filter').bind('click', filter);
	var states = function(){
		var checkbox = $(this);
		var parent = checkbox.parent().find("input[type=hidden]").val();
		var isChecked = checkbox.attr("checked");
		if(isChecked){
			$('.parent_'+parent).css('display', 'block');
		}else{
			$('.parent_'+parent).css('display', 'none');
		}
			
	}
	$('.states').click(states);
	
	var pop = function(){
		$('#screen').css({"z-index":"99",	"display": "block", opacity: 0.5, "width":$(document).width(),"height":$(document).height()})
		var button = $(this).attr('id');
		var selector = '#'+button.replace('button', 'box');
		$(selector).css({"display": "block"});
		return false;
	}
	$('#search-button, #login-button, #profile-button').click(pop);
	$('#login-cancel,#profile-cancel,#search-cancel').click(function(){
	var button = $(this).attr('id');
	var selector = '#'+button.replace('cancel', 'box');
		$(selector).css("display", "none");
		$('#screen').css("display", "none"); 
		return false;
	});
	$(window).resize(function(){
		$('#box').css("display") == 'block'?pop.call($('#button')):"";
	});
	if($('#gwe-paged').val() == 1 && $('#gwe-country').val() != "" && (jQuery.cookie('gwe_country') == "null" || jQuery.cookie('gwe_country') == ""))
		$('#search-button').trigger('click');
	/****************************
	*							*
	*		suggest logic 		*
	*							*
	****************************/
	function stripHTML(oldString) {
		return oldString.replace(/<(?:.|\s)*?>/g, "");
	}

	var gwe_state = $('#gwe_page_state').html();
	var gwe_city = $('#gwe_page_city').html();
	var gwe_country = $('#gwe_page_country').html();
	var display_state = function(look){
		var obj = $(this);
		var find = look=='country'?'gwe_page_state':'gwe_page_city';
		$('#'+find+' option:first').attr('selected', 'selected');
		if(look == 'country')
		$('#gwe_page_city option:first').attr('selected', 'selected');
		var parent = obj.val();
		
		
		look=='country'?$('#'+find).html(gwe_state):$('#'+find).html(gwe_city);
		$('.'+find).show().find('option:not(.parent_'+parent+', option:first)').remove();
	}
	$('#gwe_page_country').change(function(){
		display_state.call(this, 'country');
	});
	$('#gwe_page_state').change(function(){
		display_state.call(this, '');
	});
	
	var max = 99;
	var replaceMe = function(){
		var obj = $(this);
		if(obj.val().toLowerCase().indexOf('.jpg') == -1 && obj.val().toLowerCase().indexOf('.png') == -1 && obj.val().toLowerCase().indexOf('.gif') == -1)
		{
			alert('Sorry, we only accept GIF, PNG and JPEG images');
			obj.val("");
			return false;
		}
		var slug = string_to_slug(obj.val());
		if($("."+ slug).length > 0){
			alert('Sorry, this image already exist. Please select other images.');
			obj.val("");
			return false;
		}
		
		if($("input[type='file']").length > max)
		{
			alert('Maximum upload has reached: '+ max);
			obj.val("");
			return false;
		}
		$(obj).addClass(slug).css({'position':'absolute','left':'-9999px','display':'none'}).parent().prepend('<input type="file" name="'+obj.attr('name')+'"/>')
		$('#upload_list').append('<div style="clear:both;"><div class="gwe_file_name" style="float:left;">'+obj.val()+'</div><div class="cancel"></div></div>');
		//$("input[type='file']").change(replaceMe);
		$(".cancel").click(function(){
			var name = string_to_slug($(this).parent().find('div:first').html());
			$("."+name).remove();
			$(this).parent().remove();
			return false;
		});
	}
	//$("input[type='file']:not(.single)").change(replaceMe);
	$('.gwe_form').submit(function(){
		$('.alert').removeClass('alert');
		var result = true;		
		$('.gwe_form p:visible input.input').each(function(){
			var Obj = $(this);
			if(Obj.attr('value') == ""){
				Obj.addClass('alert');
			}else{
				Obj.removeClass('alert');
			}
		});
		$('.gwe_form p:visible textarea.input').each(function(){
			var Obj = $(this);
			if(Obj.val() == ""){
				Obj.addClass('alert');
			}else{
				Obj.removeClass('alert');
			}
		});
		if($('#gwe_content_ifr').html() != null && $('#gwe_content_ifr').html() != undefined){
			if(stripHTML($('#gwe_content_ifr').contents().find('#tinymce').html()) == ""){
				$('#gwe_content_tbl').addClass('alert');
			}else{
				$('#gwe_content_tbl').removeClass('alert');
			}
		}
		$('.gwe_form p:visible .select, .select .checkbox').each(function(){
				$(this).addClass('alert');
		});
		$('.gwe_form p:visible .select option:selected').each(function(){
			var Obj = $(this);
			if(Obj.val() != ""){
				Obj.parent().removeClass('alert');
				Obj.parent().parent().find('.checkbox').removeClass('alert');
			}
		});
		
		$('.gwe_form p:visible input:radio').each(function(){
				$(this).parent().addClass('alert');
		});
		$('.gwe_form p:visible input:checked').each(function(){
			var Obj = $(this);
			if(Obj.val() != "")
			Obj.parent().removeClass('alert');
		});
		if($('#upload_list').html() == ""){
			$('.file').addClass('alert');
		}else if($('#upload_list').html() != "")
			$('.file').removeClass('alert');
		$('.alert').each(function(){
			result = false;
			return false;
		});
		if(result)
			$(".submit").attr('disabled', 'true');
		else
			alert("We found some problems highlighted in red. Please try again.");
		if($('#startUpload').length && result){
			$('#startUpload').click();
			return false;
		}else
		return result;
	});
	function string_to_slug(str) {
		str = str.replace(/^\s+|\s+$/g, ''); // trim
		str = str.toLowerCase();

		// remove accents, swap ñ for n, etc
		var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
		var to   = "aaaaeeeeiiiioooouuuunc------";
		for (var i=0, l=from.length ; i<l ; i++) {
		str = str.replace(from[i], to[i]);
		}

		str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
		.replace(/\s+/g, '-') // collapse whitespace and replace by -
		.replace(/-+/g, '-'); // collapse dashes

		return str;
	}
	/************************************
	*									*
	*		preload thumbnail image		*
	*									*
	*************************************/
	var replace_display = function(){
		var obj = $(this);
		var imgObj = obj.find('img:first')
		var img = imgObj.attr('src');
		var new_alt = imgObj.attr('alt');
		var new_title = imgObj.attr('title');
		var img_array = img.split("&");
		var ori = img_array[0];
		
		$('.image-display:first').each(function(){
			$('#screen').css({"z-index":"99",	"display": "block", opacity: 0.5, "width":$(document).width(),"height":$(document).height()})
			$('#loadingbox').css("display", "block"); 
			var tmp = $(this);
			
			img_array[1] = img_array[1].replace('74', '600');
			img_array[2] = img_array[2].replace('74', '594');
			var new_img = img_array.join('&');
			img_array[1] = img_array[1].replace('600', '2500');
			img_array[2] = img_array[2].replace('594', '2593');
			var img_bigger = img_array.join('&');
			tmp.find('a').attr('href', img_bigger);
			var img = new Image();
			img.onload = function() {
				$('#screen').css("display", "none"); 
				$('#loadingbox').css("display", "none"); 
				tmp.find('img:first').attr({'src': new_img, 'title' : new_title, 'alt' : new_alt});
				$('.tooltip').html(new_title == ""? "No idea what is this. Please tell us what is this :(":new_title );
				$('html, body').animate({scrollTop:120 + "px"}, 250);
			}
			img.src = new_img;
			return;
		});

		
		return false;
	}
	$('.gwe_thumbnail').click(replace_display);
	/****************************
	*							*
	*		category.php		*
	*							*
	****************************/
	// $('.entry').hover(function(){
		// $(".cover", this).stop().css('zIndex', 0).animate({bottom:'-300px'},{queue:false,duration:160});
	// }, function() {
		// $(".cover", this).stop().animate({bottom:'15px'},{queue:false,duration:160}).css('zIndex', 10);
	// });
	/****************************
	*							*
	*		Google Map			*
	*							*
	****************************/
	$('#gwe-navi-3 a').toggle(function(){
		$(this).html('Hide Google Map');
		$('#map_canvas').css({height:'300px', 'border': '#CCC solid 1px'}).show();
		if (GBrowserIsCompatible()) {
			/* var map = new GMap2(document.getElementById("map_canvas"));
			var geocoder = new GClientGeocoder();
			
			map.setCenter(new GLatLng(37.339085, -121.8914807), 18);

			// Select a map type which supports aerial imagery
			map.setMapType(G_HYBRID_MAP);
			map.setUIToDefault();

			// Enable the additional map types within
			// the map type collection
			map.enableRotation();
			map.openInfoWindow(map.getCenter(),
                   document.createTextNode($('#title a').html())); */
			var map = new GMap2(document.getElementById("map_canvas"));
			var geocoder = new GClientGeocoder();
			
			function showAddress(address) {
			  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);
				  }
				}
			  );
			}
			showAddress($('#gwe_address').html().replace(/,/g, " ").replace(/<br>/g, ","));
		  }
	},
	function(){
		$(this).html('Show Google Map');
		$('#map_canvas').hide();
	});
	/****************************
	*							*
	*		Password Meter		*
	*							*
	****************************/
	$('#user_password').keyup(function(){check_pass_strength.call(this, '#user_password')})
	$('#user_confirm_password').keyup(function(){check_pass_strength.call(this, '#user_confirm_password')})
	function check_pass_strength(selector) {
		var pass = $(selector).val(), user = $('#user_login').val(), strength;

		$('#pass-strength-result').removeClass('short bad good strong');
		
		if ( ! pass ) {
		
			$('#pass-strength-result').html( 'Very Weak' );
			return;
		}

		strength = passwordStrength(pass, user);
		switch ( strength ) {
			case 2:
				$('#pass-strength-result').addClass('bad').html( 'Weak' );
				break;
			case 3:
				$('#pass-strength-result').addClass('good').html( 'Medium' );
				break;
			case 4:
				$('#pass-strength-result').addClass('strong').html( 'Strong' );
				break;
			default:
				$('#pass-strength-result').addClass('short').html( 'Very Weak' );
		}
	}
	/****************************
	*							*
	*		Select box			*
	*							*
	****************************/
	
	$('select.switch').each(function(){
		var obj = $(this);
		var objParent = obj.parent();
		var str = "";
		obj.hide().find('option').each(function(){
			var innerObj = $(this);	
			if(innerObj.val() != ""){
				var isSelected = innerObj.attr('selected')?'checked':'';
				if(obj.hasClass('stage')){
					if(innerObj.html().indexOf("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") != -1){
						str+='<span class="subcheckbox level4 none">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" '+ isSelected + ' class="checkboxFilter '+innerObj.attr('class')+'" value="'+innerObj.val()+'"></input><span>'+innerObj.html().replace(/&nbsp;/g,"")+'</span></span>';
					}else if(innerObj.html().indexOf("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;") != -1){
						str+='<span class="subcheckbox level3 none">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" '+ isSelected + ' class="checkboxFilter '+innerObj.attr('class')+'" value="'+innerObj.val()+'"></input><span>'+innerObj.html().replace(/&nbsp;/g,"")+'</span></span>';
					}else if(innerObj.html().indexOf("&nbsp;&nbsp;&nbsp;") != -1){
						str+='<span class="subcheckbox level2 none" style="width:100%"> &nbsp;&nbsp;&nbsp;<input type="checkbox" '+ isSelected + ' class="checkboxFilter '+innerObj.attr('class')+'" value="'+innerObj.val()+'"></input><span>'+innerObj.html().replace(/&nbsp;/g,"")+'</span></span>';
					}else if(innerObj.html().indexOf("&nbsp;") == -1){
						str+='<span class="subcheckbox level1" style="width:100%"><input type="checkbox" '+ isSelected + ' class="checkboxFilter '+innerObj.attr('class')+'" value="'+innerObj.val()+'"></input><span>'+innerObj.html()+'</span></span>';
					}
				}else if(objParent.hasClass('gwe_page_city'))
					str+='<span class="subcheckbox none"><input type="checkbox" '+ isSelected + ' class="checkboxFilter '+innerObj.attr('class')+'" value="'+innerObj.val()+'"></input><span>'+innerObj.html()+'</span></span>';
				else
					str+='<span class="subcheckbox"><input type="checkbox" '+ isSelected + ' class="checkboxFilter '+innerObj.attr('class')+'" value="'+innerObj.val()+'"></input><span>'+innerObj.html()+'</span></span>';
			}
		});
		if(objParent.hasClass('gwe_page_city'))
		objParent.append('<div class="checkbox gwe_page_city '+obj.attr('class')+'">'+str+'</div>');
		else
		objParent.append('<div class="checkbox '+obj.attr('class')+'">'+str+'</div>');
	});
	
	var selectFilter = function(){
		var obj = $(this);
		var checkboxes = obj.parent().parent();
		var selectParent = obj.parent().parent().parent();
		var select = selectParent.find('select');
		var options = select.find('option[value="'+obj.val()+'"]');
		if(!select.attr('multiple')){
			checkboxes.find(':checkbox[value!='+obj.val()+']').attr('checked', false);
		}
		if(selectParent.hasClass('gwe_page_state')){
			$('.gwe_page_city :checkbox').parent().show();
			$('.gwe_page_city :checkbox').attr('checked', false);
			$('.gwe_page_city :checkbox:not(.parent_'+obj.val()+', :checked)').parent().hide();
			$('#gwe_page_city option').attr('selected', false);
		}
		if(options.attr('selected') == true)
			options.attr('selected', false);
		else
			options.attr('selected', 'selected');
		
	}
	
	var checkboxFilter = function(){
		var obj = $(this);
		if(obj.attr('checked'))
		$('._parent'+obj.val()).parent().removeClass('none');
		else
		$('._parent'+obj.val()+ ':not(:checked)').parent().addClass('none');
		return true;
	}
	var checkboxFilter2 = function(){
		var obj = $(this);
		if(!obj.attr('checked'))
		obj.parent().addClass('none');
		return true;
	}
	$('.level2 input[type=checkbox], .level3 input[type=checkbox],.level4 input[type=checkbox]').bind('click', checkboxFilter2);
	$('.level1 input[type=checkbox]').bind('click', checkboxFilter);
	$('.checkboxFilter').bind('click', selectFilter);
});

