/* *** The script which displays images at random. *** */

/* Initial setting */

promBanner = new Array;
promBanner[0] = new Array("/img/top-focus001.jpg", "", "Otsuka - people creating new products for better health worldwide", "");
promBanner[1] = new Array("/img/top-focus002.jpg", "", "Otsuka - people creating new products for better health worldwide","");
promBanner[2] = new Array("/img/top-focus003.jpg", "", "Otsuka - people creating new products for better health worldwide", "");


/* For operation: Change needlessness */

function includeBanner() {
	setCookie("visiting","OK");
	var visiting = getCookie("visiting");
	var time = getCookie("time");
	if(visiting == ""){
		var rNumMain = Math.floor(Math.random()*promBanner.length);
	}else{
		if (time == "") {
			var rNumMain = 0;
		}else{
			var rNumMain = Math.floor(Math.random()*promBanner.length);
		}
		setCookie("time","OK");
	}
	
	var promMain = '';
	document.writeln('<h3>');
	
	if(promBanner[rNumMain][1]!="") promMain += '<a href="' + promBanner[rNumMain][1] + '">';
	promMain += '<img src="' + promBanner[rNumMain][0] +'" width="428" height="322" border="0" alt="' + promBanner[rNumMain][2] +'">';
	if(promBanner[rNumMain][1]!="") promMain += '</a>';

	if(promBanner[rNumMain][3]!="") {
		var swf_obj = new Object();
		swf_obj.dir      = '';
		swf_obj.file     = promBanner[rNumMain][3];
		swf_obj.id       = 'impressionMovie';
		swf_obj.requiredVer = 5;
		swf_obj.bgcolor  = '#ffffff';
		swf_obj.width    = '428';
		swf_obj.height   = '322';
		swf_obj.quality = 'high';
		swf_obj.language = 0;
		swf_obj.macie4exec = 0;
		swf_obj.opera_exec = 1;
		swf_obj.nonflashSW  = 0;
		swf_obj.swLiveConnect = false;
		swf_obj.nonFlashSRC   = promMain;
		putflash(swf_obj);
	} else {
		document.writeln(promMain);
	}
	
	document.writeln('</h3>');
}

function getCookie(key,  tmp1, tmp2, xx1, xx2, xx3) {
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    len = tmp1.length;
    while (xx1 < len) {
        xx2 = tmp1.indexOf(";", xx1);
        tmp2 = tmp1.substring(xx1 + 1, xx2);
        xx3 = tmp2.indexOf("=");
        if (tmp2.substring(0, xx3) == key) {
            return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
        }
        xx1 = xx2 + 1;
    }
    return("");
}

function setCookie(key, val) {
    tmp = key + "=" + escape(val) + "; ";
    //tmp += "path=" + location.pathname + "; ";
    //tmp += "expires=Tue, 31-Dec-2030 23:59:59; ";
    document.cookie = tmp;
}
