
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

(function($) {
	$.fn.customfadeIn = function(speed, callback) {
		$(this).fadeIn(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customfadeOut = function(speed, callback) {
		$(this).fadeOut(speed, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
	$.fn.customfadeTo = function(speed,opa, callback) {
		$(this).fadeTo(speed,opa, function() {
			if(jQuery.browser.msie)
				$(this).get(0).style.removeAttribute('filter');
			if(callback != undefined)
				callback();
		});
	};
})(jQuery);

function megaHoverOver(){
		$(this).animate({backgroundPosition: '-20px 250px'},"slow");
		$(this).find(".sub").stop().customfadeTo(100, 1).show();
		//Calculate width of all ul's
		(function($) { 
			jQuery.fn.calcSubWidth = function() {
				rowWidth = 0;
				//Calculate row
				$(this).find("ul").each(function() {					
					rowWidth += $(this).width(); 
				});	
			};
		})(jQuery); 
		
		if ( $(this).find(".row").length > 0 ) { //If row exists...
			var biggestRow = 0;	
			//Calculate each row
			$(this).find(".row").each(function() {							   
				$(this).calcSubWidth();
				//Find biggest row
				if(rowWidth > biggestRow) {
					biggestRow = rowWidth;
				}
			});
			//Set width
			$(this).find(".sub").css({'width' :biggestRow});
			$(this).find(".row:last").css({'margin':'0'});
			
		} else { //If row does not exist...
			
			$(this).calcSubWidth();
			//Set Width
			//$(this).find(".topsub").css({'width' : rowWidth});
			
		}
	}
	
function megaHoverOut(){ 
	  $(this).find(".sub").stop().customfadeTo('fast', 0, function() {
		  $(this).hide(); 
	  });
	}


function docready() {
	$("a").click(function(){
		$(this).blur();
	});
	$("#topnav > li").mouseover(function(){
		$(this).css("background-position","0 -38px");
		h=$(this).find("ul").height();  if (h>20) { h=h+35; } $(this).find("a").css("color","#fff");
		$(this).stop().animate({height: h+'px'},{queue:false, duration:600, easing: 'easeOutBounce'})
	});
	$("#topnav > li").mouseout(function(){
		$(this).stop().animate({height:'25px'},{queue:false, duration:600, easing: 'easeOutBounce'},function(){
					});
	$(this).css("background-position","0 0px"); $(this).find("> a").css("color","#555");
										  });
	}

function postpage(url,div) {
	$.post(url,$("#form1").serialize(),function(data){
					$("#"+div).html(data);						
					});
	return false;
	}

function getpage(url,div) {
	$.get(url,function(data){
					$("#"+div).html(data);						
					});
	return false;
	}
	
function takv() {
	$('.tcal .pmv').mouseover(function(e){
					$('<div class="tcalinfo">'+$(this).attr("dat")+'</div>').appendTo('body');
				    w=$(".tcalinfo").width(); if (w>300) { w=300; $(".tcalinfo").width(w);}  h=$(".tcalinfo").height(); var pm=$(this).position();  $(".tcalinfo").css({top: pm.top-(h+30), left: pm.left});
					$(".tcalinfo").customfadeTo(200, 1).show(); });
	$('.tcal .pmv').mouseout(function(){ $(".tcalinfo").hide(); $('div.tcalinfo').remove(); });
	}
