if(typeof cj == "undefined")
{
	cj = {};
}
cj.evt = {
	guid : 1,
	add : function (element, type, handler)
	{
		if(element.addEventListener){
			element.addEventListener(type, handler, false);
		}else if (element.attachEvent)
		{
			element.attachEvent("on" + type, handler);
		}else{
			if (!handler.$$guid)
			{
				handler.$$guid = this.guid++;
			}
			if (!element.events)
			{
				element.events = {};
			}
			var handlers = element.events[type];
			if (!handlers)
			{
				handlers = element.events[type] = {};
				if(element["on" + type]){
					handlers[0] = element["on" + type];
				}
			}
			handlers[handler.$$guid] = handler;
			element["on" + type] = this.handleEvent;
		}
	},
	remove : function(element, type, handler)
	{
		if (element.removeEventListener)
		{
			element.removeEventListener(type, handler, false);
		}else
		{
			if (element.events && element.events[type])
			{
				delete element.events[type][handler.$$guid];
			}
		}
	}
}
cj.util = {
	getMousePos : function(ev){
		var ev = ev ? ev : window.event;
		return (ev.pageX && ev.x) ? {"x":ev.pageX, "y":ev.pageY} : {"x":ev.clientX+this.getScrollPos().left, "y":ev.clientY+this.getScrollPos().top}
	},
	getScrollPos : function(){
		var top = left = 0;
		top = document.documentElement.scrollTop || document.body.scrollTop;
		left = document.documentElement.scrollLeft || document.body.scrollLeft;
		return {"top" : top, "left" : left}
	},
	getWindowSize : function(){
		var width = height = 0;
		width = document.documentElement.clientWidth || document.body.clientWidth;
		height = document.documentElement.clientHeight || document.body.clientHeight;
		return {"width" : width, "height" : height}
	},
   	getElementPos : function(elm){
   		var top = left = 0;
   		while(elm != null){
   			top += elm.offsetTop;
   			left += elm.offsetLeft;
   			elm = elm.offsetParent;
   		}
   		return {"top" : top, "left" : left}
   	},
   	showAttrib : function (obj, type){
   		var html = "<ul>";
		for(var i in obj){
			html += "<li>" + i + "=" + obj[i] + "</li>";
		}
		html += "</ul>";
		
		switch (type){
			default :
				var c = document.createElement("div");
				c.style.cssText = "position:absolute; border:1px solid #eeeeff; width:640px; height:480px; background:whitesmoke;";
				document.body.appendChild(c);
				c.style.top = this.getScrollPos().top + 50 + "px";
				
				var bar = document.createElement("div");
				bar.style.cssText = "width:100%; height:20px; border:1px solid #cccccc; background:#666666; color:whitesmoke; cursor:pointer; text-align:center;";
				bar.innerHTML = "Close";
				bar.onclick = function(){
					document.body.removeChild(this.offsetParent);
					return false;
				}
				c.appendChild(bar);
				
				var main = document.createElement("div");
				main.style.cssText = "width:100%; height:460px; overflow:auto;";
					main.innerHTML = html;
				c.appendChild(main);
				return false;
			break;
			
			case "text" :
				return html;
			break;
		}				
	},
	loadJs : function(src){
		var js = document.createElement("script");
		js.src = src;
		js.type = "text/javascript";
		document.getElementsByTagName("head")[0].appendChild(js);
	},
	fix_ieflash : function() {
		var objects = document.getElementsByTagName("object"); 
		for (var i=0;i<objects.length;i++)
			objects[i].outerHTML = objects[i].outerHTML;
	}
}

