function CitSlide(){
	this.slideshowTime = 5000;
	
	this.mainDiv;
	this.mainImg;
	this.mainDivPadding;
	this.infoContainerActualImg;
	this.infoContainerSumImg;
	this.bottomContainer;
	this.loadingDiv;
	this.imgContainer;
	this.playLink;
	this.pauseLink;
	this.titleContainer;
	this.mainDivMargin = 0;
	this.activeSlide = false;
	this.activeRel = '';
	this.hidedElements = new Array();
	this.imgRels = new Array();
	this.imgAlts = new Array();
	this.imgButtonsShowTimeOut;
	this.imgButtonsHiddenTimeOut;
	this.playSlideShow = false;
	this.playTimeOut;
	this.mainDivShowTimeOut;
	this.contentContainer;
	this.thisImg = true;
	this.showContentOldParent;
	this.templateHtmlHeightDiff;
	this.templateHtmlWidthDiff;
	this.imgTitleHide;
	this.onlyImg = false;
	this.loadingMainImg = new Image();
	this.mainImgSrc = false;
	this.allButton = false;
	this.oldPictureWidth = 0;
	this.oldPictureHeight = 0;
	this.newPictureWidth = 0;
	this.newPictureHeight = 0;
	this.imgLoadingAnimatedProcess = false;
	this.imgLoadingAnimatedTimeOut;
	this.imgLoadingAnimatedStep = 4;
	this.dontCopyImgDiv;
	this.dontCopyImg = true;
	
	this.isIE = false;
	this.isIE6 = false;
	this.isIE78 = false;
	this.opera = false;
	
	this.init = citSlideInit;
	this.show = citSlideShow;
	this.close = citSlideClose;
	this.prev = citSlidePrev;
	this.next = citSlideNext;
	this.play = citSlidePlay;
	this.stop = citSlideStop;
	this.firstImg = citSlideFirstImg;
	this.lastImg = citSlideLastImg;
	this.showContent = citSlideShowContent;
	this.setContentSize = citSlideSetContentSize;
	this.showOnlyImg = citSlideShowOnlyImg;
	
	this.getScreenHeight = citSlideGetScreenHeight;
	this.getScreenWidth = citSlideGetScreenWidth;
	this.getImagePosition = citSlideGetImagePosition;
	this.setMainDivHeight = citSlideSetMainDivHeight;
	this.setPicture = citSlideSetPicture;
	this.setBackgroundElementsHide = citSlideSetBackgroundElementsHide;
	this.setBackgroundElementsShow = citSlideSetBackgroundElementsShow;
	this.setImageMaxWH = citSlideSetImageMaxWH;
	this.findImgs = citSlideFindImgs;
	this.showImgButtons = citSlideShowImgButtons;
	this.hideImgButtons = citSlideHideImgButtons;
	this.showMainDiv = citSlideShowMainDiv;
	this.hideMainDiv = citSlideHideMainDiv;
	this.setContent = citSlideSetContent;
	this.copyChilds = citSlideCopyChilds;
	this.preLoad = citSlidePreLoad;
	this.resetMainDivOpacity = citSlideResetMainDivOpacity;
	this.newImgSize = citSlideNewImgSize;
	this.imgLoadingAnimated = citSlideImgLoadingAnimated;
	this.setMainImgSrc = citSlideSetMainImgSrc;
	this.browserDetect = citSlideBrowserDetect;
	this.loadedLoadingImg = citSlideLoadedLoadingImg;
}

function citSlideCopyChilds(from,to){
	var x = from.childNodes;
	to.innerHTML = '';
	while (x.length>0){
		to.appendChild(x[0]);
	}
}

function citSlideSetContentSize(width, height){
	this.contentContainer.style.width = width+'px';
	this.contentContainer.style.height = height+'px';
}

function citSlideSetContent(contentId){
	this.showContentOldParent = contentId;
	this.copyChilds(contentId, this.contentContainer);
	var elements = this.contentContainer.getElementsByTagName('select');
	var objectElements = this.contentContainer.getElementsByTagName('object');
	var i;
	for (i=0;i<elements.length;i++){
		var isHidedElement = false;
		for (j=0;j<this.hidedElements.length;j++){
			if (this.hidedElements[j].nodeValue == elements[i].nodeValue)
				isHidedElement = true;
		}
		if (elements[i].style.visibility == 'hidden' && isHidedElement){
			elements[i].style.visibility = 'visible';
		}
	}
	for (i=0;i<objectElements.length;i++){
		var isHidedElement = false;
		for (j=0;j<this.hidedElements.length;j++){
			if (this.hidedElements[j].nodeValue == objectElements[i].nodeValue)
				isHidedElement = true;
		}
		if (objectElements[i].style.visibility == 'hidden' && isHidedElement){
			objectElements[i].style.visibility = 'visible';
		}
	}
}

function citSlideShowContent(contentId){
	if (contentId!=null){
		this.thisImg = false;
		this.setBackgroundElementsHide();
		this.pictureContainer.style.display = 'none';
		this.setContent(contentId);
		this.contentContainer.style.display = '';
		this.mainImg.style.display = 'none';
		this.loadingMainImg.style.display = 'none';
		this.bottomContainer.style.display = 'none';
		this.titleContainer.style.display = 'none';
		this.activeSlide = true;
		this.mainDiv.style.display = '';
		this.resetMainDivOpacity();
		this.showMainDiv();
	}
}

function citSlideResetMainDivOpacity(){
	if (this.isIE){
		this.mainImg.filters.alpha.opacity=0;
		if (!this.isIE78)
			this.mainDivPadding.filters.alpha.opacity=0;
	} else {
		this.mainDivPadding.style.opacity=0.0;
	}
}


