jQuery.fn.equalCols = function(){
	//Array Sorter
	var sortNumber = function(a,b){return b - a;};
	var heights = [];
	//Push each height into an array
	$(this).each(function(){
		heights.push($(this).height());
	});
	heights.sort(sortNumber);
	var maxHeight = heights[0];
	return this.each(function(){
		//Set each column to the max height
		$(this).css({'height': maxHeight});
	});
};

// JavaScript Document
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#mainnav > ul > li').bind('mouseover', jsddm_open)
   $('#mainnav > ul > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;

function redimension(){
	$("#content").css("height", "auto");
	if($("#content").height()<$("#left").height()){
		$("#content").height($("#left").height());
	}
}


$(document).ready(function() {
    $('hr').replaceWith('<div class="hr"><!-- --></div>');
	Cufon.replace('.inoksfont', {hover:true});
	$("a").click(function(){
		$(this).blur();
	});
	$("div.clickable").click(function(){
		 window.location ="/"+$(this).find("a:first").attr("href");
	});
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content

	//On Click Event
	$("ul.tabs li").click(function() {

		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content

		var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active ID content
		return false;
	});

	$('a[href*=#]').click(function() {
		var parentdivid = $(this).parents("div").first().attr("id");
		if(parentdivid!="slider"){
			$('html,body').animate({scrollTop: $("a[name="+$(this).attr("href").substr(1)+"]").offset().top-20});
			return false;
		}
  });
	
	$(".opener").addClass("stopopener");
	$(".opener").nextUntil(".stopopener").hide();
	$(".opener").click(function(){
								 $(this).nextUntil(".stopopener").slideToggle('fast', function(){ redimension(); });
								 	
								 });
	$("#currentlist div.boxnews:nth-child(3n)").css("padding-right", "0px").css("border-right", "none");
	$("#currentlist div.boxnews:nth-child(3n+1)").css("padding-left", "0px").css("border-left", "none").css("clear", "left");
	$("#currentlist div.boxnews:nth-child(1)").css("padding-left", "0px").css("border-left", "none");
	$('.innerbox3').equalCols();
	$('.innerbox2').equalCols();
	$("a.btnbig").prepend("<span>&nbsp;</span>");
	$("a.btnsmall").prepend("<span>&nbsp;</span>");
	redimension();
});

