﻿// JavaScript Document

function switchImg() {
	
	if (!document.getElementById) return		
	
	num_now = getCookie("AAA_TopImg");	
	
	if ( num_now == "01"  ) {
		num_out = "02";
	} else if ( num_now == "02" ) {
		num_out = "03";
	} else if ( num_now == "03" ) {
		num_out = "04";
	} else {
		num_out = "01";
	}
	
	setCookie( "AAA_TopImg" , num_out );	
	
	var headObj = document.getElementById( 'head' );	
	
	if ( headObj != null ) {
		headObj.style.backgroundImage = "url(img/topImg_" + num_out + ".jpg)";
	}
	
}

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) {
    tmp = key + "=" + escape(val) + "; ";    
    tmp += "expires=Tue, 31-Dec-2030 23:59:59; ";
    tmp += "path=/; ";
    document.cookie = tmp;
}

