$(function(){

$id = $("body").attr("id");
$class = $("body").attr("class");

$('.blank').click(function(){
	var ua = $.browser;

	if(ua.msie){
		window.open($(this).attr('href') , '' , 'width=575 , height=739 , resizable=no , scrollbars=yes');
	}
	else {
		window.open($(this).attr('href') , '' , 'width=577 , height=739 , resizable=no , scrollbars=yes');
	}
	return false;
});

$('.blank2').click(function(){
	var ua = $.browser;

	if(ua.msie){
		window.open($(this).attr('href') , '' , 'width=718 , height=768 , resizable=no , scrollbars=yes');
	}
	else {
		window.open($(this).attr('href') , '' , 'width=715 , height=748 , resizable=no , scrollbars=yes');
	}
	return false;
});

//マップポップアップ
$('a.map').click(function(){
var ua = $.browser;

if(ua.msie){
window.open($(this).attr('href') , '' , 'width=722 , height=810 , resizable=no , scrollbars=yes');
}
else {
window.open($(this).attr('href') , '' , 'width=720 , height=810 , resizable=no , scrollbars=yes');
}
return false;
});

if($class == "report"){
$(".popup a").lightBox({
overlayBgColor: "#fff",
overlayOpacity: 0.5,
imageLoading: "../../img/lightbox-ico-loading.gif",
imageBtnPrev: "../../img/lightbox-btn-prev.gif",
imageBtnNext: "../../img/lightbox-btn-next.gif",
imageBtnClose: "../../img/lightbox-btn-close.gif"
}); 
}

//ベイザーハイデフ BMI測定
$("#adiposus_property #calculator #bmi .button #submit").click(function(){

if($("#adiposus_property #calculator #bmi #height_input").attr("value") !== undefined){

var $height = $("#adiposus_property #calculator #bmi #height_input").attr("value");

if($height.match(/^([0-9]{3}|[0-9]{3}¥.[0-9]+)$/)){}
else {
var $error = 1;
var $height_text = "身長は半角数字のみ入力可能です。";
}

}

if($("#adiposus_property #calculator #bmi #weight_input").attr("value") !== undefined){
var $weight = $("#adiposus_property #calculator #bmi #weight_input").attr("value");

if($weight.match(/^([0-9]{2,3}|[0-9]{2,3}¥.[0-9]+)$/)){}
else {
var $error = 1;
var $weight_text = "体重は半角数字のみ入力可能です。";
}

}

if($error == 1){
$text = "エラー\n"
if($height_text != undefined){
$text += "\n"+$height_text;
}
if($weight_text != undefined){
$text += "\n"+$weight_text;
}
alert($text);
}

function bmi($weight , $height){
$height = $height / 100;

$bmi = $weight / ($height * $height);

return $bmi;

}

if($weight != undefined && $height != undefined && $error != 1){

$result = bmi($weight , $height);
$result = Math.round($result);

$("#adiposus_property #calculator #message").remove();

$("#adiposus_property #calculator #bmi").after('<div id="message"></div>');

$("#adiposus_property #calculator #message").append('<p>あなたのBMIは<span>'+$result+'</span>です</p>');

if($result >= 28){
$("#adiposus_property #calculator #message").append('<p>今までダイエットやワークアウトが続かなかったという人も、ベイザーで徹底的に脂肪を落とすことで、生活習慣を改善するきっかけにしてください。</p>');
} else if($result < 28 && $result >= 23){
$("#adiposus_property #calculator #message").append('<p>あなたのカラダにはベイザーハイデフを施すことで、目に見えた結果がでます。今、決意すれば、10年後の人生は大きく変わっていることでしょう。</p>');
} else if($result <= 22 && $result >= 20){
$("#adiposus_property #calculator #message").append('<p>あなたのカラダは、ベイザーハイデフを行う価値が最も高いグループです。ベイザーハイデフで最高のBODY Value (ボディバリュー)を生み出しましょう。</p>');
} else if($result <= 19 && $result >= 18){
$("#adiposus_property #calculator #message").append('<p>あなたのカラダに単純な脂肪吸引は向いていません。<br />ベイザーハイデフなら、理想のボディラインを作るとともに、あなたの脂肪をバストなど最適な位置へ再配置することも可能です。</p>');
} else if($result <= 17){
$("#adiposus_property #calculator #message").append('<p>この状態が続くと危険です。あなたは健康的な社会生活を行うために体重を増やす必要があります。</p>');
}

}

});

$("#adiposus_property #calculator #bmi .button #reset").click(function(){
$("#adiposus_property #calculator #bmi #height_input").attr("value" ,"");
$("#adiposus_property #calculator #bmi #weight_input").attr("value" ,"");
$("#adiposus_property #calculator #message").remove();
});

if($class.indexOf('clinic') != -1){
var params = {};
params.wmode = "transparent";
var attributes = {};

if($id == 'clinic'){
var flashvars = {clinic:'tokyo'};
swfobject.embedSWF("../swf/scroll.swf", "swfdisp_tokyo", "234", "234", "9.0.0", false, flashvars, params, attributes);
var flashvars = {clinic:'fukuoka'};
swfobject.embedSWF("../swf/scroll.swf", "swfdisp_fukuoka", "234", "234", "9.0.0", false, flashvars, params, attributes);

} else if($id == 'tokyo'){
var flashvars = {clinic:'tokyo'};
swfobject.embedSWF("../swf/clinic.swf", "swfdisp", "500", "350", "9.0.0", false, flashvars, params, attributes);
} else if($id == 'fukuoka'){
var flashvars = {clinic:'fukuoka'};
swfobject.embedSWF("../swf/clinic.swf", "swfdisp", "500", "350", "9.0.0", false, flashvars, params, attributes);
}
}

});