function citSlideShowMainDiv(){
	clearTimeout(this.mainDivShowTimeOut);
	var isEnd = false;
	if (this.isIE){
		this.mainImg.filters.alpha.opacity=Math.ceil(this.mainImg.filters.alpha.opacity+20);
		if (!this.isIE78)
			this.mainDivPadding.filters.alpha.opacity=Math.ceil(this.mainDivPadding.filters.alpha.opacity+20);
		if (this.mainImg.filters.alpha.opacity>=100){
			isEnd = true;
			this.mainImg.filters.alpha.opacity=100;
			if (!this.isIE78)
				this.mainDivPadding.filters.alpha.opacity=100;
		}
	} else {
		this.mainDivPadding.style.opacity=(Math.ceil(this.mainDivPadding.style.opacity*100+10)/100);
		if (this.mainDivPadding.style.opacity>=1){
			isEnd = true;
			this.mainDivPadding.style.opacity=1;
		}
	}
	if (!isEnd)
		this.mainDivShowTimeOut = setTimeout('citSlide.showMainDiv();',20);
	else
		this.mainDiv.style.display = '';
}

function citSlideHideMainDiv(){
	clearTimeout(this.mainDivShowTimeOut);
	this.mainDiv.style.display = 'none';
	this.dontCopyImgDiv.style.display = 'none';
}

function citSlidePlay(){
	if (this.activeSlide && this.thisImg && !this.onlyImg){
		this.playLink.style.display = 'none';
		this.pauseLink.style.display = '';
		this.playSlideShow = true;
		this.next();
		this.playTimeOut = setTimeout('citSlide.play();',this.slideshowTime);
	}
}

function citSlideStop(){
	if (this.activeSlide && this.thisImg && !this.onlyImg){
		this.playLink.style.display = '';
		this.pauseLink.style.display = 'none';
		clearTimeout(this.playTimeOut);
		this.playSlideShow = false;
	}
}

function citSlidePrev() {
	if (this.activeSlide && this.thisImg && !this.onlyImg){
		if (this.imgLoadingAnimatedProcess){
			this.oldPictureHeight = 0;
			this.oldPictureWidth = 0;
			this.imgLoadingAnimated();
		}
		var position = this.getImagePosition(this.activeRel);
		if (position==1)
			position = this.imgRels.length+1;
		this.activeRel = this.imgRels[position-2];
		var relLink = this.activeRel.replace('citslide#','');
		this.setPicture(relLink);
	}
}

function citSlideNext() {
	if (this.activeSlide && this.thisImg && !this.onlyImg){
		if (this.imgLoadingAnimatedProcess){
			this.oldPictureHeight = 0;
			this.oldPictureWidth = 0;
			this.imgLoadingAnimated();
		}
		var position = this.getImagePosition(this.activeRel);
		if (position==this.imgRels.length)
			position = 0;
		this.activeRel = this.imgRels[position];
		var relLink = this.activeRel.replace('citslide#','');
		this.setPicture(relLink);
	}
}

function citSlideFirstImg() {
	if (this.activeSlide && this.thisImg && !this.onlyImg){
		if (this.imgLoadingAnimatedProcess){
			this.oldPictureHeight = 0;
			this.oldPictureWidth = 0;
			this.imgLoadingAnimated();
		}
		var position = 0;
		this.activeRel = this.imgRels[position];
		var relLink = this.activeRel.replace('citslide#','');
		this.setPicture(relLink);
	}
}

function citSlideLastImg() {
	if (this.activeSlide && this.thisImg && !this.onlyImg){
		if (this.imgLoadingAnimatedProcess){
			this.oldPictureHeight = 0;
			this.oldPictureWidth = 0;
			this.imgLoadingAnimated();
		}
		var position = this.imgRels.length-1;
		this.activeRel = this.imgRels[position];
		var relLink = this.activeRel.replace('citslide#','');
		this.setPicture(relLink);
	}
}

function citSlideShowImgButtons(){
	if (this.thisImg && !this.onlyImg){
		this.bottomContainer.style.display='';
		this.titleContainer.style.display='';
		clearTimeout(this.imgButtonsHiddenTimeOut);
		var isEnd = false;
		if (this.isIE){
			this.bottomContainer.filters.alpha.opacity=Math.ceil(this.bottomContainer.filters.alpha.opacity+5);
			if (this.imgTitleHide)
				this.titleContainer.filters.alpha.opacity=Math.ceil(this.titleContainer.filters.alpha.opacity+5);
			if (this.bottomContainer.filters.alpha.opacity>=85){
				isEnd = true;
				this.bottomContainer.filters.alpha.opacity=85;
				if (this.imgTitleHide)
					this.titleContainer.filters.alpha.opacity=85;
			}
		} else {
			this.bottomContainer.style.opacity=(Math.ceil(this.bottomContainer.style.opacity*100+5)/100);
			if (this.imgTitleHide)
				this.titleContainer.style.opacity=(Math.ceil(this.titleContainer.style.opacity*100+5)/100);
			if (this.bottomContainer.style.opacity>=0.85){
				isEnd = true;
				this.bottomContainer.style.opacity=0.85;
				if (this.imgTitleHide)
					this.titleContainer.style.opacity=0.85;
			}
		}
		if (!isEnd)
			this.imgButtonsShowTimeOut = setTimeout('citSlide.showImgButtons();',20);
	}
}

