$(document).ready(
function(){
        var tab = "images";
        var GET = new Array();
        if (location.search.length > 0)
        {
            var get_param_str = location.search.substring(1, location.search.length);
            var get_params = get_param_str.split("&");
            for (i = 0; i < get_params.length; i++)
            {
               var key_value = get_params[i].split("=");
               if (key_value.length == 2)
               {
                  var key = key_value[0];
                  var value = key_value[1];
                  GET[key] = value;
               }
            }
            if ((GET["show"] != "") && ((GET["show"] == "images") || (GET["show"] == "video") || (GET["show"] == "audio") || (GET["show"] == "text") || (GET["show"] == "galleries")))
            {
                tab = GET["show"];
            }
        }
    
	//alert(tab);
	
	// jQuery("#boxImageFlowStart").load("artworksflow.php?tab=images&flow=randomartworks");
	$("#randomartworks").click(
	function(){
	$("#boxImageFlowStart").load("artworksflow.php?tab="+tab+"&flow=randomartworks&div=FlowHome",
	function() { instance_flow(1); });
        $("#randomartworks").attr({'class': "containermenufirst-a"});
        $("#toprated").attr({'class': "containermenu"});
        $("#recentartworks").attr({'class': "containermenu"});
	})
        .click();
        
	$("#toprated").click(
	function(){
	$("#boxImageFlowStart").load("artworksflow.php?tab="+tab+"&flow=toprated&div=FlowHome",
	function() { instance_flow(0); });
        $("#randomartworks").attr({'class': "containermenufirst"});
        $("#toprated").attr({'class': "containermenu-a"});
        $("#recentartworks").attr({'class': "containermenu"});
	});
        
	$("#recentartworks").click(
	function(){
	$("#boxImageFlowStart").load("artworksflow.php?tab="+tab+"&flow=recentartworks&div=FlowHome",
	function() { instance_flow(0); });
        $("#randomartworks").attr({'class': "containermenufirst"});
        $("#toprated").attr({'class': "containermenu"});
        $("#recentartworks").attr({'class': "containermenu-a"});
	});
        
	$("#randomartworks_a").click(
	function(){
	$("#profilflow").load("artworksflow.php?tab="+tab+"&flow=randomartworks&div=FlowWide",
	function() { instance_flow(1); });
        $("#randomartworks_a").attr({'class': "containermenufirst-a"});
        $("#toprated_a").attr({'class': "containermenu"});
        $("#recentartworks_a").attr({'class': "containermenu"});
	})
        .click();
        
	$("#toprated_a").click(
	function(){
	$("#profilflow").load("artworksflow.php?tab="+tab+"&flow=toprated&div=FlowWide",
	function() { instance_flow(0); });
        $("#randomartworks_a").attr({'class': "containermenufirst"});
        $("#toprated_a").attr({'class': "containermenu-a"});
        $("#recentartworks_a").attr({'class': "containermenu"});
	});
        
	$("#recentartworks_a").click(
	function(){
	$("#profilflow").load("artworksflow.php?tab="+tab+"&flow=recentartworks&div=FlowWide",
	function() { instance_flow(0); });
        $("#randomartworks_a").attr({'class': "containermenufirst"});
        $("#toprated_a").attr({'class': "containermenu"});
        $("#recentartworks_a").attr({'class': "containermenu-a"});
	});
        
        $("#profiltabs > ul > li > a").click(
        function(){
            var flow = $(this).parent().attr('id');
            $("#profilflow").load("artworksflow.php?tab="+tab+"&flow="+flow+"&div=FlowWide",
            function() { instance_flow(1); });
            if ($(this).parent().attr('class') == "first_p")
            {
                $(this).parent().attr({'class': "firstcurrent_p"});
                $(this).parent().siblings(".middletabcurrent_p").attr({'class': "middletab_p"});
                
                $(this).parent().siblings(".lastcurrent_p_1").attr({'class': "last_p_1"});
                $(this).parent().siblings(".lastcurrent_p_2").attr({'class': "last_p_2"});
                $(this).parent().siblings(".lastcurrent_p_3").attr({'class': "last_p_3"});
                $(this).parent().siblings(".lastcurrent_p_4").attr({'class': "last_p_4"});
                $(this).parent().siblings(".lastcurrent_p_5").attr({'class': "last_p_5"});                
            }
            else if ($(this).parent().attr('class') == "middletab_p")
            {
                $(this).parent().attr({'class': "middletabcurrent_p"});
                $(this).parent().siblings(".firstcurrent_p").attr({'class': "first_p"});
                
                $(this).parent().siblings(".lastcurrent_p_1").attr({'class': "last_p_1"});
                $(this).parent().siblings(".lastcurrent_p_2").attr({'class': "last_p_2"});
                $(this).parent().siblings(".lastcurrent_p_3").attr({'class': "last_p_3"});
                $(this).parent().siblings(".lastcurrent_p_4").attr({'class': "last_p_4"});
                $(this).parent().siblings(".lastcurrent_p_5").attr({'class': "last_p_5"});
                $(this).parent().siblings(".middletabcurrent_p").attr({'class': "middletab_p"});
            }
            else if ($(this).parent().attr('class').substring(0,6) == "last_p" && $(this).parent().attr('id') != "all")
            {
                var id = $(this).parent().attr('class').substring(7,8);
                $(this).parent().attr({'class': "lastcurrent_p_"+id});
                $(this).parent().siblings(".firstcurrent_p").attr({'class': "first_p"});
                $(this).parent().siblings(".middletabcurrent_p").attr({'class': "middletab_p"});
            }
        });
        $("#profiltabs > ul > .first_p > a").click();
        $("#profiltabs > ul > .lastcurrent_p_1 > a").click();
});