function createXMLHttpRequest(){
	var xhr = null;

	if(window.XMLHttpRequest) {
		// Firefox、Safari、Internet Explorer 7.0など向け
		xhr = new XMLHttpRequest();
	} else {
		// Internet Explorer 6.0以前向け
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP"); // 6.0用
		} catch(e) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP"); // 5.5以前用
			} catch(e) {
				return null;
			}
		}
	}
	return xhr;
}

function XMLHttpRequestByTwitter(area){
	var request = createXMLHttpRequest();
	request.open("POST","/xx_biz_ajax_twitter.html",true);
	request.onreadystatechange = readyStateChangeHandlerTwitter;
	request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	request.send("area=" + area);

	function readyStateChangeHandlerTwitter(){
		switch(request.readyState){
			case 4:
				if(request.status == 200){
					obj = document.getElementById('twitter_box');
					if(obj!=null){
						$("twitter_box").fadeOut("slow");
						document.getElementById('twitter_box').innerHTML  = request.responseText;
						$("twitter_box").fadeIn("slow");
					}
					obj = document.getElementById('twitter_box_image1');
					if(obj!=null){
						document.getElementById('twitter_box_image1').innerHTML  = "&nbsp;";
						document.getElementById('twitter_box_image2').innerHTML  = "&nbsp;";
					}
				}
				break;
			default:
				obj = document.getElementById('twitter_box_image1');
				if(obj!=null){
					document.getElementById('twitter_box_image1').innerHTML  = "<IMG src='/img/loading.gif'>";
					document.getElementById('twitter_box_image2').innerHTML  = "<IMG src='/img/loading.gif'>";
				}
				break;
		}
	}
}

function twitter(area){
	XMLHttpRequestByTwitter(area);
	setTimeout("twitter('"+area+"')",30000);
}




function clock(limit){

	tmp = limit;

	lm_plus	= (23*60*60*1000)+(59*60*1000)+(59*1000);

	lm_int	= Date.parse(limit);

	lm_int	= lm_int + lm_plus;

	today = new Date();

	y = today.getFullYear();
	m = today.getMonth() + 1;
	d = today.getDate();
	h = today.getHours();
	n = today.getMinutes();
	s = today.getSeconds();

	nw_plus = (h*60*60*1000)+(n*60*1000)+(s*1000);

	nw_str = y+"/"+m+"/"+d;

	nw_int = Date.parse(nw_str);

	nw_int = nw_int + nw_plus;

	df_int = lm_int - nw_int;

	if(df_int<0){
		hh="000";
		nn="00";
		ss="00";
	}else{
		hh = Math.floor(df_int/(60*60*1000));
		zan = df_int - (hh*(60*60*1000));
		nn = Math.floor(zan/(60*1000));
		zan = zan - (nn*(60*1000));
		ss = Math.floor(zan/1000);
		if(hh<10){
			hh="00"+hh;
		}else{
			if(hh<100){
				hh="0"+hh;
			}
		}
		if(nn<10) nn="0"+nn;
		if(ss<10) ss="0"+ss;
	}

	document.getElementById("timer_hh").innerHTML=hh;
	document.getElementById("timer_mm").innerHTML=nn;
	document.getElementById("timer_ss").innerHTML=ss;

	setTimeout("clock('"+limit+"')",1000);
}

function FormatNumber(num) {
	if (isNaN(num)) return "";
	var src = (num.toString()).split(".");
	var buf = "";
	var i, j;
	for (i=src[0].length-1, j=0; i>=0; i--) {
		buf = src[0].charAt(i) + buf;
		if (++j == 3 && i > 0 && !isNaN(src[0].charAt(i-1))) {
			buf = "," + buf;
			j = 0;
		}
	}
	if (src[1]) buf += "." + src[1];
	return buf;
}

function computeDate(year, month, day, addDays) {
	var dt = new Date(year, month - 1, day);
	var baseSec = dt.getTime();
	var addSec = addDays * 86400000;//日数 * 1日のミリ秒数
	var targetSec = baseSec + addSec;
	dt.setTime(targetSec);
	return dt;
}