cj.fade = {
	fps : 10,
	otype : false,
	start : function(obj, time, current, end){
		var steps = (end - current) / (time * this.fps) ;
		this.getotype(obj);
		if (this.otype != 'none'){
			this.setfade(obj, current);
			this.dofade(steps, obj, current, end);
		}
	},
	dofade : function (steps, obj, current, end){
		var dir = (steps > 0);
		current += steps;
		this.setfade(obj, current);
		
		if (dir ^ (current - end > 0))
		{
			setTimeout(
				function()
				{
					cj.fade.dofade(steps, obj, current, end);
				},
				1000 / this.fps
			);
		}
	},
	setfade : function (obj, value){
		if (!this.otpye){
			this.getotype(obj);
		}
		switch(this.otype)
		{
			case 'ie':
				obj.filters.alpha.opacity = value * 100;
			break;
			
			case 'khtml':
				obj.style.KhtmlOpacity = value;
			break;
			
			case 'moz':
				obj.style.MozOpacity = (value == 1) ? 0.9999999 : value;
			break;
			
			default:
				obj.style.opacity = (value == 1) ? 0.9999999 : value;
			break;
		}
	},
	getotype : function(obj){
		if (typeof obj.filters == 'object'){
			this.otype = (obj.filters.length >0
				&& typeof obj.filters.alpha == 'object'
				&& typeof obj.filters.alpha.opacity == "number")
				? 'ie' : 'none';
		}else if(typeof obj.style.opacity != 'undefined'){
			this.otype = 'w3c';
		}else if (typeof obj.style.MozOpacity != 'undefined'){
			this.otype = 'moz';
		}else if (typeof obj.style.KhtmlOpacity != 'undefined'){
			this.otype = 'khtml';
		}else{
			this.otype = false;
		}
		return false;
	}
}

