$(document).ready(function(){

	var fnd = 0;
	var last_height = 0;
	$("#middle .article").each(function(){
		if($(this).hasClass('thirth')){
			h = $(this).height();
			if(last_height < h){
				last_height = h;
			}
			if(fnd == 0){
				$(this).addClass('first');
			}
			fnd++;
		}
		if(!$(this).hasClass('thirth') || fnd > 2){
			fnd = 0;
		}
	});
	$("#middle .article.thirth").height(last_height);


	$("#top ul li:first,#bottommenu ul li:first").addClass('first');
	

	$("#menu ul li").hover(
		 function(){
			 if($(this).children('ul:eq(0)').is(':hidden'))
				 $(this).children('ul:eq(0)').css('display','block');
		 },
		 function(){
			 if($(this).children('ul:eq(0)').is(':visible'))
				 $(this).children('ul:eq(0)').css('display','none');
		 }
	);
	
	$("#menu ul ul > li:last a").addClass('last');
	
	//disable right
	if(!$.trim($("#right").text())){
		$("#right").hide();
	}else{
		$("#middle").addClass('with_right');
	}
	
	if($("#content").height() < 300){
		$("#content").height(300);
	}

});



//dummy
var popInfo = function(){}

//emulate popup function...
var popWindow = function(u,w,h){
	e = u.substring(u.lastIndexOf('.')+1).toLowerCase();
	if(e == 'png' || e == 'gif' || e == 'jpg')
		popEl = $("<div class=\"popWindowDiv clear\" style=\"display:block;\"><img src=\""+ u +"\" width=\"" + w + "\" height=\"" + h + "\" border=\"0\" /></div>",{overlay:20});
	else
		popEl = $("<div class=\"popWindowDiv clear\" style=\"display:block;\"><iframe src=\""+ u +"\"  width=\"" + w + "\" height=\"" + h + "\" border=\"0\" frameborder=\"0\"></iframe></div>",{overlay:20});
	popEl.modal({
		onOpen: function (dialog) {
					dialog.overlay.fadeIn('slow', function () {
						dialog.container.slideDown('slow', function () {
							dialog.data.fadeIn('slow'); // See Other Notes below regarding
													   // data display property and
													   // iframe details
						});
					});
				},
		onClose: function (dialog) {
					dialog.data.fadeOut('slow', function () {
					  dialog.container.slideUp('slow', function () {
						dialog.overlay.fadeOut('slow', function () {
						  $.modal.close(); // must call this to have SimpleModal
										   // re-insert the data correctly and
										   // clean up the dialog elements
						});
					  });
					});
				}
	});
	$("#modalContainer").css('height',h).css('width',w).css('margin-left',(w / 2) * -1); 
}

