
(function($){$.toJSON=function(o)
{if(typeof(JSON)=='object'&&JSON.stringify)
return JSON.stringify(o);var type=typeof(o);if(o===null)
return"null";if(type=="undefined")
return undefined;if(type=="number"||type=="boolean")
return o+"";if(type=="string")
return $.quoteString(o);if(type=='object')
{if(typeof o.toJSON=="function")
return $.toJSON(o.toJSON());if(o.constructor===Date)
{var month=o.getUTCMonth()+1;if(month<10)month='0'+month;var day=o.getUTCDate();if(day<10)day='0'+day;var year=o.getUTCFullYear();var hours=o.getUTCHours();if(hours<10)hours='0'+hours;var minutes=o.getUTCMinutes();if(minutes<10)minutes='0'+minutes;var seconds=o.getUTCSeconds();if(seconds<10)seconds='0'+seconds;var milli=o.getUTCMilliseconds();if(milli<100)milli='0'+milli;if(milli<10)milli='0'+milli;return'"'+year+'-'+month+'-'+day+'T'+
hours+':'+minutes+':'+seconds+'.'+milli+'Z"';}
if(o.constructor===Array)
{var ret=[];for(var i=0;i<o.length;i++)
ret.push($.toJSON(o[i])||"null");return"["+ret.join(",")+"]";}
var pairs=[];for(var k in o){var name;var type=typeof k;if(type=="number")
name='"'+k+'"';else if(type=="string")
name=$.quoteString(k);else
continue;if(typeof o[k]=="function")
continue;var val=$.toJSON(o[k]);pairs.push(name+":"+val);}
return"{"+pairs.join(", ")+"}";}};$.evalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);return eval("("+src+")");};$.secureEvalJSON=function(src)
{if(typeof(JSON)=='object'&&JSON.parse)
return JSON.parse(src);var filtered=src;filtered=filtered.replace(/\\["\\\/bfnrtu]/g,'@');filtered=filtered.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']');filtered=filtered.replace(/(?:^|:|,)(?:\s*\[)+/g,'');if(/^[\],:{}\s]*$/.test(filtered))
return eval("("+src+")");else
throw new SyntaxError("Error parsing JSON, source is not valid.");};$.quoteString=function(string)
{if(string.match(_escapeable))
{return'"'+string.replace(_escapeable,function(a)
{var c=_meta[a];if(typeof c==='string')return c;c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+(c%16).toString(16);})+'"';}
return'"'+string+'"';};var _escapeable=/["\\\x00-\x1f\x7f-\x9f]/g;var _meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};})(jQuery);;
﻿/*
 *
 *	jQuery Timer plugin v0.1
 *		Matt Schmidt [http://www.mattptr.net]
 *
 *	Licensed under the BSD License:
 *		http://mattptr.net/license/license.txt
 *
 */
 
 jQuery.timer = function (interval, callback)
 {
 /**
  *
  * timer() provides a cleaner way to handle intervals  
  *
  *	@usage
  * $.timer(interval, callback);
  *
  *
  * @example
  * $.timer(1000, function (timer) {
  * 	alert("hello");
  * 	timer.stop();
  * });
  * @desc Show an alert box after 1 second and stop
  * 
  * @example
  * var second = false;
  *	$.timer(1000, function (timer) {
  *		if (!second) {
  *			alert('First time!');
  *			second = true;
  *			timer.reset(3000);
  *		}
  *		else {
  *			alert('Second time');
  *			timer.stop();
  *		}
  *	});
  * @desc Show an alert box after 1 second and show another after 3 seconds
  *
  * 
  */

	var interval = interval || 100;

	if (!callback)
		return false;
	
	_timer = function (interval, callback) {
		this.stop = function () {
			clearInterval(self.id);
		};
		
		this.internalCallback = function () {
			callback(self);
		};
		
		this.reset = function (val) {
			if (self.id)
				clearInterval(self.id);
			
			var val = val || 100;
			this.id = setInterval(this.internalCallback, val);
		};
		
		this.interval = interval;
		this.id = setInterval(this.internalCallback, this.interval);
		
		var self = this;
	};
	
	return new _timer(interval, callback);
 };;
/*
  @author: remy sharp / http://remysharp.com
  @params:
    feedback - the selector for the element that gives the user feedback. Note that this will be relative to the form the plugin is run against.
    hardLimit - whether to stop the user being able to keep adding characters. Defaults to true.
    useInput - whether to look for a hidden input named 'maxlength' instead of the maxlength attribute. Defaults to false.
    words - limit by characters or words, set this to true to limit by words. Defaults to false.
  @license: Creative Commons License - ShareAlike http://creativecommons.org/licenses/by-sa/3.0/
  @version: 1.2
  @changes: code tidy via Ariel Flesler and fix when pasting over limit and including \t or \n
*/

(function ($) {

$.fn.maxlength = function (settings) {

    if (typeof settings == 'string') {
        settings = { feedback : settings };
    }

    settings = $.extend({}, $.fn.maxlength.defaults, settings);

    function length(el) {
    	var parts = el.value;
    	if ( settings.words )
    		parts = el.value.length ? parts.split(/\s+/) : { length : 0 };
    	return parts.length;
    }
    
    return this.each(function () {
        var field = this,
        	$field = $(field),
        	$form = $(field.form),
        	limit = settings.useInput ? $form.find('input[name=maxlength]').val() : $field.attr('maxlength'),
        	$charsLeft = $(settings.feedback);

    	function limitCheck(event) {
        	var len = length(this),
        	    exceeded = len >= limit,
        		code = event.keyCode;

        	if ( !exceeded )
        		return;

            switch (code) {
                case 8:  // allow delete
                case 9:
                case 17:
                case 36: // and cursor keys
                case 35:
                case 37: 
                case 38:
                case 39:
                case 40:
                case 46:
                case 65:
                    return;

                default:
                    return settings.words && code != 32 && code != 13 && len == limit;
            }
        }


        var updateCount = function () {
            var len = length(field),
            	diff = limit - len;

            $charsLeft.html( diff || "0" );

            // truncation code
            if (settings.hardLimit && diff < 0) {
            	field.value = settings.words ? 
            	    // split by white space, capturing it in the result, then glue them back
            		field.value.split(/(\s+)/, (limit*2)-1).join('') :
            		field.value.substr(0, limit);

                updateCount();
            }
        };

        $field.keyup(updateCount).change(updateCount);
        if (settings.hardLimit) {
            $field.keydown(limitCheck);
        }

        updateCount();
    });
};

$.fn.maxlength.defaults = {
    useInput : false,
    hardLimit : true,
    feedback : '.charsLeft',
    words : false
};

})(jQuery);;
(function($){var i=function(e){if(!e)var e=window.event;e.cancelBubble=true;if(e.stopPropagation)e.stopPropagation()};$.fn.checkbox=function(f){try{document.execCommand('BackgroundImageCache',false,true)}catch(e){}var g={cls:'jquery-checkbox',empty:'/empty.png'};g=$.extend(g,f||{});var h=function(a){var b=a.checked;var c=a.disabled;var d=$(a);if(a.stateInterval)clearInterval(a.stateInterval);a.stateInterval=setInterval(function(){if(a.disabled!=c)d.trigger((c=!!a.disabled)?'disable':'enable');if(a.checked!=b)d.trigger((b=!!a.checked)?'check':'uncheck')},10);return d};return this.each(function(){var a=this;var b=h(a);if(a.wrapper)a.wrapper.remove();a.wrapper=$('<span class="'+g.cls+'"><span class="mark"><img src="'+g.empty+'" /></span></span>');a.wrapperInner=a.wrapper.children('span:eq(0)');a.wrapper.hover(function(e){a.wrapperInner.addClass(g.cls+'-hover');i(e)},function(e){a.wrapperInner.removeClass(g.cls+'-hover');i(e)});b.css({position:'absolute',zIndex:-1,visibility:'hidden'}).after(a.wrapper);var c=false;if(b.attr('id')){c=$('label[for='+b.attr('id')+']');if(!c.length)c=false}if(!c){c=b.closest?b.closest('label'):b.parents('label:eq(0)');if(!c.length)c=false}if(c){c.hover(function(e){a.wrapper.trigger('mouseover',[e])},function(e){a.wrapper.trigger('mouseout',[e])});c.click(function(e){b.trigger('click',[e]);i(e);return false})}a.wrapper.click(function(e){b.trigger('click',[e]);i(e);return false});b.click(function(e){i(e)});b.bind('disable',function(){a.wrapperInner.addClass(g.cls+'-disabled')}).bind('enable',function(){a.wrapperInner.removeClass(g.cls+'-disabled')});b.bind('check',function(){a.wrapper.addClass(g.cls+'-checked')}).bind('uncheck',function(){a.wrapper.removeClass(g.cls+'-checked')});$('img',a.wrapper).bind('dragstart',function(){return false}).bind('mousedown',function(){return false});if(window.getSelection)a.wrapper.css('MozUserSelect','none');if(a.checked)a.wrapper.addClass(g.cls+'-checked');if(a.disabled)a.wrapperInner.addClass(g.cls+'-disabled')})}})(jQuery);;
// jQuery Alert Dialogs Plugin
//
// Version 1.1
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 14 May 2009
//
// Visit http://abeautifulsite.net/notebook/87 for more information
//
// Usage:
//		jAlert( message, [title, callback] )
//		jConfirm( message, [title, callback] )
//		jPrompt( message, [value, title, callback] )
// 
// History:
//
//		1.00 - Released (29 December 2008)
//
//		1.01 - Fixed bug where unbinding would destroy all resize events
//
// License:
// 
// This plugin is dual-licensed under the GNU General Public License and the MIT License and
// is copyright 2008 A Beautiful Site, LLC. 
//
(function($) {
	
	$.alerts = {
		
		// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
		
		verticalOffset: -75,                // vertical offset of the dialog from center screen, in pixels
		horizontalOffset: 0,                // horizontal offset of the dialog from center screen, in pixels/
		repositionOnResize: true,           // re-centers the dialog on window resize
		overlayOpacity: .01,                // transparency level of overlay
		overlayColor: '#FFF',               // base color of overlay
		draggable: true,                    // make the dialogs draggable (requires UI Draggables plugin)
		okButton: '&nbsp;OK&nbsp;',         // text for the OK button
		cancelButton: '&nbsp;Cancel&nbsp;', // text for the Cancel button
		dialogClass: null,                  // if specified, this class will be applied to all dialogs
		
		// Public methods
		
		alert: function(message, title, callback) {
			if( title == null ) title = 'Alert';
			$.alerts._show(title, message, null, 'alert', function(result) {
				if( callback ) callback(result);
			});
		},
		
		confirm: function(message, title, callback) {
			if( title == null ) title = 'Confirm';
			$.alerts._show(title, message, null, 'confirm', function(result) {
				if( callback ) callback(result);
			});
		},
			
		prompt: function(message, value, title, callback) {
			if( title == null ) title = 'Prompt';
			$.alerts._show(title, message, value, 'prompt', function(result) {
				if( callback ) callback(result);
			});
		},
		
		// Private methods
		
		_show: function(title, msg, value, type, callback) {
			
			$.alerts._hide();
			$.alerts._overlay('show');
			
			$("BODY").append(
			  '<div id="popup_container">' +
			    '<h1 id="popup_title"></h1>' +
			    '<div id="popup_content">' +
			      '<div id="popup_message"></div>' +
				'</div>' +
			  '</div>');
			
			if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
			
			// IE6 Fix
			var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed'; 
			
			$("#popup_container").css({
				position: pos,
				zIndex: 99999,
				padding: 0,
				margin: 0
			});
			
			$("#popup_title").text(title);
			$("#popup_content").addClass(type);
			$("#popup_message").text(msg);
			$("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
			
			$("#popup_container").css({
				minWidth: $("#popup_container").outerWidth(),
				maxWidth: $("#popup_container").outerWidth()
			});
			
			$.alerts._reposition();
			$.alerts._maintainPosition(true);
			
			switch( type ) {
				case 'alert':
					$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
					$("#popup_ok").click( function() {
						$.alerts._hide();
						callback(true);
					});
					$("#popup_ok").focus().keypress( function(e) {
						if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click');
					});
				break;
				case 'confirm':
					$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
					$("#popup_ok").click( function() {
						$.alerts._hide();
						if( callback ) callback(true);
					});
					$("#popup_cancel").click( function() {
						$.alerts._hide();
						if( callback ) callback(false);
					});
					$("#popup_ok").focus();
					$("#popup_ok, #popup_cancel").keypress( function(e) {
						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
					});
				break;
				case 'prompt':
					$("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
					$("#popup_prompt").width( $("#popup_message").width() );
					$("#popup_ok").click( function() {
						var val = $("#popup_prompt").val();
						$.alerts._hide();
						if( callback ) callback( val );
					});
					$("#popup_cancel").click( function() {
						$.alerts._hide();
						if( callback ) callback( null );
					});
					$("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) {
						if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
						if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
					});
					if( value ) $("#popup_prompt").val(value);
					$("#popup_prompt").focus().select();
				break;
			}
			
			// Make draggable
			if( $.alerts.draggable ) {
				try {
					$("#popup_container").draggable({ handle: $("#popup_title") });
					$("#popup_title").css({ cursor: 'move' });
				} catch(e) { /* requires jQuery UI draggables */ }
			}
		},
		
		_hide: function() {
			$("#popup_container").remove();
			$.alerts._overlay('hide');
			$.alerts._maintainPosition(false);
		},
		
		_overlay: function(status) {
			switch( status ) {
				case 'show':
					$.alerts._overlay('hide');
					$("BODY").append('<div id="popup_overlay"></div>');
					$("#popup_overlay").css({
						position: 'absolute',
						zIndex: 99998,
						top: '0px',
						left: '0px',
						width: '100%',
						height: $(document).height(),
						background: $.alerts.overlayColor,
						opacity: $.alerts.overlayOpacity
					});
				break;
				case 'hide':
					$("#popup_overlay").remove();
				break;
			}
		},
		
		_reposition: function() {
			var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
			var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
			if( top < 0 ) top = 0;
			if( left < 0 ) left = 0;
			
			// IE6 fix
			if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
			
			$("#popup_container").css({
				top: top + 'px',
				left: left + 'px'
			});
			$("#popup_overlay").height( $(document).height() );
		},
		
		_maintainPosition: function(status) {
			if( $.alerts.repositionOnResize ) {
				switch(status) {
					case true:
						$(window).bind('resize', $.alerts._reposition);
					break;
					case false:
						$(window).unbind('resize', $.alerts._reposition);
					break;
				}
			}
		}
		
	}
	
	// Shortuct functions
	jAlert = function(message, title, callback) {
		$.alerts.alert(message, title, callback);
	}
	
	jConfirm = function(message, title, callback) {
		$.alerts.confirm(message, title, callback);
	};
		
	jPrompt = function(message, value, title, callback) {
		$.alerts.prompt(message, value, title, callback);
	};
	
})(jQuery);;
;
var his_switch_set_datetime;
var his_done_datetime;
var hc;
var sp = 0;
var id = 0;
function Init_docodoco()
{
	hc = $("#hcinfo").text();
	
	$("#switch_setting_submit").click(SetSetting);
	if(sp == 1) $("#switch_lock").change(ChgLockSetting);
	else        $("#switch_lock").click( ChgLockSetting);
	$("#message").maxlength({'feedback' : '#charsLeft'});
	$("#button_unlock").click(SetUnLock);
	
	ChkSetting();
	
	$.timer(10000, function (timer) {
		ChkSetting();
	});
}

function ChkSetting()
{
	var url = "http://api.wity.jp/docodoco/chkswitch/";
	url += "?hc="+hc;
	url += "&callback=?";
	
	$.getJSON(url, function(json){
		if(json.err) {
			if(json.msg != "No Result") {
				dAlert("情報の取得に失敗しました。" + json.msg, "エラー");
			} else {
				var info = new Object();
				info.switch_set_datetime = "";
				_setDataSettingInfo(info);
				getResult();
			}
		} else {
			$("#result").hide();
			$("#map_canvas").hide();
			$("#right_help").show();
			
			_chgSwitch(json.result);
			_setDataSettingInfo(json.result);
		}
	});
}

function getResult()
{
	var url = "http://api.wity.jp/docodoco/getresult/";
	url += "?hc="+hc;
	url += "&callback=?";
	
	$.getJSON(url, function(json){
		
		if(json.err) {
			if(json.msg != "No Result") {
				dAlert("情報の取得に失敗しました。" + json.msg, "エラー");
			} else {
				//dAlert("情報の取得に失敗しました。" + json.msg, "エラー");
			}
			$("#result").hide();
			$("#map_canvas").hide();
			$("#right_help").show();
		} else {
			if(his_done_datetime != json.result.done_datetime) {
				id = json.result.id;
				his_done_datetime = json.result.done_datetime;
				_resetSwitch()
				_setDataResultInfo(json.result);
				_gmap(json.result.loc_lon, json.result.loc_lat,json.result.loc_datetime);
			}
		}
	});
}

function SetSetting()
{
	var sr  = 0;
	var sl  = 0;
	var sk  = 0;
	//var sm  = 0;
	var msg = "";
	
	if(sp == 1)
	{
		if($("#switch_ringtone").val() == "on") sr = 1;
		if($("#switch_location").val() == "on") sl = 1;
		if($("#switch_lock").val() == "on") sk = 1;
	} else {
		if($("#switch_ringtone").is(':checked')) sr = 1;
		if($("#switch_location").is(':checked')) sl = 1;
		if($("#switch_lock").is(':checked')) sk = 1;
	}
	msg = $("#message").val();
	
	if(sk == 1 && msg == "") {
		dAlert("メッセージ内容を入力してください。");
		return;
	}
	
	/*
	if(sr == 0 && sl == 0) {
		dAlert("全ての設定がOFFになっています。設定をONにした後に再度設定ボタンを押してください。", "メッセージ");
	} else {
		_sendSetting(sr, sl);
	}
	*/
	
	_sendSetting(sr, sl, sk, msg);
}

function ChgLockSetting(){
	var sm = 0;
	var sm_before = 0;
	
	if(sp == 1)
	{
		if($("#switch_lock").val() == "on") sm = 1;
	} else {
		if($("#switch_lock").is(':checked')) sm_before = 1;
		if(sm_before == 0) sm = 1;
	}
	
	_chgEnableMessage(sm);
}

function dAlert(msg , title) {
	if(sp == 1)
	{
		alert(msg);
	} else {
		jAlert(msg, title);
	}
}

function SetUnLock()
{
	//alert(id);
	if(id != 0) {
		var url = "http://api.wity.jp/docodoco/setunlock/";
		url += "?hc="+hc;
		url += "&id="+id;
		url += "&callback=?";
		
		$.getJSON(url, function(json){
			if(json.err) {
				dAlert("ロック解除の設定に失敗しました。　" + json.msg, "エラー");
			} else {
				dAlert("ロック解除の設定を行いました。", "メッセージ");
				$("#unlock").hide();
				ChkSetting();
			}
		});
	}
}

function _sendSetting (sr , sl, sk, msg)
{
	var url = "http://api.wity.jp/docodoco/setswitch/";
	url += "?hc="+hc;
	url += "&sr="+sr;
	url += "&sl="+sl;
	url += "&sk="+sk;
	//url += "&sm=0";
	url += "&msg="+encodeURIComponent(msg);
	url += "&callback=?";
	
	//alert(url);
	$.getJSON(url, function(json){
		$("#wait").hide();
		$("#result").hide();
		$("#map_canvas").hide();
		$("#right_help").show();
		
		if(json.err) {
			if(sr != 0 || sl != 0 || sk != 0) dAlert("情報の取得に失敗しました。", "エラー");
		}else {
			if(sr == 0 && sl == 0 && sk == 0) dAlert("設定を削除しました", "メッセージ");
			else dAlert("設定しました", "メッセージ");
			ChkSetting();
		}
	});
}

function _gmap(lon ,lat,datetime)
{
    var myLatlng = new google.maps.LatLng(lat, lon);
    var myOptions = {
      zoom: 15,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	var marker = new google.maps.Marker({
		position: myLatlng,
		title:datetime
	});
    marker.setMap(map);
}

function _chgSwitch(info) {
	
	if(sp == 1){
		_chgSwitchSp(info)
	} else {
		_chgSwitchPc(info)
	}
}

function _chgSwitchPc(info)
{
	if(info.switch_ringtone == "1") {
		$("#switch_ringtone").attr("checked", "checked");
	} else {
		$("#switch_ringtone").removeAttr('checked');
	}
	
	if(info.switch_location == "1") {
		$("#switch_location").attr("checked", "checked");
	} else {
		$("#switch_location").removeAttr('checked');
	}
	
	if(info.switch_lock == "1") {
		$("#switch_lock").attr("checked", "checked");
		_chgEnableMessage(1);
	} else {
		$("#switch_lock").removeAttr('checked');
		_chgEnableMessage(0);
	}
	
	if(info.message != null) $("#message").val(info.message);
}

function _chgSwitchSp(info)
{
	if(info.switch_ringtone == "1") {
		$("#switch_ringtone").val("on");
	} else {
		$("#switch_ringtone").val("off");
	}
	
	if(info.switch_location == "1") {
		$("#switch_location").val("on");
	} else {
		$("#switch_location").val("off");
	}
	
	if(info.switch_lock == "1") {
		$("#switch_lock").val("on");
		_chgEnableMessage(1);
	} else {
		$("#switch_lock").val("off");
		_chgEnableMessage(0);
	}
	
	if(info.message != null) $("#message").val(info.message);
	
	_refreshSlider();
}

function _resetSwitch() {
	if(sp == 1){
		
		//$("#switch_ringtone").removeAttr('selected');
		//$("#switch_location").removeAttr('selected');
		$("#switch_ringtone").val("off");
		$("#switch_location").val("off");
		//$("#switch_lock").val("off");
		_refreshSlider();
	} else {
		$("#switch_ringtone").removeAttr('checked');
		$("#switch_location").removeAttr('checked');
		$("#switch_lock").removeAttr('checked');
	}
	//$("#message").val("");
	_chgEnableMessage(0);
	
}

function _setDataSettingInfo(info)
{
	if(info.switch_set_datetime != "") {
		$("#switch_datetime_view").text(info.switch_set_datetime);
		$("#wait").show();
	} else {
		//_resetSwitch()
		$("#switch_datetime_view").text("");
		$("#wait").hide();
	}
}

function _setDataResultInfo(info)
{
	
	_resetDataResultInfo();
	
	if(info.switch_set_datetime != "") $("#switch_datetime").text(info.switch_set_datetime);
	if(info.done_datetime != "") $("#done_datetime").text(info.done_datetime);

	if(info.err == 1) {
		var jp_err_msg = _setJPMsg(info.err_msg);
		
		var msg = "アンドロイド端末側でエラーが発生しました。（"+jp_err_msg+"）<br />少し時間をおいてから再度お試しください。";
		$("#error").html(msg);
		
		$("#data").hide();
		$("#error").show();
	} else {
		//if(info.play_ringtone != 0) $("#play_ringtone").text((info.play_ringtone / 1000) + " 秒");
		if(info.play_ringtone >= 1) $("#play_ringtone").text("再生 ("+(info.play_ringtone / 1000)+"秒)");
		//alert(info.lock_screen);
		if(info.switch_lock == "1") {
			if(info.switch_unlock == "1" && info.unlock_screen == "1") {
				$("#lock_screen").text("ロック ⇒ 解除");
			} else if(info.switch_unlock == "1" && info.unlock_screen == "0") {
				$("#lock_screen").text("ロック中 ⇒ 解除待ち");
			} else {
				$("#lock_screen").text("ロック中");
				$("#unlock").show();
			}
		}
		
		if(info.switch_lock == "1" && info.message != "") $("#show_message_text").text(info.message);
		
		if(info.switch_location == "1") {
			if(info.loc_lon != "") $("#loc_lon").text(info.loc_lon);
			if(info.loc_lat != "")$("#loc_lat").text(info.loc_lat);
			if(info.loc_datetime != "")$("#loc_datetime").text(info.loc_datetime);
			if(info.loc_provider != "")$("#loc_provider").text(info.loc_provider);
			
			if(sp == 1) {
				var loc = info.loc_lat+","+info.loc_lon;
				$("#map_link").attr("href","http://maps.google.co.jp/maps?hl=ja&geocode=&q="+loc+"&ie=UTF8&ll="+loc+"&z=14");
			}
			
			$("#result #data .location").show();
			$("#result #data .nolocation").hide();
			$("#map_canvas").show();
			$("#right_help").hide();
		} else {
			$("#result #data .location").hide();
			$("#result #data .nolocation").show();
			$("#map_canvas").hide();
			$("#right_help").show();
		}
		$("#data").show();
	}
	
	$("#result").show();
}

function _setJPMsg(msg) {
	var jp_err_msg = "";
	switch(msg){
		case "No Location Data":
			jp_err_msg = "端末にて位置情報の取得が出来ませんでした。[No Location Data]";
			break;
		default:
			jp_err_msg = msg;
	}
	
	return jp_err_msg;
}

function _resetDataResultInfo() {
	$("#switch_datetime").text("");
	$("#done_datetime").text("");
	$("#play_ringtone").text("なし");
	$("#lock_screen").text("なし");
	$("#unlock").hide();
	$("#show_message").text("なし");
	$("#loc_lon").text("");
	$("#loc_lat").text("");
	$("#loc_datetime").text("");
	$("#loc_provider").text("");
	
	$("#error").text("");
	$("#error").hide();
}

function _refreshSlider() {
	$("#switch_location").slider("refresh");
	$("#switch_ringtone").slider("refresh");
	//if($("#switch_lock") != null ) $("#switch_lock").slider("refresh");
}

function _chgEnableMessage(sm)
{
	var label_color = "#999";
	var textare_background_color = "#eee";
	var textare_disabled = "disabled";
	var textare_rows = "1";
	
	if(sm == 1) {
		label_color = "#6F4F2B";
		textare_background_color = "#fff";
		textare_disabled = false;
		textare_rows = "5";
	}
	$("#label_message").css('color', label_color);
	$("#message").css('background-color', textare_background_color );
	$("#message").attr('disabled',textare_disabled);
	$("#message").attr('rows',textare_rows);
}
;


