if (parent.frames.length > 0) {
    parent.location.href = self.document.location
}
/*
function replace(string,text,by) {
    // Replaces text with by in string
    var i = string.indexOf(text), newstr = '';
    if ((!i) || (i == -1))
        return string;
    newstr += string.substring(0,i) + by;
    if (i+text.length < string.length)
        newstr += replace(string.substring(i+text.length,string.length),text,by);
    return newstr;
}
*/
function slicky(){

	var x = screen.width;
	var y = screen.height;
	var d = screen.colorDepth;
	var num = Math.floor(Math.random()*5001);
	var ref = escape(document.referrer);

    document.writeln('<img src="http://somniloquy.org/lib/slicky/slicky.php?res=' + x + 'x' + y + 'x' + d + '&id=0&num=' + num + '&ref=' + ref + '" width=1 height=1>');
}

if ( screen.width <= 800 ) {
	var resDir = 800;
} else {
	var resDir = 1024;
}


var pre = new Array();
pre[0] = new Image();
pre[0].src = 'http://somniloquy.org/images/'+resDir+'/hair_grey_03.png';
pre[1] = new Image();
pre[1].src = 'http://somniloquy.org/images/'+resDir+'/hair_grey_04.png';
pre[2] = new Image();
pre[2].src = 'http://somniloquy.org/images/'+resDir+'/hair_grey_05.png';
pre[3] = new Image();
pre[3].src = 'http://somniloquy.org/images/'+resDir+'/hair_grey_06.png';
pre[4] = new Image();
pre[4].src = 'http://somniloquy.org/images/'+resDir+'/hair_grey_07.png';

pre[5] = new Image();
pre[5].src = 'http://somniloquy.org/images/'+resDir+'/hair_highlight_03.png';
pre[6] = new Image();
pre[6].src = 'http://somniloquy.org/images/'+resDir+'/hair_highlight_04.png';
pre[7] = new Image();
pre[7].src = 'http://somniloquy.org/images/'+resDir+'/hair_highlight_05.png';
pre[8] = new Image();
pre[8].src = 'http://somniloquy.org/images/'+resDir+'/hair_highlight_06.png';
pre[9] = new Image();
pre[9].src = 'http://somniloquy.org/images/'+resDir+'/hair_highlight_07.png';

var id2im = new Array();

id2im["writing"] = '03';
id2im["blog"] = '04';
id2im["misc"] = '05';
id2im["about"] = '06';
id2im["contact"] = '07';

ids = new Array();
ids[0] = 'writing';
ids[1] = 'blog';
ids[2] = 'misc';
ids[3] = 'about';
ids[4] = 'about';
ids[5] = 'contact';

function rollOver(thisId){
    thisDiv = thisId+'Div';
    document.getElementById(thisId).src = 'http://somniloquy.org/images/'+resDir+'/hair_highlight_'+id2im[thisId]+'.png';
    document.getElementById(thisDiv).style.display='block';
    for ( i = 0; i < 6; i++ ){
        if ( ids[i] != thisId ){
             closeDiv = ids[i]+'Div';
            document.getElementById(ids[i]).src = 'http://somniloquy.org/images/'+resDir+'/hair_grey_'+id2im[ids[i]]+'.png';  
            document.getElementById(closeDiv).style.display='none';   
        }
    }
}

function rollOut(){

    for ( i = 0; i < 6; i++ ){
        document.getElementById(ids[i]).src = 'http://somniloquy.org/images/'+resDir+'/hair_'+id2im[ids[i]]+'.png';    
    }
}

  function setStyle(){
        var scrWidth = screen.width;
        
        if ( scrWidth <= 800 ) {
            var x = 800;
            /*
        } else if ( scrWidth > 800 && scrWidth <= 1024 ){
            var x = 1024;
        } else if ( scrWidth > 1024 ) {
            var x = 1280;
            */
        } else {
            var x = 1024;
        }
        
        document.getElementById('css').href = 'css/index_'+x+'.css';
        var imDir = 'http://somniloquy.org/images/'+x;
        if ( x ) {
            document.getElementById('header').src = imDir + '/hair_02.png';
            document.getElementById('writing').src = imDir + '/hair_03.png';
            document.getElementById('blog').src = imDir + '/hair_04.png';
            document.getElementById('misc').src = imDir + '/hair_05.png';
            document.getElementById('about').src = imDir + '/hair_06.png';
            document.getElementById('contact').src = imDir + '/hair_07.png';
        }
        
        
    }
