function confirmit(question, urltogoto){
	var check=confirm(question);
	if(check){
		document.location.href=urltogoto;
	}

}
function go(url){
	document.location.href=url;
}
function checkAll(docform, elementname, selectit) {
	var docelements = docform.elements;
	for (n=0;n< docelements.length;n++){
		if (elementname=='' || elementname && docelements.item(n).name == elementname){
			if(selectit){
        			docelements.item(n).checked = true;
			}
			else{
        			docelements.item(n).checked = false;
			}
		}
	}
}
function preloadImages() {
	if(document.images){
		if(!document.preloaded){
			document.preloaded=new Array();
		}
		var i;
		var j = document.preloaded.length;
		var a = preloadImages.arguments;
		for(i=0; i<a.length; i++){
    			if (a[i].indexOf("#")!=0){
				document.preloaded[j]=new Image;
				document.preloaded[j++].src=a[i];
			}
		}
	}
}
function makeSmallThumbs(){
	if (screen.width<1024){
		for(n=0;n<document.images.length;n++){
			if(document.images[n].className=="thumb"){
				document.images[n].width=document.images[n].width*(100/150);
				document.images[n].height=document.images[n].height*(100/150);
			}
		}
	}
}
function changeImage(image_name, href_name, title_name, image_src, image_w, image_h, href_href, title_title, bg_name, text_name, text_text, post_type){

	var table_rsc = document.getElementById(image_name+"_holder");
	var image_rsc = document.getElementById(image_name);
	var href_rsc = document.getElementById(href_name);
	var title_rsc = document.getElementById(title_name);
	
	var text_rsc = document.getElementById(text_name);
	var bg_rsc = document.getElementById(bg_name);
	
	text_rsc.innerHTML = text_text;
	bg_rsc.className = 'previewInfo previewInfo-'+post_type;

	image_rsc.width=table_rsc.style.width=image_w;
	image_rsc.height=table_rsc.style.height=image_h;
	image_rsc.src=image_src;

	href_rsc.href=href_href;

	title_rsc.innerHTML=title_title;

}
function checkAll(docform, elementname, selectit) {
	var docelements = docform.elements;
	for (n=0;n< docelements.length;n++){
		if (elementname=='' || elementname && docelements.item(n).name == elementname){
			if(selectit){
        			docelements.item(n).checked = true;
			}
			else{
        			docelements.item(n).checked = false;
			}
		}
	}
}
function popup(u, w, h){
	if(w && h){
		var d=',width='+w+',height='+h;
	}
	else{
		d='';
	}
	new_win = window.open(u,'','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0'+d);
	new_win.opener = self;
}
function popup_lock(u, w, h){
	if(w && h){
		var d=',width='+w+',height='+h;
	}
	else{
		d='';
	}
	new_win = window.open(u,'','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0'+d);
	new_win.opener = self;
}
function expand_com(ex_id){
	try{
		var index=document.location.href.indexOf("#");
		if(index!=-1){
			var urltogoto=document.location.href.substr(0, index);
		}
		else{
			var urltogoto=document.location.href;
		}

		document.expand.comment_expand.value=ex_id;
		document.expand.action=urltogoto+"#com"+ex_id;
		document.expand.submit();

	}
	catch(e){
		alert('problem submitting, try again');
	}
}

function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function fixDate(date) {
	var base = new Date(0);
	var skew = base.getTime();
	if (skew > 0)
		date.setTime(date.getTime() - skew);
}
function trim(input){
	if(typeof input!='string')return input;
	return input.replace(/^\s*|\s*$/g,"");
}


//Popup code

Xoffset=0;
Yoffset=20;

var old,skn,iex=(document.all),yyy=Yoffset;

var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
var ua= navigator.userAgent;
var MAC= (navigator.platform.indexOf("PPC") > 0);
var IE5, MAC_IE5, xMouse, yMouse;

IE5= (ua.indexOf("MSIE 5") > 0 || ua.indexOf("MSIE 6") > 0);
MAC_IE5= (MAC && IE5);

