function createRandomCatchCopy(){

	var url = document.URL;
	var strings = url.split("/");
	var parentDir = "";
	
	for (var i = 0; i < strings.length; i++){
		if (strings[i].match(/hp/)){
			if (strings[i + 1]){
				if (strings[i + 2]){
					parentDir = "../";
				}
			}
		}
	}

   var imglist = new Array(
      "catch01.jpg",
      "catch02.jpg",
      "catch03.jpg",
      "catch04.jpg",
      "catch05.jpg"
   );
   var selectnum = Math.floor((Math.random() * 100)) % imglist.length;
   var output = "<img src=\"" + parentDir + "img/cmn/" + imglist[selectnum] + "\"  width=\"460\" height=\"32\" />";
   if (document.getElementById("catchCopy")){
   	document.getElementById("catchCopy").innerHTML = output;
   }
}


function createRandomBanner(){
	var imglist = new Array(
		new Array("0001_fineshot.png",   "http://game.fine-net.com/smartphone/fineshot/"),
		new Array("0002_kisekidrop.png", "http://game.fine-net.com/smartphone/kisekidrop/"),
		new Array("0003_sumage.png",     "http://game.fine-net.com/smartphone/")
	);
	var selectnum = Math.floor((Math.random() * 1000)) % imglist.length;
	var output = "<a href=\"" + imglist[selectnum][1] + "\"><img src=\"img/banner/site_appli/" + imglist[selectnum][0] + "\"  width=\"224\" height=\"33\" /></a>";
	if (document.getElementById("randomBanner")){
		document.getElementById("randomBanner").innerHTML = output;
	}
}


function swapImageRestore(obj) {
	var src = obj.firstChild.src;
	obj.firstChild.src = src.replace(/_on/, "");
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

type01a = new Image();
type01a.src = "img/fineshot_btn01.jpg";
type02a = new Image();
type02a.src = "img/fineshot_btn02.jpg";

type01b = new Image();
type01b.src = "img/fineshot_btn01_on.jpg";
type02b = new Image();
type02b.src = "img/fineshot_btn02_on.jpg";

function switchImageButtons(obj){
	if (obj.src.match(/_on\./)) return;
	
	var type01 = document.getElementById("type01");
	var type02 = document.getElementById("type02");
	
	
	if (type01.src == type01b.src){
		type01.src = type01a.src;
	}else{
		type01.src = type01b.src;
	}
	if (type02.src == type02b.src){
		type02.src = type02a.src;
	}else{
		type02.src = type02b.src;
	}
	
}

/*
function MM_swapImgRestore() { //v3.0
	var src = obj.firstChild.src;
	obj.firstChild.src = src.replace(/_on/, "");
}
*/

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// Start smartphone optimization
window.onload = function(){
	Smartphone.initialize("div", "_", "suffix");

	createRandomCatchCopy();
	createRandomBanner();

	// This script needs Smartphone.js which is already run. See up.
	if (Smartphone.isSmartphone()){
		GalleryScreens.initialize("ss_thumb", "thumb_");
	}
}