cj.slidshow = {
	index : 0,
	objId : "slidshow",
	obj : new Object(),
	imgs : new Array(),
	rolltime : 10,
	init : function(){
		if (typeof slidImgs == "undefined" || slidImgs == ""){
			return;
		}
		this.obj = document.getElementById(this.objId);
		if (!this.obj){
			return;
		}
		
		//clear
		while(this.obj.childNodes[0]){
			this.obj.removeChild(this.obj.childNodes[0]);
		}
		var a = slidImgs.split(',');
		for (var i=0; i<a.length; i++){
			this.imgs[i] = document.createElement("img");
			this.imgs[i].src = a[i];
			this.imgs[i].style.cssText = "position:absolute; top: 0px; left: 0px; filter:alpha(opacity=0)";
			this.obj.appendChild(this.imgs[i]);
			cj.fade.setfade(this.imgs[i], 0);
		}
		cj.fade.setfade(this.imgs[0], 1);
		if(a.length>1)
			setTimeout("cj.slidshow.roll()", 5000);
	},
	roll : function(){
		this.index  = (this.index == this.imgs.length -1) ? 0 : this.index +1;
		var pre = (this.index) ? this.index -1 : this.imgs.length -1;
		cj.fade.setfade(this.imgs[pre], 0);
		//原來的圖 : 1--> 總共1秒， 0.8->0透明度從0.8->0
		//cj.fade.start(this.imgs[pre], 2, 0.8, 0)
		//下一張圖 : 2--> 總共2秒， 0.2->1透明度從0.2->1
		cj.fade.start(this.imgs[this.index], 2, 0.2, 1)
		setTimeout("cj.slidshow.roll()", this.rolltime * 1000);
	}
}
cj.drag = {
	draging : false,
	offsetX : 0,
	offsetY : 0,
	dragObj : null,
	start : function(ev){
		var ev = ev || window.event;
		var tgt = ev.target || ev.srcElement;
		if(typeof tgt.attrib != "undefined" && tgt.attrib == "dragable"){
			cj.drag.dragObj = tgt;
			cj.drag.draging = false;
			cj.drag.offsetY = (cj.util.getMousePos(ev)).y - tgt.offsetTop;
			cj.drag.offsetX = (cj.util.getMousePos(ev)).x - tgt.offsetLeft;
			cj.evt.add(document, "mousemove", cj.drag.drag);
			cj.evt.add(document, "mouseup", cj.drag.end);
		}
		return false;
	},
	drag : function(ev){
		if (!cj.drag.dragObj){
			return false;
		}
		cj.drag.dragObj.style.top = (cj.util.getMousePos(ev)).y - cj.drag.offsetY + "px";
		cj.drag.dragObj.style.left = (cj.util.getMousePos(ev)).x - cj.drag.offsetX + "px";
		if(typeof cj.drag.dragObj.mask != "undefined" && cj.drag.dragObj.mask){
			cj.drag.dragObj.mask.style.top = cj.drag.dragObj.style.top;
			cj.drag.dragObj.mask.style.left = cj.drag.dragObj.style.left;
		}
		cj.drag.draging = true;
		return false;
	},
	end : function(ev){
		if (!cj.drag.dragObj){
			return;
		}
		cj.drag.dragObj = null;
		cj.drag.draging = false;
		cj.evt.remove(document, "mousemove", cj.drag.drag);
		cj.evt.remove(document, "mouseup", cj.drag.end);
		return false;
	}
}
cj.simpleMenu = {
	timer : null,
	openObj : null,
	ar : 0.99,
	init: function(){
		var mm;
		var sm;
		for (var i=0; i<6; i++){
			mm = document.getElementById("cjNavMenu"+i);
			sm = document.getElementById("cjNavItem"+i);
			if (mm&&sm){
				mm.index = i;
				mm.onmouseover = function(){ cj.simpleMenu.show(this.index)};
				mm.onmouseout = function(){ cj.simpleMenu.hide(this.index)};
				
				var div = document.createElement("div");
				div.id = "cjNavSubMenu"+i;
				div.sm = sm;
				div.style.cssText = "position:absolute; display: none; z-index: 1000";
				div.style.top = cj.util.getElementPos(mm).top + mm.offsetHeight + "px";
				div.style.left = cj.util.getElementPos(mm).left + "px";
				div.style.width = sm.offsetWidth + "px";
				//document.body.removeChild(sm);
				div.appendChild(sm);
				sm.style.top = "0px";
				sm.style.left = "0px";
				mm.appendChild(div);
				mm.index = i;
			}
		}
	},
	show : function(id){
		if(this.openObj){
			this.openObj.style.display = "none";
		}
		clearTimeout(this.timer);
		this.openObj = document.getElementById("cjNavSubMenu"+id);
		if(this.openObj){
			this.openObj.style.display = "block";
		}
	},
	hide : function(id){
		var obj = document.getElementById("cjNavSubMenu"+id);
		if(obj) this.timer = setTimeout(function(){obj.style.display = "none"}, 600);
	}
}