if (!MAC_IE5){
	if(ns4)
		skn=document.dek
	else if (ns6)
		skn=document.getElementById("dek").style
	else if (ie4)
		skn=document.all.dek.style
	if(ns4)
		document.captureEvents(Event.MOUSEMOVE);
	else{
		skn.visibility="visible"
		skn.display="none"
	}
	document.onmousemove=get_mouse;
}
function showmsg(msg){
	if (!MAC_IE5){
		var content="<table cellpadding=3 cellspacing=1 class=forumline><td class='table_1'><span class='gensmall'>"+msg+"</span></td></table>";
		yyy=Yoffset;
		if(ns4){skn.document.write(content);skn.document.close();skn.visibility="visible"}
		if(ns6){document.getElementById("dek").innerHTML=content;skn.display=''}
		if(ie4){document.all("dek").innerHTML=content;skn.display=''}
	}
}
function get_mouse(e)
{
	try{
		var x=document.body.scrollLeft+event.clientX;
	}
	catch(error){
		var x=document.body.scrollLeft+e.clientX;
	}
	try{
		var y=document.body.scrollTop+event.clientY;
	}
	catch(error){
		var y=document.body.scrollTop+e.clientY;
	}
	xMouse = x;
	yMouse = y;

	skn.left=x+Xoffset-(skn.width/2);
	skn.top=yyy+y;
}

function killmsg()
{
	yyy=-1000;
	if(ns4){skn.visibility="hidden";}
	else if (ns6||ie4)
	skn.display="none"
}

var buddyListOpen = false;
function openBuddies(){
	if(!buddyListOpen){
		if(Effect.PhaseIn('watchList')){
			Effect.PhaseOut('galleryList');
			buddyListOpen=true;
		}
	}
	else{
		if(Effect.PhaseOut('watchList')){
			Effect.PhaseIn('galleryList');
			buddyListOpen=false;
		}
	}
}

var showDivs = new Array();
function showDiv(name, button, index){
	if(index == undefined){
		var index = 0;
	}
	if(showDivs[index] == undefined){
		showDivs[index]={};
	}
	else{
		$(showDivs[index]['name']).style.display = 'none';
		$(showDivs[index]['button']).style.color = '';
	}

	showDivs[index]['name']=name;
	showDivs[index]['button']=button;

	$(showDivs[index]['name']).style.display = 'block';
	$(showDivs[index]['button']).style.color = '#000099';
	
}
function refreshAd(element){
	try{
		var innerAd = element.innerHTML;
		element.innerHTML = '';
		element.innerHTML = innerAd;
	}
	catch(e){}
}
function refreshAds(){
	try{ad1 = $('ad1');}catch(e){}
	try{ad2 = $('ad2');}catch(e){}
	if(ad1!=undefined){
		refreshAd(ad1);
	}
	if(ad2!=undefined){
		refreshAd(ad2);
	}
}


Element.hitTest = function(object, x, y){
	objectPosition = Position.cumulativeOffset(object);
	return (x >= objectPosition[0] && y >= objectPosition[1] && x <= objectPosition[0]+object.offsetWidth && y <= objectPosition[1]+object.offsetHeight);
}


HoverElement = Class.create();
Object.extend(HoverElement.prototype, {
	initialize: function(element, trigger){
		this.element = $(element);
		this.trigger = trigger;
		
		this.observeFunction = this.check.bindAsEventListener(this);
		
		parentPosition = Position.cumulativeOffset(this.trigger);
		
		this.element.style.top = (parentPosition[1] + this.trigger.offsetHeight)+'px';
		this.element.style.left = parentPosition[0]+'px';
		
		Element.show(this.element);
		Event.observe(document, 'mousemove', this.observeFunction);
	},
	check: function(event){
		var xmouse = Event.pointerX(event);
		var ymouse = Event.pointerY(event);
		if(!Element.hitTest(this.element, xmouse, ymouse) && !Element.hitTest(this.trigger, xmouse, ymouse)){
			Element.hide(this.element);
		}
	}
});


