/**
 * js/google.js
 * @author J-SURF Co.,Inc. - S.Yoshidome
 * @since version 1.0.0
 */


/**
 * camelize Method
 * ハイフン+小文字アルファベットを大文字アルファベットに直す
 * @return	大文字アルファベット	
 */
String.prototype.camelize = function() {

  return this.replace(/-([a-z])/g, function($0, $1) { return $1.toUpperCase() });

}


/**
 * deCamelize Method
 * 大文字アルファベットをハイフン+小文字アルファベットに直す
 * @return	ハイフン+小文字アルファベット	
 */
String.prototype.deCamelize = function() {

  return this.replace(/[A-Z]/g, function($0) { return "-" + $0.toLowerCase() });

}


/**
 * addRules Method
 * ルールを追加
 * @param	selector
 * @param	property
 * @param	sheetindex
 * @param	ruleindex
 * @return				挿入したルールの位置を表すインデックス（Number）	
 */
function addRules(selector, property, sheetindex, ruleindex) {

	if (sheetindex == undefined) {
		sheetindex = 0;
	}
	var sheet = document.styleSheets[sheetindex];

	if (sheet.addRule) {
		//IE
		if (ruleindex == undefined) {
			ruleindex = sheet.rules.length;
		}
		sheet.addRule(selector, "{" + property + "}", ruleindex);
		return ruleindex;
	} else if (sheet.insertRule) {
		//Mozilla
		if (ruleindex == undefined) {
			ruleindex = sheet.cssRules.length;
		}
		return sheet.insertRule(selector + "{" + property + "}", ruleindex);
	}

	return null;

}


/**
 * moveGoogleMaps Method
 * GoogleMapsを最大化で表示
 */	
function moveGoogleMaps() {

	window.moveTo(0, 0);
	window.resizeTo(window.screen.availWidth, window.screen.availHeight);

}

/**
 * setGoogleMaps Method
 * 
 * @return			divタグ（map）
 */
function reSizeGoogleMaps() {

	var width;		// ブラウザの表示幅
	var height;		// ブラウザの表示高さ
	
	if (document.all) {
		// IE
		width	= document.documentElement.clientWidth;
		height	= document.documentElement.clientHeight;
	} else if (document.layers || document.getElementById) {
		// NN
		width	= innerWidth;
		height	= innerHeight;
	}
	
	addRules("#map", "width:" + width + "px");
	addRules("#map", "height:" + height + "px");

}

function googleAnalyticsA() {
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

}

function googleAnalyticsB() {
	try {
		var pageTracker = _gat._getTracker("UA-7376460-1");
		pageTracker._trackPageview();
	} catch(err) {
	}
}

