/*****
 * Copyright DEERPEOPLE and Michael Curtis
 * Spittin' ink everywhere since 2010
 *****/

function inksplotch(filename, width, height){
	this.filename = '/wp-content/themes/monochrome/img/ink/'+filename;
	this.height = height;
	this.width = width;
}

var big = new Array();
var medium = new Array();
var small = new Array();

big[0] = new inksplotch('9.png', 208, 262);
big[1] = new inksplotch('10.png', 269, 535);

medium[0] = new inksplotch('1.png', 221, 90);
medium[1] = new inksplotch('2.png', 160, 154);
medium[2] = new inksplotch('3.png', 171, 158);
medium[3] = new inksplotch('4.png', 177, 114);
medium[4] = new inksplotch('5.png', 73, 66);
medium[5] = new inksplotch('6.png', 73, 69);
medium[6] = new inksplotch('7.png', 107, 45);
medium[7] = new inksplotch('8.png', 135, 102);
medium[8] = new inksplotch('11.png', 171, 147);
medium[9] = new inksplotch('12.png', 61, 135);

small[0] = new inksplotch('13.png', 23, 30);
small[1] = new inksplotch('14.png', 13, 13);
small[2] = new inksplotch('15.png', 9, 10);

var browser_height = 0;
var browser_width = 0;
var blackout_top = 300;
var blackout_left = 0;
var blackout_bottom = 0;
var blackout_right = 0

function placeSplotch(ink){
	var position_top = rand(browser_height-ink.height)
	var position_left = rand(browser_width-ink.width)
	if(position_top > blackout_top && position_top < blackout_bottom){
		while(position_left > blackout_left && position_left < blackout_right){
			position_left = rand(browser_width-ink.width);
		}
	}
	$('ink').insert({
		top: new Element('img', {src: ink.filename, 'class': 'inksplotch', style: 'height:'+ink.height+'px;width:'+ink.width+'px;top:'+position_top+'px;left:'+position_left+'px'})
	})
}

function rand(size){
	return Math.ceil(Math.random()*size) - 1;
}

function getDirty(){
	browser_height = $('body').getHeight();
	browser_width = $('body').getWidth();
	blackout_left = (browser_width - 900) / 2;
	blackout_bottom = browser_height - 90;
	blackout_right = browser_width - blackout_left;
	
	for(var i=0;i<2;i++){
		placeSplotch(big[rand(big.length)]);		
	}
	
	for(var i=0;i<25;i++){
		placeSplotch(medium[rand(medium.length)]);
	}
	
	for(var i=0;i<50;i++){
		placeSplotch(small[rand(small.length)]);
	}
}
