
function send_basic_search(url)
{
	temp_arr = new Array();
	
	temp_arr['property_category']	= document.getElementById('property_category_').value;
	temp_arr['property_city']		= document.getElementById('property_city_').value;
	temp_arr['property_type']		= document.getElementById('property_type_').value;
	temp_arr['structure_type']		= document.getElementById('structure_type_').value;
	temp_arr['property_zone']		= document.getElementById('property_zone_').value;
	temp_arr['mls']					= document.getElementById('mls_').value;
	temp_arr['price']				= document.getElementById('price_').value;
	temp_arr['to']					= document.getElementById('to_').value;
	temp_arr['sort']				= document.getElementById('sort_').value;

	
	var search = new String();
	search = base64_encode(serialize(temp_arr));
	document.location = url+search;
}

function send_advanced_search(url)
{
	temp_arr 	= new Array();
	caract_ids 	= new String();
	expl 		= new Array();
	
	temp_arr['property_category']	= document.getElementById('property_category_').value;
	temp_arr['property_city']		= document.getElementById('property_city_').value;
	temp_arr['property_type']		= document.getElementById('property_type_').value;
	temp_arr['structure_type']		= document.getElementById('str_type_id').value;
	temp_arr['property_zone']		= document.getElementById('property_zone_').value;
	temp_arr['mls']					= document.getElementById('mls_').value;
	temp_arr['price']				= document.getElementById('price_').value;
	temp_arr['to']					= document.getElementById('to_').value;
	temp_arr['sort']				= document.getElementById('sort_').value;


	if (document.getElementById('str_type_id').value > 0)
	{
		caract_ids = document.getElementById('hidden_caract_').value;
		expl = explode(',',caract_ids);
		for(var i=0; i < (expl.length-1);i++)
		{
			temp_arr['c_'+expl[i]] = document.getElementById('l_'+expl[i]).value;
		}
	}
	
	var search = new String();
	search = base64_encode(serialize(temp_arr));
	document.location = url+search;
}


