/* SVN FILE: $Id: googlemap.js 2951 2007-10-15 22:12:33Z eagashira $ */
/**
 * 共通関数ライブラリ
 *
 * @filesource
 * @copyright		Copyright (c) 2007, Catchup
 * @link				http://baser.e-catchup.jp
 * @package			cake
 * @subpackage		cake.cake
 * @since			Baser v 0.1.0
 * @version			$Revision: 2951 $
 * @modifiedby		$LastChangedBy: egashira $
 * @lastmodified	$Date: 2007-10-15 12:00:00 -0500 (Sta, 25 Oct 2007) $
 * @license
 */
/**
 * var_dump
 *	
 * デバッグ用
 *
 * @return
 */
function var_dump(obj) {
   if(typeof obj == "object") {
      return "Type: "+typeof(obj)+((obj.constructor) ? "\nConstructor: "+obj.constructor : "")+"\nValue: " + obj;
   } else {
      return "Type: "+typeof(obj)+"\nValue: "+obj;
   }
}//end function var_dump
function jquery_dump($obj) {
	var dumphtml = [];
	if(jQuery.browser.msie) {
		for(var i = 0; i < $obj.length; i++) {
			dumphtml.push('[' + i + '] ');
			dumphtml.push($obj[i].outerHTML.replace(/^[\r\n\t]+/, ''));
			dumphtml.push("\n");
		}
	} else {
		for(var i = 0; i < $obj.length; i++) {
			dumphtml.push('[' + i + '] '
				+ '<' + $obj[i].nodeName.toLowerCase());
			for(var j = 0; j < $obj[i].attributes.length; j++) {
				dumphtml.push(' ' + $obj[i].attributes[j].nodeName + '="'
					+ $obj[i].attributes[j].nodeValue + '"');
			}
			dumphtml.push('>' + $obj[i].innerHTML);
			dumphtml.push('<\/' + $obj[i].nodeName.toLowerCase() + '>');
			dumphtml.push("\n");
		}
	}
	alert(dumphtml.join(''));
}

/**
 * ウインドウをポップアップで開く
 *
 * @return void
 */
function openWindow(FileName,WindowName,Wsize,Hsize){

	window.open(FileName,WindowName,"width=" + Wsize + ",height=" + Hsize + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=no");

}
/**
 * 閉じると同時に開き元のウインドウをリロードする
 *
 * @return void
 */
function closeAndReload(){

	opener.location.reload();
	window.close();

}
/**
 * アクセス解析タグを埋め込む
 *
 * @return void
 */
function accTracker(){
	document.write("<img width='0' height='0' src='/acc/acclog.cgi?");
	document.write("referrer="+document.referrer+"&");
	document.write("width="+screen.width+"&");
	document.write("height="+screen.height+"&");
	document.write("color="+screen.colorDepth+"'>");
}
/**
 * 別窓でURLを開く
 *
 * @return void
 */
function openUrl(url){
	window.open(url,"_top");
}

/**
 * ウィンドウを閉じる
 */
function closeWindow()
{
	window.close();
}
/**
 * 印刷ダイアログを表示する
 */
function printPage(){
	if(document.getElementById || document.layers){
		window.print();		//印刷をします
	}
}
/**
 * GoogleMapsを読み込む
 */
function loadMap(mapId,longitude,latitude,title,address,tel) {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById(mapId));
	var marker = null;
	var markers = Array();
	var n_markers = 0;
	var markeropts = new Object();
	
	map.setCenter(new GLatLng(longitude,latitude), 18);
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GOverviewMapControl());
	map.setMapType(G_NORMAL_MAP);
	markeropts.title = title + "　アクセスマップ";
	marker = new GMarker(new GLatLng(longitude,latitude), markeropts);
	markers[n_markers] = marker;
	GEvent.addListener(markers[0], "mouseover", function () {markers[0].openInfoWindowHtml(
		"<font color='#FF6600'><strong>" + title + "</strong></font><br>" + address + "<br>" + tel);});
	n_markers++;
	map.addOverlay(marker);
  }
}
/**
 * お気に入りに追加
 */
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: MB Web Design | http://www.mbwebdesign.co.uk */
function bookmark(address,sitename) {
	if (window.sidebar) {
		window.sidebar.addPanel(sitename, address,"");
	} else if( document.all ) {
		window.external.AddFavorite(address, sitename);
	} else if( window.opera && window.print ) {
		return true;
	}
}