Zipper = Class.create();
Object.extend(Zipper.prototype, {
	initialize: function(container){
		this.container = $(container);
		this.options = {period: .5,fps:30};

		this.pieces = [[],[]];
		this.pieces[-1]=[];

		this.width = this.container.offsetWidth;
		this.height = this.container.offsetHeight;
		
		this.container.style.width = this.width+'px';
		this.container.style.height = this.height+'px';
		this.container.style.position = 'relative';
		this.container.style.overflow = 'hidden';

		var html = this.container.innerHTML;
		this.container.innerHTML = '';
		object = this.newObject();
		object.innerHTML = html;
		this.place(object, 0, 0);
		
	},
	loadHTML: function(html, x, y){
		if(this.transformationInterval){
			return false;
		}

		if(typeof x === 'undefined')x = 0;
		if(typeof y === 'undefined')y = 0;

		object = this.newObject();
		object.innerHTML = html;
		this.place(object, x, y);
		this.transform(x, y);
	},
	loadElement: function(element, x, y){
		if(this.transformationInterval){
			return false;
		}

		if(typeof x === 'undefined')x = 0;
		if(typeof y === 'undefined')y = 0;

		object = this.newObject();
		object.innerHTML = html;
		object.appendChild(element);
		this.place(object, x, y);
		this.transform(x, y);
	},
	newObject: function(x,y){
		var element = document.createElement('div');
		element.style.position = 'absolute';
		element.style.top = this.height+'px';
		element.style.left = '0px';
		element.style.width = this.width+'px';
		element.style.height = this.height+'px';

		this.container.appendChild(element);
		return element;
	},
	interval: function(){
		var x = this.transformation.x;
		var y = this.transformation.y;

		var xMove = -this.pieces[x][y].x/this.transformation.intervals*5;
		var yMove = -this.pieces[x][y].y/this.transformation.intervals*5;

		if(this.transformation.interval == this.transformation.intervals ||
		   (this.pieces[x][y].x+xMove)*x < 0 ||
		   (this.pieces[x][y].y+yMove)*y < 0){
			this.container.removeChild(this.pieces[0][0].element);
			this.place(this.pieces[x][y].element, 0, 0);
			clearInterval(this.transformationInterval);
			this.transformationInterval = false;
		}
		
		this.moveBy(x, y, xMove, yMove);
		this.moveBy(0, 0, xMove, yMove);


		++this.transformation.interval;
	},
	transform: function(x, y){
		this.transformation = {
			interval: 0,
			intervals: this.options.period * this.options.fps,
			x:x,
			y:y
		}
		this.transformationInterval = setInterval(this.interval.bind(this), 1000 / this.options.fps);
	},
	place: function(object, x, y){

		xp = ((x > 0) ? (this.width * x) : (object.offsetWidth * x));
		yp = ((y > 0) ? (this.height * y) : (object.offsetHeight * y));
		
		object.style.left = xp + 'px';
		object.style.top = yp + 'px';
		

		if(!this.pieces[x])this.pieces[x] = [];
		this.pieces[x][y] = {
			element: object,
			x: xp,
			y: yp
		};
	},
	moveBy: function(x,y,xMove,yMove){
		this.pieces[x][y].x += xMove;
		this.pieces[x][y].y += yMove;

		this.pieces[x][y].element.style.left = this.pieces[x][y].x + 'px';
		this.pieces[x][y].element.style.top = this.pieces[x][y].y + 'px';
	}
});