function citSlideHideImgButtons(){
	if (this.thisImg){
		this.bottomContainer.style.display='';
		this.titleContainer.style.display='';
		clearTimeout(this.imgButtonsShowTimeOut);
		var isEnd = false;
		if (this.isIE){
			this.bottomContainer.filters.alpha.opacity=Math.ceil(this.bottomContainer.filters.alpha.opacity-10);
			if (this.imgTitleHide)
				this.titleContainer.filters.alpha.opacity=Math.ceil(this.titleContainer.filters.alpha.opacity-10);
			if (this.bottomContainer.filters.alpha.opacity<=1){
				isEnd = true;
				this.bottomContainer.filters.alpha.opacity=0;
				if (this.imgTitleHide)
					this.titleContainer.filters.alpha.opacity=0;
			}
		} else {
			this.bottomContainer.style.opacity=(Math.ceil(this.bottomContainer.style.opacity*100-5)/100);
			if (this.imgTitleHide)
				this.titleContainer.style.opacity=(Math.ceil(this.titleContainer.style.opacity*100-5)/100);
			if (this.bottomContainer.style.opacity<=0.01){
				isEnd = true;
				this.bottomContainer.style.opacity=0.0;
				if (this.imgTitleHide)
					this.titleContainer.style.opacity=0.0;
			}
		}
		if (!isEnd)
			this.imgButtonsHiddenTimeOut = setTimeout('citSlide.hideImgButtons();',20);
	}
}

function citSlideShow(img_id){
	if (img_id.getAttribute('rel')!=null
		&& img_id.getAttribute('rel').indexOf('citslide#')!=-1){
		this.activeRel = img_id.getAttribute('rel');
		var relLink = this.activeRel.replace('citslide#','');
		this.setPicture(relLink);
		this.activeSlide = true;
		this.setBackgroundElementsHide();
		this.pictureContainer.style.display = '';
		this.mainDiv.style.display = '';
		if (this.dontCopyImg)
			this.dontCopyImgDiv.style.display = '';
	}
}

function citSlideShowOnlyImg(src){
	this.onlyImg = true;
	this.setPicture(src);
	this.activeSlide = true;
	this.setBackgroundElementsHide();
	this.pictureContainer.style.display = '';
	this.mainDiv.style.display = '';
	if (this.dontCopyImg)
		this.dontCopyImgDiv.style.display = '';
}

function citSlidePreLoad(){
	var i;
	var imageObj = new Image();
	var images = new Array();
	images.push("/CitSlide/images/border_bottom_left.png");
	images.push("/CitSlide/images/border_bottom_middle.png");
	images.push("/CitSlide/images/border_bottom_right.png");
	images.push("/CitSlide/images/border_middle_left.png");
	images.push("/CitSlide/images/border_middle_right.png");
	images.push("/CitSlide/images/border_top_left.png");
	images.push("/CitSlide/images/border_top_middle.png");
	images.push("/CitSlide/images/border_top_right.png");
	images.push("/CitSlide/images/bottom_container_left.png");
	images.push("/CitSlide/images/bottom_container_right.png");
	images.push("/CitSlide/images/close.png");
	images.push("/CitSlide/images/close_hover.png");
	images.push("/CitSlide/images/load.gif");
	images.push("/CitSlide/images/next.png");
	images.push("/CitSlide/images/next_hover.png");
	images.push("/CitSlide/images/pause.png");
	images.push("/CitSlide/images/pause_hover.png");
	images.push("/CitSlide/images/play.png");
	images.push("/CitSlide/images/play_hover.png");
	images.push("/CitSlide/images/prev.png");
	images.push("/CitSlide/images/prev_hover.png");
	images.push("/CitSlide/images/first.png");
	images.push("/CitSlide/images/first_hover.png");
	images.push("/CitSlide/images/last.png");
	images.push("/CitSlide/images/last_hover.png");
	for(i=0; i<images.length; i++) {
		imageObj.src=images[i];
	}
}

function citSlideBrowserDetect(){
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
		var ieversion=new Number(RegExp.$1); 
		if (ieversion>=6) this.isIE = true;
		if (ieversion>=6 && ieversion<7) this.isIE6 = true;
		if (ieversion>=7 && ieversion<9) this.isIE78 = true;
	}
	
	if (window.opera)
		this.opera = true;
}

