var isMSIE6 = $.browser.msie && $.browser.version == "6.0";
var isIPad = navigator.userAgent.match(/iPad/i);
var isIPhone = navigator.userAgent.match(/iPhone/i);

$(function() {	
	
	//placeholder
	$('input.placeholder, textarea.placeholder').each(function() {
		if (!$(this).val() || $(this).val() == $(this).attr('title')) {
			$(this).val($(this).attr('title')).addClass('empty');
		}
	}).focus(function() {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('').removeClass('empty');
		}
	}).blur(function() {
		if (!$(this).val().length) {
			$(this).val($(this).attr('title')).addClass('empty');
		}
	}).parents('form').submit(function() {
		$(this).find('input.placeholder').each(function() {
				if ($(this).val() == $(this).attr('title')) {
					$(this).val('');
				}
		});
	});

	$('.imgover').each(function() {
		var osrc = $(this).attr('src');
		var hsrc = osrc.replace(/(\.gif|\.jpg|\.png)/, '_o$1');
		$.data(this, 'osrc', osrc);
		$.data(this, 'hsrc', hsrc);
		$('<img>').attr('src', hsrc);
	}).hover(function() {
		$(this).attr('src', $.data(this, 'hsrc'));
	},function() {
		$(this).attr('src', $.data(this, 'osrc'));
	});
	
	// scroll
	/*
   $('a[href^=#]').click(function() {
      var speed = 400;// ミリ秒
	  var href= $(this).attr("href");
      var target = $(href == "#" || href == "" ? 'html' : href);
      var position = target.offset().top;
      $($.browser.safari ? 'body' : 'html').animate({scrollTop:position}, speed, 'swing');
      return false;
   });
   */

	// scroll
	$('a[href^=#]').click(function() {
		var $t = $(this.hash);
		if (this.hash.length > 1 && $t.length) {
			$.scrollTo($t, 400);
			return false;
		}
	});

/*
	//preload
	new Image().src = 'http://www.ucd.la/01JAN28_ginzaclinic/html/images/h_bg.gif';
	*/
	
	/*
	//pngfix
	if(isMSIE6) {	
		$('img[src$=png], #content > #topicPath > ol, #content h2, .png').fixPng();
	}
	*/
	
	/*
	//map
	$('#mAccess #mAccessMap > #mAccessMapInner').gmap(35.6667339, 139.7597261, {zoom: 18});
	*/
	
	// google analytics external link
	var host = 'www.proseed.co.jp';
	$("a[href^='http']:not([href^='http://" + host + "/']):not([href^='https://" + host + "/'])").live('click', function() {
		_gaq.push(['_trackPageview','/external/' + $(this).attr("href")]);
	});

	// google analytics file link
	$("a[href$='.pdf'], a[href$='.xls'], a[href$='.doc']").live('click', function() {
		_gaq.push(['_trackPageview',$(this).attr("href")]);
	});

});