$(function(){

	$("#po_res_date_1").datepicker({
		showOn: 'button',
		dateFormat: 'yy-mm-dd',
		changeMonth: true,
		changeYear: true,
		minDate: $("#po_res_date_1").val(),
		maxDate: $("#end_date").val(),
		showMonthAfterYear: false,
		monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		dayNames: ['日','月','火','水','木','金','土'],
		dayNamesMin: ['日','月','火','水','木','金','土'],
		dayNamesShort: ['日','月','火','水','木','金','土']
	});

	$("#po_res_date_2").datepicker({
		showOn: 'button',
		dateFormat: 'yy-mm-dd',
		changeMonth: true,
		changeYear: true,
		minDate: $("#po_res_date_2").val(),
		maxDate: $("#end_date").val(),
		showMonthAfterYear: false,
		monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		dayNames: ['日','月','火','水','木','金','土'],
		dayNamesMin: ['日','月','火','水','木','金','土'],
		dayNamesShort: ['日','月','火','水','木','金','土']
	});

	$("#po_res_date_3").datepicker({
		showOn: 'button',
		dateFormat: 'yy-mm-dd',
		changeMonth: true,
		changeYear: true,
		minDate: $("#po_res_date_3").val(),
		maxDate: $("#end_date").val(),
		showMonthAfterYear: false,
		monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		dayNames: ['日','月','火','水','木','金','土'],
		dayNamesMin: ['日','月','火','水','木','金','土'],
		dayNamesShort: ['日','月','火','水','木','金','土']
	});

	$("#deal_start_date").datepicker({
		showOn: 'button',
		dateFormat: 'yy-mm-dd',
		changeMonth: true,
		changeYear: true,
		showMonthAfterYear: false,
		monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		dayNames: ['日','月','火','水','木','金','土'],
		dayNamesMin: ['日','月','火','水','木','金','土'],
		dayNamesShort: ['日','月','火','水','木','金','土']
	});

	$("#deal_end_date").datepicker({
		showOn: 'button',
		dateFormat: 'yy-mm-dd',
		changeMonth: true,
		changeYear: true,
		showMonthAfterYear: false,
		monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		dayNames: ['日','月','火','水','木','金','土'],
		dayNamesMin: ['日','月','火','水','木','金','土'],
		dayNamesShort: ['日','月','火','水','木','金','土']
	});

	$("#deal_use_start_date").datepicker({
		showOn: 'button',
		dateFormat: 'yy-mm-dd',
		changeMonth: true,
		changeYear: true,
		showMonthAfterYear: false,
		monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		dayNames: ['日','月','火','水','木','金','土'],
		dayNamesMin: ['日','月','火','水','木','金','土'],
		dayNamesShort: ['日','月','火','水','木','金','土']
	});

	$("#deal_use_end_date").datepicker({
		showOn: 'button',
		dateFormat: 'yy-mm-dd',
		changeMonth: true,
		changeYear: true,
		showMonthAfterYear: false,
		monthNames: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		monthNamesShort: ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'],
		dayNames: ['日','月','火','水','木','金','土'],
		dayNamesMin: ['日','月','火','水','木','金','土'],
		dayNamesShort: ['日','月','火','水','木','金','土']
	});




	$("#po_count").change(function() {
		dp = $("#discount_price").text();
		dp = dp.replace(",","","g");
		dp = dp.replace("円","","g");
		count = $("#po_count").val();
		update = count * dp;
		update = FormatNumber(update)+" 円";
		$("#total_price").text(update);
	});

	$("#user_point").change(function() {
		dp = $("#discount_price").text();
		dp = dp.replace(",","","g");
		dp = dp.replace("円","","g");
		count = $("#user_point").val();
		update = dp - count;
		update = FormatNumber(update)+" 円";
		$("#order_price").text(update);
	});



	ov_2_height = $("#xx_ov_2").height();
	shop_height = $("#xx_shop").height();

	if(ov_2_height>shop_height){
		$("#xx_shop").height(ov_2_height);
	}else{
		$("#xx_ov_2").height(shop_height);
	}

	$('#area_list_bar').dialog({
		giframe: true,
		autoOpen: false,
		modal: true,
		resizable: true,
		width: 400,
		position:'center',
		buttons: { "Close": function() { $(this).dialog("close"); } }
	});

	$("#xx_ov_1_image").cycle({
		fx: 'fade', 
		timeout: 4000, 
		pause: 1 
	}); 

	$("#xx_ov_1_count_bar").progressBar({
		showText	: false,
		barImage	: '/img/progressbg_orange.gif'
	}
	);

	$("#xx_area_change").bind('click', function() {
		$("#area_list_bar").dialog('open');
	});

	/*
	$('#xx_tabs').tabs();
	$('#button-1').button();
	$('#button-2').button();
	$('#button-3').button();
	*/
	

	
	
	/*
	$(".xx_share").dropShadow({opacity: 0.3});
	$(".xx_discuss").dropShadow({opacity: 0.3});
	$(".xx_ov_1").dropShadow({opacity: 0.3});
	$(".xx_ov_2").dropShadow({opacity: 0.3});
	$(".xx_shop").dropShadow({opacity: 0.3});
	$(".xx_ow_comment").dropShadow({opacity: 0.3});
	$(".xx_cp_serch").dropShadow({opacity: 0.3});
	$(".xx_po").dropShadow({opacity: 0.3});
	*/



});