Gridder = Class.create();
Object.extend(Gridder.prototype, {
	initialize: function(container){
		this.holder = $(container);
		this.options = {period: .5,fps:30,compensation:50};

		this.pieces = {};
		this.position = {x: 0,y: 0};
		this.offset = {x: 0,y: 0};

		this.width = this.holder.offsetWidth;
		this.height = this.holder.offsetHeight;
		
		this.holder.style.width = this.width+'px';
		this.holder.style.height = this.height+'px';
		this.holder.style.overflow = 'hidden';

		var html = this.holder.innerHTML;
		this.holder.innerHTML = '';

		this.container = document.createElement('div');
		this.container.style.width = (this.width + this.options.compensation)+'px';
		this.container.style.height = (this.height + this.options.compensation)+'px';
		this.container.style.position = 'relative';
		this.container.style.overflow = 'auto';
		this.holder.appendChild(this.container);

		var object = this.newObject();
		object.content.innerHTML = html;
		this.place(object.container, 0, 0);
	},
	loadHTML: function(html, x, y){
		if(typeof x === 'undefined')x = 0;
		if(typeof y === 'undefined')y = 0;

		object = this.newObject();
		object.content.innerHTML = html;
		this.place(object.container, x, y);

		//this.transform(x, y);
	},
	loadElement: function(element, x, y){
		if(typeof x === 'undefined')x = 0;
		if(typeof y === 'undefined')y = 0;

		object = this.newObject();
		object.content.innerHTML = html;
		object.content.appendChild(element);
		this.place(object.container, x, y);

		//this.transform(x, y);
	},
	newObject: function(x,y){
		var hElement = document.createElement('div');
		var element = document.createElement('div');
		hElement.style.position = 'absolute';
		hElement.style.top = '-'+this.height+'px';
		hElement.style.left = '0px';
		hElement.style.width = (this.width+this.options.compensation)+'px';
		hElement.style.height = (this.height+this.options.compensation)+'px';

		element.style.width = this.width+'px';
		element.style.height = this.height+'px';

		hElement.appendChild(element);
		this.container.appendChild(hElement);

		return {container: hElement, content: element};
	},
	place: function(object, x, y){
		this.pieces[x] = this.pieces[x] || {};
		var scroll = {
			left: this.container.scrollLeft,
			top: this.container.scrollTop
		};

		if(x < this.offset.x || y < this.offset.y){
			scroll.left = (x < this.offset.x) ? scroll.left + ((this.offset.x-x)*this.width) : scroll.left;
			scroll.top = (y < this.offset.y) ? scroll.top + ((this.offset.y-y)*this.height) : scroll.top;
			this.offset.x = Math.min(this.offset.x, x);
			this.offset.y = Math.min(this.offset.y, y);
			this.redraw();
		}

		this.pieces[x] = this.pieces[x] || {};

		if(this.pieces[x][y]){
			this.remove(x, y);
		}

		this.pieces[x][y] = object;
		this.draw(x,y);

		this.container.scrollLeft = scroll.left;
		this.container.scrollTop = scroll.top;
	},
	remove: function(x,y){
		this.container.removeChild(this.pieces[x][y]);
		this.pieces[x][y] = null;
	},
	draw: function(x,y){
		var position = this.getObjectPosition(x,y);
		
		this.pieces[x][y].style.left = position.x + 'px';
		this.pieces[x][y].style.top = position.y + 'px';
	},
	getObjectPosition: function(x,y){
		return {
			x: (this.width * (x-this.offset.x)),
			y: (this.height * (y-this.offset.y))
		};
	},
	redraw: function(){
		for(x in this.pieces){
			for(y in this.pieces[x]){
				this.draw(x,y);
			}
		}
	},
	slideTo: function(x,y){
		var target = this.getObjectPosition(x,y);
		var current = {
			x: this.container.scrollLeft,
			y: this.container.scrollTop
		}
		this.movement = {
			xDistance: (target.x-current.x),
			yDistance: (target.y-current.y),
			startX: current.x,
			startY: current.y,
			endX: target.x,
			endY: target.y,
			endLocation: {x:x,y:y},
			frames: (this.options.fps*this.options.period),
			frame: 0
		}
		try{clearInterval(this.interval);}catch(e){}
		this.interval = setInterval(this.slide.bind(this), 1000/this.options.fps);
	},
	slide: function(){
		++this.movement.frame;

		////// Smooth movement
		//this.container.scrollLeft = this.movement.startX + this.movement.xDistance * this.movement.frame/this.movement.frames;
		//this.container.scrollTop = this.movement.startY + this.movement.yDistance * this.movement.frame/this.movement.frames;

		////// Sliding movement
		var moveFactor = Math.pow(2, this.movement.frame);
		this.container.scrollLeft += Math.round(this.movement.xDistance / moveFactor);
		this.container.scrollTop += Math.round(this.movement.yDistance / moveFactor);

		if(this.movement.frame == this.movement.frames){
			if(this.currentLocation){
				this.remove(this.currentLocation.x, this.currentLocation.y);
			}
			this.currentLocation = this.movement.endLocation;
			this.container.scrollLeft = this.movement.endX;
			this.container.scrollTop = this.movement.endY;
			clearInterval(this.interval);
		}
	}
});