function citSlideInit(template){
	this.preLoad();
	this.browserDetect();
	
	if (typeof citSlideTemplateHtmlHeightDiff === "undefined")
		this.templateHtmlHeightDiff = 50;
	else
		this.templateHtmlHeightDiff = citSlideTemplateHtmlHeightDiff;
	if (typeof citSlideTemplateHtmlWidthDiff === "undefined")
		this.templateHtmlWidthDiff = 75;
	else
		this.templateHtmlWidthDiff = citSlideTemplateHtmlWidthDiff;
	if (typeof citSlideImgTitleHide === "undefined")
		this.imgTitleHide = true;
	else
		this.imgTitleHide = citSlideImgTitleHide;
	if (typeof citSlideAllButton === "undefined")
		this.allButton = false;
	else
		this.allButton = citSlideAllButton;
	if (typeof citSlideDontCopyImg === "undefined")
		this.dontCopyImg = true;
	else
		this.dontCopyImg = citSlideDontCopyImg;
	
	
	this.mainDiv = document.createElement('div');
	this.mainDivPadding = document.createElement('div');
	var pictureA = document.createElement('a');
	var positionTable = document.createElement('table');
	var positionTableTbody = document.createElement('tbody');
	var positionTableTr = document.createElement('tr');
	var positionTableTd = document.createElement('td');
	this.pictureContainer = document.createElement('div');
	this.dontCopyImgDiv = document.createElement('div');
	
	this.mainDiv.id = 'cit_slide_main_div';
	this.mainDiv.className = 'cit_slide_main_div';
	this.setMainDivHeight();
	positionTable.className = 'cit_slide_position_table';
	positionTableTd.className = 'cit_slide_position_table_td';
	pictureA.className = 'cit_slide_picture_a';
	pictureA.onmouseover = function(){
		citSlide.showImgButtons();
	};
	pictureA.onmouseout = function(){
		citSlide.hideImgButtons();	
	};
	this.dontCopyImgDiv.className = 'cit_slide_dont_copy';
	
	pictureA.innerHTML = template;
	positionTableTd.appendChild(pictureA);
	positionTableTr.appendChild(positionTableTd);
	positionTableTbody.appendChild(positionTableTr);
	positionTable.appendChild(positionTableTbody);
	this.mainDivPadding.appendChild(positionTable);
	this.mainDiv.appendChild(this.mainDivPadding);
	document.getElementsByTagName('body')[0].appendChild(this.mainDiv);
	this.loadingMainImg.onload = function(){
		citSlide.loadedLoadingImg();
	};

	if (document.getElementById('cit_slide_arrow_link_pause')==null){
		this.pauseLink = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.pauseLink);
	} else {
		this.pauseLink = document.getElementById('cit_slide_arrow_link_pause');
	}
	this.pauseLink.style.display = 'none';
	this.pauseLink.onclick = function(){
		if (citSlide.playSlideShow)
			citSlide.stop();
	};
	
	if (document.getElementById('cit_slide_arrow_link_play')==null){
		this.playLink = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.playLink);
	} else {
		this.playLink = document.getElementById('cit_slide_arrow_link_play');
	}
	this.playLink.style.display = '';
	this.playLink.onclick = function(){
		if (!citSlide.playSlideShow)
			citSlide.play();
	};
	
	var prevLink;
	if (document.getElementById('cit_slide_arrow_link_prev')==null){
		prevLink = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(prevLink);
	} else {
		prevLink = document.getElementById('cit_slide_arrow_link_prev');
	}
	prevLink.onclick = function(){
		if (citSlide.playSlideShow)
			clearTimeout(citSlide.playTimeOut);
		citSlide.prev();
		if (citSlide.playSlideShow)
			citSlide.playTimeOut = setTimeout('citSlide.play();',citSlide.slideshowTime);
	};
	
	var nextLink;
	if (document.getElementById('cit_slide_arrow_link_next')==null){
		nextLink = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(nextLink);
	} else {
		nextLink = document.getElementById('cit_slide_arrow_link_next');
	}
	nextLink.onclick = function(){
		if (citSlide.playSlideShow)
			clearTimeout(citSlide.playTimeOut);
		citSlide.next();
		if (citSlide.playSlideShow)
			citSlide.playTimeOut = setTimeout('citSlide.play();',citSlide.slideshowTime);
	};
	
	var firstLink;
	if (document.getElementById('cit_slide_arrow_link_first')==null){
		firstLink = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(firstLink);
	} else {
		firstLink = document.getElementById('cit_slide_arrow_link_first');
	}
	firstLink.onclick = function(){
		if (citSlide.playSlideShow)
			clearTimeout(citSlide.playTimeOut);
		citSlide.firstImg();
		if (citSlide.playSlideShow)
			citSlide.playTimeOut = setTimeout('citSlide.play();',citSlide.slideshowTime);
	};
	
	var lastLink;
	if (document.getElementById('cit_slide_arrow_link_last')==null){
		lastLink = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(lastLink);
	} else {
		lastLink = document.getElementById('cit_slide_arrow_link_last');
	}
	lastLink.onclick = function(){
		if (citSlide.playSlideShow)
			clearTimeout(citSlide.playTimeOut);
		citSlide.lastImg();
		if (citSlide.playSlideShow)
			citSlide.playTimeOut = setTimeout('citSlide.play();',citSlide.slideshowTime);
	};
	
	var closeContainer;
	if (document.getElementById('cit_slide_close_link')==null){
		closeContainer = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(closeContainer);
	} else {
		closeContainer = document.getElementById('cit_slide_close_link');
	}
	closeContainer.onclick = function(){
		citSlide.close();
	};
	
	if (document.getElementById('cit_slide_main_img')==null){
		this.mainImg = document.createElement('img');
		document.getElementsByTagName('body')[0].appendChild(this.mainImg);
		this.mainImg.style.display = 'none';
	} else {
		this.mainImg = document.getElementById('cit_slide_main_img');
	}
	this.mainImg.src='';
	this.mainImg.onload = function(){
		if (citSlide.isIE)
			citSlide.loadingMainImg.filters.alpha.opacity = 0;
		else
			citSlide.loadingMainImg.style.opacity = 0.0;
	};
	this.mainImgSrc = false;
	
	this.pictureContainer.className = 'cit_slide_picture_container';
	this.loadingMainImg.className = 'cit_slide_loading_main_img';
	this.mainImg.parentNode.appendChild(this.pictureContainer);
	this.pictureContainer.appendChild(this.mainImg);
	this.pictureContainer.appendChild(this.loadingMainImg);
	this.pictureContainer.appendChild(this.dontCopyImgDiv);
	
	if (document.getElementById('cit_slide_loading_div')==null){
		this.loadingDiv = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.loadingDiv);
	} else {
		this.loadingDiv = document.getElementById('cit_slide_loading_div');
	}
	this.loadingDiv.style.visibility='hidden';
	
	if (document.getElementById('cit_slide_img_container')==null){
		this.imgContainer = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.imgContainer);
	} else {
		this.imgContainer = document.getElementById('cit_slide_img_container');
	}
	
	if (document.getElementById('cit_slide_info_container_act_img')==null){
		this.infoContainerActualImg = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.infoContainerActualImg);
	} else {
		this.infoContainerActualImg = document.getElementById('cit_slide_info_container_act_img');
	}
	this.infoContainerActualImg.innerHTML = ' ';
	
	if (document.getElementById('cit_slide_info_container_sum_img')==null){
		this.infoContainerSumImg = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.infoContainerSumImg);
	} else {
		this.infoContainerSumImg = document.getElementById('cit_slide_info_container_sum_img');
	}
	this.infoContainerSumImg.innerHTML = ' ';
	
	if (document.getElementById('cit_slide_bottom_button_container')==null){
		this.bottomContainer = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.bottomContainer);
	} else {
		this.bottomContainer = document.getElementById('cit_slide_bottom_button_container');
	}
	this.bottomContainer.style.display='none';
	
	if (document.getElementById('cit_slide_contant_container')==null){
		this.contentContainer = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.contentContainer);
	} else {
		this.contentContainer = document.getElementById('cit_slide_contant_container');
	}
	this.contentContainer.style.display = 'none';
	
	if (document.getElementById('cit_slide_img_title_container')==null){
		this.titleContainer = document.createElement('div');
		document.getElementsByTagName('body')[0].appendChild(this.titleContainer);
	} else {
		this.titleContainer = document.getElementById('cit_slide_img_title_container');
	}
	if (this.imgTitleHide)
		this.titleContainer.style.display='none';
	
	if (this.isIE){
		this.bottomContainer.style.filter='alpha(opacity=0)';
		if (this.imgTitleHide)
			this.titleContainer.style.filter='alpha(opacity=0)';
		this.mainImg.style.filter='alpha(opacity=0)';
		this.loadingMainImg.style.filter='alpha(opacity=0)';
		if (!this.isIE78)
			this.mainDivPadding.style.filter='alpha(opacity=0)';
	}else{
		this.loadingMainImg.style.opacity = 0.0;
	}
	this.resetMainDivOpacity();
	this.mainDiv.style.display = 'none';
	this.dontCopyImgDiv.style.display = 'none';
	if (!this.allButton){
		lastLink.style.display = 'none'; 
		firstLink.style.display = 'none';
	}
	
	this.findImgs();
}

