function getNav(_obj)
{

    if (_obj) {
        var n_id = $(_obj).attr('id');
		$.ajax({
		type: "get",
		url : "/plus/get_nav.php?action=set&nav_id="+n_id+"&v="+Math.random(),
		success: function(json){
			//alert(json);
		}
		});
		return;
    }else{

			var referrer = document.referrer;
			if(referrer == ""){
				var url = document.location.href;

				var strs= new Array();

				strs=url.split("/");
				var page = strs[strs.length-1];

				var tArr=new Array();
				tArr["overview.html"]="aa";
				tArr["zhici.html"]="bb";

				tArr["event.html"]="cc";
				tArr["zc_intro.html"]="dd";
				tArr["list.php?tid=90"]="ll";
				tArr["list.php?tid=45"]="mm";
				tArr["culture.html"]="pp";


				tArr["list.php?tid=46"]="46";
				tArr["list.php?tid=47"]="47";
				tArr["list.php?tid=48"]="48";
				tArr["list.php?tid=49"]="49";
				tArr["list.php?tid=50"]="50";
				tArr["list.php?tid=51"]="51";
				tArr["list.php?tid=52"]="52";
				tArr["list.php?tid=53"]="53";
				tArr["list.php?tid=54"]="54";
				tArr["list.php?tid=55"]="55";


				tArr["view.php?aid=26"]="aid_26";
				tArr["view.php?aid=27"]="aid_27";
				tArr["view.php?aid=28"]="aid_28";
				tArr["view.php?aid=29"]="aid_29";
				tArr["view.php?aid=30"]="aid_30";
				tArr["view.php?aid=31"]="aid_31";
				tArr["view.php?aid=32"]="aid_32";
				tArr["view.php?aid=33"]="aid_33";
				tArr["view.php?aid=34"]="aid_34";
				tArr["view.php?aid=35"]="aid_35";
				tArr["view.php?aid=36"]="aid_36";
				tArr["view.php?aid=37"]="aid_37";

				tArr["rencai_concept.html"]="rc_a";
				tArr["list.php?tid=83"]="rc_b";
				tArr["list.php?tid=82"]="rc_c";
				tArr["send_resume.html"]="rc_d";
				tArr["list.php?tid=58"]="rc_e";

				tArr["view.php?aid=51"]="c_51";
				tArr["view.php?aid=54"]="c_54";

				var nav_id = tArr[page];

				$('#'+nav_id).addClass('current_nav');
				if(nav_id == 'dd' || nav_id == 'ee'  || nav_id == 'ff'  || nav_id == 'gg'  || nav_id == 'hh'){
					showSubMenu('c_1');
					return;
				}

			}else{
				$.ajax({
				type: "get",
				url : "/plus/get_nav.php?action=get"+"&v="+Math.random(),
				success: function(nav_id){

					if(nav_id){

						$('#'+nav_id).addClass('current_nav');
						if(nav_id == 'dd' || nav_id == 'ee'  || nav_id == 'ff'  || nav_id == 'gg'  || nav_id == 'hh'){
							showSubMenu('c_1');
							return;
						}
					}
				}
				});
		}

	}
}

function getInquiryNav(_obj)
{
    if (_obj) {
        var n_id = $(_obj).attr('id');
        $.cookie('qnav_id', n_id);
    }
    if ($.cookie('qnav_id')) {
		$('#'+$.cookie('qnav_id')).addClass('current_nav');
    } else {
		$('#'+$.cookie('qnav_id')).addClass('current_nav');
    }
}
$(function(){getNav();getInquiryNav();$('#left_main a').click(function(){getNav(this)});$('.click_id a').click(function(){getInquiryNav(this)});});

jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        var options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        var path = options.path ? '; path=' + options.path : '';
        var domain = options.domain ? '; domain=' + options.domain : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

function showSubMenu(id)
{

	if(	document.getElementById(id).style.display == "block")
	document.getElementById(id).style.display = "none";
	else {
		document.getElementById(id).style.display = "block";

	}
}