cj.roller = {
	holdtime : 5000,
	rolltime : 25,
	ar : 0.99,
	gap : 7,
	init : function(boxid, itemcontainerid){
		var box = document.getElementById(boxid);
		if (!box){
			return;
		}
		var items = document.getElementById(itemcontainerid);
		if(!items)	return;
		box.items = items.getElementsByTagName('table');
		if(!box.items || box.items.length==0){
			return;
		}
		box.style.cssText = "position:relative; width:350px; height:155px; overflow:hidden;";
		box.index = 0;
		box.timer = null;
		
		box.div1 = document.createElement("div");
		box.div1.style.cssText = "position:absolute; top:0px; left:0px;";
		box.div2 = box.div1.cloneNode(true);
		box.div3 = box.div1.cloneNode(true);
		box.appendChild(box.div1);
		box.appendChild(box.div2);
		box.appendChild(box.div3);
		
		this.roll(box);
	},
	roll : function(obj){
		while(obj.div1.childNodes[0])
			obj.div1.removeChild(obj.div1.childNodes[0]);
		obj.div1.appendChild(obj.items[obj.index].cloneNode(true));
		obj.div1.style.top = 0 + "px";
		
		if(obj.items.length <2){
			return;
		}
		while(obj.div2.childNodes[0])
			obj.div2.removeChild(obj.div2.childNodes[0]);
		obj.div2.appendChild(obj.items[(obj.index+1)%obj.items.length].cloneNode(true));
		obj.div2.style.top = obj.div1.offsetHeight + 10 + "px";
		
		if(obj.items.length>2){
			obj.index  = (obj.index == obj.items.length -1) ? 0 : obj.index +1;
			while(obj.div3.childNodes[0])
				obj.div3.removeChild(obj.div3.childNodes[0]);
			obj.div3.appendChild(obj.items[(obj.index+1)%obj.items.length].cloneNode(true));
			obj.div3.style.top = 2*obj.div1.offsetHeight + this.gap + 10 + "px";
			
			obj.timer = setTimeout(function(){cj.roller.rollNext(obj, cj.roller.ar)}, cj.roller.holdtime);
		}
	},
	rollNext : function(obj, ar){
		var top = Math.floor(Math.max(0, obj.div2.offsetTop* ar));
		obj.div1.style.top = top - obj.div1.offsetHeight - this.gap + "px";
		obj.div2.style.top = top + "px";
		obj.div3.style.top = top + obj.div1.offsetHeight + this.gap + "px";
		if(!top){
			this.roll(obj);
		}else{
			obj.timer = setTimeout(function(){cj.roller.rollNext(obj, ar*cj.roller.ar)}, this.rolltime);
		}
	}
}

