var currentmenu = "";
var currentMenuItem;

var menu1bool;
var menu2bool;

function clickMenu(obj, menuname){
	var h = 0;
	if(currentmenu==menuname){
		jQuery(obj).removeClass('selectedMenuItem');
		currentmenu = "";
		h = 110;
	}else{
		h = 110 - jQuery("#"+menuname).height();	
		if(currentmenu!=""){
			jQuery("#"+currentmenu). animate({ top: 110}, 500, 'easeOutCubic');
			jQuery(currentMenuItem).removeClass('selectedMenuItem');
		}
		currentmenu = menuname;
		
		jQuery(obj).addClass('selectedMenuItem');
	}
	currentMenuItem = obj;
	jQuery("#"+menuname). animate({ top: h}, 500, 'easeOutCubic');
}


function openMenu1(){
	h = 110 - jQuery("#menumenu").height();
	jQuery("#menumenu").stop().animate({ top: h}, 800, 'easeOutCubic');
	jQuery("#menuitem1").addClass('selectedMenuItem');
	menu1bool = true;
}

function closeMenu1(){
	menu1bool = false;
	window.setTimeout('finalCloseMenu1()', 1000);
}

function finalCloseMenu1(){
	if(menu1bool == false){
		h = 110;
		jQuery("#menumenu").stop().animate({ top: h}, 800, 'easeOutCubic');
		jQuery("#menuitem1").removeClass('selectedMenuItem');
	}
}

function openMenu2(){
	h = 110 - jQuery("#newsmenu").height();
	jQuery("#newsmenu").stop().animate({ top: h}, 800, 'easeOutCubic');
	jQuery("#menuitem2").addClass('selectedMenuItem');
	menu2bool = true;
}

function closeMenu2(){
	menu2bool = false;
	window.setTimeout('finalCloseMenu2()', 1000);
}

function finalCloseMenu2(){
	if(menu2bool == false){
		h = 110;
		jQuery("#newsmenu").stop().animate({ top: h}, 800, 'easeOutCubic');
		jQuery("#menuitem2").removeClass('selectedMenuItem');
	}
}

function showiframe(){
	jQuery("#popupframe").fadeIn("fast");
}

function setPopupSize(w){
	jQuery("#popupframe").width(w);
	jQuery("#popupframe").css("margin-left",-w/2);
	jQuery("#popupiframe").attr("width", w);
}

function changepopup(file){
	
	if(file){
	jQuery("#popupiframe").attr( "src", file);
	jQuery("#popupiframe").ready(function() {
		jQuery("#popupframe").fadeIn("normal");
	});
	/*
		if(jQuery("#popupframe").is(':visible')){
			jQuery("#popupframe").fadeOut("fast",function(){
				jQuery("#popupiframe").attr( "src", file);
				jQuery("#popupiframe").ready(function() {
					jQuery("#popupframe").fadeIn("fast");
				});
			});
		}else{
			jQuery("#popupiframe").attr( "src", file);
			jQuery("#popupiframe").ready(function() {
				jQuery("#popupframe").fadeIn("fast");
			});

			//document.getElementById("popupiframe").src = file;
			
		}
		/**/
	}else{
		jQuery("#popupframe").fadeOut("normal");
	}
}
