/* IE6 flicker fix
-------------------------------------------------- */
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

/* Confirm action
-------------------------------------------------- */
function confirmAction(text) {
	var agree = confirm(text);

	if (agree) return true;
	else return false;
}

/* Show ID
-------------------------------------------------- */
function show(id){
	var element = document.getElementById(id);
	element.style.display = '';
}

/* Hide ID
-------------------------------------------------- */
function hide(id){
	var element = document.getElementById(id);
	element.style.display = 'none';
}

/* Popup
-------------------------------------------------- */
function popup(url) {

	window_width = '646px';
	window_height = '656px';
	window_name = 'Slaidiesitlus1';

	settings=
	"toolbar=no,location=no,directories=no,"+
	"status=no,menubar=no,scrollbars=yes,"+
	"resizable=yes,width="+window_width+",height="+window_height;

	NewWindow=window.open(url,window_name,settings);

	if (window.focus) {
		NewWindow.focus();
	}
}

/* =markRow
-------------------------------------------------- */
function setCheckbox(e, cell) {
	var cbox = cell.getElementsByTagName('input')[0];
	var clickedElt = window.event? event.srcElement: e.target;

	if (clickedElt != cbox)
		cbox.checked = !(cbox.checked);
	if (cbox.checked) {
		cell.parentNode.className = 'marked';
	} else {
		cell.parentNode.className = '';
	}
}

/* jQuery
-------------------------------------------------- */
var toggleLayer = {
	init : function(){
		$("#sort01 div.thumb div.footer3 p.openlayer a").click(this.clickIt);
	},
	clickIt : function(){
		$(this).attr("href","javascript:;");
		$(this).parents("#sort01").children("#layer").slideToggle("fast");
	}
};
var closeLayer = {
	init : function(){
		$("#layer p.layer-action input").click(this.clickIt);
	},
	clickIt : function(){
		$(this).parents("#layer").slideUp("fast");
	}
};

var toggleIntervall = {
	init : function(){
		$("#header #tools #tool03 a").click(this.clickIt);
	},
	clickIt : function(){
		$(this).toggleClass("open");
		$("#intervall").slideToggle("fast");
	}
};
var closeIntervall = {
	init : function(){
		$("#intervall li a").click(this.clickIt);
	},
	clickIt : function(){
		$("#intervall").slideUp("fast");
	}
};

var toggleComment = {
	init : function(){
		$("#comment-trigger").click(this.clickIt);
	},
	clickIt : function(){
		$("#addcomment").slideToggle("fast");
		$(this).toggleClass("open");
		$(this).parent().toggleClass("openheader");
	}
};
var closeComment = {
	init : function(){
		$("#addcomment p.action input").click(this.clickIt);
	},
	clickIt : function(){
		$("#addcomment").slideUp("fast");
		$("#comment-trigger").removeClass("open");
		$("#comment-trigger").parent().removeClass("openheader");
	}
};

function toggleTab(id,tab){
	var element = document.getElementById(id);
	var tabelement = document.getElementById(tab);

	if (element.style.display == 'none') {

		$("div.tabscontent").hide();
		$("ul.tabs").addClass("tabs-open");
		$("ul.tabs li").removeClass("active");

		element.style.display = 'block';
		tabelement.className = 'active';
	}
}

var closeKeyword = {
	init : function(){
		$("#add-keyword-form input:image").click(this.clickIt);
	},
	clickIt : function(){
		$("#add-keyword-form").slideUp("fast");
		$("#add-keyword").removeClass("keyword-open");
	}
};

function runMaxpopup() {
	$("#popup2 #content").css("width",$("#popup2 #content p.img img").width());
	$("#popup2 #content p.img img").css("display","block");
}

function runSmallpopup() {
	$("#popup #content div.img p.prev").css("height",$("#content div.img p.img").height());
	$("#popup #content div.img p.next").css("height",$("#content div.img p.img").height());
}

var checkThumbMove = {
	init : function(){
		$("#sort02 div.thumb div.footer3 p.input :checkbox").click(this.clickIt);
	},
	clickIt : function(){
		if($(this).is(":checked")) {
			$(this).parents("div.thumb").children("p.img").fadeTo("fast", 1);
			$(this).attr("checked","checked");
		} else {
			$(this).parents("div.thumb").children("p.img").fadeTo("fast", 0.2);
			$(this).removeAttr("checked");
		}
	}
};
var checkAllThumbs = {
	init : function(){
		$("#check-all-thumbs").click(this.clickIt);
	},
	clickIt : function(){
		$("#sort02 div.thumb p.img").fadeTo("fast", 1);
		$("#sort02 div.thumb div.footer3 p.input :checkbox").attr("checked","checked");
		return false;
	}
};
var uncheckAllThumbs = {
	init : function(){
		$("#uncheck-all-thumbs").click(this.clickIt);
	},
	clickIt : function(){
		$("#sort02 div.thumb p.img").fadeTo("fast", 0.2);
		$("#sort02 div.thumb div.footer3 p.input :checkbox").removeAttr("checked");
		return false;
	}
};