$( document ).ready ( function () {
	if(!$('#hiddenModalContent').length) $('body').append('<div id="hiddenModalContent"  style="display:none;"></div>');
	$('body').append('<a id="thickbox_window" style="display:none;" href="#TB_inline?height=320&amp;width=740&amp;inlineId=hiddenModalContent" class="thickbox"></a>');
});

showRemarkModelWindow = function(model,item_id,service_id)
{
	var remarkInfo={};
	if(model) remarkInfo['model'] = encodeURIComponent(model);
	if(item_id) remarkInfo['item_id'] = encodeURIComponent(item_id);
	if(service_id) remarkInfo['service_id'] = encodeURIComponent(service_id);
	$('#hiddenModalContent').empty();
	$.post
	(
		'/remark_model/remarkForm.php',
		{ 
			mode:'showRemarkModelWindow',
			remarkInfo:encodeURIComponent(serialize(remarkInfo))
		},
		function(data)
		{
			$('#hiddenModalContent').html(data);
			$("#thickbox_window").trigger('click');
		}
	);
	return false;
}

function serialize (mixed_value) 
{
    // *     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";}'
    // *     example 2: serialize({firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'});
    // *     returns 2: 'a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}'
    var _getType = function (inp) {
		var type = typeof inp, match; var key;
        if (type == 'object' && !inp) {return 'null';}
        if (type == "object") {if (!inp.constructor) {return 'object';} var cons = inp.constructor.toString(); match = cons.match(/(\w+)\(/); if (match) {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(mixed_value); var val, ktype = '';
    switch (type) {
        case "function": val = ""; break;
        case "boolean": val = "b:" + (mixed_value ? "1" : "0"); break;
        case "number": val = (Math.round(mixed_value) == mixed_value ? "i" : "d") + ":" + mixed_value; break;
        case "string":  val = "s:" + encodeURIComponent(mixed_value).replace(/%../g, 'x').length + ":\"" + mixed_value + "\"";break;
        case "array": case "object": val = "a"; var count = 0; var vals = ""; var okey; var key; for (key in mixed_value) {ktype = _getType(mixed_value[key]); if (ktype == "function") { continue;} okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key); vals += this.serialize(okey) + this.serialize(mixed_value[key]); count++;} val += ":" + count + ":{" + vals + "}"; break;
        case "undefined": // Fall-through
        default: val = "N"; break;
    }
    if (type != "object" && type != "array") {val += ";";}
    return val;
}