blankocom = {
	categoryMenueTimer: 0,
	toggleCategoryMenue: function(elm) {
		if($('#newInstanceTypeSelect').hasClass('hide')) {
			blankocom.showMenue(elm);
		} else {
			blankocom.hideMenue(elm);
		}
	},
	
	showMenue: function(elm) {
		$('#newInstanceTypeSelect').removeClass('hide');
		$('#newInstanceTypeSelect').bind('mouseover', function() {
			window.clearTimeout(blankocom.categoryMenueTimer);
		});
		$('#newInstanceTypeSelect').bind('mouseout', function() {
			window.clearTimeout(blankocom.categoryMenueTimer);
			blankocom.categoryMenueTimer = window.setTimeout("blankocom.hideMenue();", 1500);
		});
		$(elm).bind('mouseout', function() {
			window.clearTimeout(blankocom.categoryMenueTimer);
			blankocom.categoryMenueTimer = window.setTimeout("blankocom.hideMenue();", 1500);
		});
		var items = 0;
		$('#newInstanceTypeSelect').find('li').each(function() {
			items++;
		});
		var lines  = Math.ceil(items / 2);
		var height = 299 - (lines * 22);
		height     = (lines > 1) ? height-lines : height;
		$('#newInstanceTypeSelect').css('top', height+'px');
	},
	
	hideMenue: function(elm) {
		$('#newInstanceTypeSelect').addClass('hide');
		$(elm).unbind('mouseout');
		$('#newInstanceTypeSelect').unbind('mouseover');
		$('#newInstanceTypeSelect').unbind('mouseout');
		window.clearTimeout(blankocom.categoryMenueTimer);
	},
	
	viewportwidth: function() {
        var viewportwidth;
        if(typeof window.innerWidth != 'undefined') {
            viewportwidth = window.innerWidth;
        }
        else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
            viewportwidth = document.documentElement.clientWidth;
        } else {
            viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
        }
        return viewportwidth;
	},
	
	viewportheight: function() {
        var viewportheight;
        if(typeof window.innerWidth != 'undefined') {
            viewportheight = window.innerHeight;
        }
        else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
            viewportheight = document.documentElement.clientHeight;
        } else {
            viewportheight = document.getElementsByTagName('body')[0].clientHeight;
        }
        return viewportheight;
	},
	
	toggleOverlay: function() {
	    var layer  = $('#overlay');
	    var global = $('#global');
	    if(global.css('display') == 'none') {
	        global.css('position', 'fixed');
	        var top = blankocom.viewportheight() / 2 - parseInt(global.css('height')) / 2;
	        if(top < 0 || (top+parseInt(global.css('height'))) > blankocom.viewportheight()) {
	            global.css('position', 'absolute');
	            top = '150px';
	        } else {
	            top = top+'px';
	        }
	        if($.browser.opera) {
	            global.css('position', 'absolute');
	            top = '150px';
	        }
	        global.css('top', top);
	        //layer.fadeIn('normal');
		layer.show();
	    } else {
	       // layer.fadeOut('normal');
	       layer.hide();
	    }
	}
};

blankocom.article = {
    checkForCommentReport: function(member) {
        var hash = window.location.hash;
        if((hash.split('_'))[0] == "#report") {
        	if(member) {
				var commentID = (hash.split('_'))[1];
				global.mixxtbar.feedback.contentMarkerOpen('{"type":"custom.comment","reference":"'+commentID+'"}');
			} else {
				window.location.href = 'http://' + window.location.host + "/networks/networklogin?redirect=" + escape(window.location.pathname + window.location.hash);
			}
        }
    },
    autoSubmit: function(elm) {
        $(elm).parents('form').submit();
        /*var form = $('#articleSortForm');
        $('#articleSortForm').parents('form').submit();
        form.submit();*/
    }
};

radiopsr = {
    itemsCategory: function(elm) {
        $('#SuperArrowIcon').remove();
        
        $(elm).prepend('<img src="/images/icons/arrow.png" alt="icon" id="SuperArrowIcon" style="vertical-align:top;margin-right:2px;" />');
        $("#SuperArrowIcon").fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeIn(200)
                            .fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200).fadeIn(200).fadeOut(200)
                            .fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200);
    }
}

$(function(){
	if(typeof(global.mixxtbar) != 'undefined') {
		var oldMsgFunc = global.mixxtbar.messages.switchMessageCenter;
		global.mixxtbar.messages.switchMessageCenter = function(e1, e2, e3, e4) {
		    blankocom.toggleOverlay();
		    oldMsgFunc(e1, e2, e3, e4);
		};
		var oldSetFunc = global.mixxtbar.settings.switchSettings;
		global.mixxtbar.settings.switchSettings = function(e1) {
		    blankocom.toggleOverlay();
		    oldSetFunc(e1);
		};
	}
	
	
	$('.main_navigation ul').children('li').hover(function(){
			$(this).addClass('hover');
	}, function(){
			$(this).removeClass('hover');
	});
});

