var _IE6 = ((navigator.appName.indexOf('Microsoft Internet Explorer') != -1) && (parseInt(navigator.appVersion) < 7)) ? true : false;
var DD_belatedPNG={ns:"DD_belatedPNG",imgSize:{},delay:10,nodesFixed:0,createVmlNameSpace:function(){if(document.namespaces&&!document.namespaces[this.ns]){document.namespaces.add(this.ns,"urn:schemas-microsoft-com:vml")}},createVmlStyleSheet:function(){var b,a;b=document.createElement("style");b.setAttribute("media","screen");document.documentElement.firstChild.insertBefore(b,document.documentElement.firstChild.firstChild);if(b.styleSheet){b=b.styleSheet;b.addRule(this.ns+"\\:*","{behavior:url(#default#VML)}");b.addRule(this.ns+"\\:shape","position:absolute;");b.addRule("img."+this.ns+"_sizeFinder","behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;");this.screenStyleSheet=b;a=document.createElement("style");a.setAttribute("media","print");document.documentElement.firstChild.insertBefore(a,document.documentElement.firstChild.firstChild);a=a.styleSheet;a.addRule(this.ns+"\\:*","{display: none !important;}");a.addRule("img."+this.ns+"_sizeFinder","{display: none !important;}")}},readPropertyChange:function(){var b,c,a;b=event.srcElement;if(!b.vmlInitiated){return}if(event.propertyName.search("background")!=-1||event.propertyName.search("border")!=-1){DD_belatedPNG.applyVML(b)}if(event.propertyName=="style.display"){c=(b.currentStyle.display=="none")?"none":"block";for(a in b.vml){if(b.vml.hasOwnProperty(a)){b.vml[a].shape.style.display=c}}}if(event.propertyName.search("filter")!=-1){DD_belatedPNG.vmlOpacity(b)}},vmlOpacity:function(b){if(b.currentStyle.filter.search("lpha")!=-1){var a=b.currentStyle.filter;a=parseInt(a.substring(a.lastIndexOf("=")+1,a.lastIndexOf(")")),10)/100;b.vml.color.shape.style.filter=b.currentStyle.filter;b.vml.image.fill.opacity=a}},handlePseudoHover:function(a){setTimeout(function(){DD_belatedPNG.applyVML(a)},1)},fix:function(a){if(this.screenStyleSheet){var c,b;c=a.split(",");for(b=0;b<c.length;b++){this.screenStyleSheet.addRule(c[b],"behavior:expression(DD_belatedPNG.fixPng(this))")}}},applyVML:function(a){a.runtimeStyle.cssText="";this.vmlFill(a);this.vmlOffsets(a);this.vmlOpacity(a);if(a.isImg){this.copyImageBorders(a)}},attachHandlers:function(i){var d,c,g,e,b,f;d=this;c={resize:"vmlOffsets",move:"vmlOffsets"};if(i.nodeName=="A"){e={mouseleave:"handlePseudoHover",mouseenter:"handlePseudoHover",focus:"handlePseudoHover",blur:"handlePseudoHover"};for(b in e){if(e.hasOwnProperty(b)){c[b]=e[b]}}}for(f in c){if(c.hasOwnProperty(f)){g=function(){d[c[f]](i)};i.attachEvent("on"+f,g)}}i.attachEvent("onpropertychange",this.readPropertyChange)},giveLayout:function(a){a.style.zoom=1;if(a.currentStyle.position=="static"){a.style.position="relative"}},copyImageBorders:function(b){var c,a;c={borderStyle:true,borderWidth:true,borderColor:true};for(a in c){if(c.hasOwnProperty(a)){b.vml.color.shape.style[a]=b.currentStyle[a]}}},vmlFill:function(e){if(!e.currentStyle){return}else{var d,f,g,b,a,c;d=e.currentStyle}for(b in e.vml){if(e.vml.hasOwnProperty(b)){e.vml[b].shape.style.zIndex=d.zIndex}}e.runtimeStyle.backgroundColor="";e.runtimeStyle.backgroundImage="";f=true;if(d.backgroundImage!="none"||e.isImg){if(!e.isImg){e.vmlBg=d.backgroundImage;e.vmlBg=e.vmlBg.substr(5,e.vmlBg.lastIndexOf('")')-5)}else{e.vmlBg=e.src}g=this;if(!g.imgSize[e.vmlBg]){a=document.createElement("img");g.imgSize[e.vmlBg]=a;a.className=g.ns+"_sizeFinder";a.runtimeStyle.cssText="behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;";c=function(){this.width=this.offsetWidth;this.height=this.offsetHeight;g.vmlOffsets(e)};a.attachEvent("onload",c);a.src=e.vmlBg;a.removeAttribute("width");a.removeAttribute("height");document.body.insertBefore(a,document.body.firstChild)}e.vml.image.fill.src=e.vmlBg;f=false}e.vml.image.fill.on=!f;e.vml.image.fill.color="none";e.vml.color.shape.style.backgroundColor=d.backgroundColor;e.runtimeStyle.backgroundImage="none";e.runtimeStyle.backgroundColor="transparent"},vmlOffsets:function(d){var h,n,a,e,g,m,f,l,j,i,k;h=d.currentStyle;n={W:d.clientWidth+1,H:d.clientHeight+1,w:this.imgSize[d.vmlBg].width,h:this.imgSize[d.vmlBg].height,L:d.offsetLeft,T:d.offsetTop,bLW:d.clientLeft,bTW:d.clientTop};a=(n.L+n.bLW==1)?1:0;e=function(b,p,q,c,s,u){b.coordsize=c+","+s;b.coordorigin=u+","+u;b.path="m0,0l"+c+",0l"+c+","+s+"l0,"+s+" xe";b.style.width=c+"px";b.style.height=s+"px";b.style.left=p+"px";b.style.top=q+"px"};e(d.vml.color.shape,(n.L+(d.isImg?0:n.bLW)),(n.T+(d.isImg?0:n.bTW)),(n.W-1),(n.H-1),0);e(d.vml.image.shape,(n.L+n.bLW),(n.T+n.bTW),(n.W),(n.H),1);g={X:0,Y:0};if(d.isImg){g.X=parseInt(h.paddingLeft,10)+1;g.Y=parseInt(h.paddingTop,10)+1}else{for(j in g){if(g.hasOwnProperty(j)){this.figurePercentage(g,n,j,h["backgroundPosition"+j])}}}d.vml.image.fill.position=(g.X/n.W)+","+(g.Y/n.H);m=h.backgroundRepeat;f={T:1,R:n.W+a,B:n.H,L:1+a};l={X:{b1:"L",b2:"R",d:"W"},Y:{b1:"T",b2:"B",d:"H"}};if(m!="repeat"||d.isImg){i={T:(g.Y),R:(g.X+n.w),B:(g.Y+n.h),L:(g.X)};if(m.search("repeat-")!=-1){k=m.split("repeat-")[1].toUpperCase();i[l[k].b1]=1;i[l[k].b2]=n[l[k].d]}if(i.B>n.H){i.B=n.H}d.vml.image.shape.style.clip="rect("+i.T+"px "+(i.R+a)+"px "+i.B+"px "+(i.L+a)+"px)"}else{d.vml.image.shape.style.clip="rect("+f.T+"px "+f.R+"px "+f.B+"px "+f.L+"px)"}},figurePercentage:function(d,c,f,a){var b,e;e=true;b=(f=="X");switch(a){case"left":case"top":d[f]=0;break;case"center":d[f]=0.5;break;case"right":case"bottom":d[f]=1;break;default:if(a.search("%")!=-1){d[f]=parseInt(a,10)/100}else{e=false}}d[f]=Math.ceil(e?((c[b?"W":"H"]*d[f])-(c[b?"w":"h"]*d[f])):parseInt(a,10));if(d[f]%2===0){d[f]++}return d[f]},fixPng:function(c){c.style.behavior="none";var g,b,f,a,d;if(c.nodeName=="BODY"||c.nodeName=="TD"||c.nodeName=="TR"){return}c.isImg=false;if(c.nodeName=="IMG"){if(c.src.toLowerCase().search(/\.png$/)!=-1){c.isImg=true;c.style.visibility="hidden"}else{return}}else{if(c.currentStyle.backgroundImage.toLowerCase().search(".png")==-1){return}}g=DD_belatedPNG;c.vml={color:{},image:{}};b={shape:{},fill:{}};for(a in c.vml){if(c.vml.hasOwnProperty(a)){for(d in b){if(b.hasOwnProperty(d)){f=g.ns+":"+d;c.vml[a][d]=document.createElement(f)}}c.vml[a].shape.stroked=false;c.vml[a].shape.appendChild(c.vml[a].fill);c.parentNode.insertBefore(c.vml[a].shape,c)}}c.vml.image.shape.fillcolor="none";c.vml.image.fill.type="tile";c.vml.color.fill.on=false;g.attachHandlers(c);g.giveLayout(c);g.giveLayout(c.offsetParent);c.vmlInitiated=true;g.applyVML(c)}};try{document.execCommand("BackgroundImageCache",false,true)}catch(r){}DD_belatedPNG.createVmlNameSpace();DD_belatedPNG.createVmlStyleSheet();
DD_belatedPNG.fix('img');