function citSlideFindImgs(){
	var imgs = document.getElementsByTagName('img');
	var i;
	for (i=0;i<imgs.length;i++){
		if (imgs[i].getAttribute('rel')!=null
			&& imgs[i].getAttribute('rel').indexOf('citslide#')!=-1){
			imgs[i].onclick = function(){
				citSlide.show(this);
			};
			imgs[i].style.cursor = 'pointer';
			this.imgRels.push(imgs[i].getAttribute('rel'));
			this.imgAlts.push(imgs[i].alt);
		}		
	}	
}

function citSlideClose(){
	if (this.activeSlide){
		this.setBackgroundElementsShow();
		this.activeRel = '';
		this.stop();
		this.hideMainDiv();
		if (!this.thisImg && this.contentContainer.firstChild!=null){
			this.copyChilds(this.contentContainer, this.showContentOldParent);
		}
		this.thisImg = true;
		this.contentContainer.innerHTML = '';
		this.onlyImg = false;
		this.mainImg.src = '';
		this.loadingMainImg.src = '';
		this.mainImgSrc = false;
		this.activeSlide = false;
		this.resetMainDivOpacity();
		this.oldPictureHeight = 0;
		this.oldPictureWidth = 0;
		this.newPictureWidth = 0;
		this.newPictureHeight = 0;
		this.imgLoadingAnimatedProcess = false;
		this.pictureContainer.style.height = '';
		this.pictureContainer.style.width = '';
	}
}

function citSlideGetImagePosition(act_rel){
	var i,pos=0;
	for (i=0;i<this.imgRels.length;i++){
		if (this.imgRels[i]==act_rel){
			pos=(i+1);
			break;
		}
	}
	return pos;
}

function citSlideSetPicture(src){
	if (!this.thisImg && this.contentContainer.firstChild!=null){
		this.copyChilds(this.contentContainer, this.showContentOldParent);
	}
	this.thisImg = true;
	this.contentContainer.innerHTML = '';
	this.contentContainer.style.display = 'none';
	this.mainImg.style.display = '';
	this.bottomContainer.style.display = '';
	this.titleContainer.style.display = '';
	this.loadingDiv.style.visibility='visible';
	if (!this.mainImgSrc)
		this.imgContainer.style.display = 'none';
	if (this.isIE){
		this.loadingMainImg.removeAttribute('height');
		this.loadingMainImg.removeAttribute('width');
	}
	this.loadingMainImg.style.height = '';
	this.loadingMainImg.style.width = '';
	if (this.loadingMainImg.src.indexOf(src) != -1)
		this.loadedLoadingImg();
	else	
		this.loadingMainImg.src = src;
}

function citSlideLoadedLoadingImg(){
	this.mainImgSrc = true;
	this.setImageMaxWH();
}

function citSlideGetScreenHeight(){
	var height;
	if (!this.isIE)
		height=window.innerHeight;
	else
		height=document.documentElement.clientHeight;
	return height;
}

function citSlideGetScreenWidth(){
	var width;
	if (!this.isIE)
		width=window.innerWidth;
	else
		width=document.documentElement.clientWidth;
	return width;
}