function base64_encode( data ) {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Tyler Akins (http://rumkin.com)
	    // +   improved by: Bayron Guevara
	    // +   improved by: Thunder.m
	    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // -    depends on: utf8_encode
	    // *     example 1: base64_encode('Kevin van Zonneveld');
	    // *     returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='

	    // mozilla has this native
	    // - but breaks in 2.0.0.12!
	    //if (typeof window['atob'] == 'function') {
	    //    return atob(data);
	    //}

	    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	    var o1, o2, o3, h1, h2, h3, h4, bits, i = ac = 0, enc="", tmp_arr = [];
	    data = utf8_encode(data);

	    do { // pack three octets into four hexets
	        o1 = data.charCodeAt(i++);
	        o2 = data.charCodeAt(i++);
	        o3 = data.charCodeAt(i++);

	        bits = o1<<16 | o2<<8 | o3;

	        h1 = bits>>18 & 0x3f;
	        h2 = bits>>12 & 0x3f;
	        h3 = bits>>6 & 0x3f;
	        h4 = bits & 0x3f;

	        // use hexets to index into b64, and append result to encoded string
	        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
	    } while (i < data.length);

	    enc = tmp_arr.join('');

	    switch( data.length % 3 ){
	        case 1:
	            enc = enc.slice(0, -2) + '==';
	        break;
	        case 2:
	            enc = enc.slice(0, -1) + '=';
	        break;
	    }

	    return enc;
}



	function base64_decode( data ) {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Tyler Akins (http://rumkin.com)
	    // +   improved by: Thunder.m
	    // +      input by: Aman Gupta
	    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	    // -    depends on: utf8_decode
	    // *     example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
	    // *     returns 1: 'Kevin van Zonneveld'

	    // mozilla has this native
	    // - but breaks in 2.0.0.12!
	    //if (typeof window['btoa'] == 'function') {
	    //    return btoa(data);
	    //}

	    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
	    var o1, o2, o3, h1, h2, h3, h4, bits, i = ac = 0, dec = "", tmp_arr = [];

	    do {  // unpack four hexets into three octets using index points in b64
	        h1 = b64.indexOf(data.charAt(i++));
	        h2 = b64.indexOf(data.charAt(i++));
	        h3 = b64.indexOf(data.charAt(i++));
	        h4 = b64.indexOf(data.charAt(i++));

	        bits = h1<<18 | h2<<12 | h3<<6 | h4;

	        o1 = bits>>16 & 0xff;
	        o2 = bits>>8 & 0xff;
	        o3 = bits & 0xff;

	        if (h3 == 64) {
	            tmp_arr[ac++] = String.fromCharCode(o1);
	        } else if (h4 == 64) {
	            tmp_arr[ac++] = String.fromCharCode(o1, o2);
	        } else {
	            tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
	        }
	    } while (i < data.length);

	    dec = tmp_arr.join('');
	    dec = utf8_decode(dec);

	    return dec;
	}


	function serialize( inp ) {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Arpad Ray (mailto:arpad@php.net)
	    // *     example 1: serialize(['Kevin', 'van', 'Zonneveld']);
	    // *     returns 1: 'a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}'

	    var getType = function( inp ) {
	        var type = typeof inp, match;
	        if(type == 'object' && !inp)
	        {
	            return 'null';
	        }
	        if (type == "object") {
	            if(!inp.constructor)
	            {
	                return 'object';
	            }
	            var cons = inp.constructor.toString();
	            if (match = cons.match(/(\w+)\(/)) {
	                cons = match[1].toLowerCase();
	            }
	            var types = ["boolean", "number", "string", "array"];
	            for (key in types) {
	                if (cons == types[key]) {
	                    type = types[key];
	                    break;
	                }
	            }
	        }
	        return type;
	    };

	    var type = getType(inp);
	    var val;
	    switch (type) {
	        case "undefined":
	            val = "N";
	            break;
	        case "boolean":
	            val = "b:" + (inp ? "1" : "0");
	            break;
	        case "number":
	            val = (Math.round(inp) == inp ? "i" : "d") + ":" + inp;
	            break;
	        case "string":
	            val = "s:" + inp.length + ":\"" + inp + "\"";
	            break;
	        case "array":
	            val = "a";
	        case "object":
	            if (type == "object") {
	                var objname = inp.constructor.toString().match(/(\w+)\(\)/);
	                if (objname == undefined) {
	                    return;
	                }
	                objname[1] = serialize(objname[1]);
	                val = "O" + objname[1].substring(1, objname[1].length - 1);
	            }
	            var count = 0;
	            var vals = "";
	            var okey;
	            for (key in inp) {
	                okey = (key.match(/^[0-9]+$/) ? parseInt(key) : key);
	                vals += serialize(okey) +
	                        serialize(inp[key]);
	                count++;
	            }
	            val += ":" + count + ":{" + vals + "}";
	            break;
	    }
	    if (type != "object" && type != "array") val += ";";
	    return val;
}


	function unserialize ( inp ) {
	    // http://kevin.vanzonneveld.net
	    // +   original by: Arpad Ray (mailto:arpad@php.net)
	    // +   improved by: Pedro Tainha (http://www.pedrotainha.com)
	    // *     example 1: unserialize('a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}');
	    // *     returns 1: ['Kevin', 'van', 'Zonneveld']

	    error = 0;
	    if (inp == "" || inp.length < 2) {
	        errormsg = "input is too short";
	        return;
	    }
	    var val, kret, vret, cval;
	    var type = inp.charAt(0);
	    var cont = inp.substring(2);
	    var size = 0, divpos = 0, endcont = 0, rest = "", next = "";

	    switch (type) {
	    case "N": // null
	        if (inp.charAt(1) != ";") {
	            errormsg = "missing ; for null";
	        }
	        // leave val undefined
	        rest = cont;
	        break;
	    case "b": // boolean
	        if (!/[01];/.test(cont.substring(0,2))) {
	            errormsg = "value not 0 or 1, or missing ; for boolean";
	        }
	        val = (cont.charAt(0) == "1");
	        rest = cont.substring(2);  //changed...
	        break;
	    case "s": // string
	        val = "";
	        divpos = cont.indexOf(":");
	        if (divpos == -1) {
	            errormsg = "missing : for string";
	            break;
	        }
	        size = parseInt(cont.substring(0, divpos));
	        if (size == 0) {
	            if (cont.length - divpos < 4) {
	                errormsg = "string is too short";
	                break;
	            }
	            rest = cont.substring(divpos + 4);
	            break;
	        }
	        if ((cont.length - divpos - size) < 4) {
	            errormsg = "string is too short";
	            break;
	        }
	        if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\";") {
	            errormsg = "string is too long, or missing \";";
	        }
	        val = cont.substring(divpos + 2, divpos + 2 + size);
	        rest = cont.substring(divpos + 4 + size);
	        break;
	    case "i": // integer
	    case "d": // float
	        var dotfound = 0;
	        for (var i = 0; i < cont.length; i++) {
	            cval = cont.charAt(i);
	            if (isNaN(parseInt(cval)) && !(type == "d" && cval == "." && !dotfound++)) {
	                endcont = i;
	                break;
	            }
	        }
	        if (!endcont || cont.charAt(endcont) != ";") {
	            errormsg = "missing or invalid value, or missing ; for int/float";
	        }
	        val = cont.substring(0, endcont);
	        val = (type == "i" ? parseInt(val) : parseFloat(val));
	        rest = cont.substring(endcont + 1);
	        break;
	    case "a": // array
	        if (cont.length < 4) {
	            errormsg = "array is too short";
	            return;
	        }
	        divpos = cont.indexOf(":", 1);
	        if (divpos == -1) {
	            errormsg = "missing : for array";
	            return;
	        }
	        size = parseInt(cont.substring(1*divpos, 0));  //changed...
	        cont = cont.substring(divpos + 2);
	        val = new Array();
	        if (cont.length < 1) {
	            errormsg = "array is too short";
	            return;
	        }
	        for (var i = 0; i + 1 < size * 2; i += 2) {
	            kret = unserialize(cont, 1);
	            if (error || kret[0] == undefined || kret[1] == "") {
	                errormsg = "missing or invalid key, or missing value for array";
	                return;
	            }
	            vret = unserialize(kret[1], 1);
	            if (error) {
	                errormsg = "invalid value for array";
	                return;
	            }
	            val[kret[0]] = vret[0];
	            cont = vret[1];
	        }
	        if (cont.charAt(0) != "}") {
	            errormsg = "missing ending }, or too many values for array";
	            return;
	        }
	        rest = cont.substring(1);
	        break;
	    case "O": // object
	        divpos = cont.indexOf(":");
	        if (divpos == -1) {
	            errormsg = "missing : for object";
	            return;
	        }
	        size = parseInt(cont.substring(0, divpos));
	        var objname = cont.substring(divpos + 2, divpos + 2 + size);
	        if (cont.substring(divpos + 2 + size, divpos + 4 + size) != "\":") {
	            errormsg = "object name is too long, or missing \":";
	            return;
	        }
	        var objprops = unserialize("a:" + cont.substring(divpos + 4 + size), 1);
	        if (error) {
	            errormsg = "invalid object properties";
	            return;
	        }
	        rest = objprops[1];
	        var objout = "function " + objname + "(){";
	        for (key in objprops[0]) {
	            objout += "" + key + "=objprops[0]['" + key + "'];";
	        }
	        objout += "}val=new " + objname + "();";
	        eval(objout);
	        break;
	    default:
	        errormsg = "invalid input type";
	    }
	    return (arguments.length == 1 ? val : [val, rest]);
	}


function explode( delimiter, string, limit ) {
    // http://kevin.vanzonneveld.net
    // +     original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: kenneth
    // +     improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     improved by: d3x
    // +     bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: explode(' ', 'Kevin van Zonneveld');
    // *     returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
    // *     example 2: explode('=', 'a=bc=d', 2);
    // *     returns 2: ['a', 'bc=d']

    var emptyArray = { 0: '' };

    // third argument is not required
    if ( arguments.length < 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }

    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }

    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }

    if ( delimiter === true ) {
        delimiter = '1';
    }

    if (!limit) {
        return string.toString().split(delimiter.toString());
    } else {
        // support for limit argument
        var splitted = string.toString().split(delimiter.toString());
        var partA = splitted.splice(0, limit - 1);
        var partB = splitted.join(delimiter.toString());
        partA.push(partB);
        return partA;
    }
}

