
/* default state of backgrounds */
document.bgOn = "true";

/* generate random backgrounds */
function rimage(count) { 
    i = 0;
    /* change this depending on the number of files */
    if (Math.round(Math.random())) {
        max = 36;
	type = "purple";
    } else {
        max = 39;
	type = "black";
    }
    for (i=0;i<count;i++) {
        random = Math.ceil(Math.random() * (max)); 
	out = "<img src=\"backset/" + type + "/tiles (" + random + ").jpg\">\n"
        document.write(out);
    }
}    

/* set background to match toggle */
function backgrounds(toggle){
    var doc = window.document;
    var bg = doc.getElementById("bg");
    if (toggle) {
	bg.style.display = "none";
	doc.body.style.backgroundColor = "black";
    } else {
	bg.style.display = "block"; 
	doc.body.style.backgroundColor = "transparent";
    }
}

function checkBackgrounds(){
    document.bgOn = getCookie("backgrounds");
    backgrounds((document.bgOn == "true"));
}

/* toggle background state */
function backgroundToggle(){
    if (document.bgOn=="true"){
        backgrounds(0);
	document.bgOn = "false";
    } else {
        backgrounds(1);
        document.bgOn = "true";
    }	
    setCookie("backgrounds",document.bgOn,52560000 /* 10 year */,"/",0,0);
 }



function setCookie(name,value,expires,path,domain,secure)
{
    var today = new Date();
    today.setTime(today.getTime());
    
    if (expires) {
        /* in minutes */
        expires = expires * 100 * 60;
    }
    
    var expires_date = new Date(today.getTime() + (expires));
    var cookie = name + "=" +escape(value) +
    ((expires)? ";expires=" + expires_date.toGMTString() : "" ) +
    ((path)? ";path=" + path : "") +
    ((domain) ? ";domain=" + domain : "") +
    ((secure) ? ";secure" : "");
    if (0) alert("set: " + cookie);
    document.cookie = cookie;
    if (0) alert(document.cookie);
    if (0) alert("expires: " + expires_date.toGMTString());
}

function getCookie(name)
{
    var start = document.cookie.indexOf(name + "=");
    var len = start + name.length + 1;

    if ((!start) && (name != document.cookie.substring(0,name.length)))
    {
        return 0; 
    }
    if (0) {
            alert(start + ": start.");
	    alert(document.cookie);
    }
        
    if (start ==-1) return 0;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    var cookie = unescape(document.cookie.substring(len,end));
    return cookie;
}

function sm()
{
	alert('I answer *all* questions and inquiries sent to me. If you do not hear from me within 1-3 days, it may mean my reply is in your SPAM folder, or what you sent is in my SPAM folder and I have not seen it, if so, try sending again.');
      var s00 = "lto\x3A";
      var s5 = "\x63a";
      var s4 = "\x2E";
      var s1 = "db";
      var s3 = "nihonto";
      var s2 = "\x40";
      var s0 = "mai";
     
      window.location = s0 + s00 + s1 + s2 + s3 + s4 + s5;
}

function jpg(url,title) 
{
     document.write('<?xml version="1.0" encoding="iso-2022-jp"?>\n');
     document.write('<!doctype html public \'-//W3C//DTD HTML 4.01//EN\' \'http://www.w3.org/TR/html4/strict.dtd\'>\n');
     document.write('<HTML style="overflow:scroll" id="autoscroll" >\n<HEAD>\n');
     document.write('<TITLE>' + title + '</TITLE>\n');

     document.write('<script language="javascript" src="../style/configure.js"></script>\n');
     document.write('<LINK REL="StyleSheet" TYPE="text/css" HREF="../style/newstyle.css">\n');

     document.write('</HEAD>\n');
     document.write('<BODY style="padding-top:0px; width:100%">\n');     

     document.write('<A HREF="/index.html" id="home" class="hot">home</A>\n');
     document.write('<A HREF="javascript:sm()" id="email" class="hot">email</A>\n');
     document.write('<A HREF="index.html" id="top3" class="hot">back</A>\n');
     if (title != "") {
         document.write('<DIV class="section" id="float"><H2 style="background:transparent">' + title + '</H2></DIV>\n');
     }    
     document.write('<DIV id="copy" class="copy" >Original content Copyright &#169; 2008 D. Brockbank</DIV>\n');

     document.write('<DIV class="content" >\n');

     document.write('<CENTER><IMG SRC="' + url + '"></CENTER>\n');
     document.write('</DIV>\n');

     document.write('</BODY>\n');
     document.write('</HTML>\n');
     document.write('\n');
     document.close();
}

/*detect Browsers via DOM*/
window.BO = {};
var c =[];
BO["ie"] =  (document.all!=null)&&(window.opera==null); 
BO["ie4"]  =  BO["ie"] && (document.getElementById==null); 
BO["ie5"]  =   BO["ie"] && (document.namespaces==null) && (!BO["ie4"]) ; 
BO["ie55"]  =  BO["ie"] && (document.namespaces!=null) && (document.compatMode==null); 
BO["ie6"]  =  BO["ie"] && (document.implementation!=null) && (document.compatMode!=null) && (window.XMLHttpRequest==null) ;
BO["ie7"] = BO["ie6"] && (window.XMLHttpRequest!=null) ;
BO["ie5_6"] =  BO["ie5"] || BO["ie55"] || BO["ie6"];/*rules for IE5~IE6*/
BO["ie55_6"] =  BO["ie55"] || BO["ie6"] ;/*rules for IE5.5~IE6*/
BO["ie6_7"] =  BO["ie6"] || BO["ie7"] ;/*rules for IE6~IE7*/
BO["ie5_7"] =  BO["ie55_6"] || BO["ie6_7"] ;/*rules for IE5~IE7*/
BO["ns4"]  = !BO["ie"] &&  (document.layers !=null) &&  (window.confirm !=null) && (document.createElement ==null); 
BO["opera"] =  (self.opera!=null); 
BO["gecko"] =  (document.getBoxObjectFor!=null); 
BO["firefox15"] = BO["gecko"] && (c.map!=null);
BO["khtml"] = (navigator.vendor =="KDE"); 
BO["konq"] =  ((navigator.vendor == 'KDE')||(document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)); 
BO["safari"] = (document.childNodes)&&(!document.all)&&(!navigator.taintEnabled)&&(!navigator.accentColorName); 
BO["safari12"] = (parseInt(0).toFixed==null) && (BO["safari"] && (window.XMLHttpRequest!=null)); 
/*BO["safari13"] = (parseInt(0).toFixed!=null) && BO["safari"] && !BO["safari12"] ;*/
BO["safari13"] = (document.implementation!=null) && (document.implementation.createHTMLDocument!=null) && (window.opera==null);/*I found this method from http://www.quirksmode.org/dom/w3c_html.html*/
BO["safari11"] = BO["safari"] && !BO["safari12"]  &&!BO["safari13"] ;
BO["macie"] = document.createElement!=null && (document.createElement("tr").insertCell==null);


for(i in BO) {if(BO[i]){c[c.length]=i;}; };
for(i in BO) {if(!BO[i]){c[c.length]="not_"+i;}; };
document.documentElement.className = c.join(" ");



