

/********************************************
Google Map APIのカスタマイズ
********************************************/
function gMapsSetting() {
	var pinkParksStyles = [
    	{featureType: "all", stylers: [{ saturation: -99 }]},
    	{featureType: "poi.park", stylers: [{ saturation: -99 }]},
		{featureType: "road", stylers: [{ hue: "#22ff00" },{ saturation: -33 }]}
  	];
	
	var pinkMapType = new google.maps.StyledMapType(pinkParksStyles);
	
	var mapOptions = {
    	zoom: 15,
    	center: new google.maps.LatLng(35.633350, 139.710406),
    	mapTypeControlOptions: {
			mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'pink_parks']
    	},
		mapTypeControl : false
	};
	
	var map = new google.maps.Map(document.getElementById('gMap'), mapOptions);
	
	map.mapTypes.set('pink_parks', pinkMapType);
	map.setMapTypeId('pink_parks');
    var myLatlng = new google.maps.LatLng(35.633350, 139.710406);
    var myOptions = {
		zoom: 15,
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
    }
	
    var myLatLng = new google.maps.LatLng(35.633350, 139.710406);
    var beachMarker = new google.maps.Marker({
        position: myLatLng,
        map: map,
        icon: "images/pin.png"
    });
}

/********************************************
ブラウザ判別
********************************************/
function BrowserCheck() {

	var userAgent = window.navigator.userAgent.toLowerCase();
	var appVersion = window.navigator.appVersion.toLowerCase();

	if (userAgent.indexOf("msie") > -1) {
		if (appVersion.indexOf("msie 6.0") > -1) {
			return 'IE6';
		}
		else if (appVersion.indexOf("msie 7.0") > -1) {
			return 'IE7';
		}
		else if (appVersion.indexOf("msie 8.0") > -1) {
			return 'IE8';
		}
		else {
			return 'IE9';
		}
	} else {
		return 'notIE';
	}
}

/********************************************
メールフォーム
********************************************/
function mailform() {
	
	$("#form").clearForm();
	
	$("#result").hide();
	$(".confirmBtn").show();
	$(".submitBtn").hide();

	$(".resetBtn").click(function() {
		$("#form").resetForm();
		$(".confirmBtn").show();
		$(".submitBtn").hide();
		$("#result").hide();
		

		$('input[type="text"], textarea').removeAttr("readOnly");
			
	});
	
	var param = {
	　　submitHandler: function(form) {
			
			$str = "<p>以下の内容を送信します。</p>";
			$str += "<table>";
			
			$str += "<tr><th>氏名 : </th>";
			$str += "<td>" + $("#name").val() + "</td></tr>";

			$str += "<tr><th>会社名 : </th>";
			$str += "<td>" + $("#comname").val() + "</td></tr>";
			
			$str += "<tr><th>E-Mail : </th>";
			$str += "<td>" + $("#email").val() + "</td></tr>";
			
			$str += "<tr><th>TEL : </th>";
			$str += "<td>" + $("#phone").val() + "</td></tr>";
			
			$str += "<tr><th>お問い合わせ内容 : </th>";
			$str += "<td>" + $("#msg").val() + "</td></tr>";
			
			$str += "</table>";
			
			$str += "<div class='submitInfo'><span>よろしければ「送信する」ボタンをクリックしてください。訂正する場合は「リセット」ボタンをクリックしてください。</span></div>";
			
			$("#result").html($str);
			$("#result").addClass("resault");
			$("#result").show();
	
			$(".confirmBtn").hide();
			$(".submitBtn").show();
			
			/*
			$(":text").attr("disabled","disabled");
			$("textarea").attr("disabled","disabled");
			*/
			$('input[type="text"], textarea').attr("readOnly","true");
			
	　　　　var option = {
	　　　　　　url: "mail.php",
	　　　　　　type: "POST",
				beforeSubmit: showRequest,
	　　　　　　success: function() {
					$(".submitBtn").hide();
					$(".resetBtn").hide();
					$("#result").html("<div class='thanksInfo'><span>お問い合わせを受け付けました。後日担当者よりご連絡いたします。</span></div>");
					$(form).clearForm();
	　　　　　　}
	　　　　};
			
			$(".submitBtn").click(function() {
				$("#form").ajaxSubmit(option);
			});
	　　}
	};
	
	$("#form").validate(param);
	
}


