$(document).ready(function(){
	cizinit();
});

function cizinit() {
	var PATHNAME = location.pathname;

	$("#nmf").click(function () {
		$.cookie('nmf','1',{ path: '/', expires: 365 });
	});

	if ($("#rmenu-faq ul").size() == 0) {
		$("#rmenu-faq").css("display","none");
	}
	var OBJcontent;
	if ($("#content-2").size() == 1) {
		OBJcontent = $("#content-2");
	}
	else if ($("#content-3").size() == 1) {
		OBJcontent = $("#content-3");
	}
	else if ($("#content-affiliate").size() == 1) {
		OBJcontent = $("#content-affiliate");
	}

	var fsz = $.cookie('fsz');
	if (fsz=='20') {
		OBJcontent.css("font-size", "20px");
	}
	else if (fsz=='15') {
		OBJcontent.css("font-size", "15px");
	}
	else if (fsz=='13') {
		OBJcontent.css("font-size", "13px");
	}

	$("#fontlarge").click(function () {
		OBJcontent.css("font-size", "20px");
		$.cookie('fsz','20',{ path: '/', expires: 365 });
	});
	$("#fontmid").click(function () {
		OBJcontent.css("font-size", "15px");
		$.cookie('fsz','15',{ path: '/', expires: 365 });
	});
	$("#fontsmall").click(function () {
		OBJcontent.css("font-size", "13px");
		$.cookie('fsz','13',{ path: '/', expires: 365 });
	});

	$("a[href*='contact/reserve']").click(function () {
		$.cookie('pathname',PATHNAME,{ path: '/', expires: 365 , domain: '.ci-z.com'});
		$.cookie('hostname',location.hostname,{ path: '/', expires: 365 , domain: '.ci-z.com'});
	});

	if ($.browser.safari && $("#top-img").size() == 1) {
		$("#top-img li").css("margin-right",parseInt($("#top-img li").css("margin-right"))-2+"px");
	}
	if ($.browser.msie && $.browser.version == 8 && $("#top-img").size() == 1) {
		$("#top-img li").css("margin-right",parseInt($("#top-img li").css("margin-right"))-2+"px");
	}

	if ($("#sendcomment").size() == 1) {
		sendcommentinit();
	}
	if ($("#sendmobile").size() == 1) {
		sendmobileinit();
	}
	if ($("#sendmailmaga").size() == 1) {
		sendmailmagainit();
	}
	if ($("#sendmailmagastop").size() == 1) {
		sendmailmagastopinit();
	}

	if ($("#reserve_calc").size() == 1) {
		$('#reserve_calc').val('5963');
	}
	if ($("#request_calc").size() == 1) {
		$('#request_calc').val('5963');
	}
	if ($("#recruit_calc").size() == 1) {
		$('#recruit_calc').val('5963');
	}

	if (PATHNAME=='/mobile/index3.html') {
		if ($("#affiliateb").size() == 1) {
			var EMAILH = $.cookie('sendmailmagaEMAILH');
			$('#affiliateb').html('<img src="https://track.affiliate-b.com/commit/B3482c/'+EMAILH+'" width="1" height="1" />');
			$.cookie('sendmailmagaEMAILH',null,{ path: '/', expires: 1 });
		}
	}

	if ((PATHNAME=='/contact/reserve/')||(PATHNAME=='/contact/reserve/index.cgi')||(PATHNAME=='/index_m.html')) {
		var Lpathname = $.cookie('pathname');
		var Lhostname = $.cookie('hostname');


		if (($("select[name='course']").size() == 1)&&($("select[name='course_two']").size() == 1)) {
			if ((Lpathname)&&(Lhostname)) {
				if ((Lhostname=='ci-z.com')||(Lhostname=='www.ci-z.com')||(Lhostname=='test.ci-z.com')) {

$("input[name='courseselect']").val(['1']);

if ((Lpathname=='/campaign/nikibi.html')) {
$("select[name='course']").val('2');
}
else if ((Lpathname=='/campaign/needle.html')) {
$("select[name='course']").val('3');
}
else if ((Lpathname=='/campaign/cellulite.html')) {
$("select[name='course']").val('4');
}
else if ((Lpathname=='/campaign/thermoshape.html')) {
$("select[name='course']").val('5');
}
else if ((Lpathname=='/campaign/bridal.html')) {
$("select[name='course']").val('6');
}
else if ((Lpathname=='/campaign/kanpan.html')) {
$("select[name='course']").val('7');
}
else if ((Lpathname=='/campaign/white377.html')) {
$("select[name='course']").val('8');
}
else if ((Lpathname=='/campaign/bridalfair.html')) {
$("select[name='course']").val('6');
}
else if ((Lpathname=='/campaign/bridal.html')) {
$("select[name='course']").val('6');
}
//else if ((Lpathname=='/course/facial/needle/')||(Lpathname=='/course/facial/needle/index.html')) {
//$("select[name='course']").val('3');
//}
else if (Lpathname.match(/\/course\/facial\/needle\//i)) {
$("select[name='course']").val('3');
}
//else if ((Lpathname=='/course/facial/nikibi/')||(Lpathname=='/course/facial/nikibi/index.html')) {
//$("select[name='course']").val('2');
//}
else if (Lpathname.match(/\/course\/facial\/nikibi\//i)) {
$("select[name='course']").val('2');
}
else if ((Lpathname=='/course/facial/shiwa/')||(Lpathname=='/course/facial/shiwa/index.html')) {
$("select[name='course']").val('9');
}
else if ((Lpathname=='/course/facial/keana/')||(Lpathname=='/course/facial/keana/index.html')) {
$("select[name='course']").val('10');
}
else if ((Lpathname=='/course/facial/kanpan/')||(Lpathname=='/course/facial/kanpan/index.html')) {
$("select[name='course']").val('7');
}
//else if ((Lpathname=='/course/facial/shimi/')||(Lpathname=='/course/facial/shimi/index.html')) {
//$("select[name='course']").val('11');
//}
else if (Lpathname.match(/\/course\/facial\/shimi\//i)) {
$("select[name='course']").val('11');
}
else if ((Lpathname=='/course/facial/kogao/')||(Lpathname=='/course/facial/kogao/index.html')) {
$("select[name='course']").val('12');
}
else if ((Lpathname=='/course/facial/atopy/')||(Lpathname=='/course/facial/atopy/index.html')) {
$("select[name='course']").val('13');
}
else if ((Lpathname=='/course/facial/hadaare/')||(Lpathname=='/course/facial/hadaare/index.html')) {
$("select[name='course']").val('14');
}
//else if ((Lpathname=='/course/bodyskin/back/')||(Lpathname=='/course/bodyskin/back/index.html')||(Lpathname=='/campaign/back.html')) {
//$("select[name='course']").val('15');
//}
else if ((Lpathname.match(/\/course\/bodyskin\/back\//i))||(Lpathname=='/campaign/back.html')) {
$("select[name='course']").val('15');
}
//else if ((Lpathname=='/course/bodyskin/arm/')||(Lpathname=='/course/bodyskin/arm/index.html')||(Lpathname=='/campaign/arm.html')) {
//$("select[name='course']").val('16');
//}
else if ((Lpathname.match(/\/course\/bodyskin\/arm\//i))||(Lpathname=='/campaign/arm.html')) {
$("select[name='course']").val('16');
}
else if ((Lpathname=='/course/bodyskin/hip/')||(Lpathname=='/course/bodyskin/hip/index.html')) {
$("select[name='course']").val('17');
}
else if ((Lpathname=='/course/bodyskin/waki/')||(Lpathname=='/course/bodyskin/waki/index.html')) {
$("select[name='course']").val('18');
}
//else if ((Lpathname=='/course/diet/cellulite/')||(Lpathname=='/course/diet/cellulite/index.html')) {
//$("select[name='course']").val('4');
//}
else if (Lpathname.match(/\/course\/diet\/cellulite\//i)) {
$("select[name='course']").val('4');
}
//else if ((Lpathname=='/course/diet/thermoshape/')||(Lpathname=='/course/diet/thermoshape/index.html')) {
//$("select[name='course']").val('5');
//}
else if (Lpathname.match(/\/course\/diet\/thermoshape\//i)) {
$("select[name='course']").val('5');
}
else if ((Lpathname=='/course/diet/waist-diet/')||(Lpathname=='/course/diet/waist-diet/index.html')) {
$("select[name='course']").val('19');
}
else if ((Lpathname=='/course/diet/arm-diet/')||(Lpathname=='/course/diet/arm-diet/index.html')) {
$("select[name='course']").val('20');
}
else if ((Lpathname=='/course/diet/kotsuban-diet/')||(Lpathname=='/course/diet/kotsuban-diet/index.html')) {
$("select[name='course']").val('21');
}
else if ((Lpathname=='/course/diet/bustup/')||(Lpathname=='/course/diet/bustup/index.html')) {
$("select[name='course']").val('22');
}
else if ((Lpathname=='/course/bridal/bridalplan/')||(Lpathname=='/course/bridal/bridalplan/index.html')) {
$("select[name='course']").val('6');
}
else if ((Lpathname=='/course/bridal/3kgdown/')||(Lpathname=='/course/bridal/3kgdown/index.html')) {
$("select[name='course']").val('6');
}
else if ((Lpathname=='/course/bridal/')||(Lpathname=='/course/bridal/index.html')) {
$("select[name='course']").val('6');
}
else if ((Lpathname=='/campaign/relieve.html')) {
$("select[name='course']").val('24');
}
else if ((Lpathname=='/course/facial/backkyo/')||(Lpathname=='/course/facial/backkyo/index.html')) {
$("select[name='course']").val('23');
}
else if ((Lpathname.match(/\/course\/diet\/soshin\//i))||(Lpathname=='/campaign/soshin.html')) {
	$("select[name='course']").val('25');
}
else if (Lpathname=='/campaign/nikibiato.html') {
	$("select[name='course']").val('26');
}
else if ((Lpathname=='/course/diet/hipup/')||(Lpathname=='/course/diet/hipup/index.html')) {
	$("select[name='course']").val('27');
}
else {
$("select[name='course']").val('1');
}




				}
				if ((Lhostname=='mens.ci-z.com')||(Lhostname=='testmens.ci-z.com')) {

$("input[name='courseselect']").val(['3']);

if ((Lpathname=='/campaign/nikibi.html')) {
$("select[name='course_two']").val('2');
}
else if ((Lpathname=='/campaign/thermoshape.html')) {
$("select[name='course_two']").val('3');
}
else if ((Lpathname=='/campaign/metabolic.html')) {
$("select[name='course_two']").val('4');
}
else if ((Lpathname=='/campaign/hairtherapy.html')) {
$("select[name='course_two']").val('5');
}
else if ((Lpathname=='/bridal/')||(Lpathname=='/bridal/index.html')) {
$("select[name='course_two']").val('6');
}
else {
$("select[name='course_two']").val('1');
}

				}
			}
		}

		$.cookie('pathname',null,{ path: '/' , domain: '.ci-z.com'});
		$.cookie('hostname',null,{ path: '/' , domain: '.ci-z.com'});

	}

}


function sendmailmagainit () {
	var options_sendmailmaga = { 
		target:'#sendmailmaga_msg',
		beforeSubmit:showRequest_sendmailmaga,
		success:showResponse_sendmailmaga,
		timeout:3000
	}; 
	$('#sendmailmaga').ajaxForm(options_sendmailmaga);
	$('#sendmailmaga_calc').val('5963');
}

function showRequest_sendmailmaga(formData, jqForm, options) {

	if ($("#sendmailmaga_mad").val() == '') {
		$("#sendmailmaga_msg").html('メールアドレスをご記入ください。');
		return false;
	}

	if($("#sendmailmaga_mad").val().match(/^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i)){
	}
	else {
		$("#sendmailmaga_msg").html('正しいメールアドレスをご記入ください。');
		return false;
	}

	if(confirm('送信します。\nよろしいですか？')) {
		$("#sendmailmaga_send").attr("disabled", "1");
	}
	else {
		return false;
	}
}

function showResponse_sendmailmaga(responseText, statusText)  {
	var EMAILH = responseText;
	EMAILH = EMAILH.replace(/\r\n/g, "");
	EMAILH = EMAILH.replace(/\n/g, "");
	$.cookie('sendmailmagaEMAILH',EMAILH,{ path: '/', expires: 1 });
	$("#sendmailmaga_send").attr("disabled", "1");
	location.href='/mobile/index3.html';
} 


function sendmailmagastopinit () {
	var options_sendmailmagastop = { 
		target:'#sendmailmagastop_msg',
		beforeSubmit:showRequest_sendmailmagastop,
		success:showResponse_sendmailmagastop,
		timeout:3000
	}; 
	$('#sendmailmagastop').ajaxForm(options_sendmailmagastop);
	$('#sendmailmagastop_calc').val('5963');
}

function showRequest_sendmailmagastop(formData, jqForm, options) {

	if ($("#sendmailmagastop_mad").val() == '') {
		$("#sendmailmagastop_msg").html('メールアドレスをご記入ください。');
		return false;
	}

	if($("#sendmailmagastop_mad").val().match(/^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i)){
	}
	else {
		$("#sendmailmagastop_msg").html('正しいメールアドレスをご記入ください。');
		return false;
	}

	if(confirm('送信します。\nよろしいですか？')) {
		$("#sendmailmagastop_send").attr("disabled", "1");
	}
	else {
		return false;
	}
}

function showResponse_sendmailmagastop(responseText, statusText)  {
	$("#sendmailmagastop_send").attr("disabled", "1");
	location.href='/mobile/index4.html';
} 


function sendmobileinit () {
	var options_sendmobile = { 
		target:'#sendmobile_msg',
		beforeSubmit:showRequest_sendmobile,
		success:showResponse_sendmobile,
		timeout:3000
	}; 
	$('#sendmobile').ajaxForm(options_sendmobile);
	$('#sendmobile_calc').val('5963');
	$('#content-2').css('margin','10px');
	$('#container').css('width','704px');
}


function showRequest_sendmobile(formData, jqForm, options) {
	var mailaddress = $("#sendmobile_mad").val() + '@' + $("#sendmobile_dom").val();

	if ($("#sendmobile_mad").val() == '') {
		$("#sendmobile_msg").html('メールアドレスをご記入ください。');
		return false;
	}

	if(mailaddress.match(/^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i)){
	}
	else {
		$("#sendmobile_msg").html('正しいメールアドレスをご記入ください。');
		return false;
	}

	if(confirm('送信します。\nよろしいですか？')) {
		$("#sendmobile_send").attr("disabled", "1");
	}
	else {
		return false;
	}
}

function showResponse_sendmobile(responseText, statusText)  {
	$("#sendmobile_send").attr("disabled", "1");
	location.href='/ato/index2.html';
} 






function sendcommentinit () {
	var options_sendcomment = { 
		target:'#sendcomment_msg',
		beforeSubmit:showRequest_sendcomment,
		success:showResponse_sendcomment,
		timeout:3000
	}; 
	$('#sendcomment').ajaxForm(options_sendcomment);
	$('#calc').val('5963');
	$('#sendcomment_url').val(document.location);

//	$('#sendcomment_comment').css("color","#999999");
//	$('#sendcomment_comment').html($('#sendcomment_defaut').html());
//	$('#sendcomment_comment').focus( function () { $(this).html(''); $(this).css("color","#000000"); } );

	$("#sendcomment_mad").change(function () {
		$("#sendcomment_mad").val(zentohan($("#sendcomment_mad").val()));
	}).change();

}

function showRequest_sendcomment(formData, jqForm, options) {

	var radio = $("input[name=sendcomment_rireki]:checked").val();
	if ((radio == '1')||(radio == '2')) {
	}
	else {
		$("#sendcomment_msg").html('当サロンご利用履歴を選択してください。');
		return false;
	}

	var check1 = $("input[name=sendcomment_naiyo1]:checked").val();
	var check2 = $("input[name=sendcomment_naiyo2]:checked").val();
	var check3 = $("input[name=sendcomment_naiyo3]:checked").val();
	if ((check1)||(check2)||(check3)) {
	}
	else {
		$("#sendcomment_msg").html('お悩み内容を選択してください。');
		return false;
	}

	if ($("#sendcomment_mad").val() == '') {
		$("#sendcomment_msg").html('メールアドレスをご記入ください。');
		return false;
	}

	if ($("#sendcomment_mad").val().match(/^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i)){
	}
	else {
		$("#sendcomment_msg").html('正しいメールアドレスをご記入ください。');
		return false;
	}



	if ($("#sendcomment_comment").val() == '') {
		$("#sendcomment_msg").html('ご相談内容をご記入ください。');
		return false;
	}
	if(confirm('投稿します。\nよろしいですか？')) {
		$("#sendcomment_send").attr("disabled", "1");
	}
	else {
		return false;
	}

}

function showResponse_sendcomment(responseText, statusText)  {
	$("#sendcomment_send").attr("disabled", "1");
} 

var win = null;
function NewWindow(mypage,myname,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings)
if(win.window.focus){win.window.focus();}
}


function zentohan(bs) {
var ns="";
	for(i=0;i<bs.length;i++) {
		if(bs.charCodeAt(i)>=0xff01&&bs.charCodeAt(i)<=0xff5e)
		ns+=String.fromCharCode(0x0021+(bs.charCodeAt(i)-0xff01));
		else
		ns+=bs.charAt(i);
	}
return ns;
}