function findPosY(obj) {
	var posTop = 0;
	while (obj.offsetParent) {posTop += obj.offsetTop; obj = obj.offsetParent;}
	return posTop;
}
function findPosX(obj) {
	var posLeft = 0;
	while (obj.offsetParent) {posLeft += obj.offsetLeft; obj = obj.offsetParent;}
	return posLeft;
}
/*--- contact gallery function ---*/
function contactGallery(){
	var _hold = $$('div.contact-team')[0];
	if(_hold){
		var gal_hold = _hold.getElement('div.contact-gallery');
		if(gal_hold){
			var btn_prev = gal_hold.getChildren('a.link-prev')[0];
			var btn_next = gal_hold.getChildren('a.link-next')[0]; 
			var list_h = gal_hold.getElement('div.gallery-hold > ul');
			var _list = false;
			if(list_h) _list = list_h.getChildren();
			if(_list){
				var _step = list_h.parentNode.offsetWidth;
				var _w = 0;
				var _m = 0;
				for(var i = 0; i < _list.length; i++){
					_w += _list[i].offsetWidth;
				}
				if(_w > _step){
					var t_list_h = list_h.getChildren();
					for(var i = 0; i < t_list_h.length; i++) list_h.grab(t_list_h[i].clone());
					for(var i = 0; i < t_list_h.length; i++) list_h.grab(t_list_h[i].clone());
					_m = _w;
					list_h.style.left = - _m + 'px';
					list_h.moo = new Fx.Tween(list_h, {
						duration: 1000,
						link:'cancel',
						'onComplete': function(){
							_flag = true;
						}
					});
					if(btn_prev){
						btn_prev.onclick = function(){
							moveList(false);
							return false;
						}
					}
					if(btn_next){
						btn_next.onclick = function(){
							moveList(true);
							return false;
						}
					}
				}
				else{
					if(btn_prev){
						btn_prev.onclick = function(){
							return false;
						}
					}
					if(btn_next){
						btn_next.onclick = function(){
							return false;
						}
					}
				}
			}
			var _flag = true;
			function moveList(_f){
				if(_flag){
					_flag = false;
					if(_f){
						if(_m + _step > 3*_w -_step){
							_m -= _w;
							list_h.style.left = -_m + 'px';
						}
						_m += _step;
					}
					else{
						if(_m - _step < 0){
							_m += _w;
							list_h.style.left = -_m + 'px';
						}
						_m -=_step;
					}
					list_h.moo.start('left', -_m);
				}
			}
		}
		var btn_open = _hold.getElement('div.box > a.contact-member');
		var open_text = _hold.getElement('div.box > span.btn-contact-team');
		if(gal_hold && btn_open){
			var open_f = false;
			var open_h = gal_hold.offsetHeight;
			if(_hold.hasClass('active')){
				gal_hold.style.display = 'block';
				open_f = true;
				if(open_text) open_text.innerHTML = 'Close Team Member Selectorz';
			}
			else{
				gal_hold.style.display = 'none';
				open_f = false;
				if(open_text) open_text.innerHTML = 'Open Team Member Selectorz';
			}
			gal_hold.moo = new Fx.Tween(gal_hold, {
				duration: 500,
				link:'cancel',
				'onComplete': function(){
					if(open_f){
						gal_hold.style.height = 'auto';
					}
					else{
						gal_hold.style.display = 'none';
						gal_hold.style.height = 'auto';
					}
				}
			});
			btn_open.onclick = function(){
				if(open_f){
					open_f = false;
					_hold.removeClass('active');
					if(open_text) open_text.innerHTML = 'Open Team Member Selectorz';
					gal_hold.style.height = gal_hold.offsetHeight + 'px';
					gal_hold.moo.start('height', 0);
				}
				else{
					open_f = true;
					_hold.addClass('active');
					if(open_text) open_text.innerHTML = 'Close Team Member Selectorz';
					if(gal_hold.offsetHeight == 0){
						gal_hold.style.display = 'block';
						open_h = gal_hold.offsetHeight;
						gal_hold.style.height = '0px';
					}
					gal_hold.moo.start('height', open_h);
				}
				return false;
			}
		}
	}
}
/*--- studies gallery ---*/
var list_list;
var keyy=0;
var listLength;
function studiesGallery(){
	var _hold = $$('div.study-box')[0];
	if(_hold){
		var gal_hold = _hold.getElement('div.studies');
		var info_hold = _hold.getElement('div.home-box-hold');
		if(gal_hold){
			var btn_prev = gal_hold.getChildren('a.link-previous')[0];
			var btn_next = gal_hold.getChildren('a.link-next')[0]; 
			var list_h = gal_hold.getElement('div.study-gallery > ul');
			var _list = false;
			if(list_h) _list = list_h.getChildren();
			
			if(_list){
				var gall_hold_w = list_h.parentNode.offsetWidth;
				var _w = 0;
				var _m = 0;
				var _a = 0;
				
				var _mht=0;
				
				for(var i = 0; i < _list.length; i++){
					_w += _list[i].offsetWidth;
				}
				if(_w > gall_hold_w){
					for(var i = 0; i < _list.length; i++) list_h.grab(_list[i].clone());
					for(var i = 0; i < _list.length; i++) list_h.grab(_list[i].clone());
					
					_m = _w;
					list_h.style.left = - _m + 'px';
					list_h.moo = new Fx.Tween(list_h, {
						duration: 500,
						link:'cancel',
						'onComplete': function(){
							_flag = true;
						}
					});
					if(btn_prev){
						btn_prev.onclick = function(){
							moveList(false);
							return false;
						}
					}
					if(btn_next){
						btn_next.onclick = function(){
							moveList(true);
							return false;
						}
					}
				}
				else{
				   
					if(btn_prev){
						btn_prev.onclick = function(){
							return false;
						}
					}
					if(btn_next){
						btn_next.onclick = function(){
							return false;
						}
					}
				}
				
				var info_a = -1;
				var info_d  = (_IE6)?'0':'800';
				list_h.getChildren().each(function(_el, _i){
					var _tooltip = _el.getElement('.btn-study');
					if(_tooltip) _tooltip = _tooltip.clone();
					_el._box = false;
					_el._url = _el.getElement('a.more-button').href;
					
					if(_el.hasClass('active') && info_a == -1) info_a = _i;
					else(_el.removeClass('active'));
					_el.onmouseover = function(){
						if(_tooltip){
							$(document.body).grab(_tooltip);
							_tooltip.style.top = $(this).getPosition().y + 'px';
							_tooltip.style.left = $(this).getPosition().x + 'px';
							_tooltip.style.display = 'block';
						}
						$(this).addClass('hover2');
					}
					_el.onmouseout = function(){
						if(_tooltip) _tooltip.dispose();
						$(this).removeClass('hover2');
					}
				});
				var _list2=list_h.getChildren();
			    if(_list2.length>4){
			        _list2[0].addClass('hover');
			        _list2[_list2.length/3].addClass('hover');
			        _list2[_list2.length/3*2].addClass('hover');
			    }
			    else{
			        _list2[0].addClass('hover');
			    }
				if(info_a == -1) info_a = 0;
				var info_f = true;
				var _flag = true;
				if(info_hold){
					info_hold.empty();
					var _loader = document.createElement('div');
					_loader.className = 'loader';
					_loader.innerHTML = 'Loading...';
					_loader = $(_loader);
					info_hold.grab(_loader);
					_loader.setOpacity(0);
					_loader.style.display = 'block';
					_loader.moo = new Fx.Tween(_loader, {
						duration: 300,
						link:'cancel',
						'onComplete': function(){
							
						}
					});
					var info_btn = list_h.getChildren();
					var info_text_h = document.createElement('div');
					info_text_h = $(info_text_h);
					info_btn.each(function(_el, _i){
						if(_i == info_a){
							info_f = false;
							var myRequest = new Request.HTML({method: 'get', url: _el._url, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
								info_text_h.innerHTML = responseHTML;
								_el._box = info_text_h.getChildren('.home-box')[0];
								info_hold.grab(_el._box);
								_el._box.moo = new Fx.Tween(_el._box, {
									duration: info_d,
									link:'cancel',
									'onComplete': function(_box){
										if(_box.hasClass('active')) info_f = true;
									}
								});
								initVideoTooltips(_el._box);
								setTimeout(function(){
									_el._box.addClass('active');
									_el._box.setOpacity(0);
									_el._box.style.display = 'block';
									_el._box.moo.start('opacity', 1);
								}, 100);
							}});
							myRequest.send();
						}
						_el.onclick = function(){
							
							if(_i != info_a && info_f){
                                    info_f = false;
								    info_btn[info_a]._box.removeClass('active');
								    info_btn[info_a]._box.moo.start('opacity', 0);
								    var info_a2=info_a;
								    var _i2=_i;
                                if(_list.length>4){
                                    if(_list2.length/3<=info_a2&&info_a2<_list2.length/3*2)
                                    {
                                        info_a2-=_list2.length/3;
                                    }else if(info_a2>=_list2.length/3*2){
                                        info_a2-=_list2.length/3*2;
                                    }
                                    if(_list2.length/3<=_i2&&_i2<_list2.length/3*2){
                                        _i2-=_list2.length/3;
                                    }else if(_i2>=_list2.length/3*2){
                                        _i2-=_list2.length/3*2;
                                    }
								    _list2[info_a2].removeClass('hover');
								    _list2[info_a2+_list2.length/3].removeClass('hover');
								    _list2[info_a2+_list2.length/3*2].removeClass('hover')
								    _list2[_i2].addClass('hover');
								    _list2[_i2+_list2.length/3].addClass('hover');
								    _list2[_i2+_list2.length/3*2].addClass('hover');
								    
								    _mht=_i2;
								}
								else
								{
								    _list[info_a].removeClass('hover');
								    _list[_i].addClass('hover');
								    _mht=_i;
								}
								if(_el._box){
									_el._box.addClass('active');
									_el._box.moo.start('opacity', 1);
									info_a = _i;
								}
								else{
									_loader.moo.start('opacity', 1);
									setTimeout(function(){
										var myRequest = new Request.HTML({method: 'get', url: _el._url, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
											_loader.moo.start('opacity', 0);
											info_text_h.innerHTML = responseHTML;
											_el._box = info_text_h.getChildren('.home-box')[0];
											info_hold.grab(_el._box);
											_el._box.moo = new Fx.Tween(_el._box, {
												duration: info_d,
												link:'cancel',
												'onComplete': function(_box){
													if(_box.hasClass('active')) info_f = true;
												}
											});
											initVideoTooltips(_el._box);
											setTimeout(function(){
												_el._box.addClass('active');
												_el._box.setOpacity(0);
												_el._box.style.display = 'block';
												_el._box.moo.start('opacity', 1);
											}, 100);
											info_a = _i;
										}});
										myRequest.send();
									}, info_d);
								}
							}
							return false;
						}
					});
				}
			}
			
			function moveList(_f){
			
			    if(_mht>0)
			        _a=_mht;
			        
			    if(list_h.getStyle('left').toInt()<=-2940)
			    {
			        _a=0;
			        
			        _m=0;
			        
			        //list_h.setStyle('left','0px');
			        
		        }
			    
		        
			    if(_list.length<=4){
			        if(_a+1 == _list.length){
					    _a = -1;
					}
					_a++;
		            info_btn[_a].onclick();
			    }else{
				    if(_flag){
    				
					    _flag = false;
					    if(_f){
    					
						    if(_a == _list.length){
							    _a = 0;
							    _m = _w;
							    list_h.style.left = -_m + 'px';
						    }
						    _m += _list[_a].offsetWidth;
						    _a++;
					    }
					    else{
						    _a--;
						    if(_a == -1){
							    _a = _list.length - 1;
							    _m = _w;
							    list_h.style.left = -_m + 'px';
						    }
						    _m -= _list[_a].offsetWidth;
					    }
					    list_h.moo.start('left', -_m);
				    }
					info_btn[_a].onclick();
				}
				
			}
			
			//By Mahongtao Begin
			
			function MoveAuto()
		    {
    		    moveList(true);
		    }
		    
		    setInterval(MoveAuto,15000);
			
			//By Mahongtao End
		}
	}
}



/*----  cyc ---*/


function theNext(){
    list_list[keyy].onclick();
    if(keyy<listLength-1){
        keyy++;
    }
    else{
        keyy=0;
    }
    setTimeout("theNext()",5000);
}