/********************************************
フォームデバッグ用
********************************************/
function showRequest(formData, jqForm, options) {
	var queryString = $.param(formData);
	alert('About to submit: \n\n' + queryString);
	return true; 
}



/********************************************
初期化
********************************************/
$(document).ready(function() {

	if (BrowserCheck() == 'IE6') {
		DD_belatedPNG.fix('.png_bg');
	}
	
	mailform();
	$.superbox();

	/*
	$("#topnav li").prepend("<span></span>");

	$("#topnav li").each(function() {
		var linkText = $(this).find("a").html();
		$(this).find("span").show().html(linkText);
	}); 
	
	$("#topnav li").hover(function() {
		$(this).find("span").stop().animate({marginTop: "-40"}, 250);
	} , function() {
		$(this).find("span").stop().animate({marginTop: "0"}, 250);
	});
	*/
	
	
	if (BrowserCheck() != 'IE6') {
		$('.worksThumb').css({'position':'relative'});
		$('.worksThumb').prepend('<img src="images/magnify_icon.png" class="overlay"/>');
		$('.worksThumb .overlay').css({'position':'absolute','top':'0','left':'0', 'opacity':'0'});
	
		$('.worksThumb').hover(function() {
			if (BrowserCheck() == 'IE9' || BrowserCheck() == 'notIE') {
				$('.overlay', this).stop(true, false).fadeTo("fast", 1);
			} else {
				$('.overlay', this).css('opacity', '1');
			}
			return false;
		},function() {
			if (BrowserCheck() == 'IE9' || BrowserCheck() == 'notIE') {
				$('.overlay', this).stop(true, false).fadeTo("fast", 0);
			} else {
				$('.overlay', this).css('opacity', '0');
			}
			return false;
		});
	}
	
	$('.resetBtn').hover(function() {
        $(this).attr('src', $(this).attr('src').replace('.png', '_ov.png'));
		$(this).css('opacity', 0);
		$(this).stop();
		$(this).animate({opacity: 1.0}, 'fast');
    }, function() {
        $(this).attr('src', $(this).attr('src').replace('_ov.png', '.png'));
		$(this).css('opacity', 0);
		$(this).stop();
		$(this).animate({opacity: 1.0}, 'slow');
    });
	
	
	$('.confirmBtn').hover(function() {
        $(this).attr('src', $(this).attr('src').replace('.png', '_ov.png'));
		$(this).css('opacity', 0);
		$(this).stop();
		$(this).animate({opacity: 1.0}, 'fast');
    }, function() {
        $(this).attr('src', $(this).attr('src').replace('_ov.png', '.png'));
		$(this).css('opacity', 0);
		$(this).stop();
		$(this).animate({opacity: 1.0}, 'slow');
    });
	
	$('.submitBtn').hover(function() {
        $(this).attr('src', $(this).attr('src').replace('.png', '_ov.png'));
		$(this).css('opacity', 0);
		$(this).stop();
		$(this).animate({opacity: 1.0}, 'fast');
    }, function() {
        $(this).attr('src', $(this).attr('src').replace('_ov.png', '.png'));
		$(this).css('opacity', 0);
		$(this).stop();
		$(this).animate({opacity: 1.0}, 'slow');
    });
	
	/*
	$('a', '#footer').hover(function() {
		$(this).css('opacity', 0);
		$(this).stop();
		$(this).animate({opacity: 0.99}, 1000);
    }, function() {
		$(this).css('opacity', 1);
    });
*/

	if (BrowserCheck() != 'IE6') {
  		$('#topnav').onePageNav();
	}

	
	
	if (BrowserCheck() != 'IE6') {
		gMapsSetting();
	} else {
		$('#gMap').prepend('<img src="images/dummyGMap.jpg"/>');
	}
	
	
	/*
	if(navigator.userAgent.indexOf("MSIE") != -1) {
        $('img').each(function() {
            if($(this).attr('src').indexOf('.png') != -1) {
                $(this).css({
                    'filter': 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + $(this).attr('src') + '", sizingMethod="crop", enabled="true");'
                });
            }
        });
    }
	*/
	
	
});