function IEPNGBackgrounds() {
	var cssRules;
	if (document.all) {
		cssRules = 'rules';
	} else if (document.getElementById) {
		cssRules = 'cssRules';
	}
	var classes = {};

	for (var S = 0; S < document.styleSheets.length; S++){
		for (var R = 0; R < document.styleSheets[S][cssRules].length; R++) {
			var cssClass = document.styleSheets[S][cssRules][R].style;
			var cssName = document.styleSheets[S][cssRules][R].selectorText;
			backgroundImage = cssClass['backgroundImage'];
			if (backgroundImage) {
				var matched = backgroundImage.match(/url\((.+?)\.png\)/);
				if (matched) {
					classes[cssName] = [S,R];
				} else if(classes[cssName] && backgroundImage == 'none') {
					classes[cssName] = null;
				}
			}
		}
	}

	for(var name in classes){
		if(classes[name]){
			var S = classes[name][0];
			var R = classes[name][1];

			var cssClass = document.styleSheets[S][cssRules][R].style;
			backgroundImage = cssClass['backgroundImage'];
			if (backgroundImage) {
				var matched = backgroundImage.match(/url\((.+?)\.png\)/);
				if (matched) {
					try {
						var src = matched[1]+'.png';
						cssClass.backgroundImage = 'url(\''+imageServer+'/images/transparent.gif\')';
						cssClass.background = 'transparent url(\''+imageServer+'/images/transparent.gif\')';
						cssClass.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
					} catch (e) {}
				}
			}
		}
	}	
}


DropDown = Class.create();
Object.extend(DropDown.prototype, {
	initialize: function(element, trigger, options){
		this.element = $(element);
		this.trigger = trigger;
		this.options = Object.extend({
			method: 'click'
		}, options);
		
		this.observeFunction = this.check.bindAsEventListener(this);
		
		parentPosition = Position.cumulativeOffset(this.trigger);
		
		this.element.style.top = (parentPosition[1] + this.trigger.offsetHeight)+'px';
		this.element.style.left = parentPosition[0]+'px';
		
		if (this.options.method == 'click') {
			Event.observe(document, 'click', this.observeFunction);
			this.trigger.onclick = function(){return false;}
		} else if (this.options.method == 'rollover') {
                        Event.observe(document, 'mousemove', this.observeFunction);
		}
	},
	check: function(event){
		var xmouse = Event.pointerX(event);
		var ymouse = Event.pointerY(event);
		
		if (this.visible) {
			var hide = false;
			if (this.options.method == 'click') {
				hide = ( !Element.hitTest(this.element, xmouse, ymouse) || Element.hitTest(this.trigger, xmouse, ymouse) );
	                } else if (this.options.method == 'rollover') {
	                	hide = (!Element.hitTest(this.trigger, xmouse, ymouse) && this.options.method == 'rollover');
			}

			if ( hide ) {
				this.visible = false;
				Element.hide(this.element);
			}
		} else {
			if(Element.hitTest(this.trigger, xmouse, ymouse)){
				this.visible = true;
				Element.show(this.element);
			}
		}
	},
	visible: false
});

function htmlspecialchars(input){
	if(typeof input!='string')return input;
	input = input.replace(/&/,'&amp;');
	input = input.replace(/</,'&lt;');
	input = input.replace(/>/,'&gt;');
	return input.replace(/"/,'&quot;');
}

var imageServer = 'http://img.sheezyart.com';
var mainServer = 'http://www.sheezyart.com';
var host = 'sheezyart.com';


if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer"){
	var match = navigator.appVersion.match(/MSIE (\d+\.\d+)/);
	if(match){
		var version = Number(match[1]);
		if(version > 5 && version < 7){
			//IEPNGBackgrounds();
		}
	}	
}



Effect.PhaseIn = function(element) {
  element = $(element);
  new Effect.BlindDown(element, arguments[1] || {});
  new Effect.Appear(element, arguments[2] || arguments[1] || {});
}

Effect.PhaseOut = function(element) {
  element = $(element);
  new Effect.Fade(element, arguments[1] || {});
  new Effect.BlindUp(element, arguments[2] || arguments[1] || {});
}

Effect.Phase = function(element) {
  element = $(element);
  if (element.style.display == 'none')
    new Effect.PhaseIn(element, arguments[1] || {}, arguments[2] || arguments[1] || {});
  else new Effect.PhaseOut(element, arguments[1] || {}, arguments[2] || arguments[1] || {});
}
