//<![CDATA[
/*******************JSoul prototype extend Method [photo fade]******************/
JSoul.fn.extend({
	/**
	 * Insert a Image item
	 * @param {Image} imgItem
	 * @return JSoul
	 */
	InsertPhotoItem: function(imgItem){
		var _li = $.$b("li");
		$.insertLast(_li, imgItem);
		this.insertLast(_li);
		return this;
	},
	/**
	 * initialize photo fade
	 * @return JSoul
	 */
	initPhotoFade:function(){
		this.Subs = this.find("LI");
		var Main = this;
		this.Subs.each(function(i) {
			if(this.className == "choosed"){
				Main.Choosed = this;
			}
			this.Num = i;
		});
		this.timeOutEvent();
		return this;
	},
	/**
	 * Delay Photo fade
	 * @return JSoul
	 */
	PhotoFadeTimeout:function(){
		//Must had photo
		if(this.Choosed && this.Subs.length > 1){
			this.clearTimeEvent();
			this.Alpha = 100;
			$.css(this.Choosed,"z-index:2");
			this.Next = this.Subs[this.Choosed.Num + 1 < this.Subs.length?this.Choosed.Num + 1:0];
			$.css(this.Next,"z-index:1;visibility: visible;");
			$.setAlpha(this.Next, 100);
			this.timeIntervarEvent();
		}
		return this;
	},
	/**
	 * Photo fade effect
	 * @return JSoul
	 */
	PhotoFadeInterval:function(){
		this.Alpha -= Math.ceil(this.Alpha * this.speed);
		$.setAlpha(this.Choosed, this.Alpha);
		if(this.Alpha <= 1){
			this.clearTimeEvent();
			this.Alpha = 0;
			$.css(this.Choosed,"visibility: hidden;");
			this.Choosed = this.Next;
			this.timeOutEvent();
		}
		return this;
	}
});
/*******************JSoul prototype extend Method [Previous load images]******************/
JSoul.fn.extend({
	/**
	 * Previous load images
	 * @param {string} imageDealer
	 * @param {string} callback
	 * @param {array} imageUrls
	 * @return JSoul
	 */
	PreLoadImage: function(imageDealer, callback, imageUrls){
		if(imageUrls && imageUrls.length > 0){
			this.imageDealer = imageDealer;
			this.endCallback = callback;
			this.urlList = imageUrls;
			this.imageCount = imageUrls.length;
			this.loadCount = 0;
			if($.browser.opera){
				this.OperaImageLoader();
			}else{
				this.DefaultImageLoader();
			}
		}else{
			this[callback]();
		}
		return this;
	},
	/**
	 * Opera Image loader
	 * @return JSoul
	 */
	OperaImageLoader: function(){
		for(var i=0; i<this.imageCount; i++){
			var tmpImg=new Image(), self = this;
			tmpImg.src=this.urlList[i];
			tmpImg.onload=function() { 
				self.ImageLoader(this);
			} 
		}
		return this;
	},
	/**
	 * Default Image loader
	 * @return JSoul
	 */
	DefaultImageLoader: function(){
		var tmpImg=new Image(), self = this;
		tmpImg.src=this.urlList[this.loadCount];
		if($.browser.msie){
			if(tmpImg.readyState == "complete"){
				this.ImageLoader(tmpImg, true); 
			}else{
				tmpImg.onreadystatechange=function() { 
					if(this.readyState == "complete"){
						self.ImageLoader(this, true); 
					}
				}
			}
		}else{
			tmpImg.onload=function(){
				self.ImageLoader(this, true); 
			};
		}
		return this;
	},
	/**
	 * Image Loader
	 * @param {Object} tmpImg
	 * @param {Object} isProcess
	 * @return JSoul
	 */
	ImageLoader: function(tmpImg, isProcess){
		this.loadCount++;
		this[this.imageDealer](tmpImg);
		if(this.loadCount < this.imageCount && isProcess){
			this.DefaultImageLoader(); 
		}else if(this.loadCount == this.imageCount && this.endCallback){
			this[this.endCallback](); 
		}
		return this;
	}
});
/*******************JSoul prototype extend Method [Menu list]******************/
JSoul.fn.extend({
	/**
	 * initialize Menu list table
	 * @param {Node} Box
	 * @param {Number} minTop Menu box min top
	 * @param {Number} maxTop Menu box max top
	 * @param {Number} minHeight Menu box min height
	 * @param {Number} MaxHeight Menu box max height
	 * @return JSoul
	 */
	initMenuList:function(Box, minTop, maxTop, minHeight, MaxHeight){
		this.Box = Box;
		this.Table = this.Box.find("table");
		this.minTop = this.topStart = minTop;
		this.maxTop = maxTop;
		this.minHeight = this.heightStart = minHeight;
		this.MaxHeight = MaxHeight;
		return this;
	},
	
	/**
	 * Menu list display effect
	 * @return JSoul
	 */
	MenuListDisplay : function(){
		this.clearTimeEvent();
		this.state = true;
		this.isDisplay = true;
		this.setStyle("visibility","visible");
		this.Table.setStyle("position","static");
		this.topTarget = this.maxTop;
		this.HeightTarget = this.MaxHeight;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * Menu list hedden effect
	 * @return JSoul
	 */
	MenuListHidden : function(){
		this.clearTimeEvent();
		this.state = true;
		this.isDisplay = false;
		this.Table.setStyle("position","static");
		this.topTarget = this.minTop;
		this.HeightTarget = this.minHeight;
		this.timeIntervarEvent();
		return this;
	},
	MenuListInterval: function(){
//		var topAdd = $.getIntervalScale(this.topTarget,this.topStart,this.speed);
//		this.topStart += this.topStart + topAdd >= 0 ? 0 : topAdd; // 
//		var heightAdd = $.getIntervalScale(this.HeightTarget,this.heightStart,this.speed);
//		this.heightStart += heightAdd <= 0 ? 0 : heightAdd;

		this.topStart += $.getIntervalScale(this.topTarget,this.topStart,this.speed);
		this.heightStart += $.getIntervalScale(this.HeightTarget,this.heightStart,this.speed);
		if ($.isStopInterval(this.topTarget,this.topStart) && $.isStopInterval(this.HeightTarget,this.heightStart)) {
			this.clearTimeEvent();
			this.topStart = this.topTarget;
			this.heightStart = this.HeightTarget;
			if(this.isDisplay){
				this.Table.setStyle("position","relative");
			}else{
				this.setStyle("visibility","hidden");
			}
			this.state = false;
		}
		this.setStyle("marginTop", this.topStart + "px");
		this.Box.setStyle("height", this.heightStart + "px");
		return this;
	}
});
/*******************JSoul static extend Method [Navigator menu]******************/
JSoul.extend({
	/**
	 * display menu list table
	 */
	MenuListDisplay : function(){
		//if(!$.MenuList.state && !$.MenuList.isDisplay){}
		$.MenuList.MenuListDisplay();
		$.PrintMenu.PrintMenuOpen();
		$.MenuListHidden(this);
	},
	/**
	 * hidden menu list table
	 * @param {Object} elem
	 */
	MenuListHidden : function(elem){
		var _obj = $.MenuList.length > 0 ? $.MenuList[0]: null;
		if(!document.onmousemove){
			document.onmousemove = function(e){
				if(!$.CheckMenuListParent(elem, _obj,$.$eNode(e))){
					$.MenuList.MenuListHidden();
					$.PrintMenu.PrintMenuClose();
					this.onmousemove = null;
				}
			}
		}
	},
	/**
	 * Check is over menu
	 * @param {Node} elem
	 * @param {Node} elem2
	 * @param {Node} node
	 * @return Boolen
	 */
	CheckMenuListParent: function(elem, elem2, node){
		while(node.tagName != "HTML"){
			if(elem == node || elem2 == node){
				return true;
			}
			node = node.parentNode;
		}
		return false;
	},
	getIntervalScale: function(target, start, speed){
		var _target = Math.floor((target-start)*speed);
//nat		return _target == 0 ? 1 : _target;
		// only correct for a collapsing menu
		return (_target == 0) && (target == 0) ? 1 : _target;
	},
	isStopInterval: function(target,start){
		return Math.abs(start - target) <= 1;
	}
});
/*******************JSoul prototype extend Method [Print Menu box]******************/
JSoul.fn.extend({
	/**
	 * initialize Print Menu 
	 * @return JSoul
	 */
	initPrintMenu : function(min, max){
		this.min = this.start = min;
		this.max = max;
		return this;
	},
	PrintMenuOpen:function(){
		this.clearTimeEvent();
		this.target = this.max;
		this.timeIntervarEvent();
		return this;
	},
	PrintMenuClose:function(){
		this.clearTimeEvent();
		this.target = this.min;
		this.timeIntervarEvent();
		return this;
	},
	PrintMenuInterval: function(){
		var target = Math.floor((this.target-this.start)*this.speed);
//if(target < 0) alert("target < 0"); //nat
		this.start += target == 0 ? 1 : target;
		if (Math.abs(this.start - this.target) <= 1) {
			this.clearTimeEvent();
			this.start = this.target;
		}
		this.setStyle("marginRight", this.start + "px");
		return this;
	}
});
/*******************JSoul prototype extend Method [Partner Box]******************/
JSoul.fn.extend({
	/**
	 * initialize Partner Box
	 * @param {Number} width
	 * @param {Number} space images space
	 * @return JSoul
	 */
	initPartnerBox : function(width, space){
		var _listbox = this.find("UL").cleanEmptyNode();
		this.start = 0;
		this.width = $.clonePartnerList(_listbox[0],width, space);
		return this;
	},
	/**
	 * Partner Box scroll effect
	 * @return JSoul
	 */
	PartnerBoxInterval: function(){
		this.start += this.speed;
		if(this.start >= this.width){
			this.start = 0;
		}
		this.setStyle("marginLeft", -this.start + "px");
		return this;
	},
	/**
	 * Partner Box Mouse Event
	 * @return JSoul
	 */
	PartnerBoxMouseEvent : function(){
		this.bindEvent([["Main", this],["onmouseover", $.PartnerBoxMouseOver]]);
		return this;
	}
});
/*******************JSoul static extend Method [Partner Box]******************/
JSoul.extend({
	/**
	 * clone List when width not enough
	 * @param {Node} elem
	 * @param {Number} width
	 * @param {Number} space images space
	 * @return Number
	 */
	clonePartnerList: function(elem, width, space){
		if (elem)
		{
			var maxWidth = 0, _objs = elem.getElementsByTagName("img");
			if(_objs.length > 0){
				var maxWidth = $.getWidth(_objs, space);
				var _count = Math.ceil(width/maxWidth) + 1;
				for(var i=0;i<_count;i++){
					elem.parentNode.appendChild(elem.cloneNode(true));
				}
			}
			return maxWidth;
		}
	},
	/**
	 * Get object width
	 * @param {Node Array} objs
	 * @param {Number} space images space
	 * @return Number
	 */
	getWidth: function(objs, space){
		var widthCount = 0;
		for(var i=0,j=objs.length;i<j;i++){
			widthCount += objs[i].offsetWidth + space;
		}
		return widthCount;
	},
	/**
	 * mouse over Partner Box event
	 */
	PartnerBoxMouseOver: function(){
		if(this.Main.timeEventInterval){
			this.Main.clearTimeEvent();
			this.Main.timeEventInterval = null;
			$.PartnerBoxMouseOut(this);
		}
	},
	/**
	 * mouse out Partner Box event
	 * @param {Node} elem
	 */
	PartnerBoxMouseOut: function(elem){
		if(!document.onmousemove){
			document.onmousemove = function(e){
				if(!$.CheckMenuListParent(elem, null,$.$eNode(e))){
					elem.Main.timeIntervarEvent();
					this.onmousemove = null;
				}
			}
		}
	}
});
/*******************JSoul prototype extend Method [Message Box]******************/
JSoul.fn.extend({
	/**
	 * initialize Message Box
	 * @param {Number} fromX
	 * @param {Number} toX
	 * @param {JSoul} trigger
	 * @return JSoul
	 */
	initMsgBox : function(fromX, toX, trigger){
		this.isOpened = false;
		this.fromX = this.start = fromX;
		this.toX = toX;
		if($.browser.msie){
			this.fromX = this.start = fromX - 25;
			this.toX = toX - 25;
		}
		this.part = Math.abs(this.fromX - this.toX)/100;
		this.Alpha = 0;
		this.Title = this.find("h2");
		this.Content = this.find("$DIV,className,contexts");
		this.find("$A,className,close").bindEvent([["Main", this],["onclick",$.MsgBoxClose]]);
		trigger.bindEvent([["Main", this],["onclick",$.MsgBoxOpen]]);
		return this;
	},
	/**
	 * Message Box open
	 * @param {Node} elem
	 * @return JSoul
	 */
	MsgBoxOpen : function(elem){
		this.state = true;
		this.clearTimeEvent();
		this.end = this.toX;
		this.setStyle("visibility","visible");
		this.setAlpha(this.Alpha);
		this.elem = elem;
		this.callback = null;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * Message Box close
	 * @param {Node} elem
	 * @return JSoul
	 */
	MsgBoxClose : function(elem){
		this.state = true;
		this.clearTimeEvent();
		this.end = this.fromX;
		this.elem = elem;
		this.callback = elem?$.MsgBoxOpen:null;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * Message Box Effect
	 * @return JSoul
	 */
	MsgBoxInterval: function(){
		var target = Math.floor((this.end-this.start)*this.speed);
		this.start += target == 0 ? 1 : target;
		this.Alpha -= target/this.part;
		if (Math.abs(this.start - this.end) <= 1) {
			this.clearTimeEvent();
			this.start = this.end;
			if(this.isOpened){
				this.setStyle("visibility","hidden");
				this.Alpha = 0;
			}else{
				this.Alpha = 100;
			}
			this.state = false;
			this.isOpened = !this.isOpened;
			if (this.callback) {
				this.callback.call(this.elem);
			}
		}
		this.setAlpha(this.Alpha);
		this.setStyle("marginLeft", this.start + "px");
		return this;
	}
});
/*******************JSoul static extend Method [Message Box]******************/
JSoul.extend({
	/**
	 * Message Box close
	 */
	MsgBoxClose : function(){
		if(!this.Main.state && this.Main.isOpened){
			this.Main.MsgBoxClose();
		}
	},
	/**
	 * Message Box open
	 */
	MsgBoxOpen : function(){
		var isAjax = (this.rel == "ajax");
		if (!this.Main.state && isAjax) {
			if(this.Main.isOpened){
				this.Main.MsgBoxClose(this.Main.elem == this? null : this);
			}else{
				var obj = this;
				// Replace request uri
				var url = this.href+'?timestamp='+Date();
				url = url.replace("test.htm","responder.php");

				$.$xJson(url, function(data){
					obj.Main.Title.setAttr("innerHTML", data['title']);
					obj.Main.Content.setAttr("innerHTML", data['content']);
					obj.Main.MsgBoxOpen(obj);
				});
				return false;
			}
		}
		return !isAjax;
	}
});







/*******************JSoul prototype extend Method [Portfolio Box]******************/
JSoul.fn.extend({
	/**
	 * initialize Portfolio Box
	 * @param {Number} fromX
	 * @param {Number} toX
	 * @param {JSoul} trigger
	 * @return JSoul
	 */
	initPortfolioBox : function(fromX, toX, trigger){
		this.isOpened = false;
		this.fromX = this.start = fromX;
		this.toX = toX;
		if($.browser.msie){
			this.fromX = this.start = fromX - 25;
			this.toX = toX - 25;
		}
		this.part = Math.abs(this.fromX - this.toX)/100;
		this.Alpha = 0;
		this.Title = this.find("h2");
		this.Content = this.find("$DIV,className,contexts");
		this.find("$A,className,close").bindEvent([["Main", this],["onclick",$.PortfolioBoxClose]]);
		trigger.bindEvent([["Main", this],["onclick",$.PortfolioBoxOpen]]);
		return this;
	},
	/**
	 * Portfolio Box open
	 * @param {Node} elem
	 * @return JSoul
	 */
	PortfolioBoxOpen : function(elem){
		this.state = true;
		this.clearTimeEvent();
		this.end = this.toX;
		this.setStyle("visibility","visible");
		this.setAlpha(this.Alpha);
		this.elem = elem;
		this.callback = null;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * Portfolio Box close
	 * @param {Node} elem
	 * @return JSoul
	 */
	PortfolioBoxClose : function(elem){
		this.state = true;
		this.clearTimeEvent();
		this.end = this.fromX;
		this.elem = elem;
		this.callback = elem?$.PortfolioBoxOpen:null;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * Portfolio Box Effect
	 * @return JSoul
	 */
	PortfolioBoxInterval: function(){
		var target = Math.floor((this.end-this.start)*this.speed);
		this.start += target == 0 ? 1 : target;
		this.Alpha -= target/this.part;
		if (Math.abs(this.start - this.end) <= 1) {
			this.clearTimeEvent();
			this.start = this.end;
			if(this.isOpened){
				this.setStyle("visibility","hidden");
				this.Alpha = 0;
			}else{
				this.Alpha = 100;
			}
			this.state = false;
			this.isOpened = !this.isOpened;
			if (this.callback) {
				this.callback.call(this.elem);
			}
		}
		this.setAlpha(this.Alpha);
		this.setStyle("marginLeft", this.start + "px");
		return this;
	}
});
/*******************JSoul static extend Method [Portfolio Box]******************/
JSoul.extend({
	/**
	 * Portfolio Box close
	 */
	PortfolioBoxClose : function(){
		if(!this.Main.state && this.Main.isOpened){
			this.Main.PortfolioBoxClose();
		}
	},
	/**
	 * Portfolio Box open
	 */
	PortfolioBoxOpen : function(){
		var x = 0, y = 0;
		if( typeof( window.pageYOffset ) == 'number' )
		{
			// Netscape
			x = window.pageXOffset;
			y = window.pageYOffset;


			window.onscroll = (function ()
			{
//				document.getElementById('PortfolioBox').style.top = ((window.pageYOffset+20)+'px');
			});		
		}else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
		{
			// DOM
			x = document.body.scrollLeft;
			y = document.body.scrollTop;

			document.body.onscroll = (function ()
			{ 
//				document.getElementById('PortfolioBox').style.top =  ((document.body.scrollTop+20)+'px');
			});		
		}else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
		{
			// IE6 standards compliant mode
			x = document.documentElement.scrollLeft;
			y = document.documentElement.scrollTop;

			document.documentElement.onscroll = (function ()
			{ 
//				document.getElementById('PortfolioBox').style.top = ((document.documentElement.scrollTop+20)+'px');
			});		
		}


    
		var isAjax = (this.rel == "ajax");
		if (!this.Main.state && isAjax) {
			if(this.Main.isOpened){
				this.Main.PortfolioBoxClose(this.Main.elem == this? null : this);
			}else{
				var obj = this;

				// Set the y-position
				obj.Main.setStyle('top', (y+20)+'px');

				// Replace request uri
				var url = this.href+'?timestamp='+Date();
				url = url.replace("test.htm","portfolioresponder.php");
				
				$.$xJson(url, function(data){
					obj.Main.Content.setAttr("innerHTML", data['content']);
					obj.Main.Title.setAttr("innerHTML", data['title']);
					obj.Main.MsgBoxOpen(obj);

				});
				return false;
			}
		}
		return !isAjax;
	}
});
/*******************JSoul prototype extend Method [FileUpload Box]******************/
JSoul.fn.extend({
	/**
	 * initialize FileUpload Box
	 * @param {Number} fromX
	 * @param {Number} toX
	 * @param {JSoul} trigger
	 * @return JSoul
	 */
	initFileUploadBox : function(fromX, toX, trigger){
		this.isOpened = false;
		this.fromX = this.start = fromX;
		this.toX = toX;
		if($.browser.msie){
			this.fromX = this.start = fromX - 25;
			this.toX = toX - 25;
		}
		this.part = Math.abs(this.fromX - this.toX)/100;
		this.Alpha = 0;
		this.Title = this.find("h2");
		this.Content = this.find("$DIV,className,contexts");
		this.find("$A,className,close").bindEvent([["Main", this],["onclick",$.FileUploadBoxClose]]);
		trigger.bindEvent([["Main", this],["onclick",$.FileUploadBoxOpen]]);
		return this;
	},
	/**
	 * FileUpload Box open
	 * @param {Node} elem
	 * @return JSoul
	 */
	FileUploadBoxOpen : function(elem){
		this.state = true;
		this.clearTimeEvent();
		this.end = this.toX;
		this.setStyle("visibility","visible");
		this.setAlpha(this.Alpha);
		this.elem = elem;
		this.callback = null;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * FileUpload Box close
	 * @param {Node} elem
	 * @return JSoul
	 */
	FileUploadBoxClose : function(elem){
		this.state = true;
		this.clearTimeEvent();
		this.end = this.fromX;
		this.elem = elem;
		this.callback = elem?$.FileUploadBoxOpen:null;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * FileUpload Box Effect
	 * @return JSoul
	 */
	FileUploadBoxInterval: function(){
		var target = Math.floor((this.end-this.start)*this.speed);
		this.start += target == 0 ? 1 : target;
		this.Alpha -= target/this.part;
		if (Math.abs(this.start - this.end) <= 1) {
			this.clearTimeEvent();
			this.start = this.end;
			if(this.isOpened){
				this.setStyle("visibility","hidden");
				this.Alpha = 0;
			}else{
				this.Alpha = 100;
			}
			this.state = false;
			this.isOpened = !this.isOpened;
			if (this.callback) {
				this.callback.call(this.elem);
			}
		}
		this.setAlpha(this.Alpha);
		this.setStyle("marginLeft", this.start + "px");
		return this;
	}
});
/*******************JSoul static extend Method [FileUpload Box]******************/
JSoul.extend({
	/**
	 * FileUpload Box close
	 */
	FileUploadBoxClose : function(){
		if(!this.Main.state && this.Main.isOpened){
			this.Main.FileUploadBoxClose();
		}
	},
	/**
	 * FileUpload Box open
	 */
	FileUploadBoxOpen : function(){
	}
});
/*******************JSoul prototype extend Method [Message Box]******************/
JSoul.fn.extend({
	/**
	 * initialize Message Box
	 * @param {Number} fromX
	 * @param {Number} toX
	 * @param {JSoul} trigger
	 * @return JSoul
	 */
	initContactBox : function(fromX, toX, trigger){
		this.isOpened = false;
		this.fromX = this.start = fromX;
		this.toX = toX;
		if($.browser.msie){
			this.fromX = this.start = fromX - 25;
			this.toX = toX - 25;
		}
		this.part = Math.abs(this.fromX - this.toX)/100;
		this.Alpha = 0;
		this.Title = this.find("h2");
		this.Content = this.find("$DIV,className,contexts");
		this.find("$A,className,close").bindEvent([["Main", this],["onclick",$.ContactBoxClose]]);
		trigger.bindEvent([["Main", this],["onclick",$.ContactBoxOpen]]);
		return this;
	},
	/**
	 * Message Box open
	 * @param {Node} elem
	 * @return JSoul
	 */
	ContactBoxOpen : function(elem){
		this.state = true;
		this.clearTimeEvent();
		this.end = this.toX;
		this.setStyle("visibility","visible");
		this.setAlpha(this.Alpha);
		this.elem = elem;
		this.callback = null;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * Message Box close
	 * @param {Node} elem
	 * @return JSoul
	 */
	ContactBoxClose : function(elem){
		this.state = true;
		this.clearTimeEvent();
		this.end = this.fromX;
		this.elem = elem;
		this.callback = elem?$.ContactBoxOpen:null;
		this.timeIntervarEvent();
		return this;
	},
	/**
	 * Message Box Effect
	 * @return JSoul
	 */
	ContactBoxInterval: function(){
		var target = Math.floor((this.end-this.start)*this.speed);
		this.start += target == 0 ? 1 : target;
		this.Alpha -= target/this.part;
		if (Math.abs(this.start - this.end) <= 1) {
			this.clearTimeEvent();
			this.start = this.end;
			if(this.isOpened){
				this.setStyle("visibility","hidden");
				this.Alpha = 0;
			}else{
				this.Alpha = 100;
			}
			this.state = false;
			this.isOpened = !this.isOpened;
			if (this.callback) {
				this.callback.call(this.elem);
			}
		}
		this.setAlpha(this.Alpha);
		this.setStyle("marginLeft", this.start + "px");
		return this;
	}
});
/*******************JSoul static extend Method [Message Box]******************/
JSoul.extend({
	/**
	 * Message Box close
	 */
	ContactBoxClose : function(){
		if(!this.Main.state && this.Main.isOpened){
			this.Main.ContactBoxClose();
		}
	},
	/**
	 * Message Box open
	 */
	ContactBoxOpen : function(){
		var isAjax = (this.rel == "ajax");
		if (!this.Main.state && isAjax) {
			if(this.Main.isOpened){
				this.Main.ContactBoxClose(this.Main.elem == this? null : this);
			}else{
				var obj = this;
				// Replace request uri
				var url = this.href+'?timestamp='+Date();
				url = url.replace("javascript:void(0);","contact.php");

				$.$xJson(url, function(data){
					obj.Main.Title.setAttr("innerHTML", data['title']);
					obj.Main.Content.setAttr("innerHTML", data['content']);
					obj.Main.ContactBoxOpen(obj);
				});
				return false;
			}
		}
		return !isAjax;
	}
});












/*******************JSoul static extend Method [Search Box]******************/
JSoul.extend({
	SearchInputFocus:function(){
		if(this.value == this.defaultValue){
			this.value = "";
		}
	},
	SearchInputBlur:function(){
		if(this.value.trim() == ""){
			this.value = this.defaultValue;
		}
	}
});
/*******************JSoul prototype extend Method [Detail Box]******************/
JSoul.fn.extend({
	/**
	 * initialize Detail Box
	 * 
	 * @param {Object} Holder
	 * @param {Object} ScrollBox
	 * @param {Object} left 25
	 * @param {Object} width 900
	 * @return JSoul
	 */
	initDetailBox : function(Holder, ScrollBox, left, width){
		this.Holder = Holder;
		this.left = left;
		this.width = width;
		this.Alpha = 0;
		this.part = this.width/100;
		this.isOpened = false;
		this.Title = this.find("h2");
		this.Content = ScrollBox;
		this.find("$a,className,close").bindEvent([["Main", this],["onclick",$.DetailBoxClose]]);
		return this;
	},
	DetailBoxOpen:function(){
		this.state = true;
		this.clearTimeEvent();
		this.startX = (this.left*2) + this.width;
		this.endX = this.left;
		this.Holder.setStyle("display","block");
		this.setAlpha(this.Alpha);
		this.timeIntervarEvent();
		return this;
	},
	DetailBoxClose:function(){
		this.state = true;
		this.clearTimeEvent();
		//this.startX = this.left;
		//this.endX = -(this.left + this.width);
		this.startX = this.left;
		this.endX = (this.left*2) + this.width;
		this.timeIntervarEvent();
		return this;
	},
	DetailBoxInterval : function(){
		if (this.manual)
		{
			this.manual = false;
			this.state = false;
			this.clearTimeEvent();
		}else{

			if (this.Alpha == 0)
			{
				this.isOpened = false;
			}

			var target = Math.floor((this.endX-this.startX)*this.speed);
			this.startX += target == 0 ? 1 : target;
			this.Alpha = this.isOpened ? this.Alpha + target/this.part : this.Alpha - target/this.part;

			if (Math.abs(this.startX - this.endX) <= 1) {
				this.clearTimeEvent();
				this.startX = this.endX;
				if (this.isOpened) {
					this.Holder.setStyle("display","none");
					this.Alpha = 0;
				}else{
					$.DetailScrollBar.initBoxScrollScale();
					this.Alpha = 100;
					$('#DetailHolder').setStyle("display", "block");

				}
				this.state = false;
				this.isOpened = !this.isOpened;
			}
			this.setAlpha(this.Alpha);
			this.setStyle("marginLeft", this.startX + "px");
			return this;
		}
	}
});
/*******************JSoul static extend Method [Detail Box]******************/
JSoul.extend({
	DetailBoxOpen:function(){
		var isAjax = (this.rel == "ajax");
		if (!this.Main.state && isAjax) {
			var obj = this;
			var url = this.href;
			url = url.replace("test.htm","responder.php");

			document.getElementById('frmLogin').style.display = 'none';
			document.getElementById('overlay').style.display = 'none';

			$.$xJson(url, function(data){
					obj.Main.Content.setAttr("innerHTML", data['content']);
					obj.Main.Title.setAttr("innerHTML", data['title']);
					this.isOpened = false;
					obj.Main.DetailBoxOpen();
			});
			return false;
		}
		return !isAjax;
	},
	DetailBoxClose:function(){
		if (!this.Main.state) {
			this.Main.DetailBoxClose();
			//$('#DetailHolder').setStyle("display", "none");
		}
	}
});
/*******************standardish functions to open and close boxes - to be called from CMS-entered text******************/
JSoul.extend({
	showDetailBox : function(elem)
	{
		if(!elem.Main){
			$(elem).bindEvent([["Main", $.DetailBox],["onclick",$.DetailBoxOpen]]);
			return elem.onclick();
		}
		
		//$(elem).bindEvent([["Main", $.DetailBox],["onclick",$.DetailBoxOpen]]);
//		hideId = (hideId == null) ? "" : hideId;
//
//		var url = elem.href;
//		url = url.replace("test.htm","responder.php");
//
//		document.getElementById('frmLogin').style.display = 'none';
//		document.getElementById('overlay').style.display = 'none';
//
//		$.$xJson(url, function(data){
//			if (hideId)
//			{
//				$.hideBox(hideId);
//			}
//
//			$.DetailBox.state = true;
//			$('#DetailBox').find("H2").setAttr("innerHTML", data['title']);
//			$('#DetailInner').setAttr("innerHTML", data['content']);
//			$('#DetailHolder').setStyle("display", "block");
//			$('#DetailHolder').setStyle("visibility", "visible");
//			$('#DetailBox').setAlpha(100);
//			$('#DetailBox').setStyle("marginLeft", "26px");
//			$.DetailBox.state = false;
//			$.DetailBox.isOpened = true;
//			$.DetailBox.manual = true;
//		});
	
		//return false;
	},

	hideBox : function(id)
	{
		eval('$.'+id+'.state = false;');
		eval('$.'+id+'.isOpened = false;');
		$('#'+id).setStyle("marginLeft", "4000px");
	
		return false;
	}
});

/*******************JSoul prototype extend Method [Tel Box]******************/
JSoul.fn.extend({
	/**
	 * initialize Tel Box
	 * @param {Number} min
	 * @param {Number} max
	 * @return JSoul
	 */
	initTelBox : function(min, max){
		this.Min = min;
		this.Max = max;
		this.start = this.Min;
		this.bindEvent([["Main",this],["onmouseover",$.TelBoxOver]])
		return this;
	},
	TelBoxOver:function(){
		this.clearTimeEvent();
		this.target = this.Max;
		this.timeIntervarEvent();
		return this;
	},
	TelBoxOut: function(){
		this.clearTimeEvent();
		this.target = this.Min;
		this.timeIntervarEvent();
		return this;
	},
	TelBoxInterval:function(){
		var target = Math.floor((this.target-this.start)*this.speed);
		this.start += target == 0 ? 1 : target;
		if (Math.abs(this.start - this.target) <= 1) {
			this.clearTimeEvent();
			this.start = this.target;
		}
		this.setStyle("width",this.start + "px");
		return this;
	}
});
/*******************JSoul static extend Method [Tel Box]******************/
JSoul.extend({
	TelBoxOver: function(e){
		if (this == $.$eNode(e)) {
			this.Main.TelBoxOver();
			$.TelBoxMouseOut(this);
		}
	},
	TelBoxMouseOut: function(elem){
		if(!document.onmousemove){
			document.onmousemove = function(e){
				if(!$.CheckMenuListParent(elem, null,$.$eNode(e))){
					elem.Main.TelBoxOut();
					this.onmousemove = null;
				}
			}
		}
	}
});
/*******************JSoul prototype extend Method [Scroll bar]******************/
JSoul.fn.extend({
	initScrollBar: function(ScrollBox,height, min, max,space){
		this.Min = min;
		this.Max = max;
		this.space = space;
		this.height = height;
		this.valHeight = max - min;
		this.box = ScrollBox.bindEvent([["Main",this], ["onscroll",$.ScrollBoxMouseWhell]]);
		this.top = this.find("$div,className,scrolltop").initAttr("Main",this).initTimeIntervarEvent(100,2,"ScrollTopInterval");
		this.top.bindEvent([["Main", this],["JSoul",this.top],["onmousedown",$.ScrollMouseDown],["onmouseout",$.ScrollMouseUp],["onmouseup",$.ScrollMouseUp]])
				
		this.bottom = this.find("$div,className,scrollbottom").initAttr("Main",this).initTimeIntervarEvent(100,2,"ScrollBottomInterval");
		this.bottom.bindEvent([["Main", this],["JSoul",this.bottom],["onmousedown",$.ScrollMouseDown],["onmouseout",$.ScrollMouseUp],["onmouseup",$.ScrollMouseUp]]);
		
		this.bar = this.find("$div,className,scrollbar").initAttr("Main",this).Drag($.ScrollBarStart, $.ScrollBarRun,null);
		
		this.BarProvider = new $.IProvider(this);
		this.BarProvider.register("scroll.top",this.top,"TopCallback");
		this.BarProvider.register("scroll.bottom",this.bottom,"BottomCallback");
		return this;
	},
	initBoxScrollScale: function(){
		if(this.box.length > 0){
			var scrollHeight = this.box[0].scrollHeight;
			this.Scale=(scrollHeight-this.height)/this.valHeight;
			this.bar.setStyle("visibility",this.Scale > 0? "visible" : "hidden");
			this.box.run("onscroll");
		}
	},
	TopCallback:function(state, attchs){
		this.setStyle("height",(this.Main.Min + attchs.top)+"px");
		return this;
	},
	BottomCallback:function(state, attchs){
		this.setStyle("height",(this.Main.Max - attchs.top)+"px");
		return this;
	},
	ScrollTopInterval: function(){
		this.prevObject.box.SetBoxScrollHeight(-this.prevObject.space,true);
		return this;
	},
	ScrollBottomInterval : function(){
		this.prevObject.box.SetBoxScrollHeight(this.prevObject.space,true);
		return this;
	},
	SetBoxScrollHeight: function(space, isAdd){
		this.each(function(i) {
			this.scrollTop = isAdd? this.scrollTop + space : space;
		});
		return this;
	}
});
/*******************JSoul static extend Method [Scroll bar]******************/
JSoul.extend({
	ScrollMouseDown: function(){
		this.JSoul.timeIntervarEvent();
	},
	ScrollMouseUp : function(){
		this.JSoul.clearTimeEvent();
	},
	ScrollBoxMouseWhell: function(){
		var _top = Math.floor(this.scrollTop/this.Main.Scale);
		this.Main.BarProvider.notifyRun(false,{top:_top});
	},
	ScrollBarStart: function(e){
		this.clientY = e.clientY - Math.floor(this.JSoul.Main.box[0].scrollTop/this.JSoul.Main.Scale);
		return true;
	},
	ScrollBarRun: function(e){
		var space = Math.floor(this.JSoul.Main.Scale*(e.clientY - this.clientY));
		window.status = space;
		this.JSoul.Main.box.SetBoxScrollHeight(space);
	},
	getWinHeight:function(){
		return $.root.scrollHeight > $.root.clientHeight ? $.root.scrollHeight : $.root.clientHeight;
	},
	getWinWidth:function(){
		return $.root.scrollWidth > $.root.clientWidth ? $.root.scrollWidth : $.root.clientWidth;
	}
});
/*******************JSoul dynamic extend Method [Login Popup]******************/
JSoul.fn.extend({
	initLoginPopup : function(){
		var obj = this; // overlay
		var width = 276;
//this doesn't work because both .clientWidth and .offsetLeft are not consistent across browsers - only $.root.clientWidth is
//		var posX = (document.getElementById('PhotoBox').clientWidth + document.getElementById('PhotoBox').offsetLeft) - width;
		var PhotoBoxWidth = 925;
		var PhotBoxOffsetLeft = ($.root.clientWidth - PhotoBoxWidth) / 2;
		var posX = (PhotoBoxWidth + PhotBoxOffsetLeft) - width;

		this.frmLogin = $('#frmLogin');
		this.frmLogin.css('left:'+posX+'px;');

		this.bindEvent([["onclick", function(){
			obj.css('display: none;');
			obj.fadeOutLoginPopup((posX+100), (posX+20), 90);
		}]]);
		
		window.onresize = function(){
			var minWidth = document.getElementById('wrapper').offsetWidth;
			
			if(document.documentElement.clientWidth < minWidth){
				obj.css('width:'+minWidth+'px;');
			}else{
				obj.css('width:'+document.documentElement.clientWidth+'px;');
			}
			if(document.documentElement.clientHeight < document.documentElement.scrollHeight){
				obj.css('height:'+document.documentElement.scrollHeight+'px;');
			}else{
				obj.css('height:'+document.documentElement.clientHeight+'px;');
			}
			
			posX = (document.getElementById('PhotoBox').clientWidth + document.getElementById('PhotoBox').offsetLeft) - width;
			obj.frmLogin.css('left:'+posX+'px;');
		}
		
		$('#FileUpload').bindEvent([["onclick", function(){
			obj.css('width:'+$.getWinWidth()+'px;height:'+$.getWinHeight()+'px;');
			obj.css('display: block;');
			obj.frmLogin.css('display: block;');

			obj.frmLogin.css('left: '+(posX+100)+'px;');
			obj.frmLogin.setAlpha(0);
			obj.fadeInLoginPopup(posX, (posX+80), 10);

			obj.setAlpha(50);
		}]]);
	
		$('#FileUpload2').bindEvent([["onclick", function(){
			obj.css('width:'+$.getWinWidth()+'px;height:'+$.getWinHeight()+'px;');
			obj.css('display: block;');
			obj.frmLogin.css('display: block;');

			obj.frmLogin.css('left: '+(posX+100)+'px;');
			obj.frmLogin.setAlpha(0);
			obj.fadeInLoginPopup(posX, (posX+80), 10);

			obj.setAlpha(50);

//			obj.css('width:'+$.getWinWidth()+'px;height:'+$.getWinHeight()+'px;');
//			obj.css('display: block;');
//			obj.frmLogin.css('display: block;');
//			obj.setAlpha(50);
		}]]);
	},
	
	fadeInLoginPopup : function(posX, nextX, nextAlpha)
	{
		obj = this;
		
		obj.frmLogin.css('left: '+nextX+'px;');
		obj.frmLogin.setAlpha(nextAlpha);

		if (posX < nextX)
		{
			window.setTimeout('obj.fadeInLoginPopup('+posX+', '+Math.floor(nextX - ((nextX - posX) / 2))+', '+(nextAlpha+10)+')', 75);

		}else{
			obj.frmLogin.setAlpha(100);
		}
	},
	fadeOutLoginPopup : function(posX, nextX, nextAlpha)
	{
		obj = this;
		
		obj.frmLogin.css('left: '+nextX+'px;');
		obj.frmLogin.setAlpha(nextAlpha);

		if (posX > nextX)
		{
			window.setTimeout('obj.fadeOutLoginPopup('+posX+', '+Math.ceil(posX - ((posX - nextX) / 2))+', '+(nextAlpha-10)+')', 75);

		}else{
			obj.frmLogin.setAlpha(0);
			obj.frmLogin.css('display: none;');
		}
	}
});

JSoul.extend({
	setCompatibility : function(){
		// Set Navbar Font Bold For Firefox
		if($.browser.mozilla){
			$('#WrapBody').css("font-weight: bold;");
		}
	}
});
//]]>