cj.form = {
	chk : function(id, fields){
		var f = document.getElementById(id);
		if(!f)	return false;
		f.onsubmit = function(){
			if(typeof this.lang == "undefined" || !this.lang){
				alert("lang not set");
				return false;
			}
			if(!this.lang){
				alert("form :lang not set");
				return false;
			}
			var lang = this.lang.value;
			if( typeof cj.msg == "undefined"){
				alert("cj.msg not set or lang.js not load");
				return false;
			}
			
			for (var i=0; i<fields.length; i++){
				var a = fields[i].split(',');
				var obj = f[a[0]];
				if(!obj){
					alert(a[0] + " not set");
					return false;
				}
				var type = a[1];
				var title = obj.getAttribute("title");
				if(!title){
					alert(a[0] + " title not set");
					return false;
				}
				switch (type){
					case "text":
						if( obj.value == "" ){
							alert(title + cj.msg.not_null[lang]);
							obj.focus();
							return false;
						}
					break;
					case "email":
						if(!cj.form.isEmail(obj.value)){
							alert(cj.msg.valid[lang] + title);
							obj.focus();
							return false;
						}
					break;
					case "account":
						if(!cj.form.isAccount(obj.value)){
							alert(cj.msg.valid[lang] + title);
							obj.focus();
							return false;
						}
					break;
					case "password":
						if(!cj.form.isPasswd(obj.value)){
							alert(cj.msg.valid[lang] + title);
							obj.focus();
							return false;
						}
						var passwd2 = f[obj.getAttribute("confirm")];
						if(obj.value != passwd2.value){
							alert(cj.msg.valid[lang] + passwd2.getAttribute("title"));
							passwd2.focus();
							return false;
						}
					break;
					case "checkbox":
						if(!obj.checked){
							alert(obj.getAttribute("title"));
							obj.focus();
							return false;
						}
					break;
					case "creditCard":
						var cardname = document.getElementById(obj.getAttribute("cardName"));
						if (!cardname){
							alert('Attribute : cardName not set');
							return false;
						}
						if(!cj.form.checkCreditCard.check(cardname.value, obj.value)){
							alert(cj.msg.valid[lang] + title);
							obj.focus();
							return false;
						}
					break;
				}
			}
			return true;
		}
	},
	isEmail : function(elm){
		re = /^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/
		return elm.match(re)
	},
	isAccount : function(obj){
		if (obj.length <3){
			return false;
		}
		var exp = /^[a-z][a-z0-9_]{2,15}$/;
		if(!exp.exec(obj)){
			return false;
		}
		return true;
	},
	isPasswd : function(obj){
		if (obj.length <3){
			return false
		}
		var exp = /['"]/;
		if(exp.exec(obj)){
			return false;
		}
		return true;
	},
	checkCreditCard : {
		/*
		American Express 3400 0000 0000 009 
		Carte Blanche 3000 0000 0000 04 
		Discover 6011 0000 0000 0004 
		Diner's Club 3000 0000 0000 04 
		enRoute 2014 0000 0000 009 
		JCB 2131 0000 0000 0008 
		MasterCard 5500 0000 0000 0004 
		Solo 6334 0000 0000 0004 
		Switch 4903 0100 0000 0009 
		Visa 4111 1111 1111 1111 
		*/
		cards : [
			{ name: "Visa", length: "13,16", prefixes: "4", checkdigit: true },
			{ name: "MasterCard", length: "16", prefixes: "51,52,53,54,55",checkdigit: true },
			{ name: "DinersClub", length: "14,16", prefixes: "300,301,302,303,304,305,36,38,55",checkdigit: true },
			{ name: "CarteBlanche", length: "14", prefixes: "300,301,302,303,304,305,36,38", checkdigit: true },
			{ name: "AmEx", length: "15", prefixes: "34,37",checkdigit: true },
			{ name: "Discover", length: "16", prefixes: "6011,650",checkdigit: true },
			{ name: "JCB", length: "15,16", prefixes: "3,1800,2131",checkdigit: true },
			{ name: "enRoute", length: "15", prefixes: "2014,2149",checkdigit: true },
			{ name: "Solo", length: "16,18,19", prefixes: "6334, 6767",checkdigit: true },
			{ name: "Switch", length: "16,18,19", prefixes: "4903,4905,4911,4936,564182,633110,6333,6759", checkdigit: true },
			{ name: "Maestro", length: "16", prefixes: "5020,6", checkdigit: true },
			{ name: "VisaElectron", length: "16", prefixes: "417500,4917,4913", checkdigit: true }
		],
		check : function (cardName, cardNumber){
			var cardType = -1;
			for (var i=0; i<this.cards.length; i++) {
				if (cardName.toLowerCase () == this.cards[i].name.toLowerCase()) {
					cardType = i;
					break;
				}
			}
			if (cardType == -1) {
				alert("cardType not found!");
				return false; 
			}
			
			if (cardNumber.length == 0){
				return false; 
			}
			
			cardNumber = cardNumber.replace (/\s/g, "");
			var cardNo = cardNumber
			var cardExp = /^[0-9]{13,19}$/;
			if (!cardExp.exec(cardNo)){
				return false; 
			}
			
			if (this.cards[cardType].checkdigit) {
				var checksum = 0;
				var j = 1;
			
				var calc;
				for (i = cardNo.length - 1; i >= 0; i--) {
					calc = Number(cardNo.charAt(i)) * j;
					if (calc > 9) {
						checksum = checksum + 1;
						calc = calc - 10;
					}
					checksum = checksum + calc;
					j = (j==1) ? 2 : 1;
					//if (j ==1) {j = 2} else {j = 1};
				}
			
				if (checksum % 10 != 0)  {
					return false; 
				}
			}  
			
			var LengthValid = false;
			var PrefixValid = false; 
			
			var prefix = new Array ();
			var lengths = new Array ();
			
			prefix = this.cards[cardType].prefixes.split(",");
			for (i=0; i<prefix.length; i++) {
				var exp = new RegExp ("^" + prefix[i]);
				if (exp.test (cardNo))
					PrefixValid = true;
			}
			if (!PrefixValid) {
				return false; 
			}
			
			lengths = this.cards[cardType].length.split(",");
			for (j=0; j<lengths.length; j++) {
				if (cardNo.length == lengths[j])
					LengthValid = true;
			}
			if (!LengthValid) {
				return false; 
			} 
			return true;
		}
	}
}

cj.calendar = {
	init : function(yid, mid, did, aid){
		var a = document.getElementById(aid);
		if(!a)	return;
		a.y = document.getElementById(yid);
		a.m = document.getElementById(mid);
		a.d = document.getElementById(did);
		if(!a.y || !a.m || !a.d)	return;
		
		//select onchange --hide
		cj.evt.add(a.y, "change", function(){a.hide()});
		cj.evt.add(a.m, "change", function(){a.hide()});
		cj.evt.add(a.d, "change", function(){a.hide()});
		
		a.closeH = 13;
		a.bolder = 2;
		a.boxW = 30;
		a.boxH = 25;
		
		a.draw = cj.calendar.draw;
		a.drawBox = cj.calendar.drawBox;
		a.show = cj.calendar.show;
		a.hide = cj.calendar.hide;
		a.lastMonth = cj.calendar.lastMonth;
		a.nextMonth = cj.calendar.nextMonth;
		a.drawCaption = cj.calendar.drawCaption;
		a.setDate = cj.calendar.setDate;
		a.setH = cj.calendar.setH;
		a.setTheDay = cj.calendar.setTheDay;
		
		cj.evt.add(a, "click", function(){a.show()});
		a.style.cursor = "pointer";
		
		a.win = document.createElement("div");
		a.win.id = "calendar";
		var width = 7*a.boxW + 2*a.bolder + 6;
		a.win.style.width = width + "px";
		a.win.style.top = (cj.util.getElementPos(a)).top + a.offsetHeight + 5 + "px";
		a.win.style.left = (cj.util.getElementPos(a)).left + a.offsetWidth - width +  "px";
		
		//drag
		a.win.attrib = "dragable";
		cj.evt.add(a.win, "mousedown", cj.drag.start);
		
		if(document.attachEvent){
			a.win.mask = document.createElement("iframe");
			a.win.mask.style.cssText = "position:absolute; display:none; border:0px;";
			a.win.mask.style.width = a.win.style.width;
			a.win.mask.style.top = a.win.style.top;
			a.win.mask.style.left = a.win.style.left;
			document.body.appendChild(a.win.mask);
		}
		
		//close
		a.closer = document.createElement("div");
		a.closer.parent = a;
		a.closer.id = "calCloser";
		a.closer.style.top = 1 + "px";
		a.closer.style.right = 1 + "px";
		cj.evt.add(a.closer, "click", function(evt){
			var evt = evt || window.event;
			tgt = evt.target || evt.srcElement;
			tgt.parent.hide();
			});
		a.win.appendChild(a.closer);
		
		//last
		a.last = a.drawBox('calLast', 0, 0, 1, 1, "&#60;&#60");
		a.last.parent = a;
		a.last.style.cursor = "pointer";
		a.last.onclick = a.lastMonth;
		a.win.appendChild(a.last);
		
		//caption
		a.caption = a.drawBox('calCaption', 0, 1, 5, 1, "");
		a.win.appendChild(a.caption);
		document.body.appendChild(a.win);
		
		//next
		a.next = a.drawBox('calNext', 0, 6, 1, 1, "&#62;&#62");
		a.next.parent = a;
		a.next.style.cursor = "pointer";
		a.next.onclick = a.nextMonth;
		a.win.appendChild(a.next);
		
		//nav
		a.nav = new Array();
		var days = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat");
		for (var i=0; i<days.length; i++){
			a.nav[i] = a.drawBox("calNav", 1, i, 1, 1, days[i]);
			a.win.appendChild(a.nav[i]);
		}
		document.body.appendChild(a.win);
	},
	draw : function(){
		this.setTheDay();
		this.drawCaption();
		this.setH();
		
		if (typeof this.box != "undefined"){
			for(i in this.box){
				this.win.removeChild(this.box[i]);
			}
			this.box = null;
		}
		this.box = new Array();
		for (var i=0; i<7*this.rows; i++){
			id = (i%7==0 || i%7==6) ? "calweekend" : "";
			var day = (i - this.firstWeekDay) + 1;
			if (day < 1 || day > this.monthDay)
				day = "";
			this.box[i] = this.drawBox(id, Math.floor(i/7)+2, (i%7), 1, 1, day);
			this.box[i].parent = this;
			if (day){
				this.box[i].style.cursor = "pointer";
				this.box[i].onclick = this.setDate;
			}
			if (day == this.d.value)
					this.box[i].id = "caltheday";
			this.win.appendChild(this.box[i]);
		}
	},
	setTheDay : function(){
		this.monthDay = cj.calendar.solarDays(this.y.value, this.m.value);
		this.firstWeekDay = (new Date(this.y.value + "/" + this.m.value + "/1")).getDay(); 
	},
	setH : function(){
		this.rows =  Math.ceil((this.monthDay + this.firstWeekDay)/7);
		this.win.style.height = 2*this.bolder + this.closeH + (this.rows+2)*(this.boxH+1) + "px";
		if(typeof this.win.mask != "undefined"){
			this.win.mask.style.height = this.win.style.height;
		}
	},
	drawCaption : function(){
		this.caption.innerHTML = this.y.value + "-" + this.m.value;
	},
	show : function(){
		if(typeof this.win.mask != "undefined"){
			this.win.mask.style.display = "block";
		}
		this.win.style.display = "block";
		this.draw();
		return false;
	},
	hide : function(){
		if(typeof this.win.mask != "undefined")
			this.win.mask.style.display = "none";
		this.win.style.display = "none";
	},
	setDate : function(){
		this.parent.d.selectedIndex = this.innerHTML - 1;
		this.parent.hide();
		if(typeof this.parent.d.onchange == "function")
			this.parent.d.onchange();
	},
	lastMonth : function(ev){
		if (this.parent.y.selectedIndex == 0 && this.parent.m.selectedIndex == 0)	return;
		if (this.parent.m.selectedIndex == 0){
			this.parent.y.selectedIndex --;
			this.parent.m.selectedIndex = 11;
		}else{
			this.parent.m.selectedIndex --;
		}
		this.parent.monthDay = cj.calendar.solarDays(this.parent.y.value, this.parent.m.value);
		this.parent.firstWeekDay = (new Date(this.parent.y.value + "/" + this.parent.m.value + "/1")).getDay(); 
		this.parent.draw();
	},
	nextMonth : function(){
		if (this.parent.y.selectedIndex >= this.parent.y.options.length && this.parent.m.selectedIndex >= this.parent.m.options.length){
			return false;
		}
		if (this.parent.m.selectedIndex == 11){
			this.parent.y.selectedIndex++;
			this.parent.m.selectedIndex = 0;
		}else{
			this.parent.m.selectedIndex++;
		}
		this.parent.monthDay = cj.calendar.solarDays(this.parent.y.value, this.parent.m.value);
		this.parent.firstWeekDay = (new Date(this.parent.y.value + "/" + this.parent.m.value + "/1")).getDay(); 
		this.parent.draw();
	},
	drawBox : function (id, t, l, w, h, htm){
		var obj = document.createElement("div");
		obj.id = id;
		obj.style.top = this.bolder + this.closeH + t*(this.boxH+1) + "px";
		
		obj.style.left = this.bolder + l*(this.boxW+1) + "px";
		obj.style.width = w * (this.boxW+1) - 1 + "px";
		obj.style.height = h * (this.boxH+1) -1 + "px";
		obj.innerHTML = htm;
		return obj;
	},
	solarDays : function (y,m){
		var solarMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		if( m == 2){
			return (( y%4 == 0) && (y%100 !=0) || (y%400 == 0)) ? 29 : 28;
		}else{
			return solarMonth[m-1];
		}
	}
}