// JavaScript Document
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        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;
    }
};

var Pji=0;
if ($.cookie("Pcookie")=="true"){
	//
}else{
	$.cookie("Pcookie","true",10);
	
	
	
	
	
	for (var i=0;i<pcarray.length;i++){
		
		
		if(pcarray[i][2]==0){
			$.cookie("Pcookie"+i,1,10);
		}else{
			$.cookie("Pcookie"+i,0,10);
		}
	}
}


function ChildNode(pid){
	for (var i=0;i<pcarray.length;i++){
		if(pcarray[i][2]==pid){
			return true;
		}
	}
	return false;
}

function dpclass(pid,ProURL,EN){
	Pji+=1;
	for (var i=0;i<pcarray.length;i++){
		if(pcarray[i][2]==pid){
			document.write("<div class='PClassJI"+Pji+"'><a href='"+ProURL+"?ProClassID="+pcarray[i][0]+"' Tid='"+i+"' class='EE' >"+pcarray[i][EN]+"</a></div>");
			if($.cookie("Pcookie"+i)==1){
				document.write("<div><div  id='PclassID"+i+"'>");
			}else{
				document.write("<div><div  id='PclassID"+i+"' style='display:none;'>");
			}
			dpclass(pcarray[i][0],ProURL,EN);
			document.write("</div></div>");
			//alert(pcarray[i][0]);
		}
		//alert(pcarray[i][1]);
	}
	Pji-=1;
}



$(document).ready(function(){
	$(".EE").click(function(){

		i=$(this).attr("Tid");
		pid=pcarray[i][0];
		if(ChildNode(pid)){ 
			if($.cookie("Pcookie"+i)==1){
				$.cookie("Pcookie"+i,0,10);
			}else{
				$.cookie("Pcookie"+i,1,10);
			}
			for (var i=0;i<pcarray.length;i++){
				if($.cookie("Pcookie"+i)==1){
					$("#PclassID"+i).show();
				}else{
					$("#PclassID"+i).hide();
				}
			}
			return false;
		}
	});
	
});


