$(function() {

    // classesNav ////////////////////////////////////////////////////////////////
    var classesNav = $('#about_classes_nav', '#sub_inside');
    classesNav.find('a').click(function() {
        $('#sub_inside div').hide();
        classesNav.find('a').removeClass('on');
        $(this).addClass('on');
        var theDiv = $(this).attr('href');  
        $(theDiv).fadeIn();
        return false;
    });    
    


    // screenshot ////////////////////////////////////////////////////////////////
    var bigImage = $('#big_image img', '#screenshot');
    $('#thumbs li').find('a').click(function() {
	var newImage = $(this).attr('href');
	bigImage.attr('src', newImage);
	return false;
    });



    // left menu ////////////////////////////////////////////////////////////////
    var curLoc = window.location.href.toLowerCase();
    var op = getParam("op");

	// news
	if (curLoc.indexOf("news.og") > -1) { 
	    if( op == "") {
	        $('#notices', 'div.banner').attr('id','notices_on');
	    }
	    else if(op == "notice" || op == "nview") {
	        $('#notices', 'div.banner').attr('id','notices_on');
	    }
	    else if(op == "update" || op == "uview") {
	        $('#updates', 'div.banner').attr('id','updates_on');
	    }
	    else if(op == "event" || op == "eview") {
	        $('#events', 'div.banner').attr('id','events_on');
	    }
	}
	
	// about
	if (curLoc.indexOf("about.og") > -1) { 
	    if( op == "") {
	        $('#introduction', 'div.banner').attr('id','introduction_on');
	    }
	    else if(op == "intro") {
	        $('#introduction', 'div.banner').attr('id','introduction_on');
	    }
	    else if(op == "story") {
	        $('#story', 'div.banner').attr('id','story_on');
	    }
	    else if(op == "why") {
	        $('#features', 'div.banner').attr('id','features_on');
	    }
	    else if(op == "class") {
	        $('#classes', 'div.banner').attr('id','classes_on');
	    }
	    else if(op == "mode") {
	        $('#modes', 'div.banner').attr('id','modes_on');
	    }
	}
	
	// guide
	if (curLoc.indexOf("guide.og") > -1) { 
	    if( op == "") {
	        $('#installation', 'div.banner').attr('id','installation_on');
	    }
	    else if(op == "install") {
	        $('#installation', 'div.banner').attr('id','installation_on');
	    }
	    else if(op == "control") {
	        $('#controlkeys', 'div.banner').attr('id','controlkeys_on');
	    }
	    else if(op.indexOf("interface") > -1 ) {
	        $('#interface', 'div.banner').attr('id','interface_on');
	    }
	    else if(op == "items") {
	        $('#equipment', 'div.banner').attr('id','equipment_on');
	    }
	    else if(op == "maps") {
	        $('#maps', 'div.banner').attr('id','maps_on');
	    }
	    else if(op == "rankmarks") {
	        $('#rankmarks', 'div.banner').attr('id','rankmarks_on');
	    }
	    else if(op == "rewards") {
	        $('#rewards', 'div.banner').attr('id','rewards_on');
	    }
	}
	
	// items
	if (curLoc.indexOf("items.og") > -1) { 
	    if( op == "") {
	        $('#exocore', 'div.banner').attr('id','exocore_on');
	    }
	    else if(op == "exocore") {
	        $('#exocore', 'div.banner').attr('id','exocore_on');
	    }
	    else if(op == "sacred") {
	        $('#sacred_scroll', 'div.banner').attr('id','sacred_scroll_on');
	    }
	    else if(op == "accessory") {
	        $('#accessory', 'div.banner').attr('id','accessory_on');
	    }
	    else if(op == "appearance") {
	        $('#appearance', 'div.banner').attr('id','appearance_on');
	    }
	    else if(op == "hair") {
	        $('#hairstyle', 'div.banner').attr('id','hairstyle_on');
	    }
	    else if(op == "top") {
	        $('#top', 'div.banner').attr('id','top_on');
	    }
	    else if(op == "bottom") {
	        $('#bottom', 'div.banner').attr('id','bottom_on');
	    }
	}

	// downloads
	if (curLoc.indexOf("downloads.og") > -1) { 
	    if( op == "") {
	        $('#gameclient', 'div.banner').attr('id','gameclient_on');
	    }
	    else if(op == "client") {
	        $('#gameclient', 'div.banner').attr('id','gameclient_on');
	    }
	    else if(op == "wallpaper") {
	        $('#wallpaper', 'div.banner').attr('id','wallpaper_on');
	    }
	    else if(op == "movie") {
	        $('#movies', 'div.banner').attr('id','movies_on');
	    }
	    else if(op == "screenshot") {
	        $('#screenshots', 'div.banner').attr('id','screenshots_on');
	    }
	}

	// community 
	if(curLoc.indexOf("rf.forum") > -1) {
	        $('#forum', 'div.banner').attr('id','forum_on');
	}
	if(curLoc.indexOf("community.og") >-1) {
	    if(op == "ranking") {
	        $('#rankings', 'div.banner').attr('id','rankings_on');
	    }
	    else if(op == "plist" || op == "pview") {
	        $('#poll', 'div.banner').attr('id','poll_on');
	    }
	    else if(op == "fansites" ) {
	        $('#fansites', 'div.banner').attr('id','fansites_on');
	    }
	    else if(op == "advisors" ) {
	        $('#community_advisors', 'div.banner').attr('id','community_advisors_on');
	    }
	}
	
	// support
	if (curLoc.indexOf("support.og") > -1) { 
	    if( op == "") {
	        $('#faqs', 'div.banner').attr('id','faqs_on');
	    }
	    else if(op == "faq") {
	        $('#faqs', 'div.banner').attr('id','faqs_on');
	    }
	    else if(op == "guideline") {
	        $('#guidelines', 'div.banner').attr('id','guidelines_on');
	    }
	    else if(op == "helpdesk") {
	        $('#help_desk', 'div.banner').attr('id','help_desk_on');
	    }
	    else if(op == "saftyguide") {
	        $('#safety_guide', 'div.banner').attr('id','safety_guide_on');
	    }
	}
	
	// billing
	if (curLoc.indexOf("billing.og") > -1) { 
	    if( op == "") {
	        $('#astroshop', 'div.banner').attr('id','astroshop_on');
	    }
	    else if(op == "shop") {
	        $('#astroshop', 'div.banner').attr('id','astroshop_on');
	    }
	    else if(op == "purchase") {
	        $('#mypurchase', 'div.banner').attr('id','mypurchase_on');
	    }
	    else if(op == "used") {
	        $('#astrosused', 'div.banner').attr('id','astrosused_on');
	    }
	    else if(op == "mygift") {
	        $('#mygift', 'div.banner').attr('id','mygift_on');
	    }
	}
	

});


function getParam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}


function getSubMenu(){		
	var curLoc = location.href.toLowerCase();

	var subMenu = "";
	
	if ( curLoc.indexOf("news.og")>-1 ) {
		subMenu = "sub01.swf";
	}
	else if ( curLoc.indexOf("about.og")>-1 ) {
		subMenu = "sub02.swf";
	}
	else if ( curLoc.indexOf("guide.og")>-1 ) {
		subMenu = "sub03.swf";
	}
	else if ( curLoc.indexOf("items.og")>-1 ) {
		subMenu = "sub04.swf";
	}
	else if ( curLoc.indexOf("downloads.og")>-1 ) {
		subMenu = "sub05.swf";
	}
	else if ( curLoc.indexOf("community.og")>-1 ) {
		subMenu = "sub06.swf";
	}
	else if ( curLoc.indexOf("support.og")>-1 ) {
		subMenu = "sub07.swf";
	}
	else if ( curLoc.indexOf("billing.og")>-1 ) {
		subMenu = "sub09.swf";
	}	
	else {
		subMenu = "sub08.swf";
	}
	return subMenu;
}