function studiesGalleryTimeout(){
	var _hold = $$('div.study-box')[0];
	if(_hold){
		var gal_hold = _hold.getElement('div.studies');
		var info_hold = _hold.getElement('div.home-box-hold');
		if(gal_hold){
			var btn_prev = gal_hold.getChildren('a.link-previous')[0];
			var btn_next = gal_hold.getChildren('a.link-next')[0]; 
			var list_h = gal_hold.getElement('div.study-gallery > ul');
			list_list=list_h.getChildren();
			listLength=list_list.length;
			if(listLength>=5){
			   keyy = listLength/3;
			}else{
			    keyy=0;
			}
			//theNext(list_list,keyy);
			theNext();
		}
	}
	//setTimeout("studiesGallery("+keyy+")",10000);
}
/*--- footer slide function ---*/
function footerSlide(){
	var _hold = $('sub-footer');
	if(_hold){
		var _btn = _hold.getElement('span.btn-opener');
		var _box = _hold.getElement('div.footer-info');
		function boxHeight(e){
			if(_f){
				if(!_IE6) _y2 = k_h + _y1 - e.pageY;
				else _y2 = k_h + _y1 - e.clientY - document.documentElement.scrollTop;
				if(_y2 >= 0){
					if(_y2 < _h){
						_hold.style.marginTop = -_y2 +'px';
						_box.style.height = _y2 + 'px';
					}
				}
			}
		}
		function boxAttr2(){
			if(_f) return false;
		}
		function  boxAttr1(){
			if(_f){
				_f = false;
				if(_box.offsetHeight <= 10){
					_box.style.display = 'none';
					_box.style.height = 'auto';
					_btn.className = _btn.className.replace('opened','');
					_hold.style.marginTop = '0px';
				}
			}
		}
		if(_btn && _box){
			var _h = _box.offsetHeight;
			var k_h = 0;
			_box.style.display = 'none';
			var _y1, _y2;
			var _f = false;
			var _f1 = false;
			var _f2 = false;
			_btn.onmousedown = function(e){
				_f = true;
				k_h = _box.offsetHeight;
				if(e) _y1 = e.pageY;
				else _y1 = event.clientY + document.documentElement.scrollTop;
				if(_btn.className.indexOf('opened') == -1) _btn.className += ' opened';
				if(k_h == 0){
					_box.style.display = 'block';
					_h = _box.offsetHeight;
					_box.style.height = '0px';
				}
				return false;
			}
			_btn.onmouseup = function(e){
				_f = false;
				if(_box.offsetHeight <= 10){
					_btn.className = _btn.className.replace('opened','');
					_box.style.display = 'none';
					_box.style.height = 'auto';
					_hold.style.marginTop = '0px';
				}
				return false;
			}
			_btn.onclick = function(){
				_f = false;
				return false;
			}
			if (window.addEventListener){
				document.body.addEventListener("mousemove", boxHeight, false);
				document.body.addEventListener("mouseup", boxAttr1, false);
			}
			else if (window.attachEvent && !window.opera){
				document.body.attachEvent("onmousemove", boxHeight);
				document.body.attachEvent("onmouseup", boxAttr1);
				document.body.attachEvent("onselectstart", boxAttr2);
			}
		}
	}
}
/*---- fade gallery ----*/
function fadeGallery(){
	var list_h = $$('ul.fade-gall-list')[0];
	var box_h = $$('div.fade-gall-hold')[0];
	if(list_h && box_h){
		var _loader = document.createElement('div');
//		_loader.className = 'loader';
		_loader.innerHTML = '';
		_loader = $(_loader);
		box_h.grab(_loader);
		_loader.setOpacity(0);
		_loader.style.display = 'block';
		_loader.moo = new Fx.Tween(_loader, {
			duration: 300,
			link:'cancel',
			'onComplete': function(){
				
			}
		});
		var _a = -1;
		var move_f = true;
		var _btn = list_h.getElements('a');
		_btn.each(function(_el, _i){
			_el._img = document.createElement('img');
			_el._img = $(_el._img);
			_el._url = _el.href;
			_el._img.setOpacity(0);
			_el._img.moo = new Fx.Tween(_el._img, {
				duration: 700,
				link:'cancel',
				'onComplete': function(_img){
					if(_img.hasClass('active')) move_f = true;
				}
			});
			if(_el.hasClass('active') && _a == -1){
				_el._img.src = _el._url;
				_el._img.addClass('active');
				_el._img.setopacity(1);
				box_h.grab(_el._img);
				_a = _i;
				_el._f = true;
			}
			else{
				_el.removeClass('active');
				_el._f = false;
			}
			_el.onclick = function(){
				if(_i != _a && move_f){
					move_f = false;
					if(this._f){
						_btn[_a].removeClass('active');
						_btn[_a]._img.removeClass('active');
						_btn[_a]._img.moo.start('opacity', 0);
						
						_el.addClass('active');
						_el._img.addClass('active');
						_el._img.moo.start('opacity', 1);
					}
					else{
						_btn[_a].removeClass('active');
						_btn[_a]._img.removeClass('active');
						_btn[_a]._img.moo.start('opacity', 0);
						_loader.moo.start('opacity', 1);
						
						_el._img.src = _el._url;
						box_h.grab(_el._img);
						_el._f = true;
						_el.addClass('active');
						_el._img.addClass('active');
						setTimeout(function(){
							_loader.setOpacity(0);
							_el._img.moo.start('opacity', 1);
						}, 1500);
					}
					_a = _i;
				}
				return false;
			}
		});
		if(_a == -1){
			_a = 0;
			_btn[_a].addClass('active');
			_btn[_a]._img.src = _btn[_a]._url;
			_btn[_a]._img.addClass('active');
			_btn[_a]._img.setOpacity(1);
			box_h.grab(_btn[_a]._img);
			_btn[_a]._f = true;
		}
	}
}
/*--- recentGallery ---*/
function recentGallery(){
	var gal_hold = $$('div.purchase-gallery')[0];
	if(gal_hold){
		var btn_prev = gal_hold.getElement('a.link-prev');
		var btn_next = gal_hold.getElement('a.link-next');
		var list_h = gal_hold.getElement('div.purchase-gallery-hold > ul');
		var _list = false;
		if(list_h) _list = list_h.getChildren();
		if(_list){
			var _step = list_h.parentNode.offsetWidth;
			var _w = 0;
			var _m = 0;
			for(var i = 0; i < _list.length; i++){
				_w += _list[i].offsetWidth;
			}
			if(_w > _step){
				var t_list_h = list_h.getChildren();
				for(var i = 0; i < t_list_h.length; i++) list_h.grab(t_list_h[i].clone());
				for(var i = 0; i < t_list_h.length; i++) list_h.grab(t_list_h[i].clone());
				_m = _w;
				list_h.style.left = - _m + 'px';
				list_h.moo = new Fx.Tween(list_h, {
					duration: 1000,
					link:'cancel',
					'onComplete': function(){
						_flag = true;
					}
				});
				if(btn_prev){
					btn_prev.onclick = function(){
						moveList(false);
						return false;
					}
				}
				if(btn_next){
					btn_next.onclick = function(){
						moveList(true);
						return false;
					}
				}
			}
			else{
				if(btn_prev){
					btn_prev.onclick = function(){
						return false;
					}
				}
				if(btn_next){
					btn_next.onclick = function(){
						return false;
					}
				}
			}
		}
		var _flag = true;
		function moveList(_f){
			if(_flag){
				_flag = false;
				if(_f){
					if(_m + _step > 3*_w -_step){
						_m -= _w;
						list_h.style.left = -_m + 'px';
					}
					_m += _step;
				}
				else{
					if(_m - _step < 0){
						_m += _w;
						list_h.style.left = -_m + 'px';
					}
					_m -=_step;
				}
				list_h.moo.start('left', -_m);
			}
		}
		
		
		
	}
}
/*--- recentGallery ---*/
function caseGallery(){
	var gal_hold = $$('div.case-gallery')[0];
	if(gal_hold){
		var btn_prev = gal_hold.getElement('a.link-prev');
		var btn_next = gal_hold.getElement('a.link-next'); 
		var list_h = gal_hold.getElement('div.case-gallery-hold > ul');
		var _list = false;
		if(list_h) _list = list_h.getChildren();
		if(_list){
			var _step = list_h.parentNode.offsetWidth;
			var _w = 0;
			var _m = 0;
			for(var i = 0; i < _list.length; i++){
				_w += _list[i].offsetWidth;
			}
			if(_w > _step){
				var t_list_h = list_h.getChildren();
				for(var i = 0; i < t_list_h.length; i++) list_h.grab(t_list_h[i].clone());
				for(var i = 0; i < t_list_h.length; i++) list_h.grab(t_list_h[i].clone());
				_m = _w;
				list_h.style.left = - _m + 'px';
				list_h.moo = new Fx.Tween(list_h, {
					duration: 1000,
					link:'cancel',
					'onComplete': function(){
						_flag = true;
					}
				});
				if(btn_prev){
					btn_prev.onclick = function(){
						moveList(false);
						return false;
					}
				}
				if(btn_next){
					btn_next.onclick = function(){
						moveList(true);
						return false;
					}
				}
			}
			else{
				if(btn_prev){
					btn_prev.onclick = function(){
						return false;
					}
				}
				if(btn_next){
					btn_next.onclick = function(){
						return false;
					}
				}
			}
		}
		var _flag = true;
		function moveList(_f){
			if(_flag){
				_flag = false;
				if(_f){
					if(_m + _step > 3*_w -_step){
						_m -= _w;
						list_h.style.left = -_m + 'px';
					}
					_m += _step;
				}
				else{
					if(_m - _step < 0){
						_m += _w;
						list_h.style.left = -_m + 'px';
					}
					_m -=_step;
				}
				list_h.moo.start('left', -_m);
			}
		}
	}
}
/*--- slide  contact function ---*/
function slideContact(){
	var _hold = $$('div.slide-contact')[0];
	if(_hold){
		var _btn = _hold.getElement('a.request');
		var _box = _hold.getElement('div.frame');
		if(_btn && _box){
			var _h = _box.offsetHeight;
			var _f = false;
			_box.moo = new Fx.Tween(_box, {
				duration: 500,
				link:'cancel',
				'onComplete': function(){
					if(!_f){
						_hold.removeClass('active');
						_box.style.display = 'none';
						_box.style.height = 'auto';
					}
					else{
						_hold.addClass('active');
						_box.style.height = 'auto';
					}
				}
			});
			if(_hold.hasClass('active')){
				_box.style.display = 'block';
				_f = true;
			}
			else{
				_box.style.display = 'none';
				_f = false;
			}
			_btn.onclick = function(){
				if(_f){
					_f = false;
					_box.style.height = _box.offsetHeight + 'px';
					_box.moo.start('height', 0);
				}
				else{
					_f = true;
					if(_box.offsetHeight == 0){
						_box.style.display = 'block';
						_h = _box.offsetHeight;
						_box.style.height = '0px';
					}
					_box.style.height = _box.offsetHeight + 'px';
					_box.moo.start('height', _h+'px');
					_f = true;
				}
				return false;
			}
		}
	}
}

/*--- portfolioActions ---*/
function portfolioActions(){
	
	var prev=$$('div.portfolio-nav div.portfolio-prev');
	var next=$$('div.portfolio-nav div.portfolio-next');
	var nav=$$('ul.breadcrumbs li')[2];
	
	var btn_list =$$('div.portfolio-links ul a');
	var btn_back = $$('#main a.back-portfolio')[0];
	var p_a = -1;
	var p_f = true;
	var big_hold = $$('div.porfolio-hold')[0];
	var t_div = document.createElement('div');
	t_div = $(t_div);
	var t_el, nt_el;
	var a_d = (_IE6)?'0':'1000';
	if(btn_list.length && big_hold){
		if(btn_back) btn_back.style.display = 'none';
		btn_list.each(function(_el, _i){
			if(_el.hasClass('active') && p_a == -1) p_a = _i;
			else _el.removeClass('active');
			_el.onclick = function(){
				if(p_a != _i && p_f){
					if(btn_back) btn_back.style.display = 'none';
					btn_list[p_a].removeClass('active');
					_el.addClass('active');
					p_f = false;
					t_el = big_hold.getChildren('div.portfolio-list');
					for(var i = 0; i < t_el.length; i++){
						if(t_el[i].offsetWidth == 0) t_el[i].dispose();
						else nt_el = t_el[i];
					}
					
					//By Mahongtao Begin
					
					if(_el.innerHTML=='Web')
					{
					    next.setProperty('title','Branding');
					    nav.set('html','Web');
					}
					
					if(_el.innerHTML=='Branding')
					{
					    prev.setProperty('title','Web');
					    next.setProperty('title','Print');
					    
					    nav.set('html','Branding');
					}
					
					if(_el.innerHTML=='Print')
					{
					    prev.setProperty('title','Branding');
					    
					    nav.set('html','Print');
					}
					
					initTooltip();
					
					
					//By Mahongtao End
					
					
					nt_el.moo = new Fx.Tween(nt_el, {
						duration: a_d,
						link:'cancel',
						'onComplete': function(t_box){
							t_box.dispose();
							var myRequest = new Request.HTML({method: 'get', url: _el.href, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
								t_div.innerHTML = responseHTML;
								t_el = t_div.getChildren('div.portfolio-list')[0];
								
								if($$('div.portfolio-list').length<2)
								{
								    big_hold.grab(t_el);
								}
								
								
								
								
								t_el.setOpacity(0);
								t_el.style.display = 'block';
								t_el.moo = new Fx.Tween(t_el, {
									duration: a_d,
									'onComplete': function(){
										p_f = true;
									}
								});
								big_hold.style.height = 'auto';
								setTimeout(function(){
									t_el.moo.start('opacity', 1);
									_loader.moo.start('opacity', 0);
								}, 200);
								initList(t_el);
								
								DelayImage();
								
							}});
							myRequest.send();
							
							//By Mahongtao Begin
							location.hash=portfolioUrlHandle(_el.href);
							//By Mahongtao End
						}
					});
					p_a = _i;
					big_hold.style.height = big_hold.offsetHeight + 'px';
					nt_el.moo.start('opacity', 0);
					_loader.moo.start('opacity', 1);
				}
				return false;
			}
		});
		if(p_a == -1){
			p_a = 0;
			btn_list[p_a].addClass('active');
		}
		var _loader = document.createElement('div');
		_loader.className = 'loader';
		_loader.innerHTML = 'Loading...';
		_loader = $(_loader);
		big_hold.grab(_loader);
		_loader.setOpacity(0);
		_loader.style.display = 'block';
		_loader.moo = new Fx.Tween(_loader, {
			duration: 300,
			link:'cancel',
			'onComplete': function(){
				
			}
		});
		
		
		
		//By Mahongtao Begin
		var hash_url=location.hash;
		
		if(hash_url.indexOf('CategoryId')!=-1||hash_url.indexOf('Id')!=-1)
		{
		
		    if(hash_url.indexOf('CategoryId')!=-1)
		        hash_url='inc/Portfolio.aspx?'+hash_url.substring(1);
		    else if(hash_url.indexOf('CaseId')!=-1)
		    {
		        hash_url='inc/Portfolio-Case.aspx?'+hash_url.substring(1);
		        
		    }
		    else
		    {
		        hash_url='inc/Portfolio-Detail.aspx?'+hash_url.substring(1);
	        }
		        
		    
		        
		    var myRequest = new Request.HTML({method: 'get', url: hash_url, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
			    t_div.innerHTML = responseHTML;
			    t_el = t_div.getChildren('div.portfolio-list')[0];
			    
			    if($$('div.portfolio-list').length<2)
			    {
			        big_hold.grab(t_el);
			    }
			    
			    
			    t_el.style.display = 'block';
			    initList(t_el);
			    
			    fadeGallery();
			    
			    showCaseStudyPhoto();
			    
			    DelayImage();
		    }});
		    
		    //JQ('.porfolio-hold').load('inc/portfolio.aspx?CategoryId=1',function(){myRequest.send();});
		    myRequest.send();
		    
		    
		}
		else
		{
		    var myRequest = new Request.HTML({method: 'get', url: btn_list[p_a].href, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
			    t_div.innerHTML = responseHTML;
			    t_el = t_div.getChildren('div.portfolio-list')[0];
			    
			    if($$('div.portfolio-list').length<2)
			    {
			        big_hold.grab(t_el);
			    }
			    
			    
			    t_el.style.display = 'block';
			    initList(t_el);
			    
			    DelayImage();
		    }});
		    myRequest.send();
		}
		
		
		
		
		//By Mahongtao End
		