function utf8_encode ( str_data ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: utf8_encode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'

    str_data = str_data.replace(/\r\n/g,"\n");
    var tmp_arr = [], ac = 0;

    for (var n = 0; n < str_data.length; n++) {
        var c = str_data.charCodeAt(n);
        if (c < 128) {
            tmp_arr[ac++] = String.fromCharCode(c);
        } else if((c > 127) && (c < 2048)) {
            tmp_arr[ac++] = String.fromCharCode((c >> 6) | 192);
            tmp_arr[ac++] = String.fromCharCode((c & 63) | 128);
        } else {
            tmp_arr[ac++] = String.fromCharCode((c >> 12) | 224);
            tmp_arr[ac++] = String.fromCharCode(((c >> 6) & 63) | 128);
            tmp_arr[ac++] = String.fromCharCode((c & 63) | 128);
        }
    }

    return tmp_arr.join('');
}

function utf8_decode ( str_data ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +      input by: Aman Gupta
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'

    var tmp_arr = [], i = ac = c = c1 = c2 = 0;

    while ( i < str_data.length ) {
        c = str_data.charCodeAt(i);
        if (c < 128) {
            tmp_arr[ac++] = String.fromCharCode(c);
            i++;
        } else if ((c > 191) && (c < 224)) {
            c2 = str_data.charCodeAt(i+1);
            tmp_arr[ac++] = String.fromCharCode(((c & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i+1);
            c3 = str_data.charCodeAt(i+2);
            tmp_arr[ac++] = String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    }

    return tmp_arr.join('');
}