function citSlideSetBackgroundElementsHide(){
	var elements = document.getElementsByTagName('select');
	var objectElements = document.getElementsByTagName('object');
	var i;
	if (this.isIE6){
		for (i=0;i<elements.length;i++){
			if (elements[i].style.visibility!='hidden'){
				this.hidedElements.push(elements[i]);
				elements[i].style.visibility='hidden';
			}
		}
	}
	for (i=0;i<objectElements.length;i++){
		if (objectElements[i].style.visibility!='hidden'){
			this.hidedElements.push(objectElements[i]);
			objectElements[i].style.visibility='hidden';
		}
	}
}

function citSlideSetBackgroundElementsShow(){
	for (i=0;i<this.hidedElements.length;i++){
		this.hidedElements[i].style.visibility='visible';
	}
	this.hidedElements = new Array();
}

function citSlideSetImageMaxWH(){
	var position = this.getImagePosition(this.activeRel);
	if (this.imgAlts[(position-1)]!='' && this.imgAlts[(position-1)]!=undefined){
		this.titleContainer.innerHTML = this.imgAlts[(position-1)];
		if (this.titleContainer.className=='')
			this.titleContainer.className = 'cit_slide_img_title_container';
	} else {
		this.titleContainer.innerHTML = '';
		if (this.titleContainer.className=='cit_slide_img_title_container')
			this.titleContainer.className = '';
	}
	if (this.imgAlts[(position-1)]!=undefined){
		this.infoContainerActualImg.innerHTML = position;
		this.infoContainerSumImg.innerHTML = this.imgRels.length;
	} else {
		this.infoContainerActualImg.innerHTML = '';
		this.infoContainerSumImg.innerHTML = '';
	}
	this.loadingDiv.style.visibility='hidden';
	this.imgContainer.style.display='';
	this.showMainDiv();
	this.newImgSize(this.loadingMainImg.width, this.loadingMainImg.height);
	this.loadingMainImg.style.height = this.newPictureHeight + 'px';
	this.loadingMainImg.style.width = this.newPictureWidth + 'px';
	this.loadingMainImg.style.marginTop = '-'+Math.ceil(this.newPictureHeight/2)+'px';
	this.loadingMainImg.style.marginLeft = '-'+Math.ceil(this.newPictureWidth/2)+'px';
	this.imgLoadingAnimatedProcess = true;
	this.imgLoadingAnimated();
	if (this.isIE){ /* bug */
		if (this.mainDivPadding.childNodes[0].childNodes[0].childNodes[0].childNodes[0]!=null){
			this.mainDivPadding.childNodes[0].childNodes[0].childNodes[0].childNodes[0].style.textAlign='left';
			this.mainDivPadding.childNodes[0].childNodes[0].childNodes[0].childNodes[0].style.textAlign='center';
		}
	}
}

function citSlideImgLoadingAnimated(){
	clearTimeout(this.imgLoadingAnimatedTimeOut);
	if (this.oldPictureHeight == 0 && this.oldPictureWidth == 0){
		this.setMainImgSrc();
	} else {
		var isHEnd = false;
		var isWEnd = false;
		var isOpacityEnd = false;
		if ((this.pictureContainer.offsetHeight < this.newPictureHeight + this.imgLoadingAnimatedStep) && (this.pictureContainer.offsetHeight > this.newPictureHeight - this.imgLoadingAnimatedStep)){
			isHEnd = true;
			this.pictureContainer.style.height = this.newPictureHeight + 'px';
		} else {
			var tmp = Math.ceil(Math.abs(this.pictureContainer.offsetHeight-this.newPictureHeight)/this.imgLoadingAnimatedStep);
			if (this.pictureContainer.offsetHeight < this.newPictureHeight){
				if (tmp<this.imgLoadingAnimatedStep)
					tmp = this.imgLoadingAnimatedStep;
				this.pictureContainer.style.height = Math.ceil(this.pictureContainer.offsetHeight+tmp) + 'px';
			} else {
				if (tmp<this.imgLoadingAnimatedStep)
					tmp = this.imgLoadingAnimatedStep;
				this.pictureContainer.style.height = Math.ceil(this.pictureContainer.offsetHeight-tmp) + 'px';
			}
		}
		if ((this.pictureContainer.offsetWidth < this.newPictureWidth + this.imgLoadingAnimatedStep) && (this.pictureContainer.offsetWidth > this.newPictureWidth - this.imgLoadingAnimatedStep)){
			isWEnd = true;
			this.pictureContainer.style.width = this.newPictureWidth + 'px';
		} else {
			var tmp = Math.ceil(Math.abs(this.pictureContainer.offsetWidth-this.newPictureWidth)/this.imgLoadingAnimatedStep);
			if (this.pictureContainer.offsetWidth < this.newPictureWidth){
				if (tmp<this.imgLoadingAnimatedStep)
					tmp = this.imgLoadingAnimatedStep;
				this.pictureContainer.style.width = Math.ceil(this.pictureContainer.offsetWidth+tmp) + 'px';
			} else {
				if (tmp<this.imgLoadingAnimatedStep)
					tmp = this.imgLoadingAnimatedStep;
				this.pictureContainer.style.width = Math.ceil(this.pictureContainer.offsetWidth-tmp) + 'px';
			}
		}
		if (this.isIE){
			if (this.loadingMainImg.filters.alpha.opacity < 100){
				this.loadingMainImg.filters.alpha.opacity = Math.ceil(this.loadingMainImg.filters.alpha.opacity+Math.ceil(Math.abs(100-this.loadingMainImg.filters.alpha.opacity)/this.imgLoadingAnimatedStep));
			} else {
				isOpacityEnd = true;
				this.loadingMainImg.filters.alpha.opacity = 100;
			}
		} else {
			if (this.loadingMainImg.style.opacity < 1){
				this.loadingMainImg.style.opacity = (Math.ceil(this.loadingMainImg.style.opacity*100+Math.ceil(Math.abs(100-(this.loadingMainImg.style.opacity*100))/this.imgLoadingAnimatedStep))/100);
			} else {
				isOpacityEnd = true;
				this.loadingMainImg.style.opacity = 1;
			}
		}
			
		if (!isHEnd || !isWEnd || !isOpacityEnd)
			this.imgLoadingAnimatedTimeOut = setTimeout('citSlide.imgLoadingAnimated();',20);
		else{
			this.setMainImgSrc();
		}
	}
}