//		var myRequest = new Request.HTML({method: 'get', url: btn_list[p_a].href, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
//			t_div.innerHTML = responseHTML;
//			t_el = t_div.getChildren('div.portfolio-list')[0];
//			big_hold.grab(t_el);
//			t_el.style.display = 'block';
//			initList(t_el);
//		}});
//		myRequest.send();

		
	}
	function initList(_hold){
	
		var btn_prev = $$('div.portfolio-nav a.link-prev')[0];
		var btn_next = $$('div.portfolio-nav a.link-next')[0];
		
		if((location.hash.indexOf('#Id')!=0&&location.hash.indexOf('#CaseId')!=0))
		{
		    if(p_a == 0) btn_prev.style.display = 'none';
		    else btn_prev.style.display = 'block';
		    if(p_a == btn_list.length - 1) btn_next.style.display = 'none';
		    else btn_next.style.display = 'block';
    		
		    btn_prev.onclick = function(){
			    btn_list[p_a - 1].onclick();
			    return false;
		    }
		    btn_next.onclick = function(){
			    btn_list[p_a + 1].onclick();
			    return false;
		    }
		}
		else
		{
		    
		    var info=returnId(location.hash.split('=')[1]);
		    
	        if(info.prevHash=='')
	            btn_prev.style.display = 'none';
	        else
	            btn_prev.style.display = 'block';
		    
	        if(info.nextHash=='')
	            btn_next.style.display = 'none';
	        else
	            btn_next.style.display = 'block';
	            
	        JQ('.portfolio-links li a').removeClass('active');
		    p_a=2;
		    
		    btn_prev.onclick = function(){
			    
			    var info1=returnId(location.hash.split('=')[1]);
		    
			    
			    JQ('.porfolio-hold').load(info1.prevUrl,function(){
			        JQ('.porfolio-hold .portfolio-list').fadeIn('slow');
			        location.hash=info1.prevHash;
			        
			        fadeGallery();
			    
			        showCaseStudyPhoto();
			        
			        
			        var info2=returnId(info1.prevHash.split('=')[1]);
		    
		            if(info2.prevHash=='')
		                btn_prev.style.display = 'none';
		            else
		                btn_prev.style.display = 'block';
        		    
		            if(info2.nextHash=='')
		                btn_next.style.display = 'none';
		            else
		                btn_next.style.display = 'block';
		                
		            $('backMain').onclick = function(){
			            btn_list[info1.categoryId].onclick();
			            return false;
		            }
			    })
			    return false;
		    }
		    
		    btn_next.onclick = function(){
			    
			    var info1=returnId(location.hash.split('=')[1]);
			    
			    
			    JQ('.porfolio-hold').load(info1.nextUrl,function(){
			        JQ('.porfolio-hold .portfolio-list').fadeIn('slow');
			        location.hash=info1.nextHash;
			        
			        fadeGallery();
			    
			        showCaseStudyPhoto();
			        
			        var info2=returnId(info1.nextHash.split('=')[1]);
		    
		            if(info2.prevHash=='')
		                btn_prev.style.display = 'none';
		            else
		                btn_prev.style.display = 'block';
        		    
		            if(info2.nextHash=='')
		                btn_next.style.display = 'none';
		            else
		                btn_next.style.display = 'block';
		                
		             $('backMain').onclick = function(){
			            btn_list[info1.categoryId].onclick();
			            return false;
		            }
			    })
			    return false;
		    }
		    
		    $('backMain').onclick = function(){
			    btn_list[info.categoryId].onclick();
			    return false;
		    }
		    
		    
		    prev.setProperty('title','Previous');
			next.setProperty('title','Next');
			initTooltip();
		}
		
		var list_l = _hold.getElements('ul.left > li');
		var list_r = _hold.getElements('ul.right > li');
		var _btn = [];
		var _a = -1;
		list_l.each(function(_el, _i){
			_el.moo = new Fx.Tween(_el, {
				duration: 500,
				link:'cancel',
				'onComplete': function(){
					
				}
			});
			if(_el.getElement('a.btn-view')){
				_btn.push(_el.getElement('a.btn-view'));
				_el.getElement('a.btn-view')._i = _btn.length - 1;
				_el.getElement('a.btn-view').onclick = function(){
					_a = this._i;
					openBox(_i);
					
					return false;
				}
			}
		});
		list_r.each(function(_el, _i){
			_el.moo = new Fx.Tween(_el, {
				duration: 500,
				link:'cancel',
				'onComplete': function(){
					
				}
			});
			if(_el.getElement('a.btn-view')){
				_btn.push(_el.getElement('a.btn-view'));
				_el.getElement('a.btn-view')._i = _btn.length - 1;
				_el.getElement('a.btn-view').onclick = function(){
					_a = this._i;
					openBox(_i);
					return false;
				}
			}
		});
		if(_IE6){
			_hold.getElements('ul.logo-list > li').each(function(_el){
				_el.onmouseover = function(){
					_el.addClass('hover');
				}
				_el.onmouseout = function(){
					_el.removeClass('hover');
				}
			});
		}
		var _t1, _t2;
		var _f = true;
		var _f1 = false;
		var _f2 = false;
		function openBox(_i){
			if(_f){
				var t_i = _i;
				_f = false;
				if(list_l[t_i]){
					list_l[t_i].style.left = '0px';
					list_l[t_i].moo.start('left', -list_l[t_i].offsetWidth);
				}
				if(list_r[t_i]){
					list_r[t_i].style.right = '0px';
					list_r[t_i].moo.start('right', -list_r[t_i].offsetWidth);
				}
				_t1 = setInterval(function(){
					t_i--;
					if(t_i == -1){
						clearInterval(_t1);
						if(_f2) loadBox(-1);
						_f1 = true;
					}
					if(list_l[t_i]){
						list_l[t_i].style.left = '0px';
						list_l[t_i].moo.start('left', -list_l[t_i].offsetWidth);
					}
					if(list_r[t_i]){
						list_r[t_i].style.right = '0px';
						list_r[t_i].moo.start('right', -list_r[t_i].offsetWidth);
					}
				}, 300);
				_t2 = setInterval(function(){
					_i++;
					if(_i >= list_l.length){
						clearInterval(_t2);
						if(_f1) loadBox(-1);
						_f2 = true;
					}
					if(list_l[_i]){
						list_l[_i].style.left = '0px';
						list_l[_i].moo.start('left', -list_l[_i].offsetWidth);
					}
					if(list_r[_i]){
						list_r[_i].style.right = '0px';
						list_r[_i].moo.start('right', -list_r[_i].offsetWidth);
					}
				}, 300);
			}
			if(_a == 0) btn_prev.style.display = 'none';
			else btn_prev.style.display = 'block';
			if(_a == _btn.length - 1) btn_next.style.display = 'none';
			else btn_next.style.display = 'block';
			btn_prev.onclick = function(){
				loadBox(_a - 1);
				return false;
			}
			btn_next.onclick = function(){
				loadBox(_a + 1);
				return false;
			}
		}
		var t_more;
		var _f3 = true;
		
		
		function loadBox(_ind){
			
			
			_f1 = false;
			_f2 = false;
			_f = true;
			if(_f3 && _ind != _a){
				_f3 = false;
				if(_ind == -1){
					_ind = _a;
					if(_ind == 0) btn_prev.style.display = 'none';
					else btn_prev.style.display = 'block';
					if(_ind == _btn.length - 1) btn_next.style.display = 'none';
					else btn_next.style.display = 'block';
					
					big_hold.style.height = big_hold.offsetHeight + 'px';
					_hold.style.display = 'none';
					_loader.moo.start('opacity', 1);
					
					if($$('div.portfolio-list').length>=2)
		            {
		                $$('div.portfolio-list')[1].dispose();
		            }
					
					clearInterval(_t1);
					clearInterval(_t2);
					
					var myRequest = new Request.HTML({method: 'get', url: _btn[_ind].href+'&t='+(new Date()).getTime(), onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
						
						t_div.innerHTML = responseHTML;
						t_more = t_div.getChildren('div.portfolio-list')[0];
						
			            big_hold.grab(t_more);
			            
						t_more.setOpacity(0);
						t_more.style.display = 'block';
						big_hold.style.height = 'auto';
						t_more.moo = new Fx.Tween(t_more, {
							duration: a_d,
							link:'cancel',
							'onComplete': function(t_box){
								_f3 = true;
							}
						});
						_a = _ind;
						setTimeout(function(){
							t_more.moo.start('opacity', 1);
							_loader.moo.start('opacity', 0);
							fadeGallery();
							showCaseStudyPhoto();
							closeBox();
						}, 400);
					}});
					myRequest.send();
				}
				else{
					if(_ind == 0) btn_prev.style.display = 'none';
					else btn_prev.style.display = 'block';
					if(_ind == _btn.length - 1) btn_next.style.display = 'none';
					else btn_next.style.display = 'block';
					big_hold.style.height = big_hold.offsetHeight + 'px';
					
					if($$('div.portfolio-list').length>=2)
                    {
                        $$('div.portfolio-list')[1].destroy();
                    }
					
					
					t_more.moo = new Fx.Tween(t_more, {
						duration: a_d,
						link:'cancel',
						'onComplete': function(t_box){
							t_box.destroy();
							var myRequest = new Request.HTML({method: 'get', url: _btn[_ind].href+'&t='+(new Date()).getTime(), onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
								t_div.innerHTML = responseHTML;
								t_more = t_div.getChildren('div.portfolio-list')[0];
								
			                    big_hold.grab(t_more);
			                    
			                    
								
								t_more.setOpacity(0);
								t_more.style.display = 'block';
								big_hold.style.height = 'auto';
								t_more.moo = new Fx.Tween(t_more, {
									duration: a_d,
									link:'cancel',
									'onComplete': function(t_box){
										_f3 = true;
									}
								});
								_a = _ind;
								setTimeout(function(){
									t_more.moo.start('opacity', 1);
									_loader.moo.start('opacity', 0);
									fadeGallery();
									showCaseStudyPhoto();
									closeBox();
								}, 400);
							}});
							myRequest.send();
						}
					});
					t_more.moo.start('opacity', 0);
					_loader.moo.start('opacity', 1);
				}
				
				//By Mahongtao Begin
				location.hash=portfolioUrlHandle(_btn[_ind].href);
				
				var myFx = new Fx.Scroll(window, {
			        duration:1000,
			        link:'cancel'
		        });
		        myFx.toTop();
		        
		        
		        prev.setProperty('title','Previous');
				next.setProperty('title','Next');
				initTooltip();
				
				
				
				//By Mahongtao End
			}
		}
		function closeBox(){
			if(btn_back) btn_back.style.display = 'block';
			t_more.getElement('a.back-to-portfolio').onclick = function(){
				if(_f3){
					_f3 = false;
					t_more.moo = new Fx.Tween(t_more, {
						duration: a_d,
						link:'cancel',
						'onComplete': function(t_box){
							_f3 = true;
							t_box.destroy();
							if(p_a == 0) btn_prev.style.display = 'none';
							else btn_prev.style.display = 'block';
							if(p_a == btn_list.length - 1) btn_next.style.display = 'none';
							else btn_next.style.display = 'block';
							
							btn_prev.onclick = function(){
								btn_list[p_a - 1].onclick();
								return false;
							}
							btn_next.onclick = function(){
								btn_list[p_a + 1].onclick();
								return false;
							}
							list_l.each(function(_el){
								_el.style.left = -big_hold.offsetWidth/2 + 'px';
							});
							list_r.each(function(_el){
								_el.style.right = -big_hold.offsetWidth/2 + 'px';
							});
							_hold.style.display = 'block';
							big_hold.style.height = 'auto';
							var tt_a = 0;
							_t1 = setInterval(function(){
								if(list_l[tt_a]) list_l[tt_a].moo.start('left', 0);
								if(list_r[tt_a]) list_r[tt_a].moo.start('right', 0);
								tt_a++;
								if(tt_a == list_l.length) clearInterval(_t1);
							}, 300);
						}
					});
					big_hold.style.height = big_hold.offsetHeight + 'px';
					t_more.moo.start('opacity', 0);
				}
				if(btn_back) btn_back.style.display = 'none';
				return false;
			}
			if(btn_back){
				btn_back.onclick = function(){
					if(_f3){
						_f3 = false;
						t_more.moo = new Fx.Tween(t_more, {
							duration: a_d,
							link:'cancel',
							'onComplete': function(t_box){
								_f3 = true;
								t_box.destroy();
								if(p_a == 0) btn_prev.style.display = 'none';
								else btn_prev.style.display = 'block';
								if(p_a == btn_list.length - 1) btn_next.style.display = 'none';
								else btn_next.style.display = 'block';
								
								btn_prev.onclick = function(){
									btn_list[p_a - 1].onclick();
									return false;
								}
								btn_next.onclick = function(){
									btn_list[p_a + 1].onclick();
									return false;
								}
								list_l.each(function(_el){
									_el.style.left = -big_hold.offsetWidth/2 + 'px';
								});
								list_r.each(function(_el){
									_el.style.right = -big_hold.offsetWidth/2 + 'px';
								});
								_hold.style.display = 'block';
								big_hold.style.height = 'auto';
								var tt_a = 0;
								_t1 = setInterval(function(){
									if(list_l[tt_a]) list_l[tt_a].moo.start('left', 0);
									if(list_r[tt_a]) list_r[tt_a].moo.start('right', 0);
									tt_a++;
									if(tt_a == list_l.length) clearInterval(_t1);
								}, 300);
							}
						});
						big_hold.style.height = big_hold.offsetHeight + 'px';
						t_more.moo.start('opacity', 0);
					}
					if(btn_back) btn_back.style.display = 'none';
					return false;
				}
			}
		}
	}
}
/*--- clearInputs ---*/
function clearInputs(){
	$$('input, textarea').each(function(_el){
		if(_el.type == 'text' || _el.type == 'password' || _el.tagName == 'TEXTAREA'){
			if(!_el.val) _el.val = _el.value;
			_el.onfocus = function(){
				if(this.value == this.val) this.value = '';
			}
			_el.onblur = function(){
				if(this.value == '') this.value = this.val;
			}
		}
	});
}
/*--- fade images gallery ---*/
function fadeGallery2(){
	var _hold = $$('div.fade-images-gallery')[0];
	if(_hold){
		var img_hold = _hold.getElement('div.conteiner-img');
		var _btn = _hold.getElements('ul a');
		var _a = -1;
		var t_el;
		_btn.each(function(_el, _i){
			if(_a == -1 && _el.hasClass('active')) _a = _i;
			_el.removeClass('active');
			_el.onclick = function(){
				changeEl(_i);
				return false;
			}
		});
		var _f = false;
		if(_a == -1) _a = 0;
		_btn[_a].addClass('active');
		_btn[_a]._img = new Image();
		_btn[_a]._img = $(_btn[_a]._img);
		_btn[_a]._img.onload = function(){
			_f = true;
		}
		_btn[_a]._img.src = _btn[_a].href;
		img_hold.appendChild(_btn[_a]._img);
		_btn[_a]._img.moo = new Fx.Tween(_btn[_a]._img, {
			duration: 600,
			link:'cancel',
			'onComplete': function(_el){
				if(_el.hasClass('active')) _f = true;
			}
		});
		function changeEl(_ind){
			if(_a != _ind && _f){
				_f = false;
				if(_btn[_ind]._img){
					_btn[_a].removeClass('active');
					_btn[_ind].addClass('active');
					_btn[_a]._img.removeClass('active');
					_btn[_ind]._img.addClass('active');
					_btn[_a]._img.moo.start('opacity', 0);
					_btn[_ind]._img.moo.start('opacity', 1);
					_a = _ind;
				}
				else{
					_btn[_ind]._img = new Image();
					_btn[_ind]._img = $(_btn[_ind]._img);
					_btn[_ind]._img.setOpacity(0);
					_btn[_ind]._img.moo = new Fx.Tween(_btn[_ind]._img, {
						duration: 600,
						link:'cancel',
						'onComplete': function(_el){
							if(_el.hasClass('active')) _f = true;
						}
					});
					_btn[_ind]._img.onload = function(){
						_btn[_a].removeClass('active');
						_btn[_ind].addClass('active');
						_btn[_a]._img.removeClass('active');
						_btn[_ind]._img.addClass('active');
						_btn[_a]._img.moo.start('opacity', 0);
						_btn[_ind]._img.moo.start('opacity', 1);
						_a = _ind;
					}
					_btn[_ind]._img.src = _btn[_ind].href;
					img_hold.appendChild(_btn[_ind]._img);
				}
			}
		}
		
	}
}
/*--- tooltip's ---*/
function initTooltip(){
	
	if($('btn-case'))
	    $('btn-case').dispose();
	
	setTimeout(function(){
		var t_box;
		var _tooltips = [];
		t_box = $$('span, div, a, strong, p, em, li');
		for(var i = 0; i < t_box.length; i++){
			if(t_box[i].title) _tooltips.push(t_box[i]);
		}
		var _tooltip = document.createElement('div');
		var _text = document.createElement('span');
		_tooltip.id = 'btn-case';
		_tooltip.appendChild(_text);
		_tooltip = $(_tooltip);
		_tooltip.style.display = 'none';
		_tooltip.setOpacity(0);
		_tooltip.moo = new Fx.Tween(_tooltip, {
			duration: 650,
			link:'cancel',
			'onComplete': function(){
				if(_tooltip.getOpacity() == 0) _tooltip.style.display = 'none';
			}
		});
		document.body.appendChild(_tooltip);
		_tooltips.each(function(_el){
			_el._text = _el.title;
			var posx;
			var posy;
			_el.title = '';
			_el.onmouseover = function(e){
				_text.innerHTML = this._text;
				if (!e) var e = window.event;
				if (e.pageX || e.pageY){
					posx = e.pageX;
					posy = e.pageY;
				}
				else if (e.clientX || e.clientY){
					posx = e.clientX + document.body.scrollLeft
						+ document.documentElement.scrollLeft;
					posy = e.clientY + document.body.scrollTop
						+ document.documentElement.scrollTop;
				}
				_tooltip.style.top = posy + 'px';
				_tooltip.style.left = posx + 'px';
				_tooltip.style.display = 'block';
				_tooltip.moo.start('opacity', 1);
			}
			_el.onmouseout = function(e){
				_tooltip.moo.start('opacity', 0);
			}
			_el.onmousemove = function(e){
				if (!e) var e = window.event;
				if (e.pageX || e.pageY){
					posx = e.pageX;
					posy = e.pageY;
				}
				else if (e.clientX || e.clientY){
					posx = e.clientX + document.body.scrollLeft
						+ document.documentElement.scrollLeft;
					posy = e.clientY + document.body.scrollTop
						+ document.documentElement.scrollTop;
				}
				_tooltip.style.top = posy + 'px';
				_tooltip.style.left = posx + 'px';
			}
		});
	}, 1000);
}
/*--- video tooltips ---*/
function initVideoTooltips(_hold){
	var _posx, _posy, _px, _py;
	var _hold = _hold.getElement('div.visual');
	var _tooltip = _hold.getElement('div.overlay');
	if(_hold && _tooltip){
		_tooltip.style.display = 'none';
		_tooltip.setOpacity(0);
		var _d = (_IE6)?'0':'500';
		_tooltip.moo = new Fx.Tween(_tooltip, {
			duration: _d,
			link:'cancel',
			'onComplete': function(){
				if(_tooltip.getOpacity() == 0) _tooltip.style.display = 'none';
			}
		});
		
		_hold.onmouseover = function(e){
			if (!e) var e = window.event;
			if (e.pageX || e.pageY){
				posx = e.pageX;
				posy = e.pageY;
			}
			else if (e.clientX || e.clientY){
				posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
				posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
			}
			_px = findPosX(_hold);
			_py = findPosY(_hold);
			posx -= _px;
			posy -= _py;
			_tooltip.style.top = posy + 'px';
			_tooltip.style.left = posx + 'px';
			_tooltip.style.display = 'block';
			_tooltip.moo.start('opacity', 1);
		}
		_hold.onmousemove = function(e){
			if (!e) var e = window.event;
			if (e.pageX || e.pageY){
				posx = e.pageX;
				posy = e.pageY;
			}
			else if (e.clientX || e.clientY){
				posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
				posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
			}
			posx -= _px;
			posy -= _py;
			_tooltip.style.top = posy + 'px';
			_tooltip.style.left = posx + 'px';
		}
		_hold.onmouseout = function(){
			_tooltip.moo.start('opacity', 0);
		}
	}
}
/*--- package tooltips ---*/
function packageTooltips(){
	$$('div.package-table').each(function(_hold){
		_hold.getElements('a.open').each(function(_btn){
			var _box = _btn.href.substr(_btn.href.indexOf("#") + 1);
			if(_box) _box = document.getElementById(_box);
			if(_box){
				_box.style.display = 'none';
				_btn.onmouseover = function(){
					_box.style.top = _btn.getPosition().y - 50 + 'px';
					_box.style.display = 'block';
				}
				_btn.onmouseout = function(){
					_box.style.display = 'none';
				}
			}
		});
	});
}
/*--- team popups ---*/
function initTeamPopups(){
	var _hold = $('team-map');
	if(_hold){
		var _list = _hold.getChildren();
		var _tooltip = document.createElement('div');
		_tooltip.id = 'team-tooltip';
		var tooltip_t = document.createElement('a');
		_tooltip.appendChild(tooltip_t);
		document.body.appendChild(_tooltip);
		_tooltip = $(_tooltip);
		var _fader = document.createElement('div');
		_fader.id = 'popup-fader';
		document.body.appendChild(_fader);
		_fader = $(_fader);
		_fader.style.display = 'none';
		_fader.setOpacity(0);
		_fader.moo =  new Fx.Tween(_fader, {
			duration: 200,
			link:'cancel',
			'onComplete': function(t_box){
				if(t_box.getOpacity() == 0) t_box.style.display = 'none';
			}
		});
		var info_text_h = document.createElement('div');
		info_text_h = $(info_text_h);
		var tooltip_a = -1;
		var _a = -1;
		var _t;
		_list.each(function(_btn, _i){
			if(_btn.alt){
				var _text = _btn.alt;
				_btn.alt = '';
				var _x = 0;
				var _y = 99999;
				var _coords = _btn.coords.split(',');
				for(var i = 0; i < _coords.length; i++){
					if(i%2 == 0) _x = Math.max(_x, _coords[i]);
					else _y = Math.min(_y, _coords[i]); 
				}
				_btn.onmouseover = function(){
					if(_t) clearTimeout(_t);
					_a = _i;
					tooltip_t.innerHTML = _text;
					_tooltip.style.top = _y + findPosY(_hold.parentNode) + 'px';
					_tooltip.style.left = _x + findPosX(_hold.parentNode) + 'px';
					_tooltip.style.display = 'block';
				}
				_btn.onclick = function(){
					if(_a != -1) showPopup();
					return false;
				}
				_btn.onmouseout = function(){
					_t = setTimeout(function(){
						_a = -1;
						_tooltip.style.display = 'none';
					}, 200);
				}
			}
		});
		_tooltip.onmouseover = function(){
			if(_t) clearTimeout(_t);
		}
		_tooltip.onmouseout = function(){
			_t = setTimeout(function(){
				_a = -1;
				_tooltip.style.display = 'none';
			}, 200);
		}
		_tooltip.onclick = function(){
			_list[_a].onclick();
			return false;
		}
		_fader.onclick = function(){
			if(_list[tooltip_a]._box){
				if(_list[tooltip_a]._contact) _list[tooltip_a]._contact.style.display = 'none';
				_list[tooltip_a]._box.moo.start('opacity', 0);
				_fader.moo.start('opacity', 0);
			}
			return false;
		}
	}
	var _f = true;
	function showPopup(){
		if(_f){
			tooltip_a = _a;
			_f = false;
			_fader.setOpacity(0);
			_fader.style.height = $$('div.wrapper')[0].offsetHeight + 'px';
			_fader.style.display = 'block';
			_fader.moo.start('opacity', 0.7);
			if(_list[tooltip_a]._box){
				_list[tooltip_a]._box.style.display = 'block';
				_list[tooltip_a]._box.style.top = getCurrentYPos() + 'px';
				_list[tooltip_a]._box.moo.start('opacity', 1);
			}
			else{
				var myRequest = new Request.HTML({method: 'get', url: _list[tooltip_a].href, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
					info_text_h.innerHTML = responseHTML;
					_list[tooltip_a]._box = info_text_h.getChildren()[0];
					_list[tooltip_a]._box.setOpacity(0);
					document.body.appendChild(_list[tooltip_a]._box);
					_list[tooltip_a]._box.moo = new Fx.Tween(_list[tooltip_a]._box, {
						duration: 500,
						link:'cancel',
						'onComplete': function(t_box){
							if(t_box.getOpacity() == 0){
								t_box.style.display = 'none';
								_f = true;
							}
						}
					});
					_list[tooltip_a]._box.style.left = (document.body.offsetWidth -_list[tooltip_a]._box.offsetWidth)/2 + 'px';
					
					var myDrag = _list[tooltip_a]._box.makeDraggable({
						handle:_list[tooltip_a]._box.getElement('span.btn-popup-drag')
					});
					_list[tooltip_a]._box.style.top = getCurrentYPos() + 'px';
					_list[tooltip_a]._box.moo.start('opacity', 1);
					_list[tooltip_a]._box.getElement('a.btn-close').onclick = function(){
						_list[tooltip_a]._box.moo.start('opacity', 0);
						_fader.moo.start('opacity', 0);
						return false;
					}
					_list[tooltip_a]._contact = false;
					_list[tooltip_a]._box.getElement('a.contact-btn').onclick = function(){
						displayContact(this.href);
						return false;
					}
				}});
				myRequest.send();
			}
		}
	}
	function displayContact(_url){
		_list[tooltip_a]._box.style.display = 'none';
		if(_list[tooltip_a]._contact){
			_list[tooltip_a]._contact.style.display = 'block';
		}
		else{
			var myRequest = new Request.HTML({method: 'get', url: _url, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
				info_text_h.innerHTML = responseHTML;
				_list[tooltip_a]._contact = info_text_h.getChildren()[0];
				_list[tooltip_a]._contact.style.top = getCurrentYPos() + 'px';
				document.body.appendChild(_list[tooltip_a]._contact);
				_list[tooltip_a]._contact.getElements('a.close-button').each(function(_el){
					_el.onclick = function(){
						_list[tooltip_a]._contact.style.display = 'none';
						_list[tooltip_a]._box.style.display = 'block';
						return false;
					}
				});
				_list[tooltip_a]._contact.style.left = (document.body.offsetWidth -_list[tooltip_a]._contact.offsetWidth)/2 + 'px';
				
				var myDrag = _list[tooltip_a]._contact.makeDraggable({
					handle:_list[tooltip_a]._contact.getElement('span.btn-popup-drag')
				});
			}});
			myRequest.send();
		}
		
	}
	function getCurrentYPos(){
		var _offset = 0;
		if (document.body && document.body.scrollTop) _offset =  document.body.scrollTop;
		if (document.documentElement && document.documentElement.scrollTop) _offset = document.documentElement.scrollTop;
		if (window.pageYOffset) _offset =  window.pageYOffset;
		return _offset;
	}
}
/*--- news gallery ---*/
function initNewsGall(){
	var _hold = $$('div.news-list')[0];
	if(_hold){
		var btn_prev = _hold.getElement('div.box-prev a.btn-prev');
		var btn_next = _hold.getElement('div.box-next a.btn-next');
		var news_hold = _hold.getElement('div.news-content-hold');
		var _numb = _hold.getElement('strong.date');
		var _monem = _hold.getElement('em.month');
		var _loader = document.createElement('div');
		_loader.className = 'loader';
		_loader.innerHTML = 'Loading...';
		_loader = $(_loader);
		news_hold.grab(_loader);
		_loader.setOpacity(0);
		_loader.style.display = 'block';
		_loader.moo = new Fx.Tween(_loader, {
			duration: 300,
			link:'cancel',
			'onComplete': function(){
				
			}
		});
		var news_list = [];
		var news_a = 0;
		news_hold.getElements('ul.news-list > li').each(function(_el, _i){
			var t_el = [];
			t_el[0] = false;
			t_el[1] = _el.innerHTML;
			if(_el.hasClass('active')) _a = _i;
			news_list.push(t_el);
		});
		news_hold.getElement('ul.news-list').destroy();
		var _f = false;
		var info_text_h = document.createElement('div');
		info_text_h = $(info_text_h);
		var myRequest = new Request.HTML({method: 'get', url: news_list[_a][1], onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
			info_text_h.innerHTML = responseHTML;
			_monem.innerHTML=info_text_h.getElement('div.motimes').innerHTML;
			_numb.addClass('number-'+info_text_h.getElement('div.datimes').innerHTML);
			news_list[_a][0] = info_text_h.getChildren()[0];
			news_hold.appendChild(news_list[_a][0]);
			_f = true;
		}});
		myRequest.send();
		if(_a == news_list.length - 1) btn_next.style.display = 'none';
		else btn_next.style.display = 'block';
		if(_a == 0) btn_prev.style.display = 'none';
		else btn_prev.style.display = 'block';
		
		btn_next.onclick = function(){
			changeEl(_a + 1);
			return false;
		}
		btn_prev.onclick = function(){
			changeEl(_a - 1);
			return false;
		}
		function changeEl(_ind){
			if(_f){
				_f = false;
				var _ind = _ind;
				if(_ind == 0) btn_prev.style.display = 'none';
				else btn_prev.style.display = 'block';
				if(_ind == news_list.length - 1) btn_next.style.display = 'none';
				else btn_next.style.display = 'block';
				
				news_hold.style.height = news_hold.offsetHeight + 'px';
				//_numb.removeClass('number-'+(_a+1));
				//_numb.addClass('number-'+(_ind+1));
				if(news_list[_ind][0]){
				    
					var _moo1 = new Fx.Tween(news_list[_a][0], {
						duration: 600,
						link:'cancel',
						'onComplete': function(_box){
							
						}
					});
					var _moo2 = new Fx.Tween(news_list[_ind][0], {
						duration: 600,
						link:'cancel',
						'onComplete': function(_box){
							news_list[_a][0].style.display = 'none';
							news_list[_a][0].style.right = '0px';
							news_list[_a][0].style.left = '0px';
							news_list[_a][0].style.position = 'relative';
							
							news_list[_ind][0].style.left = 'auto';
							news_list[_ind][0].style.right = 'auto';
							news_list[_ind][0].style.position = 'relative';
							
							news_hold.style.height = 'auto';
							_f = true;
							_a = _ind;
						}
					});
					
					news_list[_ind][0].style.position = 'absolute';
					news_list[_a][0].style.position = 'absolute';
					if(_ind < _a){
						news_list[_ind][0].style.left = -news_hold.offsetWidth + 'px';
						news_list[_a][0].style.left = '0px';
						news_list[_ind][0].style.display = 'block';
						_moo1.start('left', news_hold.offsetWidth + 'px');
						_moo2.start('left', '0px');
					}
					else{
						news_list[_ind][0].style.left = news_hold.offsetWidth + 'px';
						news_list[_a][0].style.left = '0px';
						news_list[_ind][0].style.display = 'block';
						
						_moo1.start('left', -news_hold.offsetWidth + 'px');
						_moo2.start('left', '0px');
					}
					_monem.innerHTML=news_list[_ind][0].getElement('div.motimes').innerHTML;
					_numb.removeClass('number-'+news_list[_a][0].getElement('div.datimes').innerHTML);
				    _numb.addClass('number-'+news_list[_ind][0].getElement('div.datimes').innerHTML);
				}
				else{
					var _moo1 = new Fx.Tween(news_list[_a][0], {
						duration: 600,
						link:'cancel',
						'onComplete': function(_box){
							news_list[_a][0].style.display = 'none';
							news_list[_a][0].style.marginLeft = '0px';
							_loader.moo.start('opacity', 1);
							_numb.removeClass('number-'+news_list[_a][0].getElement('div.datimes').innerHTML);
							var myRequest = new Request.HTML({method: 'get', url: news_list[_ind][1], onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
								info_text_h.innerHTML = responseHTML;
								_monem.innerHTML=info_text_h.getElement('div.motimes').innerHTML;
								_numb.addClass('number-'+info_text_h.getElement('div.datimes').innerHTML);
								news_list[_ind][0] = info_text_h.getChildren()[0];
								news_list[_ind][0].style.left = news_hold.offsetWidth + 'px';
								news_hold.appendChild(news_list[_ind][0]);
								var _moo2 = new Fx.Tween(news_list[_ind][0], {
									duration: 600,
									link:'cancel',
									'onComplete': function(_box){
										news_hold.style.height = 'auto';
										_f = true;
										_a = _ind;
									}
								});
								if(_ind > _a){
									news_list[_ind][0].style.left = news_hold.offsetWidth + 'px';
									_moo2.start('left', 0);
								}
								else{
									news_list[_ind][0].style.left = -news_hold.offsetWidth + 'px';
									_moo2.start('left', 0);
								}
								_loader.moo.start('opacity', 0);
								
							}});
							myRequest.send();
						}
					});
					
					news_list[_a][0].style.marginLeft = '0px';
					if(_ind > _a) _moo1.start('margin-left', -news_hold.offsetWidth + 'px');
					else _moo1.start('margin-left', news_hold.offsetWidth + 'px'); 
				}
			}
		}
	}
}
/*--- productGall ---*/
function productGall(){
	var stay_time = 15000; //in ms
	var _hold = $$('div.products div.products-box')[0];
	if(_hold){
		var t_list = $$('div.products-text div.hold > div');
		var gall_hold = _hold.getElement('div.box-holder');
		var nav_hold = document.createElement('ul');
		nav_hold = $(nav_hold);
		var gall_list = [];
		var _a = 0;
		if(_hold.getElements('ul.prod-gall-list > li').length > 1){
			var _f1 = true;
			var _t;
			_hold.getElements('ul.prod-gall-list > li').each(function(_el, _i){
				var t_el = document.createElement('li');
				t_el.title = _el.getElement('strong').innerHTML;
				t_el.innerHTML = '<a href="#">'+(_i+1)+'</a>';
				if(_el.hasClass('active')){
					t_el.className = 'active';
					_a = _i;
				}
				nav_hold.appendChild(t_el);
				t_el = [];
				t_el[0] = false;
				t_el[1] = _el.getElement('span').innerHTML;
				gall_list[_i] = t_el;
			});
			_hold.getElement('ul.prod-gall-list').destroy();
			var _btn = nav_hold.getChildren();
			_hold.getElement('div.gallery-btns').grab(nav_hold);
			nav_hold.style.marginLeft = (nav_hold.parentNode.offsetWidth - nav_hold.offsetWidth)/2 + 'px';
			var info_text_h = document.createElement('div');
			info_text_h = $(info_text_h);
			var _f = false;
			_btn[_a].addClass('active');
			t_list.setOpacity(0.35);
			t_list[_a].setOpacity(1);
			var myRequest = new Request.HTML({method: 'get', url: gall_list[_a][1], onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
				info_text_h.innerHTML = responseHTML;
				gall_list[_a][0] = info_text_h.getChildren()[0];
				gall_hold.appendChild(gall_list[_a][0]);
				gall_list[_a][0].moo = new Fx.Morph(gall_list[_a][0], {
					duration: 600,
					link:'cancel',
					'onComplete': function(_box){
						if(_box.getOpacity() == 0) _box.style.display = 'none';
						else _f = true;
					}
				});
				_f = true;
			}});
			myRequest.send();
			_btn.each(function(_el, _i){
				_el.onclick = function(){
					_f1 = false;
					changeEl(_i);
					return false;
				}
			});
			function changeEl(_ind){
				if(_t) clearTimeout(_t);
				if(_f && _ind != _a){
					_f = false;
					var _ind = _ind;
					var t_a = _a;
					_a = _ind;
					_btn[t_a].removeClass('active');
					_btn[_ind].addClass('active');
					t_list.setOpacity(0.35);
					t_list[_a].setOpacity(1);
					if(gall_list[_ind][0]){
						if(_ind < t_a){
							gall_list[_ind][0].style.left = -gall_hold.offsetWidth + 'px';
							gall_list[_ind][0].style.display = 'block';
							gall_list[_ind][0].setOpacity(0);
							gall_list[t_a][0].style.left = '0px';
							gall_list[t_a][0].setOpacity(1);
							gall_list[_ind][0].moo.start({left:0, opacity: 1});
							gall_list[t_a][0].moo.start({left:gall_hold.offsetWidth + 'px', opacity: 0});
						}
						else{
							gall_list[_ind][0].style.left = gall_hold.offsetWidth + 'px';
							gall_list[_ind][0].style.display = 'block';
							gall_list[_ind][0].setOpacity(0);
							gall_list[t_a][0].style.left = '0px';
							gall_list[t_a][0].setOpacity(1);
							gall_list[_ind][0].moo.start({left:0, opacity: 1});
							gall_list[t_a][0].moo.start({left:-gall_hold.offsetWidth + 'px', opacity: 0});
						}
					}
					else{
						if(_ind < t_a){
							gall_list[t_a][0].style.left = '0px';
							gall_list[t_a][0].setOpacity(1);
							gall_list[t_a][0].moo.start({left:gall_hold.offsetWidth + 'px', opacity: 0});
							setTimeout(function(){
								var myRequest = new Request.HTML({method: 'get', url: gall_list[_ind][1], onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
									info_text_h.innerHTML = responseHTML;
									gall_list[_ind][0] = info_text_h.getChildren()[0];
									gall_list[_ind][0].setOpacity(0);
									gall_list[_ind][0].style.left = -gall_hold.offsetWidth + 'px';
									gall_hold.appendChild(gall_list[_ind][0]);
									gall_list[_ind][0].moo = new Fx.Morph(gall_list[_ind][0], {
										duration: 600,
										link:'cancel',
										'onComplete': function(_box){
											if(_box.getOpacity() == 0) _box.style.display = 'none';
											else _f = true;
										}
									});
									gall_list[_ind][0].moo.start({left:0, opacity: 1});
								}});
								myRequest.send();
							}, 600);
						}
						else{
							gall_list[t_a][0].style.left = '0px';
							gall_list[t_a][0].setOpacity(1);
							gall_list[t_a][0].moo.start({left:-gall_hold.offsetWidth + 'px', opacity: 0});
							setTimeout(function(){
								var myRequest = new Request.HTML({method: 'get', url: gall_list[_ind][1], onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
									info_text_h.innerHTML = responseHTML;
									gall_list[_ind][0] = info_text_h.getChildren()[0];
									gall_list[_ind][0].setOpacity(0);
									gall_list[_ind][0].style.left = gall_hold.offsetWidth + 'px';
									gall_hold.appendChild(gall_list[_ind][0]);
									gall_list[_ind][0].moo = new Fx.Morph(gall_list[_ind][0], {
										duration: 600,
										link:'cancel',
										'onComplete': function(_box){
											if(_box.getOpacity() == 0) _box.style.display = 'none';
											else _f = true;
										}
									});
									gall_list[_ind][0].moo.start({left:0, opacity: 1});
								}});
								myRequest.send();
							}, 600);
						}
					}
				}
				if(_f1){
					_t = setTimeout(function(){
						if(_a < _btn.length - 1) changeEl(_a + 1);
						else changeEl(0);
					}, stay_time)
				}
			}
			if(_f1){
				_t = setTimeout(function(){
					if(_a < _btn.length - 1) changeEl(_a + 1);
					else changeEl(0);
				}, stay_time)
			}
		}
	}
}
/*--- product detail ---*/
function productDetail(){
	var _hold = $$('div.products-container')[0];
	if(_hold){
		var _loader = document.createElement('div');
		_loader.className = 'loader';
		_loader.innerHTML = 'Loading...';
		_loader = $(_loader);
		_hold.grab(_loader);
		_loader.setOpacity(0);
		_loader.style.display = 'block';
		_loader.moo = new Fx.Tween(_loader, {
			duration: 300,
			link:'cancel',
			'onComplete': function(){
				
			}
		});
		var prod_list = [];
		var _a = 0;
		_hold.getElements('ul > li').each(function(_el, _i){
			var t_el = [];
			t_el[0] = false;
			t_el[1] = _el.innerHTML;
			if(_el.hasClass('active')) _a = _i;
			prod_list[_i] = t_el;
		});
		_hold.getElement('ul').destroy();
		
		var info_text_h = document.createElement('div');
		info_text_h = $(info_text_h);
		var _f = false;
		var myRequest = new Request.HTML({method: 'get', url: prod_list[_a][1], onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
			info_text_h.innerHTML = responseHTML;
			prod_list[_a][0] = info_text_h.getChildren()[0];
			_hold.appendChild(prod_list[_a][0]);
			prod_list[_a][0].moo = new Fx.Tween(prod_list[_a][0], {
				duration: 600,
				link:'cancel',
				'onComplete': function(_box){
					if(_box.getOpacity() == 0){
						_box.style.display = 'none';
						_box.style.position = 'relative';
					}
					else{
						_f = true;
						_hold.height = 'auto';
						_box.style.zIndex = 2;
					}
				}
			});
			_f = true;
			prod_list[_a][0].getElement('a.link-prev').onclick = function(){
				if(_a > 0) changeEl(_a - 1);
				else changeEl(prod_list.length - 1);
				return false;
			}
			prod_list[_a][0].getElement('a.link-next').onclick = function(){
				if(_a < prod_list.length - 1) changeEl(_a + 1);
				else changeEl(0);
				return false;
			}
			initMooFlow(prod_list[_a][0]);
		}});
		myRequest.send();
		function changeEl(_ind){
			if(_f && _ind != _a){
				_f = false;
				var t_a = _a;
				var _ind = _ind;
				_a = _ind;
				if(prod_list[_ind][0]){
					_hold.style.height = _hold.offsetHeight + 'px';
					prod_list[t_a][0].style.position = 'absolute';
					prod_list[t_a][0].setOpacity(1);
					prod_list[_ind][0].setOpacity(0);
					prod_list[_ind][0].style.zIndex = 3;
					prod_list[_ind][0].style.display = 'block';
					prod_list[t_a][0].moo.start('opacity', 0);
					prod_list[_ind][0].moo.start('opacity', 1);
				}
				else{
					_hold.style.height = _hold.offsetHeight + 'px';
					_loader.moo.start('opacity', 1);
					prod_list[t_a][0].style.position = 'absolute';
					prod_list[t_a][0].setOpacity(1);
					prod_list[t_a][0].moo.start('opacity', 0);
					setTimeout(function(){
						var myRequest = new Request.HTML({method: 'get', url: prod_list[_ind][1], onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
							info_text_h.innerHTML = responseHTML;
							prod_list[_ind][0] = info_text_h.getChildren()[0];
							prod_list[_ind][0].setOpacity(0);
							_hold.appendChild(prod_list[_ind][0]);
							prod_list[_ind][0].moo = new Fx.Tween(prod_list[_ind][0], {
								duration: 600,
								link:'cancel',
								'onComplete': function(_box){
									if(_box.getOpacity() == 0){
										_box.style.display = 'none';
										_box.style.position = 'relative';
									}
									else{
										_f = true;
										_hold.height = 'auto';
										_box.style.zIndex = 2;
									}
								}
							});
							initTooltip();
							_f = true;
							prod_list[_ind][0].getElement('a.link-prev').onclick = function(){
								if(_a > 0) changeEl(_a - 1);
								else changeEl(prod_list.length - 1);
								return false;
							}
							prod_list[_ind][0].getElement('a.link-next').onclick = function(){
								if(_a < prod_list.length - 1) changeEl(_a + 1);
								else changeEl(0);
								return false;
							}
							prod_list[_ind][0].moo.start('opacity', 1);
							_loader.moo.start('opacity', 0);
							initMooFlow(prod_list[_ind][0]);
						}});
						myRequest.send();
					}, 600);
				}
			}
		}
		function initMooFlow(gall_hold){
			var _box = gall_hold.getElement('div.product-gall-hold');
			if(_box){
				if(_box._f != 2){
					_box._f = 2;
					var myMooFlowPage = {
						start: function(){
							var mf = new MooFlow(_box, {
								startIndex: 1,
								offsetY: -50,
								useCaption: true,
								useMouseWheel: true,
								useKeyInput: true,
								useViewer: true,
								factor: 150,
								onEmptyinit: function(){
								this.loadJSON(_box.innerHTML.toString());
								},
								onClickView: function(obj){
									var a = new Element('a',{
										'class':'remooz-element',
										'href':obj.href,
										'title':obj.title + ' - '+ obj.alt,
										'styles':{'border':'none'}
									});
									var img = new Element('img',{
										'src':obj.src,
										'title':obj.title,
										'alt':obj.alt,
										'styles':obj.coords
									}).setStyles({
										'position':'absolute',
										'border':'none'
									}).inject(a);
									a.inject(document.body);
									var remooz = new ReMooz(a, {
										centered: true,
										resizeFactor: 0.8,
										origin: img,
										onCloseEnd: function(){
											a.destroy();
											delete remooz;
										}
									}).open();
								}
							});
						}
					}
					myMooFlowPage.start();
				}
			}
		}
	}
}
/*--- back top function ---*/
function backTop(){
	var btn_back = $('back-top');
	if(btn_back){
		var myFx = new Fx.Scroll(window, {
			duration:1000,
			link:'cancel'
		});
		btn_back.onclick = function(){
			myFx.toTop();
			return false;
		}
	}
}
/*--- change page ---*/
function initChangeP(){
	$$('a.btn-change-page').each(function(_btn){
		_btn.onclick = function(){
			var _href = this.href;
			var _moo = new Fx.Tween(document.body, {
				duration: 600,
				link:'cancel',
				'onComplete': function(_box){
					window.location = _href;
				}
			});
			_moo.start('opacity', 0);
			return false;
		}
	});
}
function initPage(){
	studiesGallery();
	contactGallery();
	recentGallery();
	caseGallery();
	portfolioActions();
	initTooltip();
	packageTooltips();
	initTeamPopups();
	initContactPageTeamPopups();
	initContactTeamPopups();
	backTop();
	initChangeP();
	//studiesGalleryTimeout();
}
if (window.addEventListener) window.addEventListener("load", initPage, false);
else if (window.attachEvent && !window.opera) window.attachEvent("onload", initPage);

