var playtm = {
	init: function(){
		playtm.nav.init()
		playtm.png.init()
		if(typeof(eval("playtm."+$("body").attr("id")))=="object") {
			eval("playtm."+$("body").attr("id")+".init()")
		}
	},
	home: {
		init: function(){
			//playtm.fixCols()
			//tooltip("#images img")
		}
	},
	forum: {
		init: function(){
			$("#newthreadbtn").click(function(){
				$("#newthreadbtn").slideUp()
				$("#newthreadform").slideDown()
			})
		}
	},
	story: {
		init: function(){
			playtm.tagtab.init()
			playtm.comments.validate.init()
		}
	},
	video: {
		init: function(){
			playtm.comments.validate.init()
			$(".embed input").focus(function(){this.select()})
		}
	},
	tag: {
		init: function(){
			playtm.tagtab.init()
			//tooltip("#images img,#videos img")
			$('#intrapage a').click(function(){
				playtm.tag.clickedanchor = $(this).attr("href")
				$.scrollTo(playtm.tag.clickedanchor,1000,{onAfter:function(){window.location.hash = playtm.tag.clickedanchor}})
				return false;
			})
		}
	},
	tagtab: {
		init: function(){
			$(".tagtab .tab").mouseover(function(){
				$(".tagtab .selected").removeClass("selected")
				$(this).parent().addClass("selected")
			})
		}
	},
	nav: {
		init: function(){
			//$(".sitenav a,.stnav a").each(function(){
			//	$(this).clone().insertAfter(this).addClass("clone")
			//})
		}
	},
	png: {
		init: function() {
			if ($.browser.msie && $.browser.version == "6.0") {
				$("*").each(function(){
					if ($(this).css("background-image").indexOf(".png") != -1) {
						$(this).css("background-image","none");
					}
				})
			}
		}
	},
	fixCols: function(){
		col1h = parseInt($(".col1").css("height").replace("px",""))
		col2h = parseInt($(".col2").css("height").replace("px",""))
		if (col2h > col1h) {$(".col1").css("height",col2h+"px")}
	},
	comments: {
		deleteme: function(comment,from){
			if(confirm("Sure you want to delete that comment?")) {
				window.location='/forum/deletecomment/'+comment+'/from'+from
			}
		},
		validate: {
			init: function(){
				$("#comments form").submit(function(){
					playtm.comments.validate.error.clear()
					loggedIn = ($("#comments .name").length == 0)
					if (loggedIn) {
						if ($.trim($("#comments textarea").val()).length == 0) {
							isValid = false
						} else {
							isValid = true
						}
					} else {
						if ($.trim($("#comments textarea").val()).length == 0 || $.trim($("#comments .name").val()).length == 0) {
							isValid = false
						} else {
							isValid = true
						}
					}
					if (!isValid) {playtm.comments.validate.error.show()}
					return isValid
				})
			},
			error: {
				show: function() {
					$("#comments form").prepend("<p class=\"error\">Sorry, please make sure you have filled out all fields</p>")
				},
				clear:function() {
					$("#comments .error").remove()
				}
			}
		}
	}
}
$(function(){playtm.init()});