function citSlideSetMainImgSrc(){
	this.mainImg.style.height = this.newPictureHeight + 'px';
	this.mainImg.style.width = this.newPictureWidth + 'px';
	this.mainImg.style.marginTop = '-'+Math.ceil(this.newPictureHeight/2)+'px';
	this.mainImg.style.marginLeft = '-'+Math.ceil(this.newPictureWidth/2)+'px';
	this.pictureContainer.style.height = this.newPictureHeight + 'px';
	this.pictureContainer.style.width = this.newPictureWidth + 'px';
	this.mainImg.src = this.loadingMainImg.src;
	this.imgLoadingAnimatedProcess = false;
}

function citSlideNewImgSize(width,height){
	var maxHeight = this.getScreenHeight()-this.templateHtmlHeightDiff-this.mainDivMargin*2;
	var maxWidth = this.getScreenWidth()-this.templateHtmlWidthDiff-this.mainDivMargin*2;
	var newHeight = height;
	var newWidth = width;
	if (height>maxHeight){
		newHeight = maxHeight;
		width = Math.ceil(width*maxHeight/height);
		newWidth = width;
	}
	if (width>maxWidth){
		newWidth = maxWidth;
		height = Math.ceil(height*maxWidth/width);
		newHeight = height;
		if (height>maxHeight){
			newHeight = maxHeight;
		}
	}
	this.oldPictureHeight = this.newPictureHeight;
	this.oldPictureWidth = this.newPictureWidth;
	this.newPictureHeight = newHeight;
	this.newPictureWidth = newWidth;
}

function citSlideSetMainDivHeight(){
	var screenHeight = this.getScreenHeight();
	if (screenHeight % 2 == 0){
		screenHeight = screenHeight + 1;
	} else {
		if (this.isIE78){
			screenHeight = screenHeight + 1;
		}
	}
	this.mainDiv.style.height = screenHeight + 'px';
	this.mainDivPadding.style.height = Math.ceil(screenHeight-this.mainDivMargin*2) + 'px';
	this.mainDivPadding.style.padding = this.mainDivMargin + 'px';
}

var citSlide = null;
var citSlideDefaultTemplate = 
	'<table><tbody>' +
		'<tr><td><div class="cit_slide_img_container" id="cit_slide_img_container">' +
			'<table cellspacing="0" cellpadding="0"><tbody>' +
				'<tr><td class="cit_slide_border_top_left"></td><td class="cit_slide_border_top_middle"></td><td class="cit_slide_border_top_right"></td></tr>' +
				'<tr><td class="cit_slide_border_middle_left"></td>' +
					'<td class="cit_slide_border_middle_middle"><img src="" alt="" class="cit_slide_main_img" id="cit_slide_main_img" /><div style="display: none;" class="cit_slide_contant_container" id="cit_slide_contant_container"></div></td>' +
				'<td class="cit_slide_border_middle_right"></td></tr>' +
				'<tr><td class="cit_slide_border_bottom_left"></td><td class="cit_slide_border_bottom_middle"></td><td class="cit_slide_border_bottom_right"></td></tr>' +
			'</tbody></table>' +
			'<div class="cit_slide_img_title_container" id="cit_slide_img_title_container"></div>' +
			'<table class="cit_slide_bottom_button_container" cellspacing="0" cellpadding="0" id="cit_slide_bottom_button_container"><tbody><tr>' +
				'<td class="cit_slide_bottom_button_c_left"></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_first" id="cit_slide_arrow_link_first"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_prev" id="cit_slide_arrow_link_prev"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_play" id="cit_slide_arrow_link_play"></a><a class="cit_slide_arrow_link_pause" id="cit_slide_arrow_link_pause"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><span id="cit_slide_info_container_act_img"></span> / <span id="cit_slide_info_container_sum_img"></span></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_next" id="cit_slide_arrow_link_next"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_last" id="cit_slide_arrow_link_last"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_close_link" id="cit_slide_close_link"></a></td>' +
				'<td class="cit_slide_bottom_button_c_right"></td>' +
			'</tr></tbody></table>' +
		'</div>' +
		'<div id="cit_slide_loading_div">' +
			'<table cellspacing="0" cellpadding="0" class="cit_slide_loading_opacity"><tbody><tr>' +
				'<td class="cit_slide_bottom_button_c_left"></td>' +
				'<td class="cit_slide_bottom_button_white">' +
					'<div class="cit_slide_loading_div">' +
					'</div>' +
				'</td>' +
				'<td class="cit_slide_bottom_button_c_right"></td>' +
			'</tr></tbody></table>' +
		'</div>' +
		'</td></tr>' +
	'</tbody></table>';