window.addEvent('domready', function(){
    
	initSlider();
	footerSlide();
	slideContact();
	fadeGallery();
	fadeGallery2();
	clearInputs();
	initNewsGall();
	productGall();
	productDetail();
	
});


function initSlider(){
	var m_hold = $$('div.slide-contact > div.frame')[0];
	if(m_hold){
		m_hold.style.height = '0px';
		m_hold.style.display = 'block';
	}
	if($('week') && $('weekSlide')){
		var _current = $('week').get('text');
		var _min = $('weekSlide').getElement('span.slider-min').get('text').toInt();
		var _max = $('weekSlide').getElement('span.slider-max').get('text').toInt();
		new Slider($('weekSlide'), $('weekSlide').getElement('span.scroll'), {
			wheel: true,
			range: [_min, _max],
			onChange: function(_val){
				$('week').set('html', _val);
			}
		}).set(_current);
	}
	if($('kSlide') && $('k')){
		var _current = $('k').get('text');
		var _min = $('kSlide').getElement('span.slider-min').get('text').toInt();
		var _max = $('kSlide').getElement('span.slider-max').get('text').toInt();
		new Slider($('kSlide'), $('kSlide').getElement('span.scroll'), {
			wheel: true,
			steps:(_max-_min)*2+1,
			range: [_min*2, _max*2],
			onChange: function(_val){
				var _res = _val*0.5;
				_res = _res.toString();
				if(_res.indexOf('.') == -1){
					_res += ',000';
				}
				else{
					_res = _res.replace('.', ',');
					_res += '00';
				}
				$('k').set('html', _res);
			}
		}).set(_current*2);
	}
	if(m_hold){
		m_hold.style.display = 'none';
		m_hold.style.height = 'auto';
	}
}


function portfolioUrlHandle(url)
{
    if(queryString(url,'CategoryId'))
        return 'CategoryId='+queryString(url,'CategoryId');
        
    if(queryString(url,'CaseId'))
        return 'CaseId='+queryString(url,'CaseId');
    
    if(queryString(url,'Id'))
        return 'Id='+queryString(url,'Id');
        
    return '';
}




/*---contact team popups ---*/
function initContactPageTeamPopups(){
    
    
	var _hold = $('team-gallery');
	if(_hold){
		var _list = _hold.getElements('a.bioPop');
		var _tooltip = document.createElement('div');
		_tooltip.id = 'team-tooltip';
		var tooltip_t = document.createElement('a');
		_tooltip.appendChild(tooltip_t);
		if(!$('team-tooltip'))
		{
		    document.body.appendChild(_tooltip);
		}
		_tooltip = $('team-tooltip');
		var _fader = document.createElement('div');
		_fader.id = 'popup-fader';
		
		if(!$('popup-fader'))
		{
		    document.body.appendChild(_fader);
		}
		
		
		_fader = $( 'popup-fader');
		_fader.style.display = 'none';
		_fader.setOpacity(0);
		_fader.moo =  new Fx.Tween(_fader, {
			duration: 200,
			link:'cancel',
			'onComplete': function(t_box){
				if(t_box.getOpacity() == 0) t_box.style.display = 'none';
			}
		});
		var info_text_h = document.createElement('div');
		info_text_h = $(info_text_h);
		var tooltip_a = -1;
		var _a = -1;
		var _t;
		_list.each(function(_btn, _i){
			if(_btn.title){
				var _text = _btn.title;
				_btn.title = '';
				var _x = 0;
				var _y = 99999;
				var _coords = _btn.coords.split(',');
				for(var i = 0; i < _coords.length; i++){
					if(i%2 == 0) _x = Math.max(_x, _coords[i]);
					else _y = Math.min(_y, _coords[i]); 
				}
				_btn.onmouseover = function(){
					if(_t) clearTimeout(_t);
					_a = _i;
					tooltip_t.innerHTML = _text;
					_tooltip.style.top = _y + findPosY(_hold.parentNode) + 'px';
					_tooltip.style.left = _x + findPosX(_hold.parentNode) + 'px';
					_tooltip.style.display = 'block';
				}
				_btn.onclick = function(){
					if(_a != -1) showPopup();
					return false;
				}
				_btn.onmouseout = function(){
					_t = setTimeout(function(){
						_a = -1;
						_tooltip.style.display = 'none';
					}, 200);
				}
			}
		});
		_tooltip.onmouseover = function(){
			if(_t) clearTimeout(_t);
		}
		_tooltip.onmouseout = function(){
			_t = setTimeout(function(){
				_a = -1;
				_tooltip.style.display = 'none';
			}, 200);
		}
		_tooltip.onclick = function(){
			_list[_a].onclick();
			return false;
		}
		_fader.onclick = function(){
			if(_list[tooltip_a]._box){
				if(_list[tooltip_a]._contact) _list[tooltip_a]._contact.style.display = 'none';
				_list[tooltip_a]._box.moo.start('opacity', 0);
				_fader.moo.start('opacity', 0);
			}
			return false;
		}
	}
	var _f = true;
	function showPopup(){
		if(_f){
			tooltip_a = _a;
			_f = false;
			_fader.setOpacity(0);
			_fader.style.height = $$('div.wrapper')[0].offsetHeight + 'px';
			_fader.style.display = 'block';
			_fader.moo.start('opacity', 0.7);
			if(_list[tooltip_a]._box){
				_list[tooltip_a]._box.style.display = 'block';
				_list[tooltip_a]._box.style.top = getCurrentYPos() + 'px';
				_list[tooltip_a]._box.moo.start('opacity', 1);
			}
			else{
				var myRequest = new Request.HTML({method: 'get', url: _list[tooltip_a].href, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
					info_text_h.innerHTML = responseHTML;
					_list[tooltip_a]._box = info_text_h.getChildren()[0];
					_list[tooltip_a]._box.setOpacity(0);
					document.body.appendChild(_list[tooltip_a]._box);
					_list[tooltip_a]._box.moo = new Fx.Tween(_list[tooltip_a]._box, {
						duration: 500,
						link:'cancel',
						'onComplete': function(t_box){
							if(t_box.getOpacity() == 0){
								t_box.style.display = 'none';
								_f = true;
							}
						}
					});
					_list[tooltip_a]._box.style.left = (document.body.offsetWidth -_list[tooltip_a]._box.offsetWidth)/2 + 'px';
					
					var myDrag = _list[tooltip_a]._box.makeDraggable({
						handle:_list[tooltip_a]._box.getElement('span.btn-popup-drag')
					});
					_list[tooltip_a]._box.style.top = getCurrentYPos() + 'px';
					_list[tooltip_a]._box.moo.start('opacity', 1);
					_list[tooltip_a]._box.getElement('a.btn-close').onclick = function(){
						_list[tooltip_a]._box.moo.start('opacity', 0);
						_fader.moo.start('opacity', 0);
						return false;
					}
					_list[tooltip_a]._contact = false;
					_list[tooltip_a]._box.getElement('a.contact-btn').onclick = function(){
						displayContact(this.href);
						return false;
					}
				}});
				myRequest.send();
			}
		}
	}
	function displayContact(_url){
		_list[tooltip_a]._box.style.display = 'none';
		{
			var myRequest = new Request.HTML({method: 'get', url: _url, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
				info_text_h.innerHTML = responseHTML;
				_list[tooltip_a]._contact = info_text_h.getChildren()[0];
				_list[tooltip_a]._contact.style.top = getCurrentYPos() + 'px';
				if($('contactMainBoxForm'))
			    {
			        $('contactMainBoxForm').dispose();
			    }
				document.body.appendChild(_list[tooltip_a]._contact);
				_list[tooltip_a]._contact.getElements('a.close-button').each(function(_el){
					_el.onclick = function(){
						_list[tooltip_a]._contact.style.display = 'none';
						_list[tooltip_a]._box.style.display = 'block';
						return false;
					}
				});
				_list[tooltip_a]._contact.style.left = (document.body.offsetWidth -_list[tooltip_a]._contact.offsetWidth)/2 + 'px';
				
				var myDrag = _list[tooltip_a]._contact.makeDraggable({
					handle:_list[tooltip_a]._contact.getElement('span.btn-popup-drag')
				});
			}});
			myRequest.send();
		}
		
	}
	function getCurrentYPos(){
		var _offset = 0;
		if (document.body && document.body.scrollTop) _offset =  document.body.scrollTop;
		if (document.documentElement && document.documentElement.scrollTop) _offset = document.documentElement.scrollTop;
		if (window.pageYOffset) _offset =  window.pageYOffset;
		return _offset;
	}
	
	
	
}

/*---contact team popups ---*/
function initContactTeamPopups(){
    
    
	var _hold = $('team-gallery');
	if(_hold){
		var _list = _hold.getElements('a.team-contact-btn');
		var _tooltip = document.createElement('div');
		_tooltip.id = 'team-tooltip';
		var tooltip_t = document.createElement('a');
		_tooltip.appendChild(tooltip_t);
		if(!$('team-tooltip'))
		{
		    document.body.appendChild(_tooltip);
		}
		_tooltip = $('team-tooltip');
		var _fader = document.createElement('div');
		_fader.id = 'popup-fader';
		if(!$('popup-fader'))
		{
		    document.body.appendChild(_fader);
		}
		_fader = $( 'popup-fader');
		_fader.style.display = 'none';
		_fader.setOpacity(0);
		_fader.moo =  new Fx.Tween(_fader, {
			duration: 200,
			link:'cancel',
			'onComplete': function(t_box){
				if(t_box.getOpacity() == 0) t_box.style.display = 'none';
			}
		});
		var info_text_h = document.createElement('div');
		info_text_h = $(info_text_h);
		var tooltip_a = -1;
		var _a = -1;
		var _t;
		_list.each(function(_btn, _i){
			if(_btn.title){
				var _text = _btn.title;
				_btn.title = '';
				var _x = 0;
				var _y = 99999;
				var _coords = _btn.coords.split(',');
				for(var i = 0; i < _coords.length; i++){
					if(i%2 == 0) _x = Math.max(_x, _coords[i]);
					else _y = Math.min(_y, _coords[i]); 
				}
				_btn.onmouseover = function(){
					if(_t) clearTimeout(_t);
					_a = _i;
					tooltip_t.innerHTML = _text;
					_tooltip.style.top = _y + findPosY(_hold.parentNode) + 'px';
					_tooltip.style.left = _x + findPosX(_hold.parentNode) + 'px';
					_tooltip.style.display = 'block';
				}
				_btn.onclick = function(){
					if(_a != -1) displayContact(this.href);
					return false;
				}
				_btn.onmouseout = function(){
					_t = setTimeout(function(){
						_a = -1;
						_tooltip.style.display = 'none';
					}, 200);
				}
			}
		});
		_tooltip.onmouseover = function(){
			if(_t) clearTimeout(_t);
		}
		_tooltip.onmouseout = function(){
			_t = setTimeout(function(){
				_a = -1;
				_tooltip.style.display = 'none';
			}, 200);
		}
		_tooltip.onclick = function(){
			_list[_a].onclick();
			return false;
		}
		_fader.onclick = function(){
			if(_list[tooltip_a]._contact){
				_list[tooltip_a]._contact.moo.start('opacity', 0);
				_fader.moo.start('opacity', 0);
			}
			return false;
		}
	}
	var _f = true;
	function displayContact(_url){
		if(_f){
			tooltip_a = _a;
			_f = false;
			_fader.setOpacity(0);
			_fader.style.height = $$('div.wrapper')[0].offsetHeight + 'px';
			_fader.style.display = 'block';
			_fader.moo.start('opacity', 0.7);
		    {
			    var myRequest = new Request.HTML({method: 'get', url: _url, onSuccess: function(responseTree, responseElements, responseHTML, responseJavaScript){
				    info_text_h.innerHTML = responseHTML;
				    _list[tooltip_a]._contact = info_text_h.getChildren()[0];
				    _list[tooltip_a]._contact.style.top = getCurrentYPos() + 'px';
				    if($('contactMainBoxForm'))
				    {
				        $('contactMainBoxForm').dispose();
				    }
				    document.body.appendChild(_list[tooltip_a]._contact);
				    
				    _list[tooltip_a]._contact.moo = new Fx.Tween(_list[tooltip_a]._contact, {
						duration: 500,
						link:'cancel',
						'onComplete': function(t_box){
							if(t_box.getOpacity() == 0){
								t_box.style.display = 'none';
								_f = true;
							}
						}
					});
				    
				    _list[tooltip_a]._contact.moo.start('opacity', 1);
				    
				    _list[tooltip_a]._contact.getElements('a.close-button').each(function(_el){
					    _el.onclick = function(){
					        _list[tooltip_a]._contact.moo.start('opacity', 0);
						    _fader.moo.start('opacity', 0);
						    return false;
					    }
				    });
				    _list[tooltip_a]._contact.style.left = (document.body.offsetWidth -_list[tooltip_a]._contact.offsetWidth)/2 + 'px';
    				
				    var myDrag = _list[tooltip_a]._contact.makeDraggable({
					    handle:_list[tooltip_a]._contact.getElement('span.btn-popup-drag')
				    });
			    }});
			    myRequest.send();
		    }
		}
	}
	function getCurrentYPos(){
		var _offset = 0;
		if (document.body && document.body.scrollTop) _offset =  document.body.scrollTop;
		if (document.documentElement && document.documentElement.scrollTop) _offset = document.documentElement.scrollTop;
		if (window.pageYOffset) _offset =  window.pageYOffset;
		return _offset;
	}
	
	
	
}

//By Mahongtao Begin

function showCaseStudyPhoto()
{
    var photos=$$('div.HeroDiv');
    var btns=$$('#photo-box a');
    
    var current=0;
    
    if(photos.length>0&&btns.length>0)
    {
        btns.each(function(el,i){
        
            el.onclick=function(){
            
                btns[current].removeClass('active');
                photos[current].fade(0);
                photos[current].set('styles',{'display':'none'});
                
                btns[i].addClass('active');
                photos[i].set('styles',{'display':''});
                photos[i].fade(1);
                
                //var myFx=new Fx.Scroll(window).toTop();
                
                current=i;
                return false;
            
            };
        
        });
        
        btns[0].onclick();
    }
}

//By Mahongtao End
