// JavaScript Document

/////////////////////////////////////////////////////////////////////////////
//PJS
var PJS = new Object();
PJS.VERSION = "1.0.0.1";
PJS.AUTHOR = "jianyu";
PJS.COPYRIGHT = "PPEMI.COM";
PJS.BASE_URL = BASE_URL;
PJS.USER_AGENT = window.navigator.userAgent.toLowerCase();
PJS.IS_OPERA = (PJS.USER_AGENT.indexOf("opera")!=-1); 
PJS.IS_IE = ((PJS.USER_AGENT.indexOf("msie")!=-1)&&((document.all&&!PJS.IS_OPERA))); 
PJS.IS_MOZILLA = (PJS.USER_AGENT.indexOf("gecko")!=-1); //is that right?
PJS.IS_NS = (navigator.appName == "Netscape") ? 1 : 0;
/////////////////////////////////////////////////////////////////////////////
//METHODS
PJS.$ = function(el){
	if(document.getElementById){
		return document.getElementById(el);
	}else if(document.layers){
		document.layers[el];
	}else{
		return eval('document.all.' + el);
	};
};
PJS.refresh = function(){
	document.location.href = document.location.href;
};
PJS.goto = function(url){
	document.location.href = PJS.BASE_URL + url;
};
PJS.redirect = function(url){
	document.location.href = url;
};
PJS.ltrim = function(str){
	return str.replace(/(^[\s]*)/g,"");
};
PJS.rtrim = function(str){
	return str.replace(/([\s]*$)/g,"");
};
PJS.trim = function(str){
	return str.replace(/(^[\s]*)|([\s]*$)/g,"");
};
PJS.inArray = function(valueToCheck,list){
	for(var i=0; i<list.length; i++){
		if(this[i] == valueToCheck ) return true;
	}
	return false;
};
PJS.rand = function(p,a,b){
	p = isUndefined(p) ? "" : p;
	if(a){
		b = b ? b:0;
		return p + "_" + Math.floor(Math.random()*a + b);
	} else {
		a = new Date();
		return p + "_" + a.getTime();
	}
};
//translate string to unicode list
PJS.encodeToArray = function(str){
	if(string == null || str.length == 0){
		return null;
	}
	var strlen = str.length;
	var strs = Array();
	for(var i=0; i<strlen; i++){
		strs[i] = str.charCodeAt(i);
	}
	
	return strs;
};
//translate unicode list to string 
PJS.decodeToString = function(strs){
	if(strs == null || strs.length == 0){
		return null;
	}
	var str = '';
	var listlen = strs.length;
	for(var i=0; i<listlen; i++){
		str += String.fromCharCode(strs[i]);
	}
	return str;
};
PJS.checkEmail = function(val){
	var emailPattern = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
	if(emailPattern.test(val) == false){
		return false;
	} else {
		return true;
	}
};
PJS.getCookie = function(name){
	var pattern = name + "=";
	if(document.cookie.length > 0){
		var offset = document.cookie.indexOf(pattern);
		if(offset != -1){
			offset += pattern.length;
			sEnd = document.cookie.indexOf(";", offset);
			if(sEnd == -1) sEnd = document.cookie.length;
			return unescape(document.cookie.substring(offset, sEnd));
		}
	}
	return "";
};
PJS.addLoadEvent = function(func){
	var oldonload = window.onload;
	if(typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){oldonload();func();}
	}
};
PJS.addLoadScript = function(){
	var a = arguments;
	if(a.length == 0 ) return;
	var func = function(){
		for(var i=0; i<a.length; i++){
			var b = a[i];
			if(!b || b.length == 0 ) continue;
			if(b.indexOf('js/') == -1 ) b = 'js/' + b;
			if(b.indexOf('.js') == -1 ) b += '.js';
			PJS.addScriptAlone(b);
		}
	};
	PJS.addLoadEvent(func);
};
PJS.include = function(sFileName){
	var objHead = document.getElementsByTagName('head');
	var objScript = document.createElement('script');
	objScript.type = 'text/javascript';
	objScript.src = PJS.BASE_URL+sFileName;
	objHead[0].appendChild(objScript);
};
PJS.load = function(sFileName){
	var objHead = document.getElementsByTagName('head');
	var objScript = document.createElement('script');
	objScript.type = 'text/javascript';
	objScript.src = PJS.BASE_URL+sFileName;
	objHead[0].appendChild(objScript);
};
PJS.loads = function(ss){
	ss.each(function(){});
};
PJS.addScript = function(sFileName,trigger){
	var objHead = document.getElementsByTagName('head');
	var objScript = document.createElement('script');
	objScript.type = 'text/javascript';
	objScript.src = PJS.BASE_URL+sFileName;
	if(trigger){
		if(PJS.IS_IE){
			objScript.onreadystatechange = function(){
				if(objScript.readyState == 'loaded' || objScript.readyState == 'complete'){
					if(typeof(trigger) == "function"){
						trigger();
					} else {
						eval(trigger);
					}
				}
			};
		} else {
			objScript.onload = function(){
				if(typeof(trigger) == "function"){
					trigger();
				} else {
					eval(trigger);
				}
			};
		}
	}
	objHead[0].appendChild(objScript);
};
PJS.addScriptAlone = function(sFileName,trigger){
	var sexist = false;
	var a = document.getElementsByTagName('script');
	for(var i=0; i<a.length; i++){
		if(a[i].src == sFileName){
			sexist = true;
		}
	}
	if(sexist == false){
		PJS.addScript(sFileName,trigger);
	}
};
PJS.addStyle = function(sFileName){
	var objHead = document.getElementsByTagName('head');
	var objLink = document.createElement('link');
	objLink.rel = 'stylesheet';
	objLink.type = 'text/css';
	objLink.href = PJS.BASE_URL+sFileName;
	objHead[0].appendChild(objLink);
};
PJS.createStyle = function(sFileName){
	var objLink = document.createElement('link');
	objLink.rel = 'stylesheet';
	objLink.type = 'text/css';
	objLink.href = PJS.BASE_URL+sFileName;
	return objLink;
};
PJS.removeStyle = function(sFileName){
	var a = document.getElementsByTagName('link');
	for(var i=0; i<a.length; i++){
		if(a[i].getAttribute('href').indexOf(sFileName) > -1 || a[i].getAttribute('href') == sFileName){
			a[i].parentNode.removeChild(a[i]);
		}
	}
};
PJS.replaceStyle = function(sFileName){
	var a = document.getElementsByTagName('link');
	for(var i=0; i<a.length; i++){
		if(a[i].getAttribute('href').indexOf(sFileName) > -1 || a[i].getAttribute('href') == sFileName){
			a[i].parentNode.replaceChild(PJS.createStyle(sFileName),a[i]);
		}
	}
};
PJS.fixEvent = function(evt){
	var evtx = (typeof evt == "undefined") ? window.event : evt;
	return evtx;
};
PJS.srcElement = function(evt){
	if(typeof evt == "undefined" ) evt = window.event;
	var src = document.all ? evt.srcElement : evt.target;
	return src;
};
PJS.stopEvent = function(evt){
	if(PJS.IS_IE){
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else {
		evt.preventDefault();
		evt.stopPropagation();
	}
};
PJS.attachEvent = function(obj,xEvent,handler){
	if(PJS.IS_IE){
		obj.attachEvent("on"+xEvent,handler);
	} else {
		obj.addEventListener(xEvent,handler,false);
	}
	if(xEvent == 'click' ) obj.style.cursor = "pointer";
};
PJS.detachEvent = function(obj,xEvent,handler){
	if(obj.removeEventListener){
		obj.removeEventListener(xEvent,handler,false);
	} else if(obj.detachEvent){
		try {
			obj.detachEvent('on'+xEvent,handler);
		} catch(e){}
	}
};
PJS.addEvent = function(obj,xEvent,handler){
	if(obj.addEventListener){
		obj.addEventListener(xEvent,handler,false);
	} else if(obj.attachEvent){
		obj.attachEvent("on" + xEvent,handler);
	} else {
		el["on"+xEvent] = handler;
	}
};
PJS.removeEvent = function(obj,xEvent,handler){
	if(obj.removeEventListener){
		obj.removeEventListener(xEvent,handler,false);
	} else if(obj.detachEvent){
		try {
			obj.detachEvent('on'+xEvent,handler);
		} catch(e){}
	}
};
PJS.isChild = function(p,d,s){
	if(!d){
		d = PJS.srcElement();
	}
	var el = d;
	while((el = el.parentNode) != null){
		if(el.tagName.toLowerCase() == "body"){
			return false;
		}
		if(el == p){
			return true;
		} else if(!s && el == s){
			return false;
		}
	}
	return false;
};
PJS.getParent = function(d,s){
	if(!d ) return null;
	var el = d;
	while((el = el.parentNode) != null){
		if(el.tagName.toLowerCase() == "body"){
			return null;
		}
		if(typeof(s) == "string" && el.tagName.toLowerCase() == s.toLowerCase()){
			return el;
		} else if(s && el == s){
			return el;
		}
	}
	return null;
};
PJS.getElements = function(p,t,f){
	if($E(p)){
		return;
	}
	var a = $E(p).getElementsByTagName(t);
	var b = [];
	for(var i=0; i<a.length; i++){
		if(a[i].className.indexOf(f) > -1 || a[i].id.indexOf(f) > -1){
			b.push(a[i]);
		}
	}
	return b;
};
PJS.getElementsC = function(p,c,f){
	if($E(p)){
		return;
	}
	var a = $E(p).getElementsByClassName(c);
	var b = [];
	for(var i=0; i<a.length; i++){
		if(a[i].tagName.indexOf(f) > -1 || a[i].id.indexOf(f) > -1){
			b.push(a[i]);
		}
	}
	return b;
};
PJS.getElementsD = function(t,f){
	return PJS.getElements(document,t,f);
};
PJS.createElement = function(parent,tag,id){
	if(typeof(parent) == "string"){
		parent = PJS.$(parent);
	}
	var elem = document.createElement(tag);
	elem.setAttribute('id',id);
	if(parent){
		parent.appendChild(elem);
	}
	return elem;
};
PJS.appendElement = function(parent,tag,id){
	if(typeof(parent) == "string"){
		parent = PJS.$(parent);
	}
	var elem = document.createElement(tag);
	elem.setAttribute('id',id);
	if(parent){
		parent.appendChild(elem);
	}
	return elem;
};
PJS.insertElement = function(before,tag,id){
	if(typeof(before) == "string"){
		before = PJS.$(before);
	}
	var elem = document.createElement(tag);
	elem.setAttribute('id',id);
	before.parentNode.insertBefore(elem,before);//objSibling
	return elem;
};
PJS.insertElementAfter = function(after,tag,id){
	if(typeof(after) == "string"){
		after = PJS.$(after);
	}
	var elem = document.createElement(tag);
	elem.setAttribute('id',id);
	after.parentNode.insertBefore(elem,after.nextSibling);//objSibling.nextSibling
	return elem;
};
PJS.insertAfter = function(after,tag,id){
	PJS.insertElementAfter(after,tag,id);
};
PJS.createInput = function(type,name,id){
	var elem;
	if(PJS.IS_IE && !window.addEventListener){
		if(isUndefined(id)){
			elem = document.createElement('<input type="'+type+'" name="'+name+'">');
		} else {
			elem = document.createElement('<input type="'+type+'" id="'+id+'" name="'+name+'">');
		}
	} else {
		elem = document.createElement('INPUT');
		elem.setAttribute('type',type);
		elem.setAttribute('name',name);
		if(isUndefined(id) == false){
			elem.setAttribute('id',id);
		}
	}
	return elem;
};
PJS.appendInput = function(parent,type,name,id){
	if(typeof(parent) == "string"){
		parent = PJS.$(parent);
	}
	var elem = PJS.createInput(type,name,id);
	if(parent && elem){
		parent.appendChild(elem);
	}
	return elem;
};
PJS.insertInput = function(sibling,type,name,id){
	if(typeof(sibling) == "string"){
		sibling = PJS.$(sibling);
	}
	var elem = PJS.createInput(type,name,id);
	if(elem && sibling && sibling.parentNode){
		sibling.parentNode.insertBefore(elem,sibling);//objSibling
	}
	return elem;
};
PJS.insertInputBefore = function(before,type,name,id){
	if(typeof(before) == "string"){
		before = PJS.$(before);
	}
	var elem = PJS.createInput(type,name,id);
	if(elem && before && before.parentNode){
		before.parentNode.insertBefore(elem,before);//objSibling
	}
	return elem;
};
PJS.insertInputAfter = function(after,type,name,id){
	if(typeof(after) == "string"){
		after = PJS.$(after);
	}
	var elem = PJS.createInput(type,name,id);
	if(elem && after && after.parentNode){
		after.parentNode.insertBefore(elem,after.nextSibling);//objSibling.nextSibling
	}
	return elem;
};
PJS.appendDIV = function(pObj,divId,className,innerHTML){
	var divObj = document.createElement("DIV");
	if(className) divObj.className = className;
	//divObj.appendChild(document.createTextNode(text));
	if(PJS.IS_IE){
		divObj.id = divId;
	} else {
		divObj.setAttribute("id",divId);
	}
	with(divObj.style){
		//display = 'none';
		position = 'absolute';
	}
	divObj.innerHTML = innerHTML;
	pObj.appendChild(divObj);
	return divObj;
};
PJS.appendDIVHTML = function(divId,innerHTML,className){
	var divObj = document.createElement('DIV');
	
	if(PJS.IS_IE){
		divObj.id = divId;
	} else {
		divObj.setAttribute("id",divId);
	}
	if(className) divObj.className = className;
	with(divObj.style){
		display = 'none';
		position = 'absolute';
	}
	divObj.innerHTML = innerHTML;
	document.body.appendChild(divObj);
	return divObj;
};
PJS.show = function(el){
	if($(el)){
		$(el).style.display = '';
	}
};
PJS.showD = function(el,time){
	if(!time ) time = 200;
	setTimeout("PJS.show("+el+")",time);
};
PJS.showE = function(el){
	if(el && el.style ) el.style.display = "block";
};
PJS.showED = function(el,time){
	if(!time ) time = 200;
	setTimeout(function(){PJS.showE(el);},time);
};
PJS.shows = function(){
	for(var i=0; i<arguments.length; i++){
		if($(arguments[i])) $(arguments[i]).style.display = '';
	}
};
PJS.hide = function(el){
	if($(el)){
		$(el).style.display = 'none';
	}
};
PJS.hideD = function(el,time){
	if(!time ) time = 200;
	setTimeout("PJS.hide("+el+")",time);
};
PJS.hideE = function(el){
	if(el && el.style ) el.style.display = 'none';
};
PJS.hideED = function(el,time){
	if(!time ) time = 200;
	setTimeout(function(){PJS.hideE(el);},time);
};
PJS.hides = function(){
	for(var i=0; i<arguments.length; i++){
		if($(arguments[i])) $(arguments[i]).style.display = 'none';
	}
};
PJS.shChb = function(el,chb){
	if(chb.checked == true){
		$(el).style.display = '';
	} else {
		$(el).style.display = 'none';
	}
};
PJS.isEditable = function(el){
	if(el.getAttribute("editable")){
		return true;
	}
	return false;
};
PJS.find = function(el,what){
	el = PJS.$(el)[what];
	while(el.nodeType != 1){
		el = el[what];
	}
	return el;
};
PJS.hasAttr = function(el,k){
	if(el.getAttribute(k)){
		return true;
	}
	return false;
};
PJS.getAttr = function(el,k,s){
	if(el && el.getAttribute && el.getAttribute(k)){
		var v = el.getAttribute(k);
		if(s && v.indexOf(s) > -1){
			return v.substring(v.indexOf(s)+1);
		}
		return v;
	}
	return -1;
};
PJS.setAttr = function(el,k,v){
	if(el && el.setAttribute){
		el.setAttribute(k,v);
	}
};
PJS.addClass = function(el,className){
	PJS.removeClass(el,className);
	if(el && el.className){
		el.className += " " + className;
	} else if(el){
		el.className = className;
	}
};
PJS.noClass = function(el){
	if(!(el && el.className)){
		return true;
	}
	return false;
};
PJS.hasClass = function(el,className,t){
	if(!(el && el.className)){
		return;
	}
	if(isUndefined(t)){
		t = 0;
	}
	if(el.className == className){
		return true;
	}
	var cls = el.className.split(" ");
	var ar = new Array();
	for(var i = cls.length; i > 0;){
		--i;
		for(var j=0; j<className.length; j++){
			if(cls[i] == className[j] && t == 0){
				return true;
			} else if(cls[i].indexOf(className[j]) > -1 && t == 1){
				return true;
			}
		}
	}
	return false;
};
PJS.hasClasses = function(el){
	if(!(el && el.className) || arguments.length <= 1){
		return false;
	}
	var classNames = new Array();
	for(var i=1; i<arguments.length; i++){
		classNames.push(arguments[i]);
	}
	var cls = el.className.split(" ");
	var ar = new Array();
	for(var i = cls.length; i > 0;){
		if(PJS.inArray(cls[--i],classNames)){
			return true;
		}
	}
	return false;
};
PJS.removeClass = function(el,className){
	if(!(el && el.className)){
		return;
	}
	var cls = el.className.split(" ");
	var ar = new Array();
	for(var i = cls.length; i > 0;){
		if(cls[--i] != className){
			ar[ar.length] = cls[i];
		}
	}
	el.className = ar.join(" ");
};
PJS.setClassName = function(el,className){
	if(el.className == ""){
		el.className = className;
		return;
	}
	if(el.className.indexOf("\""+className+"\"") > -1 || el.className.indexOf("\""+className+"\" ") > -1 || 
		el.className.indexOf(" "+className+"\"") > -1 || el.className.indexOf(" "+className+" ") > -1){
		return;
	} else {
		el.className = el.className + " " + className;
	}
};
PJS.removeClassName = function(el,className){
	el.className = el.className.replace(new RegExp("/"+className+"/","g"),"");
};
PJS.getStyle = function(el,p){
	if(el.style && el.style.p){
		return el.style[p];
	}
};
PJS.setStyle = function(el,p,v){
	if(!el && !el.style) return false;
	if(p == 'opacity'){
		if(v == 0 && el.style.visibility != "hidden"){
			el.style.visibility = "hidden";
		} else if(el.style.visibility != "visible"){
			el.style.visibility = "visible";
		}
		if(window.ActiveXObject){
			el.style.filter = "alpha(opacity=" + v*100 + ")";
		}
		el.style.opacity = v;
	} else if(p == 'position' || p == 'className'){
		el.style[p] = v;
	} else if(p == 'width' || p == 'height' || p == 'left' || p == 'top' || p == 'right'){
		el.style[p] = v+"px";
	} else {
		el.style[p] = v+"";
	}
};
PJS.write = function(content){
	document.write(content);
};
PJS.toggle = function(el){
	if($(el)){
		if($(el).style.display == ""){
			$(el).style.display = 'none';
		} else {
			$(el).style.display = '';
		}
	}
};
PJS.toggleWithImg = function(el){
	if($(el)){
		if($(el).style.display == ""){
			$(el).style.display = 'none';
			if($(el + "_img")){
				$(el + "_img").src = PJS.BASE_URL + "images/collapsed_no.gif";
			}
		} else {
			$(el).style.display = '';
			if($(el + "_img")){
				$(el + "_img").src = PJS.BASE_URL + "images/collapsed_yes.gif";
			}
		}
	}
};
PJS.toggleBH = function(el,obj){
	if($(el) && obj){
		if($(el).style.display == ""){
			$(el).style.display = 'none';
			obj.className = "toggle_yes";
		} else {
			$(el).style.display = '';
			obj.className = "toggle_no";
		}
	}
};
PJS.toggleElement = function(el){
	el = $E(el);
	if(el.style.display == "none"){
		el.style.display = '';
	} else {
		el.style.display = 'none';
	}
};
PJS.toggleSH = function(){
	if(arguments.length < 1 ) return;
	for(var i=1; i<arguments.length; i++){
		if($(arguments[i])){
			$(arguments[i]).style.display = 'none';
		}
	}
	$(arguments[0]).style.display = '';
};
PJS.toggleTab = function(d,n,h,c){
	for(var i=1; i<=n; i++){
		$(h+"_"+i).className = "tab_d";
		$(c+"_"+i).style.display = 'none';
	}
	$(h+"_"+d).className = "tab_c";
	$(c+"_"+d).style.display = '';
};
PJS.toggleD = function(divId,divId2){
    var d = $(divId);
	d.style.display = '';
	if(typeof(divId2) != "undefined"){
		$(divId2).style.display = 'none';
	}
	new Effect.BlindDown(divId,{duration:0.5});
};
PJS.enableButton = function(el){
	if($(el)){
		$(el).disabled = false;
	}
};
PJS.getOffsetLeft = function(el){
	var ol = el.offsetLeft;
	while ((el = el.offsetParent) != null)
		ol += el.offsetLeft;
	return ol;
};
PJS.getOffsetTop = function(el){
	var ot = el.offsetTop;
	while((el = el.offsetParent) != null)
		ot += el.offsetTop;
	return ot;
};
PJS.offsetWidth = function(el){
	return el.offsetWidth;
};
PJS.offsetHeight = function(el){
	return el.offsetHeight;
};
PJS.getScreenWidth = function(){
	var r = 1200;
	if(window.innerWidth){
		// all except Explorer
		r = parseInt(window.innerWidth);
	} else if(document.documentElement && document.documentElement.clientWidth){
		// Explorer 6 Strict Mode
		r = parseInt(document.documentElement.clientWidth);
	} else if(document.body){
		// other Explorers
		r = parseInt(document.body.clientWidth);
	}
	if(isNaN(r)){
		r = 1200;
	}
	return r;
};
PJS.getScreenHeight = function(){
	var height = 800;
	if(window.innerHeight){// all except Explorer
		r = parseInt(window.innerHeight);
	} else if(document.documentElement && document.documentElement.clientHeight){// Explorer 6 Strict Mode
		r = parseInt(document.documentElement.clientHeight);
	} else if(document.body){// other Explorers
		r = parseInt(document.body.clientHeight);
	}
	if(isNaN(r)){
		r = 800;
	}
	return r;
};
PJS.getScrollTop = function(){
	var r = 0;
	if(document.documentElement && document.documentElement.scrollTop){
		r = parseInt(document.documentElement.scrollTop);
	} else if(document.body){
		r = parseInt(document.body.scrollTop);
	}
	if(isNaN(r)){
		r = 0;
	}
	return r;
};
PJS.getScrollLeft = function(){
	var r = 0;
	if(document.documentElement && document.documentElement.scrollLeft){
		r = parseInt(document.documentElement.scrollLeft);
	} else if(document.body){
		r = parseInt(document.body.scrollLeft);
	}
	if(isNaN(r)){
		r = 0;
	}
	return r;
};
PJS.getX = 0;
PJS.getY = 0;
PJS.getPosition = function(){
	var position = new Array();
	var evt = null;
	if(PJS.IS_IE){
		evt = window.event;
	} else {
		//evt = arguments[0];
		try {
			window.constructor.prototype.__defineGetter__("event",window_prototype_get_event);
		} catch(e){}
		evt = window.event;
	}
	if(evt == null || typeof(evt) == 'undefined'){
		PJS.getX = 300;
		PJS.getY = 200;
		position[0] = PJS.getX;
		position[1] = PJS.getY;
		return position;
	}
	if(evt.pageX || evt.pageY){
		PJS.getX = evt.pageX;
		PJS.getY = evt.pageY;
	} else {
		if(evt.clientX || evt.clientY){
			if(document.body.scrollLeft > document.documentElement.scrollLeft){
				PJS.getX = evt.clientX + document.body.scrollLeft;
			} else {
				PJS.getX = evt.clientX + document.documentElement.scrollLeft;
			}
			
			if(document.body.scrollTop > document.documentElement.scrollTop){
				PJS.getY = evt.clientY + document.body.scrollTop;
			} else {
				PJS.getY = evt.clientY + document.documentElement.scrollTop;
			}
		}
	}
	position[0] = PJS.getX;
	position[1] = PJS.getY;
	return position;
};
PJS.windowWidth = 800;
PJS.windowHeight = 600;
PJS.getWindowSize = function(){
	if(window.innerHeight){// all except Explorer
		PJS.windowWidth = window.innerWidth;
		PJS.windowHeight = window.innerHeight;
	} else if(document.documentElement && document.documentElement.clientHeight){// Explorer 6 Strict Mode
		PJS.windowWidth = document.documentElement.clientWidth;
		PJS.windowHeight = document.documentElement.clientHeight;
	} else if(document.body){// other Explorers
		PJS.windowWidth = document.body.clientWidth;
		PJS.windowHeight = document.body.clientHeight;
	}
};
PJS.pageWidth = 800;
PJS.pageHeight = 600;
PJS.getPageSize = function(){
	var windowWidth,windowHeight;
	if(window.innerHeight){// all except Explorer
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	} else if(document.documentElement && document.documentElement.clientHeight){// Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if(document.body){// other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	var xScroll,yScroll;
	if(window.innerHeight && window.scrollMaxY){
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if(document.body.scrollHeight > document.body.offsetHeight){// all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {// Explorer Mac...would also work in Explorer 6 Strict,Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	// for small pages with total width less then width of the viewport
	if(xScroll<windowWidth){
		PJS.pageWidth = xScroll;
	} else {
		PJS.pageWidth = windowWidth;
	}
	// for small pages with total height less then height of the viewport
	if(yScroll<windowHeight){
		PJS.pageHeight = windowHeight;
	} else { 
		PJS.pageHeight = yScroll;
	}
};
PJS.getCursorPosition = function(){
	var obj = document.activeElement;
	var cur = document.selection.createRange();
	var pos = 0;
	if(obj && cur){
		var tr = obj.createTextRange();
		if(tr){
			while(cur.compareEndPoints("StartToStart",tr) > 0){
				tr.moveStart("character",1);
				pos++;
			}
			return pos;
		}
	}
	return -1;
};
PJS.Mask = function(divId,width,height,percent,text){
	if(typeof(percent) == "undefined") percent = 50;
	if(typeof(text) == "undefined") text = '';
	var element = $E(divId);
	if(element && element.innerHTML == ""){
		return;
	} else {
		element = document.body;
	}
	PJS.getPageSize();
	var pw = PJS.pageWidth;
	var ph = PJS.pageHeight;// + PJS.getScrollTop();
	var left = Math.ceil((pw - width)/2);
	var top = Math.ceil((ph - height)/2);
	var divObjInnerHTML = text;
	var objBrother = element.childNodes[0];
	var divObj = document.createElement('DIV');
	divObj.setAttribute("id","div_mask");
	divObj.style.textAlign = "center";
	divObj.style.position = "absolute";
	divObj.style.left = left+"px";
	divObj.style.top = top+"px";
	divObj.style.width = width+"px";
	divObj.style.height = height+"px";
	divObj.style.margin = "0px";
	divObj.style.opacity = (percent / 100);
	divObj.style.MozOpacity = (percent / 100);
	divObj.style.KhtmlOpacity = (percent / 100);
	divObj.style.filter = "alpha(opacity="+percent+")";
	divObj.style.backgroundColor = "#CACACA";
	
	element.insertBefore(divObj,objBrother);
	divObj.innerHTML = divObjInnerHTML;
};
PJS.MaskB = function(percent){
	if(typeof(percent) == "undefined") percent = 50;
	if(typeof(text) == "undefined") text = '';
	PJS.getPageSize();
	var width = PJS.pageWidth;
	var height = PJS.pageHeight;// + PJS.getScrollTop();
	var left = 0;
	var top = 0;
	var divObjInnerHTML = '<div></div>';
	var element = document.body;
	var objBrother = element.childNodes[0];
	var divObj = document.createElement('DIV');
	divObj.setAttribute("id","body_mask");
	divObj.style.textAlign = "center";
	divObj.style.position = "absolute";
	divObj.style.left = left+"px";
	divObj.style.top = top+"px";
	divObj.style.width = width+"px";
	divObj.style.height = height+"px";
	divObj.style.margin = "0px";
	divObj.style.opacity = (percent / 100);
	divObj.style.MozOpacity = (percent / 100);
	divObj.style.KhtmlOpacity = (percent / 100);
	divObj.style.filter = "alpha(opacity="+percent+")";
	divObj.style.backgroundColor = "#000000";
	
	element.insertBefore(divObj,objBrother);
};
PJS.MaskT = function(text){
	PJS.MaskB(5);
	PJS.Mask("processing",500,200,60,text);
};
PJS.MaskD = function(){
	PJS.removeE($("body_mask"));
};
PJS.removeD = function(id){
	PJS.removeE($(id));
};
PJS.removeE = function(el){
	if(el && el.parentNode && el.parentNode.removeChild){
		el.parentNode.removeChild(el);
	}
};
PJS.cssJsMenu_status = 0;
PJS.cssJsMenu = function(e){
	if($(e)){
		var root = $(e);
		var a = root.getElementsByTagName("LI");
		
		for(var i=0; i<a.length; i++){
			a[i].onmouseover = function(){
				for(var j=0; j<this.getElementsByTagName("UL").length; j++){
					//this.getElementsByTagName("UL")[j].style.display = "block";
					PJS.showE(this.getElementsByTagName("UL")[j]);
				}
			};
			a[i].onmouseout = function(){
				for(var j=0; j<this.getElementsByTagName("UL").length; j++){
					//this.getElementsByTagName("UL")[j].style.display = 'none';
					PJS.hideE(this.getElementsByTagName("UL")[j]);
				}
			};
		}
	}
};
PJS.cssJsMenuA = function(e){
	if($(e)){
		var root = $(e);
		var a = root.getElementsByTagName("LI");
		
		for(var i=0; i<a.length; i++){
			for(var j=0; j<a[i].getElementsByTagName("UL").length; j++){
				a[i].onmouseover = function(){
					this.getElementsByTagName("UL")[j].style.display = '';
					//this.getElementsByTagName("UL")[j].style.backgroundColor = '#666666';
					this.getElementsByTagName("UL")[j].parentNode.className = "cc";
					this.getElementsByTagName("UL")[j].style.width = "200px";
					this.getElementsByTagName("UL")[j].style.position = 'absolute';
					//this.getElementsByTagName("UL")[j].style.left = (PJS.getOffsetLeft(root) + root.offsetWidth - 20) + "px";
					//this.getElementsByTagName("UL")[j].style.top = PJS.getOffsetTop(this) + "px";
					//this.getElementsByTagName("UL")[j].style.top = (-10) + "px";
				};
				a[i].onmouseout = function(){
					this.getElementsByTagName("UL")[j].style.display = 'none';
					this.getElementsByTagName("UL")[j].parentNode.className = "cd";
				};
			}
		}
	}
};
PJS.cssJsMenuB = function(e){
	if($(e)){
		var root = $(e);
		var a = root.getElementsByTagName("LI");
		
		for(var i=0; i<a.length; i++){
			a[i].onmouseover = function(){
				for(var j=0; j<this.getElementsByTagName("UL").length; j++){
					this.getElementsByTagName("UL")[j].style.visibility = 'visible';
				}
			};
			a[i].onmouseout = function(){
				for(var j=0; j<this.getElementsByTagName("UL").length; j++){
					this.getElementsByTagName("UL")[j].style.visibility = 'hidden';
				}
			};
		}
	}
};
PJS.cssJsMenuC = function(e){
	if($(e)){
		var root = $(e);
		var a = root.getElementsByTagName("LI");
		
		for(var i=0; i<a.length; i++){
			if(a[i].getAttribute('pc') != null && a[i].getAttribute('pc').indexOf(":") == -1){
				a[i].onclick = function(){
					var pc = this.getAttribute('pc');
					if(pc != null){
						if(pc.indexOf(":") > -1){
							pc = pc.substring(pc.indexOf(":")+1);
						}
						PJS.removeClass(this,"cd");
						PJS.addClass(this,"cc");
						for(var j=0; j<a.length; j++){
							if(a[j].getAttribute('pc') != null && a[j].getAttribute('pc').indexOf(":") > -1){
								if(a[j].getAttribute('pc').indexOf(pc+":") > -1){
									if(a[j].style.display == ""){
										PJS.removeClass(this,"hsa");
										PJS.addClass(this,"hsb");
										a[j].style.display = 'none';
									} else {
										a[j].style.display = '';
										PJS.removeClass(this,"hsb");
										PJS.addClass(this,"hsa");
									}
								} else {
									//a[j].style.display = 'none';
								}
							}
						}
					}
				};
				a[i].onmouseover = function(){
					PJS.addClass(this,"over");
				};
				a[i].onmouseout = function(){
					PJS.removeClass(this,"over");
				};
			}
		}
	}
};
PJS.previewImage = function(obj,target){
	if(!obj.value || !PJS.checkImageType(obj.value)){
		return false;
	}
	if(!PJS.IS_IE){
		return false;
	}
	var image = new Image();
	image.src = obj.value.replace(/\\/g,"/");
	image.width = 200;
	image.height = 200;
	if($(target)){
		$(target).innerHTML = '<img src="' + image.src + '" width="' + image.width + '" height="' + image.height + '">';
	}
};
PJS.checkcodeImage = function(el){
	var src = $E(el).src;
	if(src.indexOf("?r=") == -1){
		src += "?r="+PJS.rand();
	} else {
		src = src.substring(0, src.indexOf("?r=")) + "?r="+PJS.rand();
	}
	$E(el).src = src;
};
PJS.checkImageType = function(filename){
	var patten = /\.jpg$|\.jpeg$|\.gif$|\.png$|\.bmp$/i;
	
	if(filename.match(patten) == null){
		return false;
	} else {
		return true;
	}
	/*
	if(filename.search(patten) != -1){
		return true;
	} else {
		return false;
	}
	*/
	var image_types = new Array(".gif",".jpg",".jpeg",".png",".bmp");
	var image_types_lenght = image_types.lenght;
	var image_url;
	var image_url_length;
	for(var i=0; i<image_types_lenght; i++){
		image_url = filename.toLowerCase();
		image_url_length = image_url.length;
		if(image_url.substring(image_url_length - image_types[i].length,image_url_length) == image_types[i]){
			return true;
		}
	}
	
	return false;
};
/////////////////////////////////////////////////////////////////////////////
//PJS.tip
PJS.tip = function(){};
PJS.tip._inited = false;
PJS.tip._tds = 0;
PJS.tip._timer = null;
PJS.tip.init = function(){
	PJS.tip.init_tipd();
	PJS.tip._inited = true;
};
PJS.tip.init_tipd = function(){
	PJS.tip._td = PJS.appendDIVHTML("tipd","","tipd");
	with(PJS.tip._td.style){
		zIndex = '1000';
		display = '';
		position = 'absolute';
		visibility = 'hidden';
	}
	PJS.attachEvent(PJS.tip._td,'mouseover',PJS.tip._over);
	PJS.attachEvent(PJS.tip._td,'mouseout',PJS.tip._out);
};
PJS.tip.init_overd = function(){
	PJS.tip.overd = PJS.appendDIVHTML("overd","overd");
	with(PJS.tip.overd.style){
		zIndex = '1000';
		display = '';
		position = 'absolute';
		//top = "50px";
		//left = "100px";
		//width = "100px";
		//height = "100px";
		//backgroundColor = "#DADADA";
		//borderWidth = "1";
		//borderColor = "#ADDADA";
		//borderStyle = "solid";
		visibility = 'hidden';
	}
};
PJS.tip._up = function(evt){
	if(PJS.tip._tds == 0) return;
	var evt = PJS.fixEvent(evt);
	var tx = PJS.tip._td.offsetLeft;
	var ty = PJS.tip._td.offsetTop;
	var tw = PJS.tip._td.offsetWidth;
	var th = PJS.tip._td.offsetHeight;
	var ex = document.body.scrollLeft+evt.clientX;
	var ey = document.body.scrollTop+evt.clientY;
	if( tx <= ex && tx + tw >= ex && ty <= ey && ty + th >= ey ){
		//
	} else {
		PJS.tip._tds = 0;
		PJS.tip._hide();
		PJS.detachEvent(document,'mouseup',PJS.tip._up);
	}
};
PJS.tip._over = function(){
	PJS.tip._tds = 1;
};
PJS.tip._out = function(){
	PJS.tip._tds = 0;
	PJS.tip._timer = window.setTimeout(PJS.tip._hide, 500);
};
PJS.tip._hide = function(){
	if(PJS.tip._tds == 1) return false;
	if(PJS.tip._inited == false){
		PJS.tip.init();
	}
	PJS.tip._td.innerHTML = '';
	PJS.tip._td.style.visibility = 'hidden';
	PJS.tip._tds = 0;
};
PJS.tip.show = function(c){
	if(PJS.tip._inited == false){
		PJS.tip.init();
	}
	PJS.tip._td.innerHTML = c;
	PJS.tip._td.style.visibility = '';
};
PJS.tip.hide = function(){
	if(PJS.tip._inited == false){
		PJS.tip.init();
	}
	PJS.tip._td.innerHTML = '';
	PJS.tip._td.style.visibility = 'hidden';
	PJS.tip._tds = 0;
};
PJS.tip.showE = function(el,c,l,t){
	if(PJS.tip._inited == false){
		PJS.tip.init();
	}
	PJS.tip._td.innerHTML = c;
	PJS.tip._td.style.visibility = '';
	PJS.tip._tds = 1;
	//
	PJS.attachEvent(document,'mouseup',PJS.tip._up);
	//
	if(!l) l = 0;
	if(!t) t = 20;
	//
	PJS.tip._td.style.left = (PJS.getOffsetLeft(el)+l)+"px";
	if(el.scrollHeight > el.offsetHeight){
		PJS.tip._td.style.top = (PJS.getOffsetTop(el)-el.scrollHeight+el.offsetHeight+t)+"px";
	} else {
		PJS.tip._td.style.top = (PJS.getOffsetTop(el)+t)+"px";
	}
};
PJS.tip.hideE = function(){
	if(PJS.tip._inited == false){
		PJS.tip.init();
	}
	if(PJS.tip._tds == 1){
		return false;
	}
	PJS.tip._td.style.visibility = 'hidden';
	PJS.tip._tds = 0;
};
PJS.tip.tc = function(cls){
	PJS.addClass(PJS.tip._td,cls);
};
PJS.tip.startlink = function(){
	var links = document.links;
	var total = links.length;
	var alink;
	for(var k=0; k<total; k++){		
		alink = links[k];
		if(alink.title){
			alink.onmouseover = function(){
				return overlib(alink.title);
			};
			alink.onmouseout = function(){
				return nd();
			};
		}
	}
};
PJS.tip.startimage = function(){
	var images = document.images;
	var total = images.length;
	var image;
	for(var k=0; k<total; k++){		
		image = images[k];
		if(image.alt){
			image.onmouseover = function(){
				return overlib(image.alt);
			};
			image.onmouseout = function(){
				return nd();
			};
		}
	}
};
/////////////////////////////////////////////////////////////////////////////
//PJS.sort
PJS.sortable = function(el,cmp){
	this.target = $E(el);
	this.compare = cmp;
};
PJS.sortable.prototype.getelements = function(){
	var els = [];
	var a = this.target.getElementsByTagName(this.compare);
	for(var i=0; i<a.length; i++){
		els.push(a[i]);
	}
	return els;
};
PJS.sortable.prototype.asc = function(){
	return false;
};
PJS.sortable.prototype.desc = function(){
	return false;
};
/////////////////////////////////////////////////////////////////////////////
//PSJ.dragable
PJS.dragable = function(target,dragger){
	if(target && dragger){
		this.register(target,dragger);
	}
};
PJS.dragable.prototype.uid = 0;
PJS.dragable.prototype.timeout = null;
PJS.dragable.prototype.register = function(target,dragger){
	this.uid = PJS.rand('dragable');
	this.target = target;
	this.dragger = dragger;
	PJS.dragable._add(this);
	PJS.attachEvent(dragger,'mousedown',function(event){var dragger = PJS.dragable._get(this);if(dragger) dragger.start(event);});
};
PJS.dragable.prototype.start = function(evt){
	//PJS.attachEvent(document,'mousedown',this.drag);
	this.drag(evt);
	var dragger = this;
	this.active = true;
	PJS.dragable._start(this);
	PJS.attachEvent(document,'mousemove',function(event){dragger.move(event);});
	PJS.attachEvent(document,'mouseup',function(event){dragger.up(event);});
	if(this.timeout){
		clearTimeout(this.timeout);
	}
};
PJS.dragable.prototype.close = function(){
	if(this.timeout){
		clearTimeout(this.timeout);
	}
	PJS.hideE(this.target);
	this.onEvent('afterclose');
};
PJS.dragable.prototype.drag = function(evt){
	this.moveFlag = true;
	//this.target.style.cursor = "pointer";
	var posX,posY;
	if(PJS.IS_IE){
		posY = window.event.clientY + document.body.scrollTop;
		posX = window.event.clientX + document.body.scrollLeft;
	} else {
		posX = evt.pageX;
		posY = evt.pageY;
	}
	this.curWidth = parseInt(posX - PJS.getOffsetLeft(this.target));
	this.curHeight = parseInt(posY - PJS.getOffsetTop(this.target));
};
PJS.dragable.prototype.dragb = function(ex){
	this.moveFlag = true;
	if(PJS.IS_IE){
		position = PJS.getPosition();
	} else {
		try {
		} catch(e){
		}
		PJS.getX = event.pageX;
		PJS.getY = event.pageY;
	}
	this.curWidth = PJS.getX;
	this.curHeight = PJS.getY;
	//this.target.style.cursor = "pointer";
};
PJS.dragable.prototype.move = function(evt){
	if(this.active == false){
		return;
	}
	var posX,posY;
	if(PJS.IS_IE){
		posY = window.event.clientY + document.body.scrollTop;
		posX = window.event.clientX + document.body.scrollLeft;
	} else {
		posX = evt.pageX;
		posY = evt.pageY;
	}
	if(posX - this.curWidth + PJS.offsetWidth(this.target)<50){
		return;
	}
	if(posY - this.curHeight < 0){
		return;
	}
	
	this.target.style.left = parseInt(posX - this.curWidth) + "px";
	this.target.style.top = parseInt(posY - this.curHeight) + "px";
	this.stopEvent(evt);
};
PJS.dragable.prototype.moveb = function(evt){
	if(this.moveFlag == false){
		return;
	}
	//this.target.style.cursor = "pointer";
	if(PJS.IS_IE){
		position = PJS.getPosition();
	} else {
		try {
		} catch(e){
		}
		PJS.getX = event.pageX;
		PJS.getY = event.pageY;
	}
	this.target.style.left = parseInt(PJS.getOffsetLeft(this.target) + PJS.getX - this.curWidth) + "px";
	this.target.style.top = parseInt(PJS.getOffsetTop(this.target) + PJS.getY - this.curHeight) + "px";
	this.curWidth = PJS.getX;
	this.curHeight = PJS.getY;
};
PJS.dragable.prototype.up = function(evt){
	this.drop();
};
PJS.dragable.prototype.drop = function(){
	this.moveFlag = false;
	PJS.detachEvent(this.dragger,'mousedown',this.drag);
	PJS.detachEvent(document,'mousemove',this.move);
	PJS.detachEvent(document,'mouseup',this.up);
	this.active = false;
};
PJS.dragable.prototype.out = function(){
	PJS.getPosition();
	this.timeout = setTimeout("PJS.dragable._process('"+this.uid+"','drop')",100);
	this.target.style.cursor = "default";
};
PJS.dragable.prototype.addEvent = function(evt,m){
	this.triggers[evt] = m;
};
PJS.dragable.prototype.onEvent = function(evt){
	if(this.triggers && this.triggers[evt] && typeof(this.triggers[evt]) == "function"){
		this.triggers[evt]();
	}
};
PJS.dragable.prototype.stopEvent = function(evt){
	if(PJS.IS_IE){
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else {
		evt.preventDefault();
		evt.stopPropagation();
	}
};
PJS.dragable._draggers = Array();
PJS.dragable._add = function(drag){
	PJS.dragable._draggers.push(drag);
};
PJS.dragable._get = function(dragger){
	for(var i=0; i<PJS.dragable._draggers.length; i++){
		if(PJS.dragable._draggers[i].dragger.uid == dragger.uid){
			return PJS.dragable._draggers[i];
		}
	}
	return null;
};
PJS.dragable._remove = function(uid){
	for(var i=0; i<PJS.dragable._draggers.length; i++){
		if(PJS.dragable._draggers[i].uid == uid){
			PJS.dragable._draggers[i] = null;
		}
	}
};
PJS.dragable._start = function(drag){
	for(var i=0; i<PJS.dragable._draggers.length; i++){
		if(PJS.dragable._draggers[i].uid == drag.uid){
			PJS.dragable._draggers[i].target.style.zIndex = 100;
		} else {
			PJS.dragable._draggers[i].target.style.zIndex = 10;
		}
	}
};
PJS.dragable._process = function(uid,action,param){
	for(var i=0; i<PJS.dragable._draggers.length; i++){
		if(PJS.dragable._draggers[i].uid == uid){
			eval("PJS.dragable._draggers[i]."+action+"("+param+")");
		}
	}
};
/////////////////////////////////////////////////////////////////////////////
//PJS.dialog
PJS.dialog = function(){
	this.td = null;
	this.uid = null;
	this.ds = null;
	this.hs = null;
	this.cs = null;
	this.dc = null;
	this.hc = null;
	this.cc = null;
	this.width = 300;
	this.height = 100;
	//
	this.inited = false;
	this.assigned = false;
	this.toggled = true;
	this.center = true;
	this.dragable = true;
	this.footable = false;
	this.largable = false;
	//
	this.xc = function(m,p){
		if(this.xc_url){
			xcb(this.xc_url,m,p);
		} else {
			xc(m,p);
		}
	};
	this.xca = function(a,b){
		xcb("ws/admin/","wsa_"+a,b);
	};
	this.xce = function(a,b){
		xcb("ws/editor/","wse_"+a,b);
	};
	this.xcm = function(a,b){
		xcb("ws/my/","wsm_"+a,b);
	};
	this.xcb = function(url,m,p){
		xcb(url,m,p);
	};
	//
	this.init = function(){
		if(this.inited == true){
			return;
		}
		this.uid = PJS.rand('dialog');
		this.uid_d = "_d_d" + this.uid;
		this.uid_d_h = "_d_d_h" + this.uid;
		this.uid_d_c = "_d_d_c" + this.uid;
		this.uid_d_f = "_d_d_f" + this.uid;
		//
		if(this.td){
			//
		} else {
			PJS.appendDIVHTML(this.uid_d,"","dialog");
			this.td = $(this.uid_d);
			//PJS.appendDIV(this.td,this.uid_d_h,"dialog_head","");
			//PJS.appendDIV(this.td,this.uid_d_c,"dialog_content","");
			//PJS.appendDIV(this.td,this.uid_d_f,"dialog_foot","");
			var c = '<div class="dialog_inner">';
			c += '<div class="dialog_head">';
			c += '<div class="dialog_close"><a onClick="PJS.dialog._close(\''+this.uid+'\');"> X </a></div>';
			c += '<div class="right dialog_zoom'+(this.largable ? '': ' hidden')+'"><a onClick="PJS.dialog._zoom(\''+this.uid+'\');">[ + ]</a>&nbsp;&nbsp;</div>';
			c += '<div id="'+this.uid_d_h+'"></div>';
			c += '</div>';
			c += '<div class="dialog_contentbox">';
			c += '<div id="'+this.uid_d_c+'" class="dialog_content"></div>';
			c += '</div>';
			c += '<div class="dialog_footbox">';
			c += '<div id="'+this.uid_d_f+'" class="dialog_foot"><input type="button" name="submit" value="Submit" onClick="PJS.dialog._submit(\''+this.uid+'\');"></div>';
			c += '</div>';
			c += '</div>';
			this.td.innerHTML = c;
			this.tdh = $(this.uid_d_h);
			this.tdc = $(this.uid_d_c);
			this.tdf = $(this.uid_d_f);
		}
		this.inited = true;
	};
	//
	this._setHead = function(hc,hs){
		this.hc = hc;
		this.hs = hs;
	};
	this._getHeader = function(){
		return this.hc;
	};
	this._setContent = function(cc,cs){
		this.cc = cc;
		this.cs = cs;
	};
	this._getContent = function(){
		return this.cc;
	};
	this._setFoot = function(r){
		this.footable = r ? true : false;
	};
	this._getFoot = function(r){
		return this.footable;
	};
	this._setWidth = function(w){
		this.width = w;
	};
	this._setHeight = function(h){
		this.height = h;
	};
	this._setSize = function(w,h){
		this.width = w;
		this.height = h;
	};
	this.size = function(x,y){
		this._setSize(w,h);
	};
	this.position = function(x,y){
		this.posx = x;
		this.posy = y;
	};
	//
	this.setLoading = function(){
		
	};
	this.setClassName = function(className){
		this.className = className;
	};
	//content
	this.setHead = function(hc){
		this.init();
		this.tdh.innerHTML = hc;
	};
	this.setContent = function(cc){
		this.init();
		this.tdc.innerHTML = cc;
	};
	//size
	this.setWidth = function(w){
		this.init();
		this._setWidth(w);
		this.td.style.width = this.width+"px";
	};
	this.setHeight = function(h){
		this.init();
		this._setHeight(h);
		this.tdc.style.height = this.height+"px";
	};
	this.setSize = function(w,h){
		this.setWidth(w);
		this.setHeight(h);
	};
	this.setWindow = function(){
		var w = PJS.getScreenWidth();
		var h = PJS.getScreenHeight();
		this.setSize(w,h);
		this.setLocation(0,0);
	};
	this.setWHCH = function(w,h,cc,hc){
		this.setSize(w,h);
		this.setContent(cc);
		this.setHead(hc);
	};
	this.setCenter = function(){
		this.init();
		var w = PJS.getScreenWidth();
		var h = PJS.getScreenHeight();
		var t = PJS.getScrollTop();
		this.td.style.left = parseInt(w/2 - this.width/2) + "px";
		this.td.style.top = parseInt(h/2 + t - this.height/2) + "px";
	};
	this.setLocation = function(x,y){
		this.init();
		this.posx = x;
		this.posy = y;
		this.td.style.left = this.posx+"px";
		this.td.style.top = this.posy+"px";
	};
	this.setLocationE = function(el,p){
		this.init();
		if(el){
			var l = PJS.getOffsetLeft(el);
			var t = PJS.getOffsetTop(el);
			var w = PJS.getScreenWidth();
			var h = PJS.getScreenHeight();
			if(l + this.width > w){
				l -= this.width;
			}
			if(t + this.height > h){
				t -= this.height;
			}
			if(p == 'bottom'){
				t += PJS.offsetHeight(el);
			} else if(p == 'top'){
				t -= PJS.offsetHeight(el);
			}
			this.posx = l;
			this.posy = t;
			this.td.style.left = this.posx+"px";
			this.td.style.top = this.posy+"px";
		}
	};
	this.setStyle = function(p,v){
		this.init();
		PJS.setStyle(this.td,p,v);
	};
	this.setCStyle = function(p,v){
		this.init();
		PJS.setStyle(this.tdc,p,v);
	};
	//
	this._show = function(){
		this.td.style.display = '';
	};
	this._hide = function(){
		this.td.style.display = 'none';
	};
	this._showfoot = function(){
		this.tdf.style.display = '';
	};
	this._hidefoot = function(){
		this.tdf.style.display = 'none';
	};
	this._toggle = function(){
		if(this.td.style.display == ""){
			this.td.style.display = 'none';
		} else {
			this.td.style.display = '';
		}
	};
	//
	this.output = function(s){
		this.init();
		
		if(this.hc == null){
			this.tdh.style.display = 'none';
		} else {
			this.tdh.innerHTML = this.hc;
		}
		this.tdc.innerHTML = this.cc;
		if(s){
			this.td.style.display = '';
		}
		if(this.footable == true){
			this.tdf.style.display = '';
		} else {
			this.tdf.style.display = 'none';
		}
		if(this.className){
			PJS.addClass(this.td,this.className);
		}
		if(this.width > 0){
			this.td.style.width = this.width+"px";
		}
		if(this.height > 0){
			this.tdc.style.height = this.height+"px";
		}
		if(this.center){
			this.setCenter();
		} else {
			if(this.posx || this.posy){
				this.td.style.left = this.posx+"px";
				this.td.style.top = this.posy+"px";
				this.td.style.position = 'absolute';
			} else {
				var evt = PJS.fixEvent();
				var el = PJS.srcElement(evt);
				this.setLocationE(el);
			}
		}
		if(this.dragable){
			var drag = new PJS.dragable();
			drag.register(this.td,this.tdh);
		}
	};
	this.zoom = function(){
		if(this._dz == null) this._dz = 1;
		if(this._dz == 1){
			var z = 2 * this._dz;
		}else if(this._dz > 1){
			var z = this._dz / 4;
		} else if(this._dz < 1){
			var z = this._dz * 4;
		}
		var w = this.width * z;
		var h = this.height * z;
		this.setSize(w, h);
		this._dz = z;
	};
	//
	this.show = function(cc,hc){
		if(this.assigned == true){
			if(this.toggled){
				this._toggle();
			} else {
				this._show();
			}
			return;
		}
		if(isUndefined(hc) == false){
			this._setHead(hc);
		}
		if(cc){
			this._setContent(cc);
		}
		this.output(1);
		//this.setCenter();
		this.assigned = true;
		//_dialogs.push(this);
		PJS.dialog._add(this);
	};
	this.showMessage = function(cc,hc){
		if(this.assigned == false){
			if(this.toggled){
				this._toggle();
			} else {
				this._show();
			}
			return;
		}
		if(isUndefined(hc) == false){
			this._setHead(hc);
		}
		if(cc){
			this._setContent(cc);
		}
		this.output(1);
		//this.setCenter();
		this.assigned = true;
		//_dialogs.push(this);
		PJS.dialog._add(this);
	};
	this.MessageBox = function(cc,hc){
		this.showMessage(cc,hc);
	};
	this.hide = function(){
		PJS.hideE(this.td);
		if(this.onhide){
			this.onhide();
		}
	};
	this.close = function(){
		//this._setHead("");
		//this._setContent("");
		//this.output(1);
		PJS.hideE(this.td);
		if(this.onclose){
			this.onclose();
		}
	};
	this.submit = function(){
		PJS.hideE(this.td);
		if(this.onsubmit){
			this.onsubmit();
		}
	};
	this.clear = function(){
		this.init();
		this.tdc.innerHTML = '';
	};
	//
	this.load = function(a,b,hc){
		this.show("loading...",hc);
		this.xc(a,b);
	};
	this.loada = function(a,b,hc){
		this.show("loading...",hc);
		this.xca(a,b);
	};
	this.loade = function(a,b,hc){
		this.show("loading...",hc);
		this.xce(a,b);
	};
	this.loadm = function(a,b,hc){
		this.show("loading...",hc);
		this.xcm(a,b);
	};
	this.loadb = function(url,a,b,hc){
		this.show("loading...",hc);
		this.xcb(url,a,b);
	};
};
//
PJS.dialog._dialogs = Array();
PJS.dialog._add = function(dialog){
	PJS.dialog._dialogs.push(dialog);
};
PJS.dialog._get = function(uid){
	for(var i=0; i<PJS.dialog._dialogs.length; i++){
		if(PJS.dialog._dialogs[i].uid == uid){
			return PJS.dialog._dialogs[i]
		}
	}
};
PJS.dialog._remove = function(uid){
	for(var i=0; i<PJS.dialog._dialogs.length; i++){
		if(PJS.dialog._dialogs[i].uid == uid){
			PJS.dialog._dialogs[i] = null;
		}
	}
};
PJS.dialog._process = function(uid,action,param){
	for(var i=0; i<PJS.dialog._dialogs.length; i++){
		if(PJS.dialog._dialogs[i].uid == uid){
			eval("PJS.dialog._dialogs[i]."+action+"("+param+")");
		}
	}
};
PJS.dialog._close = function(uid){
	for(var i=0; i<PJS.dialog._dialogs.length; i++){
		if(PJS.dialog._dialogs[i].uid == uid){
			PJS.dialog._dialogs[i].close();
		}
	}
};
PJS.dialog._zoom = function(uid){
	for(var i=0; i<PJS.dialog._dialogs.length; i++){
		if(PJS.dialog._dialogs[i].uid == uid){
			PJS.dialog._dialogs[i].zoom();
		}
	}
};
PJS.dialog._submit = function(uid){
	for(var i=0; i<PJS.dialog._dialogs.length; i++){
		if(PJS.dialog._dialogs[i].uid == uid){
			PJS.dialog._dialogs[i].submit();
		}
	}
};
//dialogs
var _dialogs = Array();
function _dialog_add(dialog){
	_dialogs.push(dialog);
};
function _dialog_get(uid){
	for(var i=0; i<_dialogs.length; i++){
		if(_dialogs[i].uid == uid){
			return _dialogs[i];
		}
	}
	return null;
};
function _dialog_remove(uid){
	for(var i=0; i<_dialogs.length; i++){
		if(_dialogs[i].uid == uid){
			_dialogs[i] = null;
		}
	}
};
function _dialog_process(uid,action,param){
	for(var i=0; i<_dialogs.length; i++){
		if(_dialogs[i].uid == uid){
			eval("_dialogs[i]."+action+"("+param+")");
		}
	}
};
function _dialog_close(uid){
	for(var i=0; i<_dialogs.length; i++){
		if(_dialogs[i].uid == uid){
			_dialogs[i].close();
		}
	}
};
//PJS.account.get();
/////////////////////////////////////////////////////////////////////////////
//PJS.preloadImages
PJS.validator = function(){};
PJS.validator.registerFormAction = function(){
	//common form validate
	if( arguments.length > 1 ) {
		var forms = arguments;	
	} else if( arguments.length == 1 ) {
		var forms = [arguments[0]];	
	} else {
		var forms = document.forms;
	}
	for(var i=0; i<forms.length; i++){
		if((forms[i].method == 'post' || forms[i].method == 'get') && (isUndefined(forms[i].onsubmit) || forms[i].onsubmit == null)){
			var fm = forms[i];
			fm.onsubmit = function(){
					var form = this;
					return PJS.validator.checkFormValid(form);
						};
		}
	}
};
PJS.validator.checkFormValid = function(form){
	var checkbefore = form.getAttribute("checkbefore");
	var checkafter = form.getAttribute("checkafter");
	if(checkbefore != ""){
		var _ca = eval(checkbefore);
		if(_ca == false){
			return false;
		}
	}
	if(form.field_name && form.field_name.value == ""){
		alert("Please enter the name");
		form.field_name.focus();
		return false;
	} else if(form.field_subject && form.field_subject.value == ""){
		alert("Please enter the subject");
		form.field_subject.focus();
		return false;
	}
	if(form.category && form.field_category){
		if(form.field_category.value == "" && form.category.value == ""){
			alert("Please enter the category or select one");
			form.category.focus();
			return false;
		}
	}
	if(form.group && form.field_group){
		if(form.field_group.value == "" && form.group.value == ""){
			alert("Please enter the group or select one");
			form.group.focus();
			return false;
		}
	}
	/*
	if(form.field_email_address){
		if(form.field_email_address.value == ""){
			form.field_email_address.focus();
			return false;
		} else if(checkEmail(form.field_email_address.value) == false){
			//form.field_email_address.select();
			form.field_email_address.focus();
			return false;
		}
	}
	*/
	if(form.field_start_time && form.field_end_time && form.field_end_time.value.length > 0){
		if(form.field_start_time.value >= form.field_end_time.value){
			alert("The start time must be before the end time");
			//form.field_end_time.focus();
			return false;
		}
	} else if(form.date_from && form.date_to && form.date_to.value.length > 0){
		if(form.date_from.value > form.date_to.value){
			alert("The start time must be before the end time");
			form.date_from.focus();
			return false;
		}
	}
	if(form.field_sort_order && IsNumeric(form.field_sort_order.value) == false){
		alert("The sort order must be number");
		form.field_sort_order.focus();
		return false;
	}
	var vfs = [];
	var berr = false;
	for(var i=0; i<form.elements.length; i++){
		var v = form.elements[i].getAttribute("valid");
		var _v = form.elements[i].getAttribute("_valid");
		if( v && (_v == null || _v == 1) && (isUndefined(form.elements[i].diabled) || form.elements[i].diabled == false)){
			var vs = v.split(",");
			for(var j in vs){
				v = vs[j];
				switch(v){
					case 'number':
						if(form.elements[i].value == ""){
						} else if(IsNumeric(form.elements[i].value) == false){
							alert("The field must be number");
							form.elements[i].focus();
							berr = true;
						}
						break;
					case 'decimal':
					case 'percent':
						if(form.elements[i].value == ""){
							alert("The field must be decimal");
							form.elements[i].focus();
							berr = true;
						} else if(IsDecimal(form.elements[i].value) == false){
							alert("The field must be decimal");
							form.elements[i].focus();
							berr = true;
						}
						break;
					case 'float':
						if(form.elements[i].value == ""){
						} else if(IsFloat(form.elements[i].value) == false){
							alert("The field must be float");
							form.elements[i].focus();
							berr = true;
						}
						break;
					case 'price':
						if(form.elements[i].value == ""){
						} else if(IsFloat(form.elements[i].value) == false){
							alert("The field must be price");
							form.elements[i].focus();
							berr = true;
						}
						break;
					case 'time':
						break;
					case 'email':
						if(form.elements[i].value == ""){
							alert("The field must be email address");
							form.elements[i].focus();
							berr = true;
						} else if(PJS.checkEmail(form.elements[i].value) == false){
							alert("The field must be a valid email address");
	
							form.elements[i].focus();
							berr = true;
						}
						break;
					case 'require':
					case 'notnull':
					case 'not_null':
						if(form.elements[i].type == "checkbox" && form.elements[i].checked == false) {
							var msg = form.elements[i].getAttribute("valid_"+v+"_msg");
							if(!msg) msg = "The field is required";
							alert(msg);
							return false;
						} else if(form.elements[i].value == "" || form.elements[i].value == "0"){
							var msg = form.elements[i].getAttribute("valid_"+v+"_msg");
							if(!msg) msg = "The field is required";
							alert(msg);
							form.elements[i].focus();
							berr = true;
						}
						break;
				}
			}
		} else if( v ) {
			//
		} else if(form.elements[i].getAttribute("require") == "true" || form.elements[i].getAttribute("require") == "1"){
			if( form.elements[i].tagName.toUpperCase() == "SELECT" ) {
				if( form.elements[i].value == "" ) {
					form.elements[i].focus();
					//alert("The field must be selected");
					PJS.addClass(form.elements[i].parentNode, "form-element-error");
					berr = true;
				} else {
					PJS.removeClass(form.elements[i].parentNode, "form-element-error");
				}
			} else if( form.elements[i].tagName.toUpperCase() == "INPUT" ) {
				if( form.elements[i].type.toUpperCase() == "CHECKBOX" || form.elements[i].type.toUpperCase() == "RADIO" ) {
					var en = form.elements[i].name;
					if( PJS.list.hasSelected(form.elements[i], en) == false ) {
						form.elements[i].focus();
						//alert("The field must be selected");
						PJS.addClass(form.elements[i].parentNode.parentNode, "form-element-error");
						berr = true;
					} else {
						PJS.removeClass(form.elements[i].parentNode.parentNode, "form-element-error");
					}
				}
			} else {
				vfs.push(form.elements[i].name);
			}
		}
	}
	if( berr == true ) {
		return false;
	}
	var r = validator_form(form,vfs);
	if(r == false){
		return false;
	}
	if(checkafter != ""){
		var _ca = eval(checkafter);
		if(_ca == false){
			return false;
		}
	}
	return true;
};
/////////////////////////////////////////////////////////////////////////////
//PJS.preloadImages
PJS.onload = function(){};
PJS.onload.preloadImages = function(){
	var d = document;
	if(d.images){
		//pms
		var i,j,a;
		if(!d._PMS){
			d._PMS = new Array();
			j = d._PMS.length;
			a = document.getElementsByTagName("IMG");
			for(i=0; i<a.length; i++){
				if(a[i].className == "pm"){
					if(a[i].src.indexOf('.jpg') > -1 && a[i].src.substring(0,a[i].src.indexOf('.jpg')).length > 0){
						d._PMS[j] = new Image;
						d._PMS[j++].src = a[i].src.substring(0,a[i].src.indexOf('.jpg'))+'_2.jpg';
					} else if(a[i].src.indexOf('.gif') > -1 && a[i].src.substring(0,a[i].src.indexOf('.gif')).length > 0){
						d._PMS[j] = new Image;
						d._PMS[j++].src = a[i].src.substring(0,a[i].src.indexOf('.gif'))+'_2.gif';
					}
				}
			}
		}
	}
};
PJS.onload.registerImageAction = function(){
	//attachimage
	var images = document.images;
	for(var i=0; i<images.length; i++){
		if(images[i].className == "pm"){
			PJS.addEvent(images[i],'mouseover',
						function(event){
							var o = event.srcElement;
							if(o == null) o = event.target;
							if(o.tagName == 'IMG'){
								if(o.src.indexOf('.jpg') > -1){
									o.src = o.src.substring(0,o.src.indexOf('.jpg'))+'_2.jpg';
								} else if(o.src.indexOf('.gif') > -1){
									o.src = o.src.substring(0,o.src.indexOf('.gif'))+'_2.gif';
								}
							}
						});
			PJS.addEvent(images[i],'mouseout',
						function(event){
							var o = event.srcElement;
							if(o == null) o = event.target;
							if(o.tagName == 'IMG'){
								o.src = o.src.replace('_2','');
							}
						});
		} else if(images[i].className == 'attachimage'){
			if(images[i].width > 500){
				images[i].height = parseInt((images[i].height / images[i].width) * 500);
				images[i].width = 500;
			}
		} else if(images[i].className == 'pimage'){
			if(images[i].width > 10){
				var r = images[i].height / images[i].width;
				if(r > 1){
					images[i].width = parseInt(images[i].width * 120 / images[i].height);
					images[i].height = 120;
				} else {
					images[i].height = parseInt(images[i].height * 120 / images[i].width);
					images[i].width = 120;
				}
			}
		}
	}
};
//
PJS.onload.listBoxAction = function(){
	var a = document.getElementsByTagName("TABLE");
	for(var i=0;i<a.length; i++){
		if(a[i].className.indexOf("listBox") > -1 && a[i].className.indexOf("nolight") == -1){
			var b = a[i].getElementsByTagName("TR");
			if(b.length > 0){
				var k = 0;
				for(var j=0;j<b.length; j++){
					if(PJS.noClass(b[j]) || PJS.hasClass(b[j],["Action","Head"],1) == false){
						if(PJS.hasAttr(b[j],'id') == false){
							if(k/2 == parseInt(k/2)){
								PJS.addClass(b[j],"row0");
							} else {
								PJS.addClass(b[j],"row1");
							}
							k++;
							PJS.attachEvent(b[j],'mouseover',function(evt){PJS.addClass(PJS.getParent(evt.toElement,"TR"),"rowover");});
							PJS.attachEvent(b[j],'mouseout',function(evt){PJS.removeClass(PJS.getParent(evt.fromElement,"TR"),"rowover");});
						}
					}
				}
			}
		}
	}
};
//
PJS.onload.cart = function(el){
	var c = getCookie("_pcart");
	//var cc = getCookie("_pcc");
	//var ct = getCookie("_pct");
	if(c.indexOf("-") > -1){
		//xcb('call.php?xc=cart', 'xc_topcartinfo');
		var cs = c.split("-");
		var cc = cs[1];
		var ct = cs[2];
		$(el).innerHTML = cc+" item(s): $"+ct;
	}
};
//
PJS.onload.user = function(el){
	if(typeof(PJS.onload.onUser) == "function" ){
		PJS.onload.onUser(el,getCookie("_pustatus"));
		return false;
	}
	//xcb('call.php?xc=my', 'xc_topmenu_status');
	var un = getCookie("_puname");
	var uc = getCookie("_pucompany");
	$(el).innerHTML = "Welcome, " + unescape(decodeURIComponent(uc)) + "!";
};
//
PJS.onload.registerAction = function(){
	PJS.onload.preloadImages();
	PJS.onload.registerImageAction();
	PJS.onload.listBoxAction();
	
	PJS.validator.registerFormAction();
};
/////////////////////////////////////////////////////////////////////////////
//onload
window.onload = function(){	
	//
	//var dialog = new PJS.dialog;
	//
	//PJS.tip.init();
	PJS.onload.registerAction();
	PJS.cssJsMenu('topmenu');
	//
	//PJS.addScriptAlone('js/category.js');
};
/////////////////////////////////////////////////////////////////////////////