var citSlideDefaultCornerTemplate = 
	'<table><tbody>' +
		'<tr><td><div class="cit_slide_img_container" id="cit_slide_img_container">' +
			'<table cellspacing="0" cellpadding="0"><tbody>' +
				'<tr><td class="cit_slide_corner_border_top_left"></td><td class="cit_slide_corner_border_top_middle"></td><td class="cit_slide_corner_border_top_right"></td></tr>' +
				'<tr><td class="cit_slide_corner_border_middle_left"></td>' +
					'<td class="cit_slide_corner_border_middle_middle"><img src="" alt="" class="cit_slide_main_img" id="cit_slide_main_img" /><div style="display: none;" class="cit_slide_contant_container" id="cit_slide_contant_container"></div></td>' +
				'<td class="cit_slide_corner_border_middle_right"></td></tr>' +
				'<tr><td class="cit_slide_corner_border_bottom_left"></td><td class="cit_slide_corner_border_bottom_middle"></td><td class="cit_slide_corner_border_bottom_right"></td></tr>' +
			'</tbody></table>' +
			'<div class="cit_slide_img_title_container" id="cit_slide_img_title_container"></div>' +
			'<table class="cit_slide_bottom_button_container" cellspacing="0" cellpadding="0" id="cit_slide_bottom_button_container"><tbody><tr>' +
				'<td class="cit_slide_bottom_button_c_left"></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_first" id="cit_slide_arrow_link_first"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_prev" id="cit_slide_arrow_link_prev"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_play" id="cit_slide_arrow_link_play"></a><a class="cit_slide_arrow_link_pause" id="cit_slide_arrow_link_pause"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><span id="cit_slide_info_container_act_img"></span> / <span id="cit_slide_info_container_sum_img"></span></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_next" id="cit_slide_arrow_link_next"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_arrow_link_last" id="cit_slide_arrow_link_last"></a></td>' +
				'<td class="cit_slide_bottom_button_padding"><a class="cit_slide_close_link" id="cit_slide_close_link"></a></td>' +
				'<td class="cit_slide_bottom_button_c_right"></td>' +
			'</tr></tbody></table>' +
		'</div>' +
		'<div id="cit_slide_loading_div">' +
			'<table cellspacing="0" cellpadding="0" class="cit_slide_loading_opacity"><tbody><tr>' +
				'<td class="cit_slide_bottom_button_c_left"></td>' +
				'<td class="cit_slide_bottom_button_white">' +
					'<div class="cit_slide_loading_div">' +
					'</div>' +
				'</td>' +
				'<td class="cit_slide_bottom_button_c_right"></td>' +
			'</tr></tbody></table>' +
		'</div>' +
		'</td></tr>' +
	'</tbody></table>';

function citslideonload_js_onload(){
	citSlide = new CitSlide();
	if (typeof citSlideTemplateHtml === "undefined"){
		if (typeof citSlideCornerTemplate === "undefined")
			citSlide.init(citSlideDefaultTemplate);
		else
			citSlide.init(citSlideDefaultCornerTemplate);
	} else {
		citSlide.init(citSlideTemplateHtml);
	}
}

function citslideonresize_js_onresize(){
	if (citSlide!=null)
		citSlide.setMainDivHeight();
}

function citslideonkeyup_js_onkeydown(e){
	if (citSlide != null && citSlide.activeSlide){
		var key=window.event?window.event.keyCode:e.which;
		var citSlideUsedKey = false;
		if (key==27){
			citSlide.close();
			citSlideUsedKey = true;
		} else if (key==39 || key==40){
			if (citSlide.playSlideShow)
				clearTimeout(citSlide.playTimeOut);
			citSlide.next();
			if (citSlide.playSlideShow)
				citSlide.playTimeOut = setTimeout('citSlide.play();',citSlide.slideshowTime);
			citSlideUsedKey = true;
		} else if (key==37 || key==38){
			if (citSlide.playSlideShow)
				clearTimeout(citSlide.playTimeOut);
			citSlide.prev();
			if (citSlide.playSlideShow)
				citSlide.playTimeOut = setTimeout('citSlide.play();',citSlide.slideshowTime);
			citSlideUsedKey = true;
		} else if (key==32){
			if (citSlide.playSlideShow)
				citSlide.stop();
			else
				citSlide.play();
			citSlideUsedKey = true;
		} else if (key==36){
			if (citSlide.playSlideShow)
				clearTimeout(citSlide.playTimeOut);
			citSlide.firstImg();
			if (citSlide.playSlideShow)
				citSlide.playTimeOut = setTimeout('citSlide.play();',citSlide.slideshowTime);
			citSlideUsedKey = true;
		} else if (key==35){
			if (citSlide.playSlideShow)
				clearTimeout(citSlide.playTimeOut);
			citSlide.lastImg();
			if (citSlide.playSlideShow)
				citSlide.playTimeOut = setTimeout('citSlide.play();',citSlide.slideshowTime);
			citSlideUsedKey = true;
		}
		if (citSlideUsedKey){
			if (citSlide.opera || !window.event){
				e.preventDefault();
				e.stopPropagation();
			} else {
				window.event.returnValue = false;
				window.event.keyCode = 0;
			}
			return false;
		}
	}
}

if (window.attachEvent) {
	window.attachEvent("onload", citslideonload_js_onload);
} else {
	window.addEventListener("load", citslideonload_js_onload, false);
}

if (window.attachEvent) {
	window.attachEvent("onresize", citslideonresize_js_onresize);
} else {
	window.addEventListener("resize", citslideonresize_js_onresize, false);
}

if (window.opera){
	window.addEventListener("keypress", citslideonkeyup_js_onkeydown, false);
} else if (document.attachEvent) {
	document.attachEvent("onkeydown", citslideonkeyup_js_onkeydown);
} else {
	window.addEventListener("keydown", citslideonkeyup_js_onkeydown, false);
}