/*----------global JS----------*/

//------image preload------i//
function preImages() { 
  var doc=document; 
  if(doc.images){ 
  	if(!doc.mo_p) doc.mo_p=new Array();
    var i,j=doc.mo_p.length,a=preImages.arguments; 
	for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){
		doc.mo_p[j]=new Image; doc.mo_p[j++].src=a[i];
		}
	}
}

//------swap images functions------//
function swpImgRest() {
  var i,x,a=document.mo_sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, doc) {
  var p,i,x;  if(!doc) doc=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    doc=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=doc[n])&&doc.all) x=doc.all[n]; 
  for (i=0;!x&&i<doc.forms.length;i++) x=doc.forms[i][n];
  for(i=0;!x&&doc.layers&&i<doc.layers.length;i++) x=findObj(n,doc.layers[i].document);
  if(!x && doc.getElementById) x=doc.getElementById(n); return x;
}

function swpImage() { 
  var i,j=0,x,a=swpImage.arguments; 
  document.mo_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
  if ((x=findObj(a[i]))!=null){document.mo_sr[j++]=x; 
  if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//------open window functions------//
var newWin;

function MM_openBrWindow(theURL,w,h){
	if (newWin && newWin.closed == false){
		newWin.close();
	}
	var param = "width=" + w + ",height=" + h + ",toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes";
	newWin = window.open(theURL,"mapwin",param);
	newWin.focus();
}

function MM_openBrWindow2(theURL,w,h){
	if (newWin && newWin.closed == false){
		newWin.close();
	}
	var param = "width=" + w + ",height=" + h + ",left=210,top=140,toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no";
	newWin = window.open(theURL,"mapwin",param);
	newWin.focus();
}

function MM_openBrWindow3(theURL,wName,w,h){
	if (newWin && newWin.closed == false){
		newWin.close();
	}
	var param = "width=" + w + ",height=" + h + ",left=0,top=0toolbar=0,location=0,status=yes,menubar=0,scrollbars=yes,resizable=0";
	newWin = window.open(theURL,wName,param);
	newWin.focus();
}

////specific////
//swap images only for header//
function swpHead(id){
	swpImage(id,'','http://www.tgs.co.jp/images/global/head_arrow_ov.gif',1);
}
//swap images only for footer//
function swpFoot(id){
	swpImage(id,'','http://www.tgs.co.jp/images/global/foot_arrow_ov.gif',1);
}
//swap images only for common//
function swpOver(id,fname){
	   swpImage(id,"",fname,1);
}

// function FlashRun() {
// 	var now = new Date(); 
// 
// 	var year = now.getYear(); // ”N 
// 	var month = now.getMonth() + 1; // ŒŽ 
// 	var day = now.getDate(); // “ú
// 
// 	if(month < 10) { month = "0" + month; } 
// 	if(day < 10) { day = "0" + day; } 
// 
// 	var now_date = year + '/' + month + '/' + day;
// 
// 	var set_date = '2008/01/01';
// 
// 	if(now_date >= set_date) {
// 		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
// 		document.write('codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ');
// 		document.write('width=800 height=323>');
// 		document.write('<param name="movie" value="images/top/tgs_sinnen.swf"><param name="quality" value=high>');
// 		document.write('<param name="loop" value="false"><param name="menu" value="false">');
// 		document.write('<embed src="images/top/tgs_sinnen.swf" width=800 height=323 quality="high" loop="false" menu="false" ');
// 		document.write('type="application/x-shockwave-flash" pluginspaage="https://www.macromedia.com/go/getflashplayer"></embed></object>');
// 	} else {
// 		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
// 		document.write('codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ');
// 		document.write('width=800 height=323>');
// 		document.write('<param name="movie" value="images/top/tgs.swf"><param name="quality" value=high>');
// 		document.write('<param name="loop" value="false"><param name="menu" value="false">');
// 		document.write('<embed src="images/top/tgs.swf" width=800 height=323 quality="high" loop="false" menu="false" ');
// 		document.write('type="application/x-shockwave-flash" pluginspaage="https://www.macromedia.com/go/getflashplayer"></embed></object>');
// 	}
// }

function FlashRun() {
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
	document.write('codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" ');
	document.write('width=800 height=323>');
	document.write('<param name="movie" value="images/top/tgs.swf"><param name="quality" value=high>');
	document.write('<param name="loop" value="false"><param name="menu" value="false">');
	document.write('<embed src="images/top/tgs.swf" width=800 height=323 quality="high" loop="false" menu="false" ');
	document.write('type="application/x-shockwave-flash" pluginspaage="https://www.macromedia.com/go/getflashplayer"></embed></object>');